mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-12-23 03:25:12 +01:00
Remove existing stylesheets when changing themes
This commit is contained in:
parent
12a70469eb
commit
af9cbd727f
@ -229,7 +229,7 @@ module.exports = function buildThemes(options) {
|
||||
type: "text/css",
|
||||
media: "(prefers-color-scheme: dark)",
|
||||
href: `./${darkThemeLocation}`,
|
||||
class: "default-theme",
|
||||
class: "theme",
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -239,7 +239,7 @@ module.exports = function buildThemes(options) {
|
||||
type: "text/css",
|
||||
media: "(prefers-color-scheme: light)",
|
||||
href: `./${lightThemeLocation}`,
|
||||
class: "default-theme",
|
||||
class: "theme",
|
||||
}
|
||||
},
|
||||
];
|
||||
|
@ -345,17 +345,15 @@ export class Platform {
|
||||
}
|
||||
|
||||
_replaceStylesheet(newPath) {
|
||||
// remove default theme
|
||||
const defaultStylesheets = document.getElementsByClassName("default-theme");
|
||||
for (const tag of defaultStylesheets) {
|
||||
tag.remove();
|
||||
}
|
||||
// add new theme
|
||||
const head = document.querySelector("head");
|
||||
// remove default theme
|
||||
document.querySelectorAll(".theme").forEach(e => e.remove());
|
||||
// add new theme
|
||||
const styleTag = document.createElement("link");
|
||||
styleTag.href = `./${newPath}`;
|
||||
styleTag.rel = "stylesheet";
|
||||
styleTag.type = "text/css";
|
||||
styleTag.className = "theme";
|
||||
head.appendChild(styleTag);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user