(cookieValue = '')
| 71 | } |
| 72 | |
| 73 | export function getCssTheme(cookieValue = ''): CssColorTheme { |
| 74 | if (!cookieValue) return defaultCSSTheme |
| 75 | try { |
| 76 | const parsed = JSON.parse(cookieValue) |
| 77 | const { color_mode, light_theme, dark_theme } = parsed |
| 78 | return { |
| 79 | colorMode: filterMode(color_mode) || defaultCSSTheme.colorMode, |
| 80 | lightTheme: filterTheme(light_theme) || defaultCSSTheme.lightTheme, |
| 81 | darkTheme: filterTheme(dark_theme) || defaultCSSTheme.darkTheme, |
| 82 | } |
| 83 | } catch (err) { |
| 84 | if (process.env.NODE_ENV === 'development') |
| 85 | console.warn("Unable to parse 'color_mode' cookie", err) |
| 86 | return defaultCSSTheme |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | export function getComponentTheme(cookieValue = ''): ComponentColorTheme { |
| 91 | const { colorMode, lightTheme, darkTheme } = getCssTheme(cookieValue) |
no test coverage detected