mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 06:48:42 +02:00
UI: Expose theme as css custom props (#2380)
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user