MCPcopy Index your code
hub / github.com/github/docs / getCssTheme

Function getCssTheme

components/hooks/useTheme.ts:73–88  ·  view source on GitHub ↗
(cookieValue = '')

Source from the content-addressed store, hash-verified

71}
72
73export 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
90export function getComponentTheme(cookieValue = ''): ComponentColorTheme {
91 const { colorMode, lightTheme, darkTheme } = getCssTheme(cookieValue)

Callers 3

use-theme.jsFile · 0.90
getComponentThemeFunction · 0.85
useThemeFunction · 0.85

Calls 2

filterModeFunction · 0.85
filterThemeFunction · 0.85

Tested by

no test coverage detected