(defaultTheme: "light" | "dark" = "light")
| 4 | import { useMemo } from "react"; |
| 5 | |
| 6 | export const useThemeNormalized = (defaultTheme: "light" | "dark" = "light") => { |
| 7 | const { theme: _theme, systemTheme, setTheme } = useThemeBase(); |
| 8 | |
| 9 | const theme = useMemo(() => { |
| 10 | if (_theme === "system") { |
| 11 | return systemTheme ?? defaultTheme; |
| 12 | } |
| 13 | |
| 14 | return _theme ?? defaultTheme; |
| 15 | }, [_theme, systemTheme, defaultTheme]); |
| 16 | |
| 17 | return { |
| 18 | theme, |
| 19 | systemTheme, |
| 20 | setTheme, |
| 21 | }; |
| 22 | } |
no outgoing calls
no test coverage detected