feat(editor): board 01 annotation card, side column from 1 024 px

Annotations of the view move from under the drawing to the overview card
(grouped by category, name filter, all rows); side column from lg.
Properties panel gains « Toutes les annotations ».

E2E mapping (R-24): after a creation the card is hidden (the new annotation is
selected), so list(...).getByText(name) became selectionTag toContainText
(annotations, geometry, journey); row clicks go through pickAnnotation
(annotations, geometry, journey, structures); geometry's list count 0 while a
creation is pending became selectionTag count 0.
This commit is contained in:
bchanot committed 2026-11-06 21:40:25 +01:00
1 parent 51fd3db608
commit 6131225288
16 files changed
+404 -94

No files matched your search

@@ -1,12 +1,18 @@
import { useMemo, useState } from 'react'
import type {
AnatomicalSheetDocument,
SheetView,
} from '@faunosteo/core-wasm/types'
import { useOverviewCounts } from '@/editor/annotations/overview'
import Input from '@/components/ui/Input'
import {
groupAnnotations,
useOverviewCounts,
} from '@/editor/annotations/overview'
import type { AnnotationSection } from '@/editor/navigation'
import { usePlural } from '@/editor/plural'
import { useT } from '@/i18n/useT'
import { useLocaleStore } from '@/state/localeStore'
import AnnotationList, { annotationName } from './AnnotationList'
const CARD = 'space-y-2 rounded-xl border border-[var(--color-border)] p-4'
const TITLE = 'text-sm font-semibold'
@@ -24,6 +30,7 @@ export interface OverviewPanelProps {
/** Put before every id (the read-only twin beside the kept edit panel). */
idPrefix?: string
onSelectView: (viewId: string) => void
onSelectAnnotation: (annotationId: string) => void
onOpenSection: (section: AnnotationSection, opener: HTMLElement) => void
}
@@ -183,7 +190,59 @@ function CategoriesCard(props: OverviewPanelProps) {
)
}
/** Board 01's overview: the views and the categories, with the entries to their sections. */
function AnnotationsCard(props: OverviewPanelProps) {
const t = useT()
const locale = useLocaleStore((s) => s.locale)
const { doc, viewId, onSelectAnnotation } = props
const [term, setTerm] = useState('')
const prefix = props.idPrefix ?? ''
const total = useOverviewCounts(doc).annotationsByView.get(viewId) ?? 0
const groups = useMemo(
() =>
groupAnnotations(doc, viewId, term, (a) =>
annotationName(a, doc.views, locale),
),
[doc, viewId, term, locale],
)
return (
<section aria-labelledby={`${prefix}overview-annotations`} className={CARD}>
<h3
id={`${prefix}overview-annotations`}
className={`${TITLE} flex items-center justify-between`}
>
{t('editor.annotations.list')}
<span className="font-normal text-[var(--color-ink-muted)]">
{total}
</span>
</h3>
<Input
type="search"
id={`${prefix}overview-filter`}
aria-label={t('editor.overview.filter')}
placeholder={t('editor.overview.filter')}
value={term}
onChange={(event) => setTerm(event.target.value)}
/>
{groups.length > 0 ? (
<AnnotationList
groups={groups}
views={doc.views}
onSelect={onSelectAnnotation}
/>
) : (
<p className="text-sm text-[var(--color-ink-muted)]">
{t(
total === 0
? 'editor.annotations.list_empty'
: 'editor.overview.no_match',
)}
</p>
)}
</section>
)
}
/** Board 01's overview: the views, the categories, then the annotations of the shown view. */
export default function OverviewPanel(props: OverviewPanelProps) {
const t = useT()
return (
@@ -195,6 +254,7 @@ export default function OverviewPanel(props: OverviewPanelProps) {
>
<ViewsCard {...props} />
<CategoriesCard {...props} />
<AnnotationsCard {...props} />
</div>
)
}