AccentModePicker.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <template>
  2. <div class="flex">
  3. <!-- text-green-500 -->
  4. <!-- text-teal-500 -->
  5. <!-- text-blue-500 -->
  6. <!-- text-indigo-500 -->
  7. <!-- text-purple-500 -->
  8. <!-- text-yellow-500 -->
  9. <!-- text-orange-500 -->
  10. <!-- text-red-500 -->
  11. <!-- text-pink-500 -->
  12. <ButtonSecondary
  13. v-for="(color, index) of accentColors"
  14. :key="`color-${index}`"
  15. v-tippy="{ theme: 'tooltip' }"
  16. :title="`${color.charAt(0).toUpperCase()}${color.slice(1)}`"
  17. :class="[{ 'bg-primaryLight': color === active }]"
  18. class="rounded"
  19. icon="lens"
  20. :color="color"
  21. @click.native="setActiveColor(color)"
  22. />
  23. </div>
  24. </template>
  25. <script lang="ts">
  26. import { defineComponent } from "@nuxtjs/composition-api"
  27. import {
  28. HoppAccentColors,
  29. HoppAccentColor,
  30. applySetting,
  31. useSetting,
  32. } from "~/newstore/settings"
  33. export default defineComponent({
  34. setup() {
  35. return {
  36. accentColors: HoppAccentColors,
  37. active: useSetting("THEME_COLOR"),
  38. }
  39. },
  40. methods: {
  41. setActiveColor(color: HoppAccentColor) {
  42. document.documentElement.setAttribute("data-accent", color)
  43. applySetting("THEME_COLOR", color)
  44. },
  45. },
  46. })
  47. </script>