From 7e674fd2d42d0413fc5fb7864bfb5d03734a2cbf Mon Sep 17 00:00:00 2001 From: Amazingca Date: Sun, 3 May 2026 22:07:21 -0600 Subject: [PATCH] Add final touches --- archived.html | 4 +- archived.js | 19 +++++++++ index.html | 4 +- index.js | 19 +++++++++ settings.html | 12 +++++- settings.js | 40 +++++++++++++++--- style.css | 115 ++++++++++++++++++++++++++++++++++++++++++++++---- 7 files changed, 192 insertions(+), 21 deletions(-) diff --git a/archived.html b/archived.html index 1cf4e00..31d0acf 100644 --- a/archived.html +++ b/archived.html @@ -2,11 +2,11 @@ todo - + - +

todo

diff --git a/archived.js b/archived.js index 9996c47..913cd04 100644 --- a/archived.js +++ b/archived.js @@ -105,3 +105,22 @@ const hydrateTodos = () => { }; hydrateTodos(); + +const updateTheme = (force = false) => { + + if (theme.colorScheme != "default") { + + document.getElementsByTagName("body")[0].className = theme.colorScheme; + } + + if (theme.css != "" || force) { + + const cssOverride = document.createElement("style"); + cssOverride.setAttribute("id", "styleOverride"); + cssOverride.innerHTML = theme.css.replaceAll("<", "<").replaceAll(">", ">"); + if (document.getElementById("styleOverride")) document.getElementById("styleOverride").remove(); + document.getElementsByTagName("head")[0].appendChild(cssOverride); + } +} + +updateTheme(); diff --git a/index.html b/index.html index 915a938..092a4ee 100644 --- a/index.html +++ b/index.html @@ -2,11 +2,11 @@ todo - + - +

todo

diff --git a/index.js b/index.js index 7ca7fa9..8f11f5a 100644 --- a/index.js +++ b/index.js @@ -211,3 +211,22 @@ const hydrateTodos = () => { }; hydrateTodos(); + +const updateTheme = (force = false) => { + + if (theme.colorScheme != "default") { + + document.getElementsByTagName("body")[0].className = theme.colorScheme; + } + + if (theme.css != "" || force) { + + const cssOverride = document.createElement("style"); + cssOverride.setAttribute("id", "styleOverride"); + cssOverride.innerHTML = theme.css.replaceAll("<", "<").replaceAll(">", ">"); + if (document.getElementById("styleOverride")) document.getElementById("styleOverride").remove(); + document.getElementsByTagName("head")[0].appendChild(cssOverride); + } +} + +updateTheme(); diff --git a/settings.html b/settings.html index 1403db1..a2c629b 100644 --- a/settings.html +++ b/settings.html @@ -2,11 +2,11 @@ todo - + - +

todo

@@ -27,6 +27,14 @@

export as link

theming

+
+ + + + + + +

override css

