feat: limiter section for mobile

This commit is contained in:
Lucas
2026-10-29 11:07:15 +01:00
parent 5bbef3f960
commit 8e6e4b5a65
2 changed files with 397 additions and 8 deletions
@@ -1,3 +1,22 @@
/* LimiterSection.css */
/* ---------- Page wrapper ---------- */
.limiter-page {
display: contents; /* invisible on desktop; a flex column on phones */
}
.limiter-tabs,
.limiter-rotate-hint {
display: none; /* phones only */
}
.limiter-panel__label-short {
display: none;
}
/* ---------- Control strip ---------- */
.limiter-section {
container-type: size;
position: absolute;
@@ -110,6 +129,8 @@
white-space: nowrap;
}
/* ---------- Graph ---------- */
.limiter-linear-graph-section {
flex: 0 0 calc(100% - var(--dsp-control-heigth));
min-height: 0;
@@ -177,3 +198,338 @@
flex: 1;
min-height: 0;
}
/* ---------- Phone (shared) ----------
Landscape: tabs (Controls / Limiter 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) {
.limiter-page {
flex: 1 1 0;
min-height: 0;
width: 100%;
display: flex;
flex-direction: column;
background: var(--bg-panel);
}
/* ----- Tabs ----- */
.limiter-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);
}
.limiter-page .limiter-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;
}
.limiter-page .limiter-tabs__tab[aria-selected='true'] {
background: var(--bg-raised);
color: var(--text-primary);
border-color: var(--accent-brand);
}
/* ----- Which view is visible ----- */
.limiter-page[data-view='controls'] .limiter-linear-graph-section,
.limiter-page[data-view='response'] .limiter-section {
display: none;
}
/* ----- Response view: graph + meters fill everything ----- */
.limiter-linear-graph-section {
flex: 1 1 0;
min-height: 0;
gap: var(--space-1);
padding: var(--space-1);
}
.limiter-graph__title {
padding: var(--space-1);
font-size: var(--font-xs);
}
.limiter-graph__meters {
gap: var(--space-1);
padding: var(--space-1);
}
/* ----- Controls view: strips, swipe sideways, snap per panel ----- */
.limiter-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;
}
.limiter-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 strips (never shrunk to the viewport),
so .limiter-panels is the only thing that scrolls. */
.limiter-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;
}
.limiter-section .channel-group__label {
top: 7px;
font-size: var(--font-sm);
}
.limiter-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 .limiter-panels */
}
/* Centered when everything fits, left-aligned and scrollable when it doesn't */
.limiter-panels > .channel-group:first-child {
margin-left: auto;
}
.limiter-panels > .channel-group:last-child {
margin-right: auto;
}
/* One strip per output: 3 faders side by side, full height */
.limiter-panel {
flex: 0 0 auto;
width: clamp(160px, 22vw, 200px);
height: auto; /* stretches to the row */
aspect-ratio: auto;
scroll-snap-align: start;
}
.limiter-panel__title {
padding-block: var(--space-2);
font-size: var(--font-xs);
}
.limiter-panel__grid {
grid-template-columns: repeat(3, minmax(0, 1fr));
grid-template-rows: minmax(0, 1fr);
grid-template-areas: 'threshold attack release';
gap: var(--space-1);
padding: var(--space-2) var(--space-1);
}
.limiter-panel__cell {
gap: var(--space-1);
}
.limiter-panel__cell-label {
max-width: 100%;
font-size: 10px;
overflow: hidden;
text-overflow: ellipsis;
}
.limiter-panel__label-long {
display: none;
}
.limiter-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. */
.limiter-panel__cell > :first-child,
.limiter-panel__cell > :first-child * {
touch-action: pan-x !important;
}
}
/* ---------- Portrait phone: controls only, 8 panels in 2 rows, each with its own layout ---------- */
@media (max-width: 768px) and (orientation: portrait) {
.limiter-tabs {
display: none;
}
.limiter-rotate-hint {
flex: 0 0 auto;
display: block;
padding: var(--space-1) var(--space-2);
font-family: var(--font-ui);
font-size: 11px;
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 */
.limiter-page[data-view] .limiter-linear-graph-section {
display: none;
}
.limiter-page[data-view] .limiter-section {
display: flex;
}
/* Swipe sideways: both rows move together (Out1-4 on top, Out5-8 below) */
.limiter-panels {
padding: var(--space-1);
gap: 0;
}
.limiter-section .channel-group {
padding: 28px var(--space-1) var(--space-1);
}
.limiter-section .channel-group__label {
top: 6px;
font-size: var(--font-xs);
}
.limiter-section .channel-group__items {
flex: 1 1 auto;
min-height: 0;
display: grid;
grid-template-columns: repeat(4, clamp(150px, 46vw, 200px));
grid-template-rows: repeat(2, minmax(0, 1fr));
gap: var(--space-1);
}
.limiter-panel {
width: 100%;
min-width: 0;
min-height: 0;
margin: 0;
/* 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. */
container-type: size;
}
.limiter-panel__title {
padding-block: 4px;
font-size: 11px;
}
/* Each panel keeps its desktop layout: Threshold tall on the left,
Attack above Release on the right */
.limiter-panel__grid {
grid-template-columns: repeat(2, minmax(0, 1fr));
grid-template-rows: repeat(2, minmax(0, 1fr));
grid-template-areas:
'threshold attack'
'threshold release';
gap: 2px;
padding: 4px;
position: relative;
z-index: 1; /* paint above the title if a thumb still reaches it */
}
.limiter-panel__label-long {
display: inline;
}
.limiter-panel__label-short {
display: none;
}
.limiter-panel__cell {
gap: 2px;
/* The thumb sticks out of the track by half its height at min/max: leave that
room inside the cell instead of clipping it or letting it slide under the title. */
overflow: visible;
padding-block: 3cqh;
box-sizing: border-box;
}
.limiter-panel__cell > :first-child {
min-height: 0;
max-height: 100%;
}
.limiter-panel__cell-label {
font-size: 10px;
line-height: 1.1;
}
}
/* ---------- Landscape phone: thinner strips ---------- */
@media (max-height: 500px) and (pointer: coarse) {
.limiter-panels {
padding: var(--space-1) var(--space-2);
}
.limiter-section .channel-group {
padding-top: 24px;
}
.limiter-section .channel-group__label {
top: 4px;
font-size: var(--font-xs);
}
.limiter-panel {
width: clamp(150px, 19vw, 190px);
}
.limiter-panel__title {
padding-block: var(--space-1);
font-size: 11px;
}
.limiter-panel__grid {
padding: var(--space-1);
}
}
@@ -9,9 +9,9 @@ import { useState } from 'react';
import './LimiterSection.css';
const LIMITER_SLIDER_PARAMS = [
{ key: 'threshold', label: 'Threshold', min: -90, max: 20, step: 0.5, unit: ' dB' },
{ key: 'attack', label: 'Attack', min: 1, 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: 20, step: 0.5, unit: ' dB' },
{ key: 'attack', label: 'Attack', short: 'Atk', min: 1, max: 999, step: 1, unit: ' ms' },
{ key: 'release', label: 'Release', short: 'Rel', min: 10, max: 3000, step: 1, unit: ' ms' },
] as const;
type LimiterParamKey = 'threshold' | 'attack' | 'release';
@@ -29,6 +29,14 @@ type SetLimiterFn = (
release: number
) => Promise<boolean>;
// Phone only: one view at a time (CSS hides the tabs on desktop)
type LimiterView = 'controls' | 'response';
const LIMITER_VIEWS: { id: LimiterView; label: string }[] = [
{ id: 'controls', label: 'Controls' },
{ id: 'response', label: 'Limiter response' },
];
function LimiterPanel({
channel,
dsp,
@@ -66,7 +74,10 @@ function LimiterPanel({
onChange={(value) => commit({ [param.key]: value } as Partial<LimiterValues>)}
style={{ width: '100%', flex: '1 1 auto' }}
/>
<div className="limiter-panel__cell-label">{param.label}</div>
<div className="limiter-panel__cell-label">
<span className="limiter-panel__label-long">{param.label}</span>
<span className="limiter-panel__label-short">{param.short}</span>
</div>
</div>
))}
</div>
@@ -88,6 +99,7 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
const [activeChannel, setActiveChannel] = useState<OutputChannel>(outputs[0]);
const [liveLim, setLiveLim] = useState<Partial<Record<OutputChannel, LimiterValues>>>({});
const [view, setView] = useState<LimiterView>('controls');
const handleLiveValue = (channel: OutputChannel, key: LimiterParamKey, value: number) => {
setActiveChannel(channel);
@@ -118,7 +130,28 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
const activeLim = liveLim[activeChannel] ?? (activeOutputState.limiter as LimiterValues);
return (
<>
<div className="limiter-page" data-view={view}>
{/* Phone only (hidden on desktop by CSS): one view at a time */}
<div className="limiter-tabs" role="tablist" aria-label="Limiter views">
{LIMITER_VIEWS.map((v) => (
<button
key={v.id}
type="button"
role="tab"
aria-selected={view === v.id}
className="limiter-tabs__tab"
onClick={() => setView(v.id)}
>
{v.label}
</button>
))}
</div>
{/* Portrait phone only (CSS): the graph needs the width of landscape */}
<div className="limiter-rotate-hint">
Rotate your phone to landscape to see the limiter graph.
</div>
<div className="limiter-linear-graph-section">
<div className="limiter-graph-panel">
<div className="limiter-graph__title">{activeOutputState.name} - Limiter</div>
@@ -135,7 +168,7 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
key={output}
label={outputState.name}
meter={dsp.output_meters.meters[output]}
variant='output'
variant="output"
/>
);
})}
@@ -158,7 +191,7 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
</ChannelGroup>
</div>
</div>
</>
</div>
);
}