Add category rings and beat labels

This commit is contained in:
Ninosaurier committed 2026-11-15 14:35:36 +01:00
1 parent 9d8f277971
commit 4f221ea122
21 files changed
+752 -339

No files matched your search

+19 -10
View File
@@ -1,34 +1,43 @@
import { memo } from 'react';
import { getLoopPositionPercent } from '../domain/timeline';
import { INSTRUMENT_BY_ID } from '../domain/instruments';
import { INSTRUMENT_BY_ID, INSTRUMENT_CATEGORY_BY_ID } from '../domain/instruments';
import type { BeatPoint } from '../domain/sequencer';
import type { InstrumentId } from '../domain/instruments';
import type { InstrumentCategoryId } from '../domain/instruments';
import type { CategoryLabelOverrides } from '../hooks/useCategoryLabels';
interface BeatSelectionHintProps {
selectedBeat: BeatPoint | undefined;
focusedSoundId: InstrumentId | null;
colorBySoundId: Partial<Record<InstrumentId, string>>;
focusedCategoryId: InstrumentCategoryId | null;
categoryLabelById: CategoryLabelOverrides;
colorByCategoryId: Partial<Record<InstrumentCategoryId, string>>;
totalSteps: number;
}
export const BeatSelectionHint = memo(function BeatSelectionHint({
selectedBeat,
focusedSoundId,
colorBySoundId,
focusedCategoryId,
categoryLabelById,
colorByCategoryId,
totalSteps,
}: BeatSelectionHintProps) {
const soundId = selectedBeat?.soundId ?? focusedSoundId;
if (!soundId) return <p className="timeline-hint" aria-live="polite" />;
const selectedInstrument = selectedBeat ? INSTRUMENT_BY_ID[selectedBeat.soundId] : undefined;
const categoryId = selectedInstrument?.categoryId ?? focusedCategoryId;
if (!categoryId) return <p className="timeline-hint" aria-live="polite" />;
const category = INSTRUMENT_CATEGORY_BY_ID[categoryId];
const categoryLabel = categoryLabelById[categoryId] ?? category.label;
return (
<p className="timeline-hint" aria-live="polite">
<span
className="hint-swatch"
style={{ backgroundColor: colorBySoundId[soundId] }}
style={{ backgroundColor: colorByCategoryId[categoryId] }}
/>
{INSTRUMENT_BY_ID[soundId].label}
{category.letter} · {categoryLabel}
{selectedBeat && (
<>
<span className="hint-separator">·</span>
{selectedBeat.letter} · {selectedInstrument?.label}
<span className="hint-separator">·</span>
Step {getLoopPositionPercent(selectedBeat.step, totalSteps)}% selected
</>