mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
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.
This commit is contained in:
1 parent
530415b50b
commit
69b256eb42
2 files changed
+38
-2
No files matched your search
+33
-1
@@ -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;
|
||||
|
||||
+5
-1
@@ -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<ActiveTab>("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 (
|
||||
<div className={`ts-app ts-theme-${theme}`}>
|
||||
<div className={`ts-app ts-theme-${theme}${demoForceMobile ? " ts-force-mobile" : ""}`}>
|
||||
{DEMO_MODE && (
|
||||
<div className="ts-demo-banner">
|
||||
Demo mode — simulated data only, no real TeamSpeak server involved.{" "}
|
||||
<a href="https://github.com/Moepchi/webspeak3" target="_blank" rel="noreferrer">
|
||||
Get WebSpeak3
|
||||
</a>
|
||||
<button className="ts-demo-mobile-toggle" onClick={() => setDemoForceMobile((v) => !v)}>
|
||||
{demoForceMobile ? "🖥 Desktop view" : "📱 Mobile view"}
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
<div className="ts-menubar">
|
||||
|
||||
Reference in new issue
Block a user