-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
53 lines (50 loc) · 1.38 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const themes = [
{
background: "#1A1A2E",
color: "#FFFFFF",
primaryColor: "#0F3460"
},
{
background: "#461220",
color: "#FFFFFF",
primaryColor: "#E94560"
},
{
background: "#192A51",
color: "#FFFFFF",
primaryColor: "#967AA1"
},
{
background: "#F7B267",
color: "#000000",
primaryColor: "#F4845F"
},
{
background: "#F25F5C",
color: "#000000",
primaryColor: "#642B36"
},
{
background: "#231F20",
color: "#FFF",
primaryColor: "#BB4430"
}
];
const setTheme = (theme) => {
const root = document.querySelector(":root");
root.style.setProperty("--background", theme.background);
root.style.setProperty("--color", theme.color);
root.style.setProperty("--primary-color", theme.primaryColor);
root.style.setProperty("--glass-color", theme.glassColor);
};
const displayThemeButtons = () => {
const btnContainer = document.querySelector(".theme-btn-container");
themes.forEach((theme) => {
const div = document.createElement("div");
div.className = "theme-btn";
div.style.cssText = `background: ${theme.background}; width: 25px; height: 25px`;
btnContainer.appendChild(div);
div.addEventListener("click", () => setTheme(theme));
});
};
displayThemeButtons();