ThemeColorPopover.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <script setup lang="ts">
  2. import { NPopover } from 'naive-ui'
  3. import { ButtonAnimation } from '@/components'
  4. import { usePersonalization } from '@/composable/usePersonalization'
  5. import themeColors from '@/utils/themeColor'
  6. const { color: currentColor, setColor } = usePersonalization()
  7. const colorSwatches = [
  8. themeColors.red[500],
  9. themeColors.orange[500],
  10. themeColors.amber[500],
  11. themeColors.yellow[500],
  12. themeColors.lime[500],
  13. themeColors.green[500],
  14. themeColors.emerald[500],
  15. themeColors.teal[500],
  16. themeColors.cyan[500],
  17. themeColors.sky[500],
  18. themeColors.blue[500],
  19. themeColors.indigo[500],
  20. themeColors.violet[500],
  21. themeColors.purple[500],
  22. themeColors.fuchsia[500],
  23. themeColors.pink[500],
  24. ]
  25. </script>
  26. <template>
  27. <NPopover
  28. trigger="click"
  29. placement="bottom"
  30. :to="false"
  31. >
  32. <template #trigger>
  33. <ButtonAnimation>
  34. <template #default>
  35. <span class="size-5 i-ph:palette" />
  36. </template>
  37. </ButtonAnimation>
  38. </template>
  39. <div class="grid grid-cols-6 gap-1.5">
  40. <div
  41. v-for="color in colorSwatches"
  42. :key="color"
  43. class="size-5 cursor-pointer rounded-full"
  44. :class="{
  45. 'ring-3 ring-primary/30': color === currentColor,
  46. }"
  47. :style="{ backgroundColor: color }"
  48. @click="setColor(color)"
  49. />
  50. </div>
  51. </NPopover>
  52. </template>