Add category rings and beat labels
This commit is contained in:
1 parent
9d8f277971
commit
4f221ea122
21 files changed
+752
-339
No files matched your search
@@ -1,82 +1 @@
|
||||
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: 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>
|
||||
</>
|
||||
);
|
||||
});
|
||||
export { CategoryRingSelector as SoundRingSelector } from './CategoryRingSelector';
|
||||
Reference in new issue
Block a user