AccentModePicker.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <div class="flex flex-col">
  3. <label>{{ $t("color") }}: {{ active.charAt(0).toUpperCase() + active.slice(1) }}</label>
  4. <div>
  5. <!-- text-blue-400 -->
  6. <!-- text-green-400 -->
  7. <!-- text-teal-400 -->
  8. <!-- text-indigo-400 -->
  9. <!-- text-purple-400 -->
  10. <!-- text-orange-400 -->
  11. <!-- text-pink-400 -->
  12. <!-- text-red-400 -->
  13. <!-- text-yellow-400 -->
  14. <span
  15. v-for="(color, index) of accentColors"
  16. :key="`color-${index}`"
  17. v-tooltip="`${color.charAt(0).toUpperCase()}${color.slice(1)}`"
  18. class="inline-flex items-center justify-center p-3 m-2 transition duration-150 ease-in-out bg-transparent rounded-full cursor-pointer hover:shadow-none"
  19. :class="[`text-${color}-400`, { 'bg-actColor': color === active }]"
  20. @click="setActiveColor(color)"
  21. >
  22. <i class="material-icons">lens</i>
  23. </span>
  24. </div>
  25. </div>
  26. </template>
  27. <script>
  28. export default {
  29. data() {
  30. return {
  31. active: localStorage.getItem("THEME_COLOR") || "green",
  32. accentColors: [
  33. "blue",
  34. "green",
  35. "teal",
  36. "indigo",
  37. "purple",
  38. "orange",
  39. "pink",
  40. "red",
  41. "yellow",
  42. ],
  43. }
  44. },
  45. methods: {
  46. setActiveColor(color) {
  47. document.documentElement.setAttribute("data-accent", color)
  48. this.active = color
  49. },
  50. },
  51. watch: {
  52. active(color) {
  53. localStorage.setItem("THEME_COLOR", color)
  54. },
  55. },
  56. }
  57. </script>