useComponentThemeOverrides.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import { computed } from 'vue'
  2. import twc from '@/utils/tailwindColor'
  3. import { usePersonalization } from './usePersonalization'
  4. import type { GlobalThemeOverrides } from 'naive-ui'
  5. export function useComponentThemeOverrides() {
  6. const { isDark } = usePersonalization()
  7. const scrollbarInModal = computed<GlobalThemeOverrides['Scrollbar']>(() =>
  8. isDark.value
  9. ? {
  10. color: twc.neutral[750],
  11. colorHover: twc.neutral[700],
  12. }
  13. : {
  14. color: twc.neutral[200],
  15. colorHover: twc.neutral[250],
  16. },
  17. )
  18. const scrollbarInMainLayout = computed<GlobalThemeOverrides['Scrollbar']>(() =>
  19. isDark.value
  20. ? {
  21. color: twc.neutral[800],
  22. colorHover: twc.neutral[750],
  23. }
  24. : {
  25. color: twc.neutral[350],
  26. colorHover: twc.neutral[400],
  27. },
  28. )
  29. const selectInPopover = computed<GlobalThemeOverrides['Select']>(() =>
  30. isDark.value
  31. ? {
  32. peers: {
  33. InternalSelectMenu: {
  34. color: twc.neutral[700],
  35. optionColorPending: twc.neutral[600],
  36. },
  37. },
  38. }
  39. : {
  40. peers: {
  41. InternalSelectMenu: {
  42. color: '#fff',
  43. optionColorPending: twc.neutral[150],
  44. },
  45. },
  46. },
  47. )
  48. const datePickerInPopover = computed<GlobalThemeOverrides['DatePicker']>(() =>
  49. isDark.value
  50. ? {
  51. panelColor: twc.neutral[700],
  52. }
  53. : {
  54. panelColor: '#fff',
  55. },
  56. )
  57. return {
  58. scrollbarInModal,
  59. scrollbarInMainLayout,
  60. selectInPopover,
  61. datePickerInPopover,
  62. }
  63. }