UI: Expose theme as css custom props (#2380)

This commit is contained in:
Shy
2025-11-04 01:58:09 +01:00
committed by GitHub
parent e599988af7
commit 9cd3ffd308
2 changed files with 19 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ declare module "@mui/material/styles" {
}
let theme: Theme;
const themeStyleSheet = new CSSStyleSheet();
export function refreshTheme(): void {
theme = createTheme({
@@ -419,7 +420,18 @@ export function refreshTheme(): void {
});
document.body.style.backgroundColor = theme.colors.backgroundprimary?.toString() ?? "black";
const styleSheet =
":root {" +
Object.entries(Settings.theme)
.map(([k, v]) => `--bb-theme-${k}: ${v}`)
.join(";") +
"}";
themeStyleSheet.replaceSync(styleSheet);
}
document.adoptedStyleSheets.push(themeStyleSheet);
refreshTheme();
interface IProps {