mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 09:52:50 +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);
|
background: var(--bg);
|
||||||
color: var(--text);
|
color: var(--text);
|
||||||
color-scheme: light;
|
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 {
|
.ts-app.ts-theme-dark {
|
||||||
@@ -56,6 +68,11 @@
|
|||||||
|
|
||||||
.ts-demo-banner {
|
.ts-demo-banner {
|
||||||
flex-shrink: 0;
|
flex-shrink: 0;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
padding: 0.35rem 0.75rem;
|
padding: 0.35rem 0.75rem;
|
||||||
background: #7a4d00;
|
background: #7a4d00;
|
||||||
color: #fff;
|
color: #fff;
|
||||||
@@ -68,6 +85,21 @@
|
|||||||
text-decoration: underline;
|
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 */
|
/* Toolbar */
|
||||||
|
|
||||||
.ts-menubar {
|
.ts-menubar {
|
||||||
@@ -1255,7 +1287,7 @@
|
|||||||
|
|
||||||
/* Mobile layout */
|
/* Mobile layout */
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
@container (max-width: 700px) {
|
||||||
.ts-menubar {
|
.ts-menubar {
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
row-gap: 0.2rem;
|
row-gap: 0.2rem;
|
||||||
|
|||||||
+5
-1
@@ -1404,6 +1404,7 @@ function AppInner() {
|
|||||||
const [pokeTarget, setPokeTarget] = useState<{ id: number; name: string } | null>(null);
|
const [pokeTarget, setPokeTarget] = useState<{ id: number; name: string } | null>(null);
|
||||||
const [pokeMessage, setPokeMessage] = useState("");
|
const [pokeMessage, setPokeMessage] = useState("");
|
||||||
const pokeBackdrop = useBackdropDismiss(() => setPokeTarget(null));
|
const pokeBackdrop = useBackdropDismiss(() => setPokeTarget(null));
|
||||||
|
const [demoForceMobile, setDemoForceMobile] = useState(false);
|
||||||
const [activeTab, setActiveTab] = useState<ActiveTab>("channel");
|
const [activeTab, setActiveTab] = useState<ActiveTab>("channel");
|
||||||
const [theme, setTheme] = useState<"light" | "dark">(() =>
|
const [theme, setTheme] = useState<"light" | "dark">(() =>
|
||||||
window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
window.matchMedia?.("(prefers-color-scheme: dark)").matches ? "dark" : "light"
|
||||||
@@ -2144,13 +2145,16 @@ function AppInner() {
|
|||||||
const t = useT();
|
const t = useT();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`ts-app ts-theme-${theme}`}>
|
<div className={`ts-app ts-theme-${theme}${demoForceMobile ? " ts-force-mobile" : ""}`}>
|
||||||
{DEMO_MODE && (
|
{DEMO_MODE && (
|
||||||
<div className="ts-demo-banner">
|
<div className="ts-demo-banner">
|
||||||
Demo mode — simulated data only, no real TeamSpeak server involved.{" "}
|
Demo mode — simulated data only, no real TeamSpeak server involved.{" "}
|
||||||
<a href="https://github.com/Moepchi/webspeak3" target="_blank" rel="noreferrer">
|
<a href="https://github.com/Moepchi/webspeak3" target="_blank" rel="noreferrer">
|
||||||
Get WebSpeak3
|
Get WebSpeak3
|
||||||
</a>
|
</a>
|
||||||
|
<button className="ts-demo-mobile-toggle" onClick={() => setDemoForceMobile((v) => !v)}>
|
||||||
|
{demoForceMobile ? "🖥 Desktop view" : "📱 Mobile view"}
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<div className="ts-menubar">
|
<div className="ts-menubar">
|
||||||
|
|||||||
Reference in new issue
Block a user