mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-17 06:45:25 +00:00
22 lines
No EOL
545 B
TypeScript
22 lines
No EOL
545 B
TypeScript
'use client';
|
|
|
|
import { useTheme as useThemeBase } from "next-themes";
|
|
import { useMemo } from "react";
|
|
|
|
export const useThemeNormalized = (defaultTheme: "light" | "dark" = "light") => {
|
|
const { theme: _theme, systemTheme, setTheme } = useThemeBase();
|
|
|
|
const theme = useMemo(() => {
|
|
if (_theme === "system") {
|
|
return systemTheme ?? defaultTheme;
|
|
}
|
|
|
|
return _theme ?? defaultTheme;
|
|
}, [_theme, systemTheme, defaultTheme]);
|
|
|
|
return {
|
|
theme,
|
|
systemTheme,
|
|
setTheme,
|
|
};
|
|
} |