@@ -204,8 +204,7 @@ export function setupOpenCloseTriggers(panel: Element, button_selector: string =
204204
205205function setupThemes ( setting_panel : Element ) {
206206
207- let default_theme = < string > document . body . dataset . defaulttheme ;
208- let active_theme = getLocalValue ( LocalStoreKeys . ActiveTheme ) || default_theme ;
207+ let active_theme = getLocalValue ( LocalStoreKeys . ActiveTheme ) ;
209208
210209 //document.body.classList.add(active_theme);
211210 let node = < HTMLTemplateElement > document . querySelector ( "#theme-entry-template" ) ;
@@ -219,13 +218,15 @@ function setupThemes(setting_panel: Element) {
219218 let title = < HTMLElement > theme_entry . querySelector ( ".theme-entry-title" ) ;
220219 let theme_entry_theme = < HTMLElement > theme_entry . querySelector ( ".theme" ) ;
221220
222- let { bg, mg , fg , target : target_class } = theme . dataset ;
221+ let { text , bg, inner_border , inner_bg , border , target : target_class } = theme . dataset ;
223222
224- theme_entry . style . color = < string > fg ;
223+ theme_entry . style . color = < string > text ;
225224 theme_entry . style . backgroundColor = < string > bg ;
225+ theme_entry . style . borderColor = < string > border ;
226226
227- theme_entry_theme . style . borderColor = < string > mg ;
228- theme_entry_theme . style . backgroundColor = < string > fg ;
227+ theme_entry_theme . style . borderColor = < string > inner_border ;
228+ theme_entry_theme . style . backgroundColor = < string > inner_bg ;
229+ title . style . color = < string > text
229230
230231 title . innerHTML = ( < string > target_class ) . replace ( / ^ ( \w ) | - ( \w ) / g, " <span style='text-transform:uppercase'>$1$2</span>" ) ;
231232
@@ -234,22 +235,22 @@ function setupThemes(setting_panel: Element) {
234235 let old_theme = active_theme ;
235236 active_theme = < string > target_class ;
236237 setLocalValue ( LocalStoreKeys . ActiveTheme , active_theme ) ;
237- document . body . classList . replace ( old_theme , active_theme ) ;
238- //document.body.classList.remove(old_theme);
238+ if ( active_theme )
239+ document . body . classList . add ( active_theme ) ;
240+ if ( old_theme )
241+ document . body . classList . remove ( old_theme ) ;
239242 await sleep ( 400 ) ;
240243 }
241244 } ) ;
242245
243246 theme . parentElement ?. replaceChild ( theme_entry , theme ) ;
244247
245-
246- if ( default_theme != active_theme ) {
247- document . body . classList . replace ( default_theme , active_theme ) ;
248+ if ( active_theme ) {
249+ document . body . classList . add ( active_theme ) ;
248250 }
249251
250-
251252 return {
252- theme_entry, bg, fg, target_class
253+ theme_entry, bg, fg : inner_bg , target_class
253254 } ;
254255 } ) ;
255256}
0 commit comments