diff --git a/settings.js b/settings.js index f250084..1623357 100644 --- a/settings.js +++ b/settings.js @@ -35,7 +35,7 @@ document.getElementById("exportData").addEventListener("click", async (event) => const exportURL = window.location.href.replace("settings.html", "") + "index.html#" + btoa(JSON.stringify(dataExport)); - if (!window.navigator.userAgent.includes("Firefox")) { + if (!window.navigator.userAgent.includes("Firefox") && !/(Linux|Windows|Mac)/g.test(window.navigator.platform)) { try { @@ -84,15 +84,43 @@ override_css.addEventListener("input", (event) => { theme.css = event.target.value; backupData(); - update(true); + updateTheme(true); }); -const update = (force = false) => { +const themes_select = document.getElementsByClassName("themes_select"); - if (theme.colorScheme != "default") { +for (const option of themes_select) { - document.getElementByTagName("body")[0].classList.add(theme.colorScheme); + option.addEventListener("click", (event) => { + + if (event.target.checked) { + + theme.colorScheme = event.target.getAttribute("value"); + backupData(); + updateTheme(true); + } + }) +} + +const dispatchThemesSelectUpdate = () => { + + for (const option of themes_select) { + + if (option.getAttribute("value") == theme.colorScheme) { + + option.checked = true; + } } +} + +const updateTheme = (force = false) => { + + if (theme.colorScheme != "default" || true) { + + document.getElementsByTagName("body")[0].className = theme.colorScheme; + } + + dispatchThemesSelectUpdate(); if (theme.css != "" || force) { @@ -106,4 +134,4 @@ const update = (force = false) => { } } -update(); +updateTheme(); diff --git a/style.css b/style.css index 2e83146..d788701 100644 --- a/style.css +++ b/style.css @@ -1,8 +1,5 @@ :root { - --text-primary: #000; - --background-primary: #fff; - --background-secondary: #eee; - --background-tertiary: #ccc; + color-scheme: light dark; } body { @@ -12,6 +9,53 @@ body { color: var(--text-primary); background-color: var(--background-primary); font-family: Arial; + + --text-primary: var(--tp); + --background-primary: var(--bp); + --background-secondary: var(--bs); + --background-tertiary: var(--bt); +} + +.default { + --tp: light-dark(#000, #fff); + --bp: light-dark(#fff, #000); + --bs: light-dark(#eee, #111); + --bt: light-dark(#ccc, #333); +} + +.blue { + --tp: light-dark(#001, #eef); + --bp: light-dark(#eef, #001); + --bs: light-dark(#cce, #224); + --bt: light-dark(#99c, #559); +} + +.green { + --tp: light-dark(#010, #efe); + --bp: light-dark(#efe, #010); + --bs: light-dark(#cec, #242); /* Maybe step by 2 in the middle, so "#232" */ + --bt: light-dark(#9c9, #464); +} + +.yellow { + --tp: light-dark(#110, #ffe); + --bp: light-dark(#ffe, #110); + --bs: light-dark(#eec, #442); + --bt: light-dark(#cc9, #664); +} + +.red { + --tp: light-dark(#100, #fee); + --bp: light-dark(#fee, #100); + --bs: light-dark(#ecc, #422); + --bt: light-dark(#c99, #644); +} + +.purple { + --tp: light-dark(#101, #fef); + --bp: light-dark(#fef, #101); + --bs: light-dark(#ece, #424); + --bt: light-dark(#c9c, #646); } h3 { @@ -29,7 +73,7 @@ header { gap: 0.5rem; } & > hr { - border: 1px solid var(--text-primary); + border: 1px solid var(--background-tertiary); } } @@ -44,7 +88,8 @@ nav { width: 100%; justify-content: center; & > div, #todos, #todos-completed, #archived { - width: 400px; + max-width: 400px; + width: 100%; display: flex; flex-direction: column; gap: 0.25rem; @@ -55,19 +100,19 @@ todo { background-color: var(--background-secondary); border-radius: 0.5rem; display: flex; - /* align-items: center; */ padding: 0.5rem; gap: 0.5rem; & .completion { cursor: pointer; } & .data { - flex-grow: 0.97; + flex-grow: 1; & textarea { - width: 100%; + width: -webkit-fill-available; resize: none; border: unset; border-radius: 0.25rem; + background-color: var(--background-primary); &:focus-visible { outline: unset; } @@ -92,6 +137,7 @@ todo { } button { + color: var(--text-primary); background-color: var(--background-secondary); border: unset; border-radius: 0.5rem; @@ -103,6 +149,38 @@ button { cursor: pointer; } +.themes { + display: flex; + flex-wrap: wrap; + justify-content: center; + gap: 0.5rem; + & > label { + display: flex; + justify-content: center; + align-items: center; + flex: 0 0 30%; + width: 40%; + aspect-ratio: 3 / 2; + background-image: linear-gradient(to right, light-dark(var(--bs), var(--tp)), light-dark(var(--tp), var(--bs))); + border-radius: 0.5rem; + border: 0.25rem solid color-mix(in oklab, var(--bs), var(--tp) 50%); + cursor: pointer; + &:active { + filter: brightness(75%); + } + & > input[type="radio"] { + accent-color: color-mix(in oklab, var(--bs), var(--tp) 50%); + opacity: 0; + margin: 0; + } + &:has(> input[type="radio"]:checked) > input[type="radio"] { + opacity: unset; + width: 2rem; + height: 2rem; + } + } +} + #override_css { font-family: monospace; border-radius: 0.5rem; @@ -135,3 +213,22 @@ div:has(> #todos-completed.hidden), #main div:not(:has(#todos-completed.hidden)) show { display: none; } + +@media screen and (max-width: 400px) { + h3 { + font-size: 1.5rem !important; + } + p { + font-size: 1rem !important; + } + button { + font-size: 1rem !important; + } +} + +@media screen and (max-width: 250px) { + .themes > label > input[type="radio"] { + width: unset !important; + height: unset !important; + } +} -- 2.54.0