mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
UI: Expose theme as css custom props (#2380)
This commit is contained in:
@@ -26,5 +26,12 @@ export default class FixJSDOMEnvironment extends JSDOMEnvironment {
|
|||||||
this.global.TextDecoderStream = TextDecoderStream;
|
this.global.TextDecoderStream = TextDecoderStream;
|
||||||
this.global.URL = URL;
|
this.global.URL = URL;
|
||||||
this.global.Response = Response;
|
this.global.Response = Response;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* https://github.com/jsdom/jsdom/issues/3766
|
||||||
|
* https://github.com/jsdom/jsdom/issues/3444
|
||||||
|
*/
|
||||||
|
this.global.document.adoptedStyleSheets = [];
|
||||||
|
this.global.CSSStyleSheet.prototype.replaceSync = () => {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ declare module "@mui/material/styles" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let theme: Theme;
|
let theme: Theme;
|
||||||
|
const themeStyleSheet = new CSSStyleSheet();
|
||||||
|
|
||||||
export function refreshTheme(): void {
|
export function refreshTheme(): void {
|
||||||
theme = createTheme({
|
theme = createTheme({
|
||||||
@@ -419,7 +420,18 @@ export function refreshTheme(): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
document.body.style.backgroundColor = theme.colors.backgroundprimary?.toString() ?? "black";
|
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();
|
refreshTheme();
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
|
|||||||
Reference in New Issue
Block a user