TagCard.vue 842 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <script setup lang="ts">
  2. import type { Tag } from '@/models'
  3. import { lightenHexColor } from '@/utils'
  4. import { computed } from 'vue'
  5. const props = defineProps<{
  6. target: Tag,
  7. onClick?: () => void
  8. }>();
  9. const color = computed(() => {
  10. if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
  11. return lightenHexColor(props.target.color);
  12. }
  13. return props.target.color;
  14. })
  15. </script>
  16. <template>
  17. <div
  18. class="tag"
  19. @click="props.onClick?.call(undefined)"
  20. >
  21. {{ props.target.name }}
  22. </div>
  23. </template>
  24. <style scoped>
  25. .tag {
  26. color: v-bind(color);
  27. border: 1px solid;
  28. border-radius: 50px;
  29. padding: 0 16px;
  30. display: inline-block;
  31. margin: 3px 6px 3px 0;
  32. cursor: pointer;
  33. transition: all .2s;
  34. }
  35. .tag:hover {
  36. text-shadow: v-bind(color) 0 0 8px;
  37. box-shadow: v-bind(color) 0 0 8px;
  38. }
  39. </style>