feat: gate section for mobile

This commit is contained in:
Lucas
2026-10-29 10:40:26 +01:00
parent e70082f6cc
commit f3745db927
2 changed files with 427 additions and 9 deletions
@@ -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);
}
}
@@ -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<boolean>;
// 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' }}
/>
<div className="gate-panel__cell-label">{param.label}</div>
<div className="gate-panel__cell-label">
<span className="gate-panel__label-long">{param.label}</span>
<span className="gate-panel__label-short">{param.short}</span>
</div>
</div>
))}
</div>
@@ -84,6 +95,7 @@ function GateSection({ dsp, set_gate }: { dsp: DSP; set_gate: SetGateFn }) {
const [activeChannel, setActiveChannel] = useState<InputChannel>(inputs[0]);
const [liveGate, setLiveGate] = useState<Partial<Record<InputChannel, GateValues>>>({});
const [view, setView] = useState<GateView>('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 (
<>
<div className="gate-page" data-view={view}>
{/* Phone only (hidden on desktop by CSS): one view at a time */}
<div className="gate-tabs" role="tablist" aria-label="Gate views">
{GATE_VIEWS.map((v) => (
<button
key={v.id}
type="button"
role="tab"
aria-selected={view === v.id}
className="gate-tabs__tab"
onClick={() => setView(v.id)}
>
{v.label}
</button>
))}
</div>
{/* Portrait phone only (CSS): the graph needs the width of landscape */}
<div className="gate-rotate-hint">
Rotate your phone to landscape to see the gate response graph.
</div>
<div className="gate-linear-graph-section">
<div className="gate-graph-panel">
<div className="gate-graph-title">Gate Response</div>
@@ -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 }) {
</ChannelGroup>
</div>
</div>
</>
</div>
);
}
export default GateSection;
export default GateSection;