19 lines
595 B
JavaScript
19 lines
595 B
JavaScript
// Applies a theme's stylesheet. Texts are handled by i18n.js, mechanics are
|
|
// shared (public/data); a theme is only a skin: colours, vocabulary, images.
|
|
|
|
export function applyThemeStyles(themeId) {
|
|
document.documentElement.dataset.theme = themeId;
|
|
|
|
let link = document.getElementById('theme-css');
|
|
if (!link) {
|
|
link = document.createElement('link');
|
|
link.id = 'theme-css';
|
|
link.rel = 'stylesheet';
|
|
document.head.append(link);
|
|
}
|
|
return new Promise((resolve) => {
|
|
link.onload = link.onerror = () => resolve();
|
|
link.href = `themes/${themeId}/theme.css`;
|
|
});
|
|
}
|