forked from deepStateMirrors/tabi
Refactor the theme initialization script to use 'const' instead of 'let' for the 'currentTheme' variable, as the value is not expected to change after initialization. This makes the code more clear and prevents accidental re-assignment.
9 lines
377 B
JavaScript
9 lines
377 B
JavaScript
(function () {
|
|
const currentTheme = localStorage.getItem('theme');
|
|
if (currentTheme) {
|
|
document.documentElement.setAttribute('data-theme', currentTheme);
|
|
} else {
|
|
const isSystemDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
document.documentElement.setAttribute('data-theme', isSystemDark ? 'dark' : 'light');
|
|
}
|
|
})();
|