1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00
Files
fm-dx-webserver/web/themes.js
NoobishSVK 59469dbeb8 flags
2024-01-21 18:57:43 +01:00

58 lines
1.2 KiB
JavaScript

const themes = {
theme1: {
'--color-main': '#1d1838',
'--color-main-bright': '#8069fa',
},
theme2: {
'--color-main': '#381818',
'--color-main-bright': '#ff7070',
},
theme3: {
'--color-main': '#121c0c',
'--color-main-bright': '#a9ff70',
},
theme4: {
'--color-main': '#0c1c1b',
'--color-main-bright': '#68f7ee',
},
theme5: {
'--color-main': '#171106',
'--color-main-bright': '#f5b642',
},
theme6: {
'--color-main': '#21091d',
'--color-main-bright': '#ed51d3',
},
theme7: {
'--color-main': '#111',
'--color-main-bright': '#aaa',
}
};
function setTheme(themeName) {
const theme = themes[themeName];
if (theme) {
for (const [variable, value] of Object.entries(theme)) {
document.documentElement.style.setProperty(variable, value);
}
}
}
// Get the dropdown element
const themeSelector = document.getElementById('theme-selector');
const savedTheme = localStorage.getItem("theme");
if(savedTheme) {
setTheme(savedTheme);
themeSelector.value = savedTheme;
}
// Listen for changes in the dropdown
themeSelector.addEventListener('change', (event) => {
const selectedTheme = event.target.value;
setTheme(selectedTheme);
localStorage.setItem("theme", selectedTheme);
});