mirror of
https://github.com/MrPatben8/konduktor.git
synced 2026-11-27 10:22:51 +01:00
Mode switch chan now be clicked anywhere to swap options
This commit is contained in:
1 parent
75cb0c8138
commit
667068c2f1
1 file changed
+6
-2
@@ -1,6 +1,8 @@
|
||||
/**
|
||||
* The deck's two-way mode switch: two small stacked tabs in a well, the chosen
|
||||
* one lit. BEAT / MAN (loops) and HOT / MEM (the cue bank) are both this.
|
||||
* With exactly two options a click anywhere on it flips to the other one;
|
||||
* with more, each tab selects itself.
|
||||
*/
|
||||
export function ModeSwitch<T extends string>({
|
||||
label,
|
||||
@@ -14,16 +16,18 @@ export function ModeSwitch<T extends string>({
|
||||
options: { value: T; text: string; title: string }[]
|
||||
onChange: (value: T) => void
|
||||
}) {
|
||||
const other = options.length === 2 ? options.find((o) => o.value !== value) : undefined
|
||||
return (
|
||||
<div
|
||||
role="group"
|
||||
aria-label={label}
|
||||
className="well flex h-10 shrink-0 flex-col justify-center gap-0.5 rounded-[10px] p-0.5"
|
||||
onClick={other ? () => onChange(other.value) : undefined}
|
||||
className={`well ${other ? 'cursor-pointer ' : ''}flex h-10 shrink-0 flex-col justify-center gap-0.5 rounded-[10px] p-0.5`}
|
||||
>
|
||||
{options.map((o) => (
|
||||
<button
|
||||
key={o.value}
|
||||
onClick={() => onChange(o.value)}
|
||||
onClick={other ? undefined : () => onChange(o.value)}
|
||||
title={o.title}
|
||||
aria-pressed={value === o.value}
|
||||
className={`h-[17px] rounded-[7px] px-[7px] text-[9px] font-bold tracking-[0.08em] transition-colors ${
|
||||
|
||||
Reference in new issue
Block a user