feat: home pages adapted to mobile

This commit is contained in:
Lucas
2026-10-26 14:25:56 +01:00
parent 631a66ceb5
commit cb34e5ef41
50 changed files with 1219 additions and 7 deletions
+67
View File
@@ -34,6 +34,7 @@ body {
display: flex;
flex-direction: column;
height: 100vh;
height: 100dvh;
}
@media (prefers-reduced-motion: reduce) {
@@ -60,11 +61,13 @@ button {
.stage {
flex: 1;
min-height: 0;
display: flex;
align-items: center;
justify-content: center;
background: var(--bg-panel);
overflow-y: auto;
-webkit-overflow-scrolling: touch;
}
/* Global scrollbar */
@@ -85,3 +88,67 @@ button {
::-webkit-scrollbar-thumb:hover {
background: var(--text-muted);
}
/* ---------- Touch / phone support ---------- */
html,
body {
overscroll-behavior: none; /* no pull-to-refresh / rubber-band */
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: transparent;
}
button,
[role='button'] {
touch-action: manipulation; /* removes 300ms delay + double-tap zoom */
}
/* Safe areas (notch, status bar, home indicator) */
.app {
padding-top: env(safe-area-inset-top);
padding-bottom: env(safe-area-inset-bottom);
padding-left: env(safe-area-inset-left);
padding-right: env(safe-area-inset-right);
}
/* Touch devices: bigger hit targets, no hover-only behaviour */
@media (pointer: coarse) {
button,
select,
input[type='checkbox'],
input[type='radio'] {
min-height: 44px;
}
::-webkit-scrollbar {
width: 0;
height: 0;
}
}
/* Phone layout */
@media (max-width: 768px) {
.stage {
align-items: center; /* tall content starts at top instead of being clipped */
justify-content: center;
padding: 8px;
}
.stage > * {
margin: auto;
}
/* iOS zooms the page if an input's font is under 16px */
input,
select,
textarea {
font-size: 16px;
}
}
/* Landscape phone: reclaim vertical space */
@media (max-height: 500px) and (orientation: landscape) {
.stage {
padding: 4px;
}
}
+3 -1
View File
@@ -13,6 +13,7 @@ import { removeDSP } from './dsp/dspShared';
import { stopAllPolling } from './dsp/pollRegistry';
import { loadSavedDSPs, saveDSPs, toSaved } from './dsp/dspStorage';
import { DSPMode } from './features/dsp408/types';
import { useIsMobile } from './hooks/useIsMobile';
function App() {
const [dsps, setDsps] = useState<DSP[]>([]);
@@ -22,6 +23,7 @@ function App() {
const { notifications, notify, removeNotification, hoverNotification } = useNotifications();
const connectedDspCount = dsps.filter((dsp) => isConnected(dsp)).length;
const restoreStarted = useRef(false);
const isMobile = useIsMobile();
const activeDsp = dsps.find((d) => d.id === selected) ?? null;
const activeInstance = activeDsp ? createDSPInstance(activeDsp, setDsps, notify) : null;
@@ -70,7 +72,7 @@ function App() {
}, [activeDsp?.id]);
return (
<div className="app">
<div className={`app${isMobile ? ' app--mobile' : ''}`}>
<Notifications
notifications={notifications}
onRemove={removeNotification}
+117
View File
@@ -265,3 +265,120 @@
var(--tab-close-size)
);
}
/* ---------- Phone / touch ---------- */
/* Touch has no real hover: stop highlights from sticking after a tap */
@media (hover: none) {
.tab:hover {
background: transparent;
color: var(--text-muted);
border-color: var(--border-hairline);
}
.tab--active:hover {
background: var(--bg-panel);
color: var(--text-primary);
border-color: var(--accent-brand);
}
.tab-action:hover {
background: transparent;
border-color: transparent;
}
.tab-close:hover {
background: transparent;
color: var(--text-muted);
}
}
/* Undo the global 44px min-height for TopBar buttons (sized by the bar instead) */
@media (pointer: coarse) {
.topbar button {
min-height: 0;
}
/* Bigger invisible tap areas without changing the look */
.tab-led,
.tab-close {
position: relative;
}
.tab-led::after,
.tab-close::after {
content: '';
position: absolute;
inset: -10px;
}
}
@media (max-width: 768px) {
.topbar {
--header-height: 56px;
--tab-height: 40px;
gap: var(--space-2);
padding-inline: var(--space-2);
}
.logo-slot {
height: 70%;
flex: 0 0 auto;
}
.tabstrip {
gap: var(--space-2);
padding-left: var(--space-2);
scroll-snap-type: x mandatory;
scrollbar-width: none;
-webkit-overflow-scrolling: touch;
overscroll-behavior-x: contain;
}
.tabstrip::-webkit-scrollbar {
display: none;
}
/* Fixed-ish tab width instead of 25%, so names stay readable and you swipe */
.tab,
.tab[data-step='6'],
.tab[data-step='8'],
.tab[data-step='10'] {
flex: 0 0 auto;
width: min(44vw, 180px);
max-width: none;
min-width: 0;
font-size: var(--font-sm, var(--font-xs));
padding: 0 var(--space-2);
}
.tab-led {
height: 60%;
}
.tab-close {
height: 60%;
}
.tabstrip-actions {
gap: var(--space-2);
}
/* Buttons at least ~40px wide */
.tab-add,
.crown-action {
height: 40px;
width: 40px;
}
/* Empty state: keep the full "Add DSP" button, but let it be a bit taller */
.tab-add-empty {
height: 40px;
padding-inline: var(--space-3);
}
}
/* Very narrow phones: the Add DSP label would crowd the logo */
@media (max-width: 380px) {
.tab-add-empty span {
display: none;
}
.tab-add-empty {
width: 40px;
padding-inline: 0;
}
}
+6
View File
@@ -176,6 +176,12 @@ function TopBar({
prevCount.current = dsps.length;
}, [dsps.length]);
useEffect(() => {
tabstripRef.current
?.querySelector<HTMLElement>('.tab--active')
?.scrollIntoView({ behavior: 'smooth', inline: 'nearest', block: 'nearest' });
}, [selected, page]);
return (
<header className="topbar">
<button
+15
View File
@@ -0,0 +1,15 @@
import { useEffect, useState } from 'react';
export function useIsMobile(breakpoint = 768) {
const query = `(max-width: ${breakpoint}px)`;
const [isMobile, setIsMobile] = useState(() => window.matchMedia(query).matches);
useEffect(() => {
const mq = window.matchMedia(query);
const handler = (e: MediaQueryListEvent) => setIsMobile(e.matches);
mq.addEventListener('change', handler);
return () => mq.removeEventListener('change', handler);
}, [query]);
return isMobile;
}
+66
View File
@@ -190,3 +190,69 @@
.choice-stepper__input:disabled {
cursor: not-allowed;
}
/* ---------- Phone / touch ---------- */
@media (pointer: coarse) {
/* Comfortable control height, keeps your variable as the minimum */
.add-dsp-form__field input:not([type='checkbox']),
.add-dsp-form__stepper,
.add-dsp-form__selector {
min-height: 44px;
}
/* Undo the global min-height on the custom checkbox (it's a fixed 18px box) */
.add-dsp-form__checkbox-label input[type='checkbox'] {
min-height: 0;
}
/* Make the whole label row the tap target instead */
.add-dsp-form__checkbox-label {
min-height: 44px;
align-items: center;
}
}
@media (max-width: 768px) {
/* Prevent iOS focus-zoom (must be >= 16px) */
.add-dsp-form__field input,
.add-dsp-form__field .choice-stepper__input {
font-size: 16px;
}
.add-dsp-form {
width: 100%;
max-width: 520px;
}
}
/* Narrow phones: one field per line */
@media (max-width: 420px) {
.add-dsp-form__row {
flex-direction: column;
gap: 0;
}
.add-dsp-form__row .add-dsp-form__field {
flex: none;
}
.add-dsp-form__stepper {
width: 100%;
min-width: 0;
flex: 1 1 auto;
}
.add-dsp-form__checkbox-label {
align-items: flex-start;
line-height: 1.35;
}
/* Full-width buttons, primary action on top (thumb-friendly) */
.add-dsp-form__actions {
flex-direction: column-reverse;
}
.add-dsp-form__actions > * {
width: 100%;
}
}
+7
View File
@@ -100,6 +100,9 @@ function AddDSPForm({
placeholder="Main Room DSP"
value={form.name}
onChange={(e) => setForm({ ...form, name: e.target.value })}
autoCapitalize="words"
autoCorrect="off"
spellCheck={false}
/>
</div>
@@ -155,6 +158,10 @@ function AddDSPForm({
e.currentTarget.blur();
}
}}
inputMode="decimal"
autoCapitalize="off"
autoCorrect="off"
spellCheck={false}
/>
</div>