mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2025-02-06 03:43:32 +08:00
fix(colorScheme): systemPreferScheme not initialized on start up (#1061)
This commit is contained in:
parent
0fb25c808b
commit
245b0f2810
@ -8,6 +8,10 @@ class StackColorScheme {
|
||||
constructor(toggleEl: HTMLElement) {
|
||||
this.bindMatchMedia();
|
||||
this.currentScheme = this.getSavedScheme();
|
||||
if (window.matchMedia('(prefers-color-scheme: dark)').matches === true)
|
||||
this.systemPreferScheme = 'dark'
|
||||
else
|
||||
this.systemPreferScheme = 'light';
|
||||
|
||||
this.dispatchEvent(document.documentElement.dataset.scheme as colorScheme);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user