import { useRef } from 'react'; import { useTranslation } from 'react-i18next'; import type { PaintingAnnotation } from '../types'; import './PaintingAnnotations.css'; const CATEGORY_KEYS: Record = { technique: 'categoryTechnique', composition: 'categoryComposition', symbolism: 'categorySymbolism', history: 'categoryHistorical', subject: 'categorySubject', }; interface PanelProps { annotations: PaintingAnnotation[]; activeId: number | null; onSelect: (id: number | null) => void; } export function PaintingAnnotationMarkers({ annotations, activeId, onSelect, }: PanelProps) { const positioned = annotations.filter( (a) => a.pos_x != null && a.pos_y != null && Number.isFinite(Number(a.pos_x)) && Number.isFinite(Number(a.pos_y)) ); if (!positioned.length) return null; return (
{positioned.map((ann) => { const number = annotations.indexOf(ann) + 1; const isActive = activeId === ann.id; return ( ); })}
); } export default function PaintingAnnotationsPanel({ annotations, activeId, onSelect, }: PanelProps) { const { t } = useTranslation('annotations'); const cardRefs = useRef>(new Map()); if (!annotations.length) return null; const focusAnnotation = (id: number | null) => { onSelect(id); if (id != null) { cardRefs.current.get(id)?.scrollIntoView({ behavior: 'smooth', block: 'nearest' }); } }; return ( ); }