From 69b256eb421de7248cc1b8cc80a68137f57919af Mon Sep 17 00:00:00 2001 From: Moepchi Date: Sun, 2 Aug 2026 13:43:17 +0200 Subject: [PATCH] Add demo-only mobile view toggle Simulates a narrow viewport by capping .ts-app's own width and using a container query (instead of a media query) for the mobile breakpoint, so the toggle exercises the exact same CSS path real narrow browsers hit. Only rendered when VITE_DEMO_MODE is set. --- web/src/App.css | 34 +++++++++++++++++++++++++++++++++- web/src/App.tsx | 6 +++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/web/src/App.css b/web/src/App.css index aa240ed..af519bd 100644 --- a/web/src/App.css +++ b/web/src/App.css @@ -26,6 +26,18 @@ background: var(--bg); color: var(--text); color-scheme: light; + container-type: inline-size; +} + +/* Demo-only: simulates a narrow viewport so the mobile layout (driven by + the @container rules below) can be previewed without resizing the + actual browser window. */ +.ts-app.ts-force-mobile { + max-width: 390px; + margin: 0 auto; + box-shadow: + 0 0 0 1px rgba(0, 0, 0, 0.4), + 0 0 40px rgba(0, 0, 0, 0.5); } .ts-app.ts-theme-dark { @@ -56,6 +68,11 @@ .ts-demo-banner { flex-shrink: 0; + display: flex; + align-items: center; + justify-content: center; + flex-wrap: wrap; + gap: 0.5rem; padding: 0.35rem 0.75rem; background: #7a4d00; color: #fff; @@ -68,6 +85,21 @@ text-decoration: underline; } +.ts-demo-mobile-toggle { + flex-shrink: 0; + border: 1px solid rgba(255, 255, 255, 0.6); + border-radius: 999px; + background: rgba(255, 255, 255, 0.15); + color: #fff; + padding: 0.15rem 0.6rem; + font-size: 11px; + cursor: pointer; +} + +.ts-demo-mobile-toggle:hover { + background: rgba(255, 255, 255, 0.28); +} + /* Toolbar */ .ts-menubar { @@ -1255,7 +1287,7 @@ /* Mobile layout */ -@media (max-width: 700px) { +@container (max-width: 700px) { .ts-menubar { flex-wrap: wrap; row-gap: 0.2rem; diff --git a/web/src/App.tsx b/web/src/App.tsx index 15b37c1..cb1683d 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -1404,6 +1404,7 @@ function AppInner() { const [pokeTarget, setPokeTarget] = useState<{ id: number; name: string } | null>(null); const [pokeMessage, setPokeMessage] = useState(""); const pokeBackdrop = useBackdropDismiss(() => setPokeTarget(null)); + const [demoForceMobile, setDemoForceMobile] = useState(false); const [activeTab, setActiveTab] = useState("channel"); const [theme, setTheme] = useState<"light" | "dark">(() => window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light" @@ -2144,13 +2145,16 @@ function AppInner() { const t = useT(); return ( -
+
{DEMO_MODE && (
Demo mode — simulated data only, no real TeamSpeak server involved.{" "} Get WebSpeak3 +
)}