Skip to content

Commit

Permalink
fix: dark theme detect
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Jul 17, 2024
1 parent 411e2f9 commit 9ab39d7
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/commandpalette/widgets/utils/handleDarkMode.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export function handleDarkMode() {
const isDark = $tw.wiki.getTiddlerText('$:/info/darkmode') === 'yes';
if (isDark) {
// https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-theme-classic/#dark-mode
const dataset = document.body?.dataset;
if (dataset !== undefined) {
const isDark = $tw.wiki.filterTiddlers('[[$:/palette]get[text]get[color-scheme]compare:string:eq[dark]]').length > 0;
const dataset = document.body?.dataset;
if (dataset !== undefined) {
if (isDark) {
// https://www.algolia.com/doc/ui-libraries/autocomplete/api-reference/autocomplete-theme-classic/#dark-mode
dataset.theme = 'dark';
} else {
dataset.theme = 'light';
}
}
}

0 comments on commit 9ab39d7

Please sign in to comment.