mirror of
https://github.com/CaiJimmy/hugo-theme-stack.git
synced 2024-11-27 04:03:48 +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) {
|
constructor(toggleEl: HTMLElement) {
|
||||||
this.bindMatchMedia();
|
this.bindMatchMedia();
|
||||||
this.currentScheme = this.getSavedScheme();
|
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);
|
this.dispatchEvent(document.documentElement.dataset.scheme as colorScheme);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue