From eb0585072ddf1c5d6db2a52d9eee3c6eb9001570 Mon Sep 17 00:00:00 2001 From: ISA Date: Mon, 8 Sep 2025 13:14:04 +0200 Subject: [PATCH] WIP: dark mode --- .env.development | 2 +- .env.production | 2 +- CHANGELOG.md | 5 +++++ components/header/Header.tsx | 43 +++++++++++++++++++++++++++++------- package-lock.json | 4 ++-- package.json | 2 +- pages/_document.tsx | 17 +++++++++++--- 7 files changed, 59 insertions(+), 16 deletions(-) diff --git a/.env.development b/.env.development index 5d818ce..226bc4b 100644 --- a/.env.development +++ b/.env.development @@ -6,6 +6,6 @@ NEXT_PUBLIC_USE_MOCK_BACKEND_LOOP_START=false NEXT_PUBLIC_EXPORT_STATIC=false NEXT_PUBLIC_USE_CGI=false # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.869 +NEXT_PUBLIC_APP_VERSION=1.6.870 NEXT_PUBLIC_CPL_MODE=json # json (Entwicklungsumgebung) oder jsSimulatedProd (CPL ->CGI-Interface-Simulator) oder production (CPL-> CGI-Interface Platzhalter) diff --git a/.env.production b/.env.production index 32cfc40..b9091ba 100644 --- a/.env.production +++ b/.env.production @@ -5,5 +5,5 @@ NEXT_PUBLIC_CPL_API_PATH=/CPL NEXT_PUBLIC_EXPORT_STATIC=true NEXT_PUBLIC_USE_CGI=true # App-Versionsnummer -NEXT_PUBLIC_APP_VERSION=1.6.869 +NEXT_PUBLIC_APP_VERSION=1.6.870 NEXT_PUBLIC_CPL_MODE=production \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 94f3c0c..df97e2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## [1.6.870] – 2025-09-08 + +- fix: Beim Aufruf der TDR-Detailseite erscheint im Hintergrund auf der KÜ ein Schleifenwiderstand von 0 KOhm. In der Daten Javascriptdatei steht jedoch der richtige Wert. + +--- ## [1.6.869] – 2025-09-08 - fix: Beim Ausführen einer TDR-Messung (Klick auf blauen Button in der TDR-Detailseite) erscheint keine Rückmeldung. Dort müsste ein Hinweis erscheinen “TDR-Messung wird ausgeführt und kann bis zu zwei Minuten dauern” diff --git a/components/header/Header.tsx b/components/header/Header.tsx index 4458bcf..57b753a 100644 --- a/components/header/Header.tsx +++ b/components/header/Header.tsx @@ -109,19 +109,46 @@ function Header() { }, [deviceName, dispatch]); //---------------------------------------------------------------- - // Dark/Light Mode Toggle - const [isDark, setIsDark] = useState(false); - useEffect(() => { + // Dark/Light Mode Toggle (persist in localStorage) + const [isDark, setIsDark] = useState(() => { if (typeof window !== "undefined") { - const html = document.documentElement; - if (isDark) { - html.classList.add("dark"); - } else { - html.classList.remove("dark"); + return document.documentElement.classList.contains("dark"); + } + return false; + }); + + // Apply + persist when toggled + useEffect(() => { + if (typeof window === "undefined") return; + const html = document.documentElement; + if (isDark) { + html.classList.add("dark"); + try { + localStorage.setItem("theme", "dark"); + } catch { + /* ignore storage write errors */ + } + } else { + html.classList.remove("dark"); + try { + localStorage.setItem("theme", "light"); + } catch { + /* ignore storage write errors */ } } }, [isDark]); + // Sync if another tab changes the theme + useEffect(() => { + const handler = (e: StorageEvent) => { + if (e.key === "theme" && e.newValue) { + setIsDark(e.newValue === "dark"); + } + }; + window.addEventListener("storage", handler); + return () => window.removeEventListener("storage", handler); + }, []); + return (
{try{const k='theme';const t=localStorage.getItem(k);const m=window.matchMedia('(prefers-color-scheme: dark)').matches;const useDark = t? t==='dark' : m;const c=document.documentElement.classList;useDark?c.add('dark'):c.remove('dark');}catch(e){/* ignore */}})();`; return ( - {/* Füge Meta-Tags, CSS-Links und andere Header-Inhalte hier hinzu */} + {/* Early inline script (no external blocking) */} +