mirror of
https://github.com/derf/travelynx
synced 2024-12-14 06:52:35 +00:00
12 lines
476 B
JavaScript
12 lines
476 B
JavaScript
var validThemes = ['dark.min', 'light.min'];
|
|
var currentTheme = localStorage.getItem('theme');
|
|
if (!validThemes.includes(currentTheme)) {
|
|
currentTheme = window.matchMedia('(prefers-color-scheme: dark').matches ? 'dark.min' : 'light.min';
|
|
}
|
|
addStyleSheet(currentTheme, 'theme');
|
|
|
|
function toggleTheme() {
|
|
currentTheme = currentTheme === 'dark.min' ? 'light.min' : 'dark.min';
|
|
localStorage.setItem('theme', currentTheme);
|
|
addStyleSheet(currentTheme, 'theme');
|
|
}
|