mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-23 10:21:46 +01:00
fix(colorScheme): systemPreferScheme not initialized on start up (#1061)
This commit is contained in:
parent
0fb25c808b
commit
245b0f2810
1 changed files with 4 additions and 0 deletions
|
@ -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 a new issue