Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jul 2, 2024. It is now read-only.

Commit 094a283

Browse files
[Presentation] Database normalization (w/o styling) (#223)
1 parent 120434a commit 094a283

36 files changed

+1627
-1284
lines changed

‎assets/icons/moon-svgrepo-com.svg

Lines changed: 45 additions & 0 deletions
Loading[フレーム]

‎assets/icons/sun-svgrepo-com.svg

Lines changed: 101 additions & 0 deletions
Loading[フレーム]

‎src/_static/js/theme.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// theme variables
2+
const themeAttribute = "data-theme"
3+
const theme = {
4+
light: "light",
5+
dark: "dark",
6+
}
7+
const userTheme = localStorage.getItem(themeAttribute)
8+
const isSystemThemeDark = window.matchMedia("(prefers-color-scheme: dark)").matches
9+
10+
11+
// initial theme check
12+
const checkTheme = () => {
13+
if (userTheme === theme.dark || (!userTheme && isSystemThemeDark)) {
14+
document.documentElement.setAttribute(themeAttribute, theme.dark)
15+
} else document.documentElement.setAttribute(themeAttribute, theme.light)
16+
}
17+
18+
19+
// manual theme select
20+
const swapTheme = () => {
21+
const currentTheme = document.documentElement.getAttribute(themeAttribute)
22+
const themeValue = currentTheme === theme.light ? theme.dark : theme.light
23+
localStorage.setItem(themeAttribute, themeValue)
24+
document.documentElement.setAttribute(themeAttribute, themeValue)
25+
}
26+
27+
28+
const swapThemeBtn = document.getElementById("swap-theme-btn");
29+
if (swapThemeBtn) swapThemeBtn.addEventListener("click", swapTheme)
30+
31+
document.addEventListener("DOMContentLoaded", () => {
32+
checkTheme()
33+
})

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /