import { Icon } from '../lib/icons' /** One size, 1/32 → 32 beats, shared by beat loops AND beat jump: the number a * DJ has in their head ("4 beats") should not differ between the two. */ export const LOOP_SIZES = [1 / 32, 1 / 16, 1 / 8, 1 / 4, 1 / 2, 1, 2, 4, 8, 16, 32] export function sizeLabel(size: number): string { return size < 1 ? `1/${Math.round(1 / size)}` : String(size) } export type LoopMode = 'beat' | 'manual' interface Props { mode: LoopMode onMode: (mode: LoopMode) => void hasGrid: boolean // beat loops and jumps are sized in beats; inert without a grid ready: boolean /** The shared loop/jump size, in beats. */ size: number onSmaller: () => void onBigger: () => void /** A loop is engaged right now (either kind). */ loopActive: boolean /** The engaged loop is a beat loop of exactly `size` — the size key is lit. */ sizeLit: boolean onToggleSize: () => void // manual mode canToggle: boolean // a loop region exists to switch on/off /** IN was pressed and is waiting for OUT. */ inArmed: boolean /** A manual (IN/OUT) loop exists, engaged or not. */ manualSet: boolean onLoopIn: () => void onLoopOut: () => void onToggleLoop: () => void /** ‹ ›: move an engaged loop by its own length, else jump by `size`. */ onMove: (dir: -1 | 1) => void } const LIT = 'bg-gradient-to-b from-[#7bf0ad] to-mint text-ink-950 shadow-[inset_0_1px_0_rgb(255_255_255/0.6),0_0_14px_rgb(61_220_132/0.55)]' // Every key presses in when clicked, so a press is felt even when what it did // (a loop moved, an in-point set) is somewhere else on screen. const KEY = 'flex items-center justify-center rounded-[9px] transition-[color,background-color,box-shadow,transform,filter] duration-75 ' + 'active:scale-[0.93] active:brightness-125 disabled:opacity-30 disabled:active:scale-100' // An armed IN: a green rim and glow — "waiting for OUT". const ARMED = 'bg-mint/15 text-mint shadow-[inset_0_0_0_1px_rgb(61_220_132/0.75),0_0_12px_-3px_rgb(61_220_132/0.7)]' // A set point (the loop exists): green text on a faint green tint. const SET = 'bg-mint/10 text-mint shadow-[inset_0_0_0_1px_rgb(61_220_132/0.35)]' // BOTH modes' clusters are this wide, so switching BEAT ⇄ MAN never shifts // the pads and tempo controls to their right. const CLUSTER = 'well flex h-10 w-[8.5rem] shrink-0 items-center gap-0.5 rounded-xl p-[3px]' /** * The deck's loop + jump cluster: a BEAT / MAN switch, then either the beat * size (− size +, the size itself toggling a loop of that length) or the manual * IN / OUT / toggle, then ‹ › which move an engaged loop or jump the playhead. * * Presentational: PrepStrip owns every piece of state and does the seeking. */ export function LoopControls({ mode, onMode, hasGrid, ready, size, onSmaller, onBigger, loopActive, sizeLit, onToggleSize, canToggle, inArmed, manualSet, onLoopIn, onLoopOut, onToggleLoop, onMove, }: Props) { const atMin = size <= LOOP_SIZES[0] const atMax = size >= LOOP_SIZES[LOOP_SIZES.length - 1] const what = loopActive ? 'Move the loop' : `Jump ${sizeLabel(size)} beat${size === 1 ? '' : 's'}` // A beat jump needs a grid; moving a manual loop does not. const canMove = ready && (loopActive || hasGrid) const tab = (m: LoopMode, text: string, title: string) => ( ) return (