Restore sound-specific rings and refine studio UI

This commit is contained in:
Ninosaurier committed 2026-11-17 17:04:02 +01:00
1 parent 02eb8911e8
commit e7b6c0bb3e
16 files changed
+318 -524

No files matched your search

+82 -1
View File
@@ -1 +1,82 @@
export { CategoryRingSelector as SoundRingSelector } from './CategoryRingSelector';
import { memo } from 'react';
import { IonButton, IonIcon, IonPopover } from '@ionic/react';
import { chevronDown } from 'ionicons/icons';
import { INSTRUMENT_BY_ID } from '../domain/instruments';
import type { InstrumentId } from '../domain/instruments';
import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure';
interface SoundRingSelectorProps {
soundIds: readonly InstrumentId[];
focusedSoundId: InstrumentId | null;
colorBySoundId: Partial<Record<InstrumentId, string>>;
onSelectSound: (soundId: InstrumentId) => void;
}
export const SoundRingSelector = memo(function SoundRingSelector({
soundIds,
focusedSoundId,
colorBySoundId,
onSelectSound,
}: SoundRingSelectorProps) {
const popover = usePopoverDisclosure();
const focusedSound = focusedSoundId ? INSTRUMENT_BY_ID[focusedSoundId] : undefined;
return (
<>
<IonButton
id="sound-ring-selector-trigger"
className="sound-ring-selector-trigger"
fill="clear"
disabled={soundIds.length === 0}
aria-label={focusedSound ? `Selected ring: ${focusedSound.label}` : 'Select a sound ring'}
aria-haspopup="dialog"
aria-expanded={popover.isOpen}
>
<span className="sound-ring-trigger-content">
{focusedSoundId && (
<span
className="ring-selector-swatch"
style={{ backgroundColor: colorBySoundId[focusedSoundId] ?? '#b8b4e0' }}
/>
)}
<span>{focusedSound ? `${focusedSound.label} ring` : 'Sound rings'}</span>
<IonIcon icon={chevronDown} />
</span>
</IonButton>
<IonPopover
className="sound-ring-popover"
trigger="sound-ring-selector-trigger"
triggerAction="click"
side="bottom"
alignment="end"
dismissOnSelect
onDidPresent={popover.onDidPresent}
onDidDismiss={popover.onDidDismiss}
>
<div className="sound-ring-options" role="group" aria-label="Sound rings">
{soundIds.map((soundId) => {
const selected = soundId === focusedSoundId;
return (
<IonButton
key={soundId}
className="sound-ring-option"
fill={selected ? 'solid' : 'clear'}
aria-pressed={selected}
onClick={() => onSelectSound(soundId)}
>
<span className="sound-ring-option-content">
<span
className="ring-selector-swatch"
style={{ backgroundColor: colorBySoundId[soundId] ?? '#b8b4e0' }}
/>
<span>{INSTRUMENT_BY_ID[soundId].label} ring</span>
</span>
</IonButton>
);
})}
</div>
</IonPopover>
</>
);
});