diff --git a/src/features/dsp408/components/LimiterSection/LimiterSection.css b/src/features/dsp408/components/LimiterSection/LimiterSection.css index 49b00f6..13931fd 100644 --- a/src/features/dsp408/components/LimiterSection/LimiterSection.css +++ b/src/features/dsp408/components/LimiterSection/LimiterSection.css @@ -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); + } +} \ No newline at end of file diff --git a/src/features/dsp408/components/LimiterSection/LimiterSection.tsx b/src/features/dsp408/components/LimiterSection/LimiterSection.tsx index 8896c6c..1a096cf 100644 --- a/src/features/dsp408/components/LimiterSection/LimiterSection.tsx +++ b/src/features/dsp408/components/LimiterSection/LimiterSection.tsx @@ -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; +// 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)} style={{ width: '100%', flex: '1 1 auto' }} /> -
{param.label}
+
+ {param.label} + {param.short} +
))} @@ -88,6 +99,7 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite const [activeChannel, setActiveChannel] = useState(outputs[0]); const [liveLim, setLiveLim] = useState>>({}); + const [view, setView] = useState('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 ( - <> +
+ {/* Phone only (hidden on desktop by CSS): one view at a time */} +
+ {LIMITER_VIEWS.map((v) => ( + + ))} +
+ + {/* Portrait phone only (CSS): the graph needs the width of landscape */} +
+ Rotate your phone to landscape to see the limiter graph. +
+
{activeOutputState.name} - Limiter
@@ -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,8 +191,8 @@ function LimiterSection({ dsp, set_limiter }: { dsp: DSP; set_limiter: SetLimite
- +
); } -export default LimiterSection; +export default LimiterSection; \ No newline at end of file