summaryrefslogtreecommitdiff
path: root/public/static/js/theme.js
blob: 71fb6ae34b80e8b746342f132a82d88f915ef7f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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');
}