From f3745db9270fc5037c60e5b6f8da35dac7c4aed3 Mon Sep 17 00:00:00 2001 From: Lucas Date: Thu, 29 Oct 2026 10:40:26 +0100 Subject: [PATCH] feat: gate section for mobile --- .../components/GateSection/GateSection.css | 384 ++++++++++++++++++ .../components/GateSection/GateSection.tsx | 52 ++- 2 files changed, 427 insertions(+), 9 deletions(-) diff --git a/src/features/dsp408/components/GateSection/GateSection.css b/src/features/dsp408/components/GateSection/GateSection.css index ed7eac8..e153a3c 100644 --- a/src/features/dsp408/components/GateSection/GateSection.css +++ b/src/features/dsp408/components/GateSection/GateSection.css @@ -1,4 +1,22 @@ /* GateSection.css */ + +/* ---------- Page wrapper ---------- */ + +.gate-page { + display: contents; /* invisible on desktop; a flex column on phones */ +} + +.gate-tabs, +.gate-rotate-hint { + display: none; /* phones only */ +} + +.gate-panel__label-short { + display: none; +} + +/* ---------- Control strip ---------- */ + .gate-section { container-type: size; @@ -98,6 +116,8 @@ white-space: nowrap; } +/* ---------- Graph ---------- */ + .gate-linear-graph-section { flex: 0 0 calc(100% - var(--dsp-control-heigth)); min-height: 0; @@ -165,3 +185,367 @@ gap: 1cqh; padding: 1cqh; } + +/* ---------- Phone (shared) ---------- + Landscape: tabs (Controls / Gate response), one view at a time. + Portrait: controls only + a hint to rotate for the graph. */ + +@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) { + .gate-page { + flex: 1 1 0; + min-height: 0; + width: 100%; + + display: flex; + flex-direction: column; + background: var(--bg-panel); + } + + /* ----- Tabs ----- */ + + .gate-tabs { + flex: 0 0 auto; + display: flex; + gap: var(--space-1); + padding: var(--space-1) var(--space-2); + border-bottom: var(--border-width) solid var(--border-hairline); + } + + .gate-page .gate-tabs__tab { + flex: 1 1 0; + min-width: 0; + min-height: 0; + height: 34px; + padding: 0 var(--space-2); + + font-family: var(--font-ui); + font-size: var(--font-xs); + font-weight: var(--font-weight-semibold); + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + + background: var(--bg-void); + color: var(--text-muted); + border: var(--border-width) solid var(--border-hairline); + border-radius: var(--radius-sm); + cursor: pointer; + } + + .gate-page .gate-tabs__tab[aria-selected='true'] { + background: var(--bg-raised); + color: var(--text-primary); + border-color: var(--accent-brand); + } + + /* ----- Which view is visible ----- */ + + .gate-page[data-view='controls'] .gate-linear-graph-section, + .gate-page[data-view='response'] .gate-section { + display: none; + } + + /* ----- Response view: graph + meters fill everything ----- */ + + .gate-linear-graph-section { + flex: 1 1 0; + min-height: 0; + gap: var(--space-1); + padding: var(--space-1); + } + + .gate-graph-title { + display: none; /* the tab already says which graph this is */ + } + + .gate-graph__meters { + gap: var(--space-1); + padding: var(--space-1); + } + + /* ----- Controls view: strips, swipe sideways, snap per panel ----- */ + + .gate-section { + position: relative; + z-index: auto; + flex: 1 1 0; + height: auto; + min-height: 0; + + align-items: stretch; + justify-content: flex-start; + border-top: none; + } + + .gate-panels { + display: flex; + justify-content: flex-start; /* desktop's "center" would clip the left side on overflow */ + width: 100%; + min-width: 0; + height: auto; + gap: var(--space-3); + padding: var(--space-2); + box-sizing: border-box; + + overflow-x: auto; + overflow-y: hidden; + scroll-snap-type: x proximity; + overscroll-behavior-x: contain; + -webkit-overflow-scrolling: touch; + } + + /* The group is as wide as its 4 strips (never shrunk to the viewport), + so .gate-panels is the only thing that scrolls. */ + .gate-section .channel-group { + flex: 0 0 auto; + width: max-content; + max-width: none; + margin: 0; + padding: 30px var(--space-2) var(--space-2); + scroll-snap-align: start; + } + + .gate-section .channel-group__label { + top: 7px; + font-size: var(--font-sm); + } + + .gate-section .channel-group__items { + height: auto; + align-self: stretch; + justify-content: flex-start; + gap: var(--space-2); + overflow: visible; /* no nested scroller: it would fight with .gate-panels */ + } + + /* Centered when everything fits, left-aligned and scrollable when it doesn't */ + .gate-panels > .channel-group:first-child { + margin-left: auto; + } + + .gate-panels > .channel-group:last-child { + margin-right: auto; + } + + /* One strip per input: 4 faders side by side, full height */ + .gate-panel { + flex: 0 0 auto; + width: clamp(200px, 30vw, 260px); + height: auto; /* stretches to the row */ + aspect-ratio: auto; + scroll-snap-align: start; + } + + .gate-panel__title { + padding-block: var(--space-2); + font-size: var(--font-xs); + } + + .gate-panel__grid { + grid-template-columns: repeat(4, minmax(0, 1fr)); + grid-template-rows: minmax(0, 1fr); + gap: var(--space-1); + padding: var(--space-2) var(--space-1); + } + + .gate-panel__cell { + gap: var(--space-1); + } + + .gate-panel__cell-label { + max-width: 100%; + font-size: 10px; + overflow: hidden; + text-overflow: ellipsis; + } + + .gate-panel__label-long { + display: none; + } + + .gate-panel__label-short { + display: inline; + } + + /* pan-x: vertical drags move the fader, horizontal swipes still scroll the strip. + Applied to the thumb/track too so a swipe that starts on them scrolls. */ + .gate-panel__cell > :first-child, + .gate-panel__cell > :first-child * { + touch-action: pan-x !important; + } +} + +/* ---------- Portrait phone: controls only, 2x2 panels, each with 2x2 sliders ---------- */ + +@media (max-width: 768px) and (orientation: portrait) { + .gate-tabs { + display: none; + } + + .gate-rotate-hint { + flex: 0 0 auto; + display: block; + padding: var(--space-2) var(--space-3); + + font-family: var(--font-ui); + font-size: var(--font-xs); + text-align: center; + color: var(--text-muted); + + border-bottom: var(--border-width) solid var(--border-hairline); + } + + /* Whatever tab was active in landscape, portrait always shows the controls */ + .gate-page[data-view] .gate-linear-graph-section { + display: none; + } + + .gate-page[data-view] .gate-section { + display: flex; + } + + /* Everything fits on screen: no horizontal scroll */ + .gate-panels { + overflow: hidden; + scroll-snap-type: none; + padding: var(--space-1); + gap: 0; + } + + .gate-section .channel-group { + flex: 1 1 auto; + width: 100%; + min-width: 0; + min-height: 0; + box-sizing: border-box; + padding: 28px var(--space-1) var(--space-1); + scroll-snap-align: none; + } + + .gate-section .channel-group__label { + top: 6px; + font-size: var(--font-xs); + } + + /* The 4 input panels in a 2x2 grid */ + .gate-section .channel-group__items { + flex: 1 1 auto; + width: 100%; + min-width: 0; + min-height: 0; + + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + grid-template-rows: repeat(2, minmax(0, 1fr)); + gap: var(--space-1); + } + + .gate-panel { + width: 100%; + min-width: 0; + min-height: 0; + scroll-snap-align: none; + margin: 0; + } + + .gate-panel__title { + padding-block: var(--space-1); + font-size: 11px; + } + + /* Each panel keeps its 2x2 sliders */ + .gate-panel__grid { + grid-template-columns: repeat(2, minmax(0, 1fr)); + grid-template-rows: repeat(2, minmax(0, 1fr)); + gap: var(--space-1); + padding: var(--space-1); + } + + .gate-panel__label-long { + display: inline; + } + + .gate-panel__label-short { + display: none; + } + + /* Each panel is its own size container (like the rows in GainSection): + the slider's cqh sizes (thumb, track, readout) scale to the panel height, + which is bigger than a single cell but never the whole screen. */ + .gate-panel { + container-type: size; + } + + /* The thumb sticks out of the track by half its height at min/max: leave that + room inside the cell (padding) instead of clipping it or letting it slide + under the title. */ + .gate-panel__cell { + overflow: visible; + padding-block: 3cqh; + box-sizing: border-box; + } + + .gate-panel__grid { + position: relative; + z-index: 1; /* paint above the title if a thumb still reaches it */ + } + + .gate-panel__cell > :first-child { + min-height: 0; + max-height: 100%; + } + + /* Give the height back to the sliders: tighter hint, title, gaps and label */ + .gate-rotate-hint { + padding: var(--space-1) var(--space-2); + font-size: 11px; + } + + .gate-panel__title { + padding-block: 4px; + } + + .gate-panel__grid { + gap: 2px; + padding: 4px; + } + + .gate-panel__cell { + gap: 2px; + } + + .gate-panel__cell-label { + font-size: 10px; + line-height: 1.1; + } +} + +/* ---------- Landscape phone: thinner strips ---------- */ + +@media (max-height: 500px) and (pointer: coarse) { + .gate-panels { + padding: var(--space-1) var(--space-2); + } + + .gate-section .channel-group { + padding-top: 24px; + } + + .gate-section .channel-group__label { + top: 4px; + font-size: var(--font-xs); + } + + .gate-panel { + width: clamp(190px, 24vw, 240px); + } + + .gate-panel__title { + padding-block: var(--space-1); + font-size: 11px; + } + + .gate-panel__grid { + padding: var(--space-1); + } +} \ No newline at end of file diff --git a/src/features/dsp408/components/GateSection/GateSection.tsx b/src/features/dsp408/components/GateSection/GateSection.tsx index 74260a2..6f2ce2a 100644 --- a/src/features/dsp408/components/GateSection/GateSection.tsx +++ b/src/features/dsp408/components/GateSection/GateSection.tsx @@ -9,10 +9,10 @@ import { useState } from 'react'; import './GateSection.css'; const GATE_PARAMS = [ - { key: 'threshold', label: 'Threshold', min: -90, max: 0, step: 0.5, unit: ' dB' }, - { key: 'attack', label: 'Attack', min: 1, max: 999, step: 1, unit: ' ms' }, - { key: 'hold', label: 'Hold', min: 10, max: 999, step: 1, unit: ' ms' }, - { key: 'release', label: 'Release', min: 10, max: 3000, step: 1, unit: ' ms' }, + { key: 'threshold', label: 'Threshold', short: 'Thr', min: -90, max: 0, step: 0.5, unit: ' dB' }, + { key: 'attack', label: 'Attack', short: 'Atk', min: 1, max: 999, step: 1, unit: ' ms' }, + { key: 'hold', label: 'Hold', short: 'Hld', min: 10, max: 999, step: 1, unit: ' ms' }, + { key: 'release', label: 'Release', short: 'Rel', min: 10, max: 3000, step: 1, unit: ' ms' }, ] as const; type GateParamKey = (typeof GATE_PARAMS)[number]['key']; @@ -32,6 +32,14 @@ type SetGateFn = ( release: number ) => Promise; +// Phone only: one view at a time (CSS hides the tabs on desktop) +type GateView = 'controls' | 'response'; + +const GATE_VIEWS: { id: GateView; label: string }[] = [ + { id: 'controls', label: 'Controls' }, + { id: 'response', label: 'Gate response' }, +]; + function GatePanel({ channel, dsp, @@ -71,7 +79,10 @@ function GatePanel({ }} style={{ width: '100%', flex: '1 1 auto' }} /> -
{param.label}
+
+ {param.label} + {param.short} +
))} @@ -84,6 +95,7 @@ function GateSection({ dsp, set_gate }: { dsp: DSP; set_gate: SetGateFn }) { const [activeChannel, setActiveChannel] = useState(inputs[0]); const [liveGate, setLiveGate] = useState>>({}); + const [view, setView] = useState('controls'); const handleLiveValue = (channel: InputChannel, key: GateParamKey, value: number) => { setActiveChannel(channel); @@ -113,7 +125,28 @@ function GateSection({ dsp, set_gate }: { dsp: DSP; set_gate: SetGateFn }) { const activeGate = liveGate[activeChannel] ?? activeInputState.gate; return ( - <> +
+ {/* Phone only (hidden on desktop by CSS): one view at a time */} +
+ {GATE_VIEWS.map((v) => ( + + ))} +
+ + {/* Portrait phone only (CSS): the graph needs the width of landscape */} +
+ Rotate your phone to landscape to see the gate response graph. +
+
Gate Response
@@ -135,7 +168,7 @@ function GateSection({ dsp, set_gate }: { dsp: DSP; set_gate: SetGateFn }) { key={input} label={inputState.name} meter={dsp.input_meters.meters[input]} - variant='input' + variant="input" /> ); })} @@ -158,7 +191,8 @@ function GateSection({ dsp, set_gate }: { dsp: DSP; set_gate: SetGateFn }) {
- +
); } -export default GateSection; + +export default GateSection; \ No newline at end of file