diff --git a/decnet_web/src/App.tsx b/decnet_web/src/App.tsx index 814d0fa5..bba561b9 100644 --- a/decnet_web/src/App.tsx +++ b/decnet_web/src/App.tsx @@ -182,6 +182,17 @@ function App() { } } catch { /* fall through to default */ } document.documentElement.setAttribute('data-accent', accent); + + /* Lab theme persists in sessionStorage so a tab reload keeps the + * dev's chosen theme without leaking to other tabs or users. The + * production user-facing toggle (localStorage `decnet_theme`) + * arrives with the Config-page setting in a later task. */ + try { + const labTheme = sessionStorage.getItem('decnet_theme_lab'); + if (labTheme === 'light' || labTheme === 'dark') { + document.documentElement.setAttribute('data-theme', labTheme); + } + } catch { /* ignore */ } }, []); const handleLogin = (newToken: string) => setToken(newToken); diff --git a/decnet_web/src/components/ThemeLab/ThemeLab.css b/decnet_web/src/components/ThemeLab/ThemeLab.css index c076daa4..0a4cebdc 100644 --- a/decnet_web/src/components/ThemeLab/ThemeLab.css +++ b/decnet_web/src/components/ThemeLab/ThemeLab.css @@ -8,6 +8,19 @@ gap: var(--space-8); } +.lab-page-header { + display: flex; + justify-content: space-between; + align-items: flex-end; + gap: var(--space-4); + flex-wrap: wrap; +} + +.lab-theme-toggle { + display: inline-flex; + gap: var(--space-2); +} + .theme-lab .page-header h1 { font-size: var(--fs-page); letter-spacing: var(--ls-title); diff --git a/decnet_web/src/components/ThemeLab/ThemeLab.tsx b/decnet_web/src/components/ThemeLab/ThemeLab.tsx index 3a51dc98..dd3b7a0b 100644 --- a/decnet_web/src/components/ThemeLab/ThemeLab.tsx +++ b/decnet_web/src/components/ThemeLab/ThemeLab.tsx @@ -1,4 +1,5 @@ import React, { useEffect, useState } from 'react'; +import ThemeToggle from './ThemeToggle'; import './ThemeLab.css'; /* Kitchen-sink theme lab. @@ -314,13 +315,14 @@ const NetBoxes: React.FC = () => ( const ThemeLab: React.FC = () => { return (