import { memo } from 'react'; import { IonButton, IonIcon, IonPopover } from '@ionic/react'; import { chevronDown } from 'ionicons/icons'; import { INSTRUMENT_CATEGORY_BY_ID } from '../domain/instruments'; import type { InstrumentCategoryId } from '../domain/instruments'; import type { CategoryLabelOverrides } from '../hooks/useCategoryLabels'; import { usePopoverDisclosure } from '../hooks/usePopoverDisclosure'; interface CategoryRingSelectorProps { categoryIds: readonly InstrumentCategoryId[]; focusedCategoryId: InstrumentCategoryId | null; colorByCategoryId: Partial>; labelByCategoryId: CategoryLabelOverrides; onSelectCategory: (categoryId: InstrumentCategoryId) => void; } export const CategoryRingSelector = memo(function CategoryRingSelector({ categoryIds, focusedCategoryId, colorByCategoryId, labelByCategoryId, onSelectCategory, }: CategoryRingSelectorProps) { const popover = usePopoverDisclosure(); const focusedCategory = focusedCategoryId ? INSTRUMENT_CATEGORY_BY_ID[focusedCategoryId] : undefined; const focusedLabel = focusedCategory ? labelByCategoryId[focusedCategory.id] ?? focusedCategory.label : undefined; return ( <> {focusedCategory && ( <> {focusedCategory.letter} )} {focusedLabel ? `${focusedLabel} ring` : 'Category rings'}
{categoryIds.map((categoryId) => { const category = INSTRUMENT_CATEGORY_BY_ID[categoryId]; const label = labelByCategoryId[categoryId] ?? category.label; const selected = categoryId === focusedCategoryId; return ( onSelectCategory(categoryId)} > {category.letter} {label} ring ); })}
); });