Skip to content

Commit 89fc5ab

Browse files
committed
Update light theme and create manual toggling function between themes
1 parent 3b24f44 commit 89fc5ab

4 files changed

Lines changed: 48 additions & 32 deletions

File tree

css/style.css

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,22 @@ Colors
3535
Colors : Light
3636
****************************************************************************************/
3737
:root.light {
38-
--color-foreground-100: rgb(63, 63, 70, 1);
39-
--color-foreground-075: rgba(63, 63, 70, 0.75);
40-
--color-foreground-050: rgba(63, 63, 70, 0.5);
41-
--color-foreground-025: rgba(63, 63, 70, 0.25);
42-
--color-foreground-010: rgba(63, 63, 70, 0.1);
43-
--color-foreground-005: rgba(63, 63, 70, 0.05);
44-
--color-background-100: rgba(250, 250, 250, 1);
45-
--color-background-075: rgba(250, 250, 250, 0.75);
46-
--color-background-050: rgba(250, 250, 250, 0.5);
47-
--color-background-025: rgba(250, 250, 250, 0.25);
48-
--color-background-010: rgba(250, 250, 250, 0.1);
38+
--color-foreground-100: rgb(46, 43, 41);
39+
--color-foreground-075: rgba(46, 43, 41, 0.75);
40+
--color-foreground-050: rgba(46, 43, 41, 0.5);
41+
--color-foreground-025: rgba(46, 43, 41, 0.25);
42+
--color-foreground-010: rgba(46, 43, 41, 0.1);
43+
--color-foreground-005: rgba(46, 43, 41, 0.05);
44+
--color-background-100: rgb(254, 250, 239);
45+
--color-background-075: rgba(254, 250, 239, 0.75);
46+
--color-background-050: rgba(254, 250, 239, 0.5);
47+
--color-background-025: rgba(254, 250, 239, 0.25);
48+
--color-background-010: rgba(254, 250, 239, 0.1);
49+
--color-warning-100: rgb(155, 144, 0);
50+
--color-warning-075: rgba(155, 144, 0, 0.75);
51+
--color-warning-050: rgba(155, 144, 0, 0.5);
52+
--color-warning-025: rgba(155, 144, 0, 0.25);
53+
--color-warning-010: rgba(155, 144, 0, 0.1);
4954
}
5055
:root.light .status-content {
5156
background-color: var(--color-background-100);

index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@
177177
</div>
178178
</form>
179179
<div class="footer-container">
180-
<span>By using Autoassets, you agree <a href="legal.html">Terms of Service</a><a href="https://github.com/gsbm/autoassets" target="_blank"><span class="icon icon-github"></span> GitHub</a></span>
180+
<span>By using Autoassets, you agree <a href="legal.html">Terms of Service</a></span>
181+
<a href="https://github.com/gsbm/autoassets" target="_blank"><span class="icon icon-github"></span> GitHub</a>
181182
</div>
182183
</div>
183184

js/script.js

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,6 @@ Language handler
1111
// }
1212

1313

14-
/****************************************************************************************
15-
Update sheme based on user preference
16-
****************************************************************************************/
17-
function updateColorScheme(type) {
18-
const root = document.querySelector(':root')
19-
if (type === "light") {
20-
root.classList.add('light');
21-
} else {
22-
root.classList.remove('light');
23-
}
24-
}
25-
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
26-
updateColorScheme("light");
27-
}
28-
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
29-
const new_color_scheme = event.matches ? "dark" : "light";
30-
updateColorScheme(new_color_scheme);
31-
});
32-
33-
3414
/****************************************************************************************
3515
Prompt presets list
3616
****************************************************************************************/

js/utils.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,33 @@ function addFormEvent(event) {
8686

8787
previousEvent = event;
8888
}
89+
90+
/****************************************************************************************
91+
Update sheme based on user preference
92+
****************************************************************************************/
93+
function updateColorScheme(type) {
94+
const root = document.querySelector(':root')
95+
if (type === "light") {
96+
root.classList.add('light');
97+
} else {
98+
root.classList.remove('light');
99+
}
100+
}
101+
102+
function toggleColorScheme() {
103+
const root = document.querySelector(':root');
104+
if (root.classList.contains('light')) {
105+
updateColorScheme("dark");
106+
} else {
107+
updateColorScheme("light");
108+
}
109+
}
110+
111+
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: light)').matches) {
112+
updateColorScheme("light");
113+
}
114+
115+
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
116+
const new_color_scheme = event.matches ? "dark" : "light";
117+
updateColorScheme(new_color_scheme);
118+
});

0 commit comments

Comments
 (0)