From 3caec3041343982ef6a9fc2f324c65a0a2857863 Mon Sep 17 00:00:00 2001 From: Lucas Date: Fri, 30 Oct 2026 15:39:33 +0100 Subject: [PATCH] feat: peq section for mobile --- .../ChannelSection/ChannelSection.css | 666 +++++++++++++++--- .../ChannelSection/ChannelSection.tsx | 243 ++++--- 2 files changed, 737 insertions(+), 172 deletions(-) diff --git a/src/features/dsp408/components/ChannelSection/ChannelSection.css b/src/features/dsp408/components/ChannelSection/ChannelSection.css index 3948725..97fed7d 100644 --- a/src/features/dsp408/components/ChannelSection/ChannelSection.css +++ b/src/features/dsp408/components/ChannelSection/ChannelSection.css @@ -1,4 +1,35 @@ -/* InputSection.css */ +/* ChannelSection.css */ + +/* Font-size hooks: desktop uses the cqh values, the phone block below + overrides them with fixed px sizes. + --ch-fs main text in the control strip (titles, steppers, buttons) + --ch-fs-action buttons in the Actions group + --ch-fs-label small labels under the sliders */ + +/* ---------- Page wrapper ---------- */ + +.channel-page { + display: contents; /* invisible on desktop; a flex column on phones */ +} + +.channel-tabs, +.channel-rotate-hint { + display: none; /* phones only */ +} + +.channel-panel__label-short, +.peq-band-list__label-short { + display: none; +} + +/* Invisible wrappers on desktop (layout identical to before) */ +.peq-block, +.crossover-panel__slider { + display: contents; +} + +/* ---------- Graph ---------- */ + .channel-graph-section { flex: 0 0 calc(100% - var(--dsp-control-heigth)); min-height: 0; @@ -65,9 +96,55 @@ min-height: 0; } -/* Bottom control bar — same pattern as .compressor-section: absolute, +.channel-graph-panel__magnitude-wrap { + flex: 1 1 0; + min-height: 0; + min-width: 0; + position: relative; +} + +.channel-graph__title-row { + flex: 0 0 auto; + display: flex; + align-items: center; + justify-content: space-between; + padding: 1cqh 1.5cqh; +} + +.channel-graph__title-row .channel-graph__title { + padding: 0; /* was on the standalone title element; row now owns spacing */ +} + +.channel-graph-view-toggle { + display: flex; + gap: 0.4cqh; + border: var(--border-width) solid var(--border-hairline); + border-radius: var(--radius-sm); + padding: 0.3cqh; + background: var(--bg-void); +} + +.channel-graph-view-toggle__btn { + font-family: var(--font-ui); + font-size: 2cqh; + padding: 0.6cqh 1.2cqh; + background: transparent; + color: var(--text-muted); + border: none; + border-radius: var(--radius-sm); + cursor: pointer; +} + +.channel-graph-view-toggle__btn.active { + background: var(--accent-brand); + color: var(--bg-void); +} + +/* ---------- Control strip ---------- + Bottom control bar — same pattern as .compressor-section: absolute, bottom-anchored, panels flow in a row and scroll horizontally instead of squeezing into a fixed max-width. */ + .channel-control-section { container-type: size; position: absolute; @@ -105,7 +182,8 @@ padding: 2cqh; } -/* Peq Sliders */ +/* ---------- PEQ sliders ---------- */ + .channel-panel { position: relative; height: 100%; @@ -129,7 +207,7 @@ width: 100%; text-align: center; font-family: var(--font-ui); - font-size: 4cqh; + font-size: var(--ch-fs, 4cqh); font-weight: var(--font-weight-semibold); padding-top: 2cqh; padding-bottom: 2cqh; @@ -167,11 +245,13 @@ .channel-panel__cell-label { flex: 0 0 auto; font-family: var(--font-ui); - font-size: 3.2cqh; + font-size: var(--ch-fs-label, 3.2cqh); color: var(--text-muted); white-space: nowrap; } +/* ---------- Crossover ---------- */ + .crossover-panel { position: relative; height: 100%; @@ -196,7 +276,7 @@ width: 100%; text-align: center; font-family: var(--font-ui); - font-size: 4cqh; + font-size: var(--ch-fs, 4cqh); font-weight: var(--font-weight-semibold); padding-top: 2cqh; padding-bottom: 2cqh; @@ -207,36 +287,20 @@ text-overflow: ellipsis; } -/* Now the root of a ChoiceSelect rather than a native . */ .crossover-panel__select { flex: 0 0 auto; width: 85%; + height: auto; + min-height: 0; + font-family: var(--font-ui); -} + font-size: var(--ch-fs, 4cqh); -.crossover-panel__select .choice-select__input, -.crossover-panel__select .choice-select__input option { - font-size: 4cqh; color: var(--accent-brand); - /* padding-left: 1cqh; */ } -.crossover-panel__select { - flex: 0 0 auto; - width: 85%; - font-family: var(--font-ui); - font-size: 4cqh; -} - -.crossover-panel__select .choice-select__input, -.crossover-panel__select .choice-select__input option { - height: 100%; - padding: 0; - padding-left: 2cqh; - font-size: 4cqh; - color: var(--accent-brand); - border-radius: var(--radius-sm); -} +/* ---------- PEQ band list ---------- */ .peq-band-list { flex: 1 1 auto; @@ -267,6 +331,8 @@ align-items: stretch; gap: 1cqh; + color: var(--accent-brand); + box-sizing: border-box; } @@ -274,7 +340,7 @@ flex: 0 0 auto; font-family: var(--font-ui); - font-size: 4cqh; + font-size: var(--ch-fs, 4cqh); color: var(--text-primary); text-align: center; font-weight: var(--font-weight-semibold); @@ -334,66 +400,494 @@ min-height: 0; font-family: var(--font-ui); - font-size: 4cqh; + font-size: var(--ch-fs, 4cqh); } -.channel-graph-panel__magnitude-wrap { - flex: 1 1 0; - min-height: 0; - min-width: 0; - position: relative; -} - -.channel-graph__title-row { - flex: 0 0 auto; - display: flex; - align-items: center; - justify-content: space-between; - padding: 1cqh 1.5cqh; -} - -.channel-graph__title-row .channel-graph__title { - padding: 0; /* was on the standalone title element; row now owns spacing */ -} - -.channel-graph-view-toggle { - display: flex; - gap: 0.4cqh; - border: var(--border-width) solid var(--border-hairline); - border-radius: var(--radius-sm); - padding: 0.3cqh; - background: var(--bg-void); -} - -.channel-graph-view-toggle__btn { - font-family: var(--font-ui); - font-size: 2cqh; - padding: 0.6cqh 1.2cqh; - background: transparent; - color: var(--text-muted); - border: none; - border-radius: var(--radius-sm); - cursor: pointer; -} - -.channel-graph-view-toggle__btn.active { - background: var(--accent-brand); - color: var(--bg-void); -} - -.peq-band-list__stepper .choice-stepper__input, -.peq-band-list__select .choice-select__input { +.peq-channel-selector { + width: 80px; height: 100%; - min-height: 0; + align-self: stretch; - font-family: var(--font-mono); - font-size: 4cqh; - color: var(--accent-brand); + display: flex; + flex-direction: column; + justify-content: center; + align-items: stretch; - background: transparent; - - text-align: center; - text-align-last: center; - padding: 0; - margin: 0; + gap: var(--space-1); + box-sizing: border-box; } + +/* ---------- Phone (shared) ---------- + Landscape: tabs (Controls / Filter response), one view at a time. + Portrait: controls only + a hint to rotate for the graphs. */ + +@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) { + .channel-page { + --ch-fs: 11px; + --ch-fs-action: 12px; + --ch-fs-label: 10px; + --peq-list-width: 480px; + + flex: 1 1 0; + min-height: 0; + width: 100%; + + display: flex; + flex-direction: column; + background: var(--bg-panel); + } + + /* ----- Tabs ----- */ + + .channel-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); + } + + .channel-page .channel-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; + } + + .channel-page .channel-tabs__tab[aria-selected='true'] { + background: var(--bg-raised); + color: var(--text-primary); + border-color: var(--accent-brand); + } + + /* ----- Which view is visible ----- */ + + .channel-page[data-view='controls'] .channel-graph-section, + .channel-page:not([data-view='controls']) .channel-control-section { + display: none; + } + + /* ----- Magnitude / Phase tabs: one graph fills everything ----- */ + + .channel-graph-section { + flex: 1 1 0; + min-height: 0; + gap: var(--space-1); + padding: var(--space-1); + } + + .channel-graph__title { + padding: 0; + font-size: var(--font-xs); + } + + .channel-graph__title-row { + padding: var(--space-1); + gap: var(--space-2); + } + + .channel-graph-view-toggle { + gap: 2px; + padding: 2px; + } + + .channel-graph-view-toggle__btn { + font-size: 11px; + padding: 4px 10px; + } + + .channel-bypass-overlay span { + font-size: 28px; + } + + /* ----- Controls view: groups, swipe sideways, snap per group ----- */ + + .channel-control-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; + } + + .channel-control-panel { + 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; + } + + /* Each group is as wide as its content (never shrunk to the viewport), + so .channel-control-panel is the only thing that scrolls. */ + .channel-control-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; + } + + .channel-control-section .channel-group__label { + top: 7px; + font-size: var(--font-sm); + } + + .channel-control-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 .channel-control-panel */ + } + + /* Centered when everything fits, left-aligned and scrollable when it doesn't */ + .channel-control-panel > .channel-group:first-child { + margin-left: auto; + } + + .channel-control-panel > .channel-group:last-child { + margin-right: auto; + } + + /* PEQ group: band table + slider panel side by side (landscape) */ + .peq-block { + display: flex; + flex-direction: row; + align-items: stretch; + gap: var(--space-2); + min-height: 0; + } + + .peq-band-list { + flex: 0 0 auto; + width: var(--peq-list-width); + gap: 3px; + padding: 3px; + } + + .peq-band-list__row { + gap: 3px; + } + + .peq-band-list__row--header { + padding-block: 3px; + } + + .channel-panel { + flex: 0 0 auto; + width: clamp(210px, 28vw, 260px); + height: auto; /* stretches to the row */ + aspect-ratio: auto; + } + + .channel-panel__title { + padding-block: var(--space-1); + } + + .channel-panel__grid { + gap: var(--space-1); + padding: var(--space-2) var(--space-1); + } + + .channel-panel__cell { + gap: var(--space-1); + } + + .channel-panel__cell-label { + max-width: 100%; + overflow: hidden; + text-overflow: ellipsis; + } + + /* Crossover: two narrow strips */ + .crossover-panel { + flex: 0 0 auto; + width: clamp(80px, 8vw, 100px); + height: auto; /* stretches to the row */ + aspect-ratio: auto; + gap: var(--space-2); + padding-bottom: var(--space-2); + } + + .peq-channel-selector { + width: 80px; + height: 100%; + align-self: stretch; + + display: flex; + flex-direction: column; + justify-content: center; + align-items: stretch; + + gap: var(--space-2); + box-sizing: border-box; + } + + .crossover-panel__title { + padding-block: var(--space-1); + } + + .crossover-panel__slider > * { + min-height: 0; + } + + .peq-band-list__label-long { + display: none; + } + + .peq-band-list__label-short { + display: inline; + } + + .channel-panel__label-long { + display: none; + } + + .channel-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. */ + .channel-panel__cell > :first-child, + .channel-panel__cell > :first-child *, + .crossover-panel__slider, + .crossover-panel__slider * { + touch-action: pan-x !important; + } +} + +/* ---------- Portrait phone: controls only, no groups ---------- + Row 1: PEQ band table (full width) + Row 2: PEQ sliders | HighPass | LowPass | Actions (all on the same row) + The groups are flattened (display: contents) so panels from different + groups can share a row. Nothing scrolls. */ + +@media (max-width: 768px) and (orientation: portrait) { + .channel-page { + --ch-fs: 11px; + --ch-fs-action: 13px; + } + + .channel-tabs { + display: none; + } + + .channel-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 */ + .channel-page[data-view] .channel-graph-section { + display: none; + } + + .channel-page[data-view] .channel-control-section { + display: flex; + } + + .channel-control-panel { + flex: 1 1 auto; + display: grid; + width: 100%; + min-width: 0; + box-sizing: border-box; + + /* Fixed widths (same idea as the 40px GEQ cells): the strip scrolls instead of shrinking. + Total ≈ the landscape band-table width (--peq-list-width), so the table stays readable. */ + grid-template-columns: + 210px /* PEQ sliders */ + 100px /* HighPass */ + 100px /* LowPass */ + 110px; /* Actions */ + grid-template-rows: minmax(0, 1.15fr) minmax(0, 1fr); + justify-content: start; /* desktop's "center" would clip the left side on overflow */ + gap: var(--space-1); + padding: var(--space-1) var(--space-2); + + overflow-x: auto; + overflow-y: hidden; + scroll-snap-type: none; + overscroll-behavior-x: contain; + -webkit-overflow-scrolling: touch; + } + + /* Flatten the groups (and hide their labels) */ + .channel-control-section .channel-group, + .channel-control-section .channel-group__items, + .peq-block { + display: contents; + } + + .channel-control-section .channel-group__label { + display: none; + } + + /* Each panel is its own size container (like the panels in CompressorSection): + the cqh sizes inside (slider thumb, track, readout, paddings) scale to the panel. */ + .peq-band-list { + grid-row: 1; + grid-column: 1 / -1; + width: auto; + min-width: var(--peq-list-width); /* 480px, same as landscape */ + min-height: 0; + container-type: size; + --peq-cols: 0.45fr 0.9fr 0.55fr 0.9fr 1.1fr 0.55fr; + } + + .peq-band-list__row { + grid-template-columns: var(--peq-cols); + } + + /* Row 2: columns fill in DOM order = PEQ sliders, HighPass, LowPass, Actions */ + .channel-panel, + .crossover-panel { + grid-row: 2; + width: auto; /* fills its fixed grid column */ + min-width: 0; + min-height: 0; + height: auto; + margin: 0; + container-type: size; + } + + .channel-panel__title, + .crossover-panel__title { + padding-block: 4px; + } + + .channel-panel__grid { + gap: 2px; + padding: 4px; + + position: relative; + z-index: 1; /* paint above the title if a thumb still reaches it */ + } + + /* 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. */ + .channel-panel__cell { + overflow: visible; + padding-block: 3cqh; + box-sizing: border-box; + gap: 2px; + } + + .channel-panel__cell > :first-child { + min-height: 0; + max-height: 100%; + } + + .crossover-panel { + gap: 4px; + padding-bottom: 4px; + } + + .crossover-panel__slider { + display: contents; + } + + .crossover-panel__select { + width: 90%; + } + + /* Actions: its own panel in the 4th column, Bypass above Reset */ + .channel-control-section .peq-channel-selector { + grid-row: 2; + width: auto; + height: auto; + min-width: 0; + min-height: 0; + align-self: stretch; + + display: flex; + flex-direction: column; + justify-content: center; + gap: var(--space-1); + + padding: var(--space-1); + box-sizing: border-box; + background: var(--bg-void); + border: var(--border-width) solid var(--border-hairline); + border-radius: var(--radius-md); + } + + .channel-control-section .peq-channel-selector > * { + flex: 1 1 0; + min-height: 0; + max-height: 64px; + width: 100% !important; + padding: 0 !important; /* inline paddings are in cqh: too big on a phone */ + font-size: var(--ch-fs-action) !important; + overflow: hidden; + text-overflow: ellipsis; + } +} + +/* ---------- Landscape phone: thinner strips ---------- */ + +@media (max-height: 500px) and (pointer: coarse) { + .channel-control-panel { + padding: var(--space-1) var(--space-2); + } + + .channel-control-section .channel-group { + padding-top: 24px; + } + + .channel-control-section .channel-group__label { + top: 4px; + font-size: var(--font-xs); + } + + .channel-panel { + width: clamp(200px, 26vw, 240px); + } + + .channel-panel__title, + .crossover-panel__title { + padding-block: var(--space-1); + } + + .channel-panel__grid { + padding: var(--space-1); + } +} \ No newline at end of file diff --git a/src/features/dsp408/components/ChannelSection/ChannelSection.tsx b/src/features/dsp408/components/ChannelSection/ChannelSection.tsx index ce07179..86bda22 100644 --- a/src/features/dsp408/components/ChannelSection/ChannelSection.tsx +++ b/src/features/dsp408/components/ChannelSection/ChannelSection.tsx @@ -28,6 +28,10 @@ import { } from '../../constants'; import { MagnitudeGraph, PhaseGraph } from './ChannelGraph'; +// Font size used by the buttons below. On desktop it falls back to the cqh value; +// the mobile CSS overrides --ch-fs with a fixed px size. +const BTN_FS = 'var(--ch-fs, 4cqh)'; + function nearestQValue(q: number, values: readonly number[] = PEAK_Q_VALUES): number { return values.reduce((nearest, current) => Math.abs(current - q) < Math.abs(nearest - q) ? current : nearest @@ -36,6 +40,32 @@ function nearestQValue(q: number, values: readonly number[] = PEAK_Q_VALUES): nu type GraphView = 'both' | 'magnitude' | 'phase'; +// Phone only: one view at a time (CSS hides the tabs on desktop) +type ChannelView = 'controls' | 'magnitude' | 'phase'; + +const CHANNEL_VIEWS: { id: ChannelView; label: string }[] = [ + { id: 'controls', label: 'Controls' }, + { id: 'magnitude', label: 'Magnitude' }, + { id: 'phase', label: 'Phase' }, +]; + +// Must match the phone media query in ChannelSection.css +const MOBILE_QUERY = '(max-width: 768px), (max-height: 500px) and (pointer: coarse)'; + +function useIsMobile(): boolean { + const [matches, setMatches] = useState(() => window.matchMedia(MOBILE_QUERY).matches); + + useEffect(() => { + const mql = window.matchMedia(MOBILE_QUERY); + const onChange = () => setMatches(mql.matches); + onChange(); + mql.addEventListener('change', onChange); + return () => mql.removeEventListener('change', onChange); + }, []); + + return matches; +} + function GraphViewToggle({ view, onChange, @@ -77,14 +107,14 @@ function ChannelActions({ onReset: () => void; }) { return ( -
+
@@ -249,21 +282,24 @@ function CrossoverPanel({
{title}
- (value >= 1000 ? 'kHz' : 'Hz')} - value={frequency} - formatValue={(value) => - value >= 1000 ? `${(value / 1000).toFixed(2)}` : `${value.toFixed(1)}` - } - onChange={(value) => commit({ frequency: value })} - onInput={(value) => onLiveValue(value)} - style={{ width: '100%', flex: '1 1 auto' }} - /> + {/* display: contents on desktop; lets the mobile CSS target the slider for touch-action */} +
+ (value >= 1000 ? 'kHz' : 'Hz')} + value={frequency} + formatValue={(value) => + value >= 1000 ? `${(value / 1000).toFixed(2)}` : `${value.toFixed(1)}` + } + onChange={(value) => commit({ frequency: value })} + onInput={(value) => onLiveValue(value)} + style={{ width: '100%', flex: '1 1 auto' }} + /> +
setActiveBand(band)} style={{ minHeight: 0, - fontSize: '4cqh', }} > {`B${i + 1}`} @@ -423,9 +458,10 @@ function PeqBandList({ variant="toggle" className={peq.bypass ? 'active-warning' : ''} onClick={() => commit(band, { bypass: !peq.bypass })} - style={{ minHeight: 0, fontSize: '4cqh', paddingInline: 0 }} + style={{ minHeight: 0, fontSize: BTN_FS, paddingInline: 0 }} > - {peq.bypass ? 'Bypassed' : 'Bypass'} + {peq.bypass ? 'Bypassed' : 'Bypass'} + Byp
); @@ -468,6 +504,15 @@ function ChannelSection({ const [graphView, setGraphView] = useState('both'); const [resetting, setResetting] = useState(false); const [isResetConfirmOpen, setIsResetConfirmOpen] = useState(false); + const [view, setView] = useState('controls'); + const isMobile = useIsMobile(); + + // Phone: one tab per graph, so the Both / Mag / Phase toggle is not shown + const shownGraph: GraphView = isMobile + ? view === 'phase' + ? 'phase' + : 'magnitude' + : graphView; // Live values const [liveHpFreq, setLiveHpFreq] = useState(FREQUENCY_MIN); @@ -595,72 +640,98 @@ function ChannelSection({ return ( <> -
-
-
-
{activeChannelState.name} - Filters
- -
- - {(graphView === 'both' || graphView === 'magnitude') && ( -
- -
- )} - - {(graphView === 'both' || graphView === 'phase') && } - - {ActivePeq.bypass && ( -
- BYPASSED -
- )} +
+ {/* Phone only (hidden on desktop by CSS): one view at a time */} +
+ {CHANNEL_VIEWS.map((v) => ( + + ))}
-
-
-
- - - - commitPEQ(activeBand, gain, frequency, q, filter_type, bypass) - } - onLiveValue={(value) => handleLivePEQValue(activeBand, value)} - /> - + {/* Portrait phone only (CSS): the graphs need the width of landscape */} +
+ Rotate your phone to landscape to see the filter graphs. +
- - - - +
+
+
+
{activeChannelState.name} - Filters
+ {!isMobile && } +
- - - + {(shownGraph === 'both' || shownGraph === 'magnitude') && ( +
+ +
+ )} + + {(shownGraph === 'both' || shownGraph === 'phase') && } + + {ActivePeq.bypass && ( +
+ BYPASSED +
+ )} +
+
+ +
+
+ + {/* display: contents on desktop; a row (landscape) / column (portrait) on phones */} +
+ + + commitPEQ(activeBand, gain, frequency, q, filter_type, bypass) + } + onLiveValue={(value) => handleLivePEQValue(activeBand, value)} + /> +
+
+ + + + + + + + + +
@@ -688,4 +759,4 @@ function ChannelSection({ ); } -export default ChannelSection; +export default ChannelSection; \ No newline at end of file