Fixed popped panels to display as selected theme.

This commit is contained in:
rainbow napkin 2026-10-03 08:10:07 -04:00
parent 315c5340f3
commit 86acfa5b7c
3 changed files with 30 additions and 10 deletions

View file

@ -49,7 +49,7 @@ class themeManager{
* Sets theme by name
* @param {String} theme - name of theme to set, keep blank for default theme
*/
setTheme(theme){
setTheme(theme = localStorage.getItem("theme")){
//If we didnt get a theme to set
if(theme == null){
//Use the first theme in the list
@ -63,14 +63,7 @@ class themeManager{
}
//Create new link element and use it to set themeLink
this.themeLink = document.createElement('link');
//Set themeLink attributes
this.themeLink.type = "text/css";
this.themeLink.rel = "stylesheet";
//Set theme href to theme location
this.themeLink.href = this.themes.get(theme);
this.themeLink = this.genThemeLink(theme);
//Append themeLink to header
document.querySelector('head').appendChild(this.themeLink);
@ -78,6 +71,20 @@ class themeManager{
//Save theme choice to local storage
localStorage.setItem("theme", theme);
}
genThemeLink(theme = localStorage.getItem("theme")){
//Create new link element and use it to set themeLink
const themeLink = document.createElement('link');
//Set themeLink attributes
themeLink.type = "text/css";
themeLink.rel = "stylesheet";
//Set theme href to theme location
themeLink.href = this.themes.get(theme);
return themeLink;
}
}
ThemeManager = new themeManager();