Check.vue 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div class="nana-checkbox" @click="() => $emit('update:modelValue', modelValue ? false : true)">
  3. <div class="checker">
  4. <CheckIcon v-if="modelValue" />
  5. </div>
  6. <span>
  7. <slot />
  8. </span>
  9. </div>
  10. </template>
  11. <script lang="ts" setup>
  12. import CheckIcon from './CheckIcon.vue';
  13. defineProps({
  14. modelValue: {
  15. type: [Number,Object, Boolean],
  16. default: null
  17. },
  18. })
  19. defineEmits([
  20. 'update:modelValue'
  21. ])
  22. </script>
  23. <style lang="scss">
  24. .nana-checkbox {
  25. vertical-align: middle;
  26. display: inline-flex;
  27. flex-direction: row;
  28. align-items: center;
  29. position: relative;
  30. .checker {
  31. position: relative;
  32. border: 1px solid #c5c5c5;
  33. width: 18px;
  34. height: 18px;
  35. border-radius: 6px;
  36. overflow: hidden;
  37. margin-right: 6px;
  38. &:hover {
  39. background-color:#ececec;
  40. }
  41. &:active {
  42. background-color:#eaeaea;
  43. }
  44. &:active, &:hover {
  45. border-color: #0092e7;
  46. }
  47. svg {
  48. position: absolute;
  49. left: 1px;
  50. top: 1px;
  51. width: 16px;
  52. height: 16px;
  53. }
  54. }
  55. }
  56. </style>