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 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)]' const KEY = 'flex items-center justify-center rounded-[9px] transition-colors disabled:opacity-30' // 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, 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 (