Skip to content

Commit 545de20

Browse files
committed
Only dark and light mode.
1 parent ce5ddff commit 545de20

2 files changed

Lines changed: 13 additions & 29 deletions

File tree

_sass/_themes.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,17 @@
4444
--global-danger-block-title: #c00;
4545

4646
#light-toggle-system {
47-
padding-left: 10px;
48-
padding-top: 12px;
49-
display: block;
47+
display: none;
5048
}
5149

5250
#light-toggle-dark {
5351
display: none;
5452
}
5553

5654
#light-toggle-light {
57-
display: none;
55+
padding-left: 10px;
56+
padding-top: 12px;
57+
display: block;
5858
}
5959

6060
.only-light {

assets/js/theme.js

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
// Has to be in the head tag, otherwise a flicker effect will occur.
22

3-
// Toggle through light, dark, and system theme settings.
3+
// Toggle between light and dark theme settings.
44
let toggleThemeSetting = () => {
55
let themeSetting = determineThemeSetting();
6-
if (themeSetting == "system") {
7-
setThemeSetting("light");
8-
} else if (themeSetting == "light") {
6+
if (themeSetting == "light") {
97
setThemeSetting("dark");
108
} else {
11-
setThemeSetting("system");
9+
setThemeSetting("light");
1210
}
1311
};
1412

@@ -251,30 +249,19 @@ let transTheme = () => {
251249
}, 500);
252250
};
253251

254-
// Determine the expected state of the theme toggle, which can be "dark", "light", or
255-
// "system". Default is "system".
252+
// Determine the expected state of the theme toggle, which can be "dark" or "light". Default is "light".
256253
let determineThemeSetting = () => {
257254
let themeSetting = localStorage.getItem("theme");
258-
if (themeSetting != "dark" && themeSetting != "light" && themeSetting != "system") {
259-
themeSetting = "system";
255+
if (themeSetting != "dark" && themeSetting != "light") {
256+
themeSetting = "light";
260257
}
261258
return themeSetting;
262259
};
263260

264-
// Determine the computed theme, which can be "dark" or "light". If the theme setting is
265-
// "system", the computed theme is determined based on the user's system preference.
261+
// Determine the computed theme, which can be "dark" or "light".
266262
let determineComputedTheme = () => {
267263
let themeSetting = determineThemeSetting();
268-
if (themeSetting == "system") {
269-
const userPref = window.matchMedia;
270-
if (userPref && userPref("(prefers-color-scheme: dark)").matches) {
271-
return "dark";
272-
} else {
273-
return "light";
274-
}
275-
} else {
276-
return themeSetting;
277-
}
264+
return themeSetting;
278265
};
279266

280267
let initTheme = () => {
@@ -291,8 +278,5 @@ let initTheme = () => {
291278
});
292279
});
293280

294-
// Add event listener to the system theme preference change.
295-
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", ({ matches }) => {
296-
applyTheme();
297-
});
281+
// System theme preference listener removed - only light/dark modes supported
298282
};

0 commit comments

Comments
 (0)