From 2cb39f0c55d33dbba7af917f62796900ef47a7ac Mon Sep 17 00:00:00 2001 From: Ermin Zoronjic Date: Tue, 28 Apr 2026 21:57:39 +0200 Subject: [PATCH] add darkmode switch --- parfum-shop/src/App.css | 50 +++++- parfum-shop/src/App.jsx | 68 +++++--- .../src/components/ProductDetailPage.css | 152 +++++++++--------- parfum-shop/src/components/SharedNavbar.jsx | 13 ++ parfum-shop/src/components/ShopDrawer.css | 108 +++++++------ parfum-shop/src/components/SupportChatbot.css | 57 +++---- parfum-shop/src/index.css | 30 +++- parfum-shop/src/main.jsx | 1 + parfum-shop/src/pages/AboutPage.css | 71 ++++---- parfum-shop/src/pages/DatenschutzPage.css | 27 ++-- parfum-shop/src/pages/DiscoverySetPage.css | 55 +++---- parfum-shop/src/pages/ImpressumPage.css | 33 ++-- parfum-shop/src/pages/LandingPage.css | 19 +-- parfum-shop/src/pages/SmallBatchPage.css | 26 +-- parfum-shop/src/pages/SupportPage.css | 55 +++---- parfum-shop/src/style/navbar.css | 59 ++++++- 16 files changed, 501 insertions(+), 323 deletions(-) diff --git a/parfum-shop/src/App.css b/parfum-shop/src/App.css index b128901..fd25b17 100644 --- a/parfum-shop/src/App.css +++ b/parfum-shop/src/App.css @@ -10,6 +10,52 @@ body, font-family: "Questrial", Arial, Helvetica, sans-serif; } -body { - background: #efefef; +#root { + background: var(--theme-bg); + color: var(--theme-text); +} + +body { + background: var(--theme-bg); +} + +.navbar--light .nav-pill, +.navbar--light .nav-link, +[class*="-page"], +[class*="-shell"], +[class*="-card"], +[class*="-panel"], +[class*="-box"], +button, +input, +textarea { + transition: background-color 0.24s ease, border-color 0.24s ease, color 0.24s ease; +} + +body.theme-dark .navbar--light .nav-pill { + background: rgba(38, 38, 38, 0.88); + border-color: rgba(234, 234, 234, 0.26); +} + +body.theme-dark .navbar--light .nav-link { + color: var(--theme-white); +} + +body.theme-dark .navbar--light .nav-link:hover, +body.theme-dark .navbar--light .nav-link.active { + background: rgba(234, 234, 234, 0.15); +} + +body.theme-dark .navbar--light .nav-theme-switch__track { + border-color: rgba(234, 234, 234, 0.3); + background: rgba(234, 234, 234, 0.14); +} + +body.theme-dark .navbar--light .nav-brand-logo { + filter: invert(1) brightness(1.08); +} + +body.theme-light .navbar--light .nav-link:hover, +body.theme-light .navbar--light .nav-link.active { + background: var(--theme-surface-soft); } diff --git a/parfum-shop/src/App.jsx b/parfum-shop/src/App.jsx index a1b763c..e9d27f7 100644 --- a/parfum-shop/src/App.jsx +++ b/parfum-shop/src/App.jsx @@ -1,4 +1,4 @@ -import { useRef } from "react"; +import { useEffect, useRef, useState } from "react"; import { Routes, Route, useLocation } from "react-router"; import LandingPage from "./pages/LandingPage"; import ProductDetailPage from "./components/ProductDetailPage"; @@ -14,38 +14,66 @@ import ScrollToTop from "./components/ScrollToTop"; import ShopDrawer from "./components/ShopDrawer"; import CartToast from "./components/CartToast"; import useScrollTextReveal from "./hooks/useScrollTextReveal"; +import { ThemeProvider } from "./theme/ThemeContext"; import "./style/textReveal.css"; +const THEME_STORAGE_KEY = "atmos-theme"; + function App() { const location = useLocation(); const routeContentRef = useRef(null); + const [theme, setTheme] = useState(() => { + if (typeof window === "undefined") return "dark"; + const storedTheme = window.localStorage.getItem(THEME_STORAGE_KEY); + return storedTheme === "light" ? "light" : "dark"; + }); const shouldFlushFooter = location.pathname === "/" || location.pathname.startsWith("/duft/"); useScrollTextReveal(routeContentRef, [location.pathname]); + useEffect(() => { + if (typeof document === "undefined") return; + + document.body.classList.remove("theme-dark", "theme-light"); + document.body.classList.add(theme === "light" ? "theme-light" : "theme-dark"); + document.documentElement.style.colorScheme = theme === "light" ? "light" : "dark"; + + if (typeof window !== "undefined") { + window.localStorage.setItem(THEME_STORAGE_KEY, theme); + } + }, [theme]); + + const toggleTheme = () => { + setTheme((currentTheme) => (currentTheme === "dark" ? "light" : "dark")); + }; + + const isLight = theme === "light"; + return ( - <> - + + <> + -
- - } /> - } /> - } /> - } /> - } /> - } /> - } /> - } /> - -
+
+ + } /> + } /> + } /> + } /> + } /> + } /> + } /> + } /> + +
- - -