AvatarMenuAppearanceItem.vue 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { storeToRefs } from 'pinia'
  4. import { computed, useTemplateRef } from 'vue'
  5. import CommonPopoverMenuItem, {
  6. type Props,
  7. } from '#desktop/components/CommonPopoverMenu/CommonPopoverMenuItem.vue'
  8. import ThemeSwitch from '#desktop/components/ThemeSwitch/ThemeSwitch.vue'
  9. import { useThemeStore } from '#desktop/stores/theme.ts'
  10. defineProps<Props>()
  11. const themeSwitchInstance = useTemplateRef('theme-switch')
  12. const cycleThemeSwitchValue = () => {
  13. themeSwitchInstance.value?.cycleValue()
  14. }
  15. const themeStore = useThemeStore()
  16. const { updateTheme } = themeStore
  17. const { currentTheme } = storeToRefs(themeStore)
  18. const modelTheme = computed({
  19. get: () => currentTheme.value,
  20. set: (theme) => updateTheme(theme),
  21. })
  22. </script>
  23. <template>
  24. <CommonPopoverMenuItem
  25. v-bind="{ ...$props, ...$attrs }"
  26. @click="cycleThemeSwitchValue"
  27. />
  28. <div class="flex items-center px-2">
  29. <ThemeSwitch
  30. ref="theme-switch"
  31. v-model="modelTheme"
  32. class="hover:outline-blue-300 focus:outline-blue-600 hover:focus:outline-blue-600 dark:hover:outline-blue-950 dark:focus:outline-blue-900 dark:hover:focus:outline-blue-900"
  33. size="small"
  34. />
  35. </div>
  36. </template>