Isolate common stylesheets

This commit is contained in:
Federico Bologni 2023-06-30 17:19:45 +02:00
parent 50b6e0104b
commit 00fc29c6ad
3 changed files with 9 additions and 8 deletions

View file

@ -13,6 +13,12 @@ const app = {
link: { link: {
icon: appIconURL, icon: appIconURL,
}, },
styleSheets: [robotoFontStyle, appStyle]
.map((rawSheet) => {
const sheet = new CSSStyleSheet();
sheet.replaceSync(rawSheet);
return sheet;
}),
page: null, page: null,
router: new Router(), router: new Router(),
loader: WDLoader.instance, loader: WDLoader.instance,
@ -23,12 +29,7 @@ const app = {
<meta name="viewport" content="${app.meta.viewport}"> <meta name="viewport" content="${app.meta.viewport}">
`; `;
document.title = app.title; document.title = app.title;
document.adoptedStyleSheets = [robotoFontStyle, appStyle] document.adoptedStyleSheets = app.styleSheets;
.map((rawSheet) => {
const sheet = new CSSStyleSheet();
sheet.replaceSync(rawSheet);
return sheet;
});
}, },
}; };

View file

@ -26,7 +26,7 @@ class HomePage {
#addPageStyle() { #addPageStyle() {
const sheet = new CSSStyleSheet(); const sheet = new CSSStyleSheet();
sheet.replaceSync(pageStyle); sheet.replaceSync(pageStyle);
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet]; document.adoptedStyleSheets = [...app.styleSheets, sheet];
} }
/** /**

View file

@ -26,7 +26,7 @@ class RoutesPage {
#addPageStyle() { #addPageStyle() {
const sheet = new CSSStyleSheet(); const sheet = new CSSStyleSheet();
sheet.replaceSync(pageStyle); sheet.replaceSync(pageStyle);
document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet]; document.adoptedStyleSheets = [...app.styleSheets, sheet];
} }
/** /**