Skip to content

Commit

Permalink
fix(utterances): correct theme on the auto color mode
Browse files Browse the repository at this point in the history
  • Loading branch information
razonyang committed Jul 6, 2022
1 parent e8ff2f8 commit 2720497
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion assets/main/js/utterances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,27 @@ class Utterances {
self.rerender(self.getTheme(e.detail.mode));
});
setTimeout(function() {
self.rerender('github-' + LocalStorage.getItem('mode'));
self.rerender(self.getTheme(LocalStorage.getItem('mode')));
}, 2000);
}
}

getPreferMode(): string {
if (window.getComputedStyle(document.body).getPropertyValue('--mode').toString().trim() === 'dark') {
return 'dark';
}
return 'light';
}

getTheme(mode) {
if (mode === 'auto') {
mode = this.getPreferMode();
}
return mode === 'dark' ? 'github-dark' : 'github-light';
}

rerender(theme) {
console.log(theme);
const msg = {
type: 'set-theme',
theme: theme
Expand Down

0 comments on commit 2720497

Please sign in to comment.