|
| 1 | +import { appThemeColors } from '@/lib/AppTheme/appThemeColors'; |
| 2 | +import { appThemeColorsDark } from '@/lib/AppTheme/appThemeColorsDark'; |
| 3 | +import { useTheme } from '@/lib/AppTheme/ThemeContext'; |
| 4 | +import { useMemo } from 'react'; |
1 | 5 | import { Theme } from 'react-select'; |
2 | 6 |
|
3 | | -export default function SelectTheme(theme: Theme) { |
| 7 | +// Hook version for components that need reactive theme updates |
| 8 | +export function useSelectTheme() { |
| 9 | + const { theme: appTheme } = useTheme(); |
| 10 | + |
| 11 | + return useMemo(() => { |
| 12 | + return (theme: Theme) => { |
| 13 | + const colors = appTheme === 'dark' ? appThemeColorsDark : appThemeColors; |
| 14 | + |
| 15 | + return { |
| 16 | + ...theme, |
| 17 | + colors: { |
| 18 | + ...theme.colors, |
| 19 | + primary: colors.select.primary, |
| 20 | + primary25: colors.select.primary25, |
| 21 | + neutral0: colors.select.neutral0, |
| 22 | + neutral80: colors.select.neutral80, |
| 23 | + }, |
| 24 | + }; |
| 25 | + }; |
| 26 | + }, [appTheme]); |
| 27 | +} |
| 28 | + |
| 29 | +// Static function for backward compatibility |
| 30 | +// Checks DOM at render time |
| 31 | +function SelectTheme(theme: Theme) { |
| 32 | + const isDark = |
| 33 | + typeof window !== 'undefined' && |
| 34 | + document.documentElement.classList.contains('dark'); |
| 35 | + |
| 36 | + const colors = isDark ? appThemeColorsDark : appThemeColors; |
| 37 | + |
4 | 38 | return { |
5 | 39 | ...theme, |
6 | 40 | colors: { |
7 | 41 | ...theme.colors, |
8 | | - primary25: 'rgba(48, 164, 108, 0.3)', |
9 | | - primary: 'rgba(48, 164, 108, 0.3)', |
| 42 | + primary: colors.select.primary, |
| 43 | + primary25: colors.select.primary25, |
| 44 | + neutral0: colors.select.neutral0, |
| 45 | + neutral80: colors.select.neutral80, |
10 | 46 | }, |
11 | 47 | }; |
12 | 48 | } |
| 49 | + |
| 50 | +export default SelectTheme; |
0 commit comments