PersonalSettingAppearance.vue 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <!-- Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/ -->
  2. <script setup lang="ts">
  3. import { storeToRefs } from 'pinia'
  4. import { computed } from 'vue'
  5. import {
  6. NotificationTypes,
  7. useNotifications,
  8. } from '#shared/components/CommonNotifications/index.ts'
  9. import LayoutContent from '#desktop/components/layout/LayoutContent.vue'
  10. import { useThemeStore } from '#desktop/stores/theme.ts'
  11. import { useBreadcrumb } from '../composables/useBreadcrumb.ts'
  12. const { notify } = useNotifications()
  13. const themeStore = useThemeStore()
  14. const { updateTheme } = themeStore
  15. const { currentTheme, savingTheme } = storeToRefs(themeStore)
  16. const modelTheme = computed({
  17. get: () => currentTheme.value,
  18. set: (theme) => {
  19. updateTheme(theme).then(() => {
  20. notify({
  21. id: 'theme-update',
  22. message: __('Your theme has been updated.'),
  23. type: NotificationTypes.Success,
  24. })
  25. })
  26. },
  27. })
  28. const themeOptions = [
  29. {
  30. value: 'dark',
  31. label: __('Dark'),
  32. description: __(
  33. 'A color scheme that uses light-colored elements on a dark background.',
  34. ),
  35. },
  36. {
  37. value: 'light',
  38. label: __('Light'),
  39. description: __(
  40. 'A color scheme that uses dark-colored elements on a light background.',
  41. ),
  42. },
  43. {
  44. value: 'auto',
  45. label: __('Sync with computer'),
  46. description: __(
  47. 'Prefer color scheme as indicated by the operating system.',
  48. ),
  49. },
  50. ]
  51. const { breadcrumbItems } = useBreadcrumb(__('Appearance'))
  52. </script>
  53. <template>
  54. <LayoutContent :breadcrumb-items="breadcrumbItems" width="narrow">
  55. <div class="mb-4">
  56. <FormKit
  57. v-model="modelTheme"
  58. type="radioList"
  59. name="theme"
  60. :label="__('Theme')"
  61. :options="themeOptions"
  62. :disabled="savingTheme"
  63. />
  64. </div>
  65. </LayoutContent>
  66. </template>