diff --git a/src/Web/Pages/wwwroot/js/theme.js b/src/Web/Pages/wwwroot/js/theme.js index 3b90eda4..548b187a 100644 --- a/src/Web/Pages/wwwroot/js/theme.js +++ b/src/Web/Pages/wwwroot/js/theme.js @@ -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); -} \ No newline at end of file + if (theme === 'Dark') { + document.body.setAttribute('data-theme', theme); + } +} + +