Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #235 from trba1810/Theme-always-dark-after-page-re…
Browse files Browse the repository at this point in the history
…fresh-#216

Fixed issue with theme
  • Loading branch information
jamesmontemagno authored Oct 11, 2023
2 parents 54f8155 + 03710de commit 0b587ff
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/Web/Pages/wwwroot/js/theme.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
const theme = localStorage.getItem('theme')
?? matchMedia('(prefers-color-scheme: dark)').matches
const choice = localStorage.getItem('theme');
if (choice != null) {
document.body.setAttribute('data-theme', choice)
}
else {
const theme = localStorage.getItem('theme')
?? matchMedia('(prefers-color-scheme: dark)').matches
? 'Dark' : 'Light';
if (theme === 'Dark') {
document.body.setAttribute('data-theme', theme);
}
if (theme === 'Dark') {
document.body.setAttribute('data-theme', theme);
}
}


0 comments on commit 0b587ff

Please sign in to comment.