From 14f5bf3774eb75d0e858847352ebf99ecda2b973 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 4 Jul 2026 20:14:03 +0200 Subject: [PATCH] Improved prep control UI --- frontend/src/components/HotcueBar.tsx | 15 ++--- frontend/src/components/LoopControls.tsx | 79 +++++++----------------- frontend/src/components/PrepStrip.tsx | 58 ++++++++--------- 3 files changed, 60 insertions(+), 92 deletions(-) diff --git a/frontend/src/components/HotcueBar.tsx b/frontend/src/components/HotcueBar.tsx index 00a49f0..c6a0c11 100644 --- a/frontend/src/components/HotcueBar.tsx +++ b/frontend/src/components/HotcueBar.tsx @@ -10,13 +10,14 @@ interface Props { const SLOTS = [0, 1, 2, 3, 4, 5, 6, 7] // Traktor hotcue slots → labelled 1–8 /** - * Traktor-style hotcue bar: all 8 hotcue slots, colour-coded by cue type when - * assigned (gray when empty). Clicking a slot selects it — the parent decides - * whether that creates a cue (empty slot) or jumps to it (assigned slot). + * The 8 hotcue slots, colour-coded by cue type when assigned (gray when empty). + * Rendered as a flex-1 group inside the hotcue row; the parent supplies the row + * chrome and the trailing edit controls. Clicking a slot delegates to the parent + * (create when empty, jump/trigger when assigned). */ export function HotcueBar({ cues, selectedSlot, onSlotClick }: Props) { return ( -
+
{SLOTS.map((slot) => { const cue = cues.find((c) => c.hotcue === slot) ?? null const selected = selectedSlot === slot @@ -34,9 +35,9 @@ export function HotcueBar({ cues, selectedSlot, onSlotClick }: Props) { } style={color ? { backgroundColor: color, color: contrastText(color) } : undefined} className={ - 'flex flex-1 items-center justify-center text-xs font-semibold transition-[filter] hover:brightness-110 ' + - (color ? '' : 'text-faint hover:bg-ink-900 ') + - (selected ? 'ring-2 ring-inset ring-white/80' : '') + 'relative flex flex-1 items-center justify-center text-sm font-semibold transition-colors ' + + (color ? 'hover:brightness-110' : 'bg-ink-900 text-faint hover:bg-ink-800') + + (selected ? ' ring-2 ring-inset ring-white/80' : '') } > {slot + 1} diff --git a/frontend/src/components/LoopControls.tsx b/frontend/src/components/LoopControls.tsx index 9a7db63..0768f82 100644 --- a/frontend/src/components/LoopControls.tsx +++ b/frontend/src/components/LoopControls.tsx @@ -1,5 +1,3 @@ -import { useState } from 'react' - interface Props { bpm: number | null // beat-loops need a grid; buttons disable without one active: boolean // a loop is currently engaged @@ -13,15 +11,17 @@ interface Props { onToggleActive: () => void } -// Fixed beat-loop sizes, 1/32 → 32 beats. +// All fixed beat-loop sizes, 1/32 → 32 beats, shown at once. const SIZES = [1 / 32, 1 / 16, 1 / 8, 1 / 4, 1 / 2, 1, 2, 4, 8, 16, 32] -const WINDOW = 6 // sizes shown at once (Traktor-style), shifted with the arrows -const DEFAULT_START = 3 // start on 1/4 … 8 function label(size: number): string { return size < 1 ? `1/${Math.round(1 / size)}` : String(size) } +const CELL = 'flex items-center justify-center text-sm font-semibold transition-colors select-none' +const IDLE = 'bg-ink-900 text-text hover:bg-ink-800' +const OFF = 'disabled:opacity-30 disabled:hover:bg-ink-900' + export function LoopControls({ bpm, active, @@ -34,37 +34,15 @@ export function LoopControls({ onLoopOut, onToggleActive, }: Props) { - const [start, setStart] = useState(DEFAULT_START) - const maxStart = SIZES.length - WINDOW - const visible = SIZES.slice(start, start + WINDOW) const hasGrid = !!bpm && bpm > 0 - const btn = - 'flex h-6 min-w-8 items-center justify-center rounded px-1.5 text-xs font-semibold ' + - 'border border-line text-muted hover:text-text disabled:opacity-30' - return ( -
- +
+ + Loop + - - {visible.map((size) => { + {SIZES.map((size) => { const isActive = active && activeBeats === size return ( ) })} - -
- - - +
) } diff --git a/frontend/src/components/PrepStrip.tsx b/frontend/src/components/PrepStrip.tsx index 363a904..06bb4b8 100644 --- a/frontend/src/components/PrepStrip.tsx +++ b/frontend/src/components/PrepStrip.tsx @@ -490,40 +490,40 @@ export function PrepStrip({ track, onError }: Props) { onToggleActive={toggleLoop} /> - - - {/* Selected-hotcue editing: type + delete. */} -
- - {selectedCue ? `Hotcue ${(selectedSlot ?? 0) + 1}` : 'No hotcue selected'} + {/* Hotcue row: label · 8 slots · type of selected cue · delete. */} +
+ + Cues -
- {selectedCue && selectedCue.type === LOOP_TYPE ? ( - Loop - ) : ( - - )} + +
+ {selectedCue && selectedCue.type === LOOP_TYPE ? ( + Loop + ) : ( + + )} +