Compare commits

...

3 commits

Author SHA1 Message Date
ffe6cb2203
item/css
All checks were successful
/ job (push) Successful in 1m18s
2025-04-17 11:55:01 +02:00
aec7a3fd61
js 2025-04-17 11:19:35 +02:00
e395348e62
item/html 2025-04-17 11:02:37 +02:00
4 changed files with 31 additions and 30 deletions

View file

@ -31,8 +31,9 @@
<a href="https://en.wikipedia.org/wiki/France">France</a> <a href="https://en.wikipedia.org/wiki/France">France</a>
</p> </p>
</div> </div>
<button id="theme"><img class="inline" src="../img/theme.svg" alt="Theme"></button>
<button class="link" id="link"><img class="inline" src="../img/link.svg" alt="Links"></button> <button class="link" id="link"><img class="inline" src="../img/link.svg" alt="Links"></button>
<button class="item" id="item"><ul><li></li></ul></button>
<button id="theme"><img class="inline" src="../img/theme.svg" alt="Theme"></button>
</header> </header>
<section class="banner"> <section class="banner">

View file

@ -31,8 +31,9 @@
</p> </p>
</div> </div>
<button id="theme"><img class="inline" src="../img/theme.svg" alt="Thème"></button>
<button class="link" id="link"><img class="inline" src="../img/link.svg" alt="Liens"></button> <button class="link" id="link"><img class="inline" src="../img/link.svg" alt="Liens"></button>
<button class="item" id="item"><ul><li></li></ul></button>
<button id="theme"><img class="inline" src="../img/theme.svg" alt="Thème"></button>
</header> </header>
<section class="banner"> <section class="banner">

View file

@ -1,6 +1,4 @@
const buttons = ["link", "swap"]; const buttons = ["item", "link", "swap"];
// toggle buttons
for (let button of buttons) { for (let button of buttons) {
document.getElementById(button).addEventListener("click", () => { document.getElementById(button).addEventListener("click", () => {
@ -8,35 +6,32 @@ for (let button of buttons) {
}); });
} }
// theme let theme
const button = document.getElementById("theme");
function theme_get() { function theme_get() {
return document.documentElement.getAttribute("data-theme"); theme = localStorage.getItem("theme");
} if (! theme) {
function theme_load() { if (window.matchMedia("(prefers-color-scheme: dark)").matches) {
const theme = localStorage.getItem("theme"); theme = "dark";
if (theme) { } else {
theme_set(theme); theme = "light";
}
} }
theme_set()
} }
function theme_set(theme) {
function theme_set() {
document.documentElement.setAttribute("data-theme", theme); document.documentElement.setAttribute("data-theme", theme);
theme_write(theme);
}
function theme_swap(theme) {
return theme === "dark" ? "light" : "dark";
}
function theme_toggle() {
theme_set(theme_swap(theme_get()));
}
function theme_write(theme) {
localStorage.setItem("theme", theme); localStorage.setItem("theme", theme);
} }
button.addEventListener("click", () => { function theme_swap() {
theme_toggle(); theme = theme === "light" ? "dark" : "light";
theme_set();
}
document.getElementById("theme").addEventListener("click", () => {
theme_swap();
}); });
theme_load(); theme_get()

View file

@ -54,7 +54,7 @@
/* main */ /* main */
#link, #theme, #swap { #item, #link, #swap, #theme {
background-color: var(--button-background); background-color: var(--button-background);
} }
#swap::after { content: "←"; } #swap::after { content: "←"; }
@ -107,6 +107,10 @@ a:hover {
color: var(--anchor-text); color: var(--anchor-text);
} }
body.item button.item {
background: var(--item-odd-gradient);
}
article.org, header { article.org, header {
border-radius: .25em; border-radius: .25em;
padding-block: .25em; padding-block: .25em;
@ -198,10 +202,10 @@ img.photo {
border-top: var(--border-on); border-top: var(--border-on);
} }
li:nth-of-type(even) { body.item li:nth-of-type(even) {
background: var(--item-even-gradient); background: var(--item-even-gradient);
} }
li:nth-of-type(odd) { body.item li:nth-of-type(odd) {
background: var(--item-odd-gradient); background: var(--item-odd-gradient);
} }