index.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <template>
  2. <div
  3. class="radio-select"
  4. @click="toggleSelect"
  5. >
  6. <div
  7. v-if="!props.isSelected"
  8. class="radio-no-select"
  9. />
  10. <Icon
  11. v-else
  12. :file="radioIcon"
  13. :size="'20px'"
  14. />
  15. </div>
  16. </template>
  17. <script lang="ts" setup>
  18. import Icon from '../Icon.vue';
  19. import radioIcon from '../../../assets/icon/radio.svg';
  20. interface IProps {
  21. isSelected: boolean;
  22. }
  23. interface IEmits {
  24. (e: 'onChange', value: boolean): void;
  25. }
  26. const emits = defineEmits<IEmits>();
  27. const props = withDefaults(defineProps<IProps>(),
  28. {},
  29. );
  30. function toggleSelect() {
  31. emits('onChange', !props.isSelected);
  32. }
  33. </script>
  34. <style lang="scss" scoped>
  35. :not(not) {
  36. display: flex;
  37. flex-direction: column;
  38. min-width: 0;
  39. box-sizing: border-box
  40. }
  41. .radio-select {
  42. flex: 1;
  43. flex-direction: column;
  44. cursor: pointer;
  45. -webkit-tap-highlight-color: transparent;
  46. justify-content: center;
  47. .radio-no-select {
  48. height: 20px;
  49. width: 20px;
  50. border-radius: 50%;
  51. border: 2px solid #ddd;
  52. }
  53. }
  54. </style>