diff --git a/.claude/memory/learnings.md b/.claude/memory/learnings.md index d69cda1c..f15c840a 100644 --- a/.claude/memory/learnings.md +++ b/.claude/memory/learnings.md @@ -14,8 +14,8 @@ Apply: any polymorphic field with a literal discriminant. ## LRN-002 | 2026-05-18 | SVG hitbox+visible twin pattern -Two SVG elements share same data-bone-id: hitbox (pointer-events:all, fill:transparent) + visible (pointer-events:none, colored). -Parser groups by data-bone-id → Bone.hitboxEls[], Bone.visibleEls[]. +Two SVG elements share same data-anno-id: hitbox (pointer-events:all, fill:transparent) + visible (pointer-events:none, colored). +Parser groups by data-anno-id → Bone.hitboxEls[], Bone.visibleEls[]. Apply: any SVG-based interactive map needing precise click areas. --- diff --git a/.claude/tasks/TODO.md b/.claude/tasks/TODO.md index 6562e1fa..b55403e2 100644 --- a/.claude/tasks/TODO.md +++ b/.claude/tasks/TODO.md @@ -30,7 +30,7 @@ - [ ] `src/lib/assert.ts` — already implemented ### 2b. Anatomy convention parser -- [ ] `src/anatomy/svgConvention.ts` — parseSvgBones: walk DOM, group by data-bone-id +- [ ] `src/anatomy/svgConvention.ts` — parseSvgBones: walk DOM, group by data-anno-id - [ ] `src/anatomy/svgLoader.ts` — loadSvg: fetch + DOMParser inline - [ ] Tests: valid SVG fixture → bones map; bad SVG → SvgConventionError diff --git a/CLAUDE.md b/CLAUDE.md index 9d4b2d35..d3f57e8f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -184,7 +184,7 @@ SVG interaction → parseSvgBones() walks DOM → Bone map → delegated click listener → getBoneIdFromEvent() → if spine-zone → VertebraPicker modal - → if data-opens-detail → DetailModal (loads detail SVG) + → if data-anno-opens-detail → DetailModal (loads detail SVG) → else → updateObservation() in store PDF export @@ -224,9 +224,9 @@ Runtime config ### SVG convention - docs/ANATOMY-SVG-CONVENTION.md is the source of truth -- Every clickable element must have: data-bone-id, data-bone-fr, data-bone-en, data-category +- Every clickable element must have: data-anno-id, data-anno-name-fr, data-anno-name-en, data-anno-category - SvgConventionError thrown on any missing required attribute -- Never rely on element id or className for click targeting — always data-bone-id +- Never rely on element id or className for click targeting — always data-anno-id ### Schemas - domain/schema/*.ts are the data contracts — never change without bumping version @@ -310,4 +310,4 @@ Allowed scopes: `schema`, `store`, `anatomy`, `pdf`, `editor`, `home`, `new`, `u Examples: - `test(schema): cover Report version literal` - `feat(store): implement addObservation` -- `feat(anatomy): parse data-bone-id from SVG` +- `feat(anatomy): parse data-anno-id from SVG` diff --git a/docs/ADDING-A-SPECIES.md b/docs/ADDING-A-SPECIES.md index faca1818..b2885229 100644 --- a/docs/ADDING-A-SPECIES.md +++ b/docs/ADDING-A-SPECIES.md @@ -20,11 +20,11 @@ Every clickable zone element must carry these data attributes: | Attribute | Required | Notes | |----------------------|----------|-----------------------------------------------------------------| -| `data-bone-id` | yes | Stable kebab-case id, unique within the SVG. | -| `data-bone-fr` | yes | French anatomical label (used in tooltips and PDF text). | -| `data-bone-en` | yes | English anatomical label (used as fallback and a11y hint). | -| `data-category` | yes | One of: `articulation`, `charniere`, `spine-zone`, `os`, `os-overlay`, `head`, `cadran-crane`. | -| `data-opens-detail` | no | Id of a detail popup SVG to open when the zone is clicked. The id must match a key in the species manifest's `details` map. | +| `data-anno-id` | yes | Stable kebab-case id, unique within the SVG. | +| `data-anno-name-fr` | yes | French anatomical label (used in tooltips and PDF text). | +| `data-anno-name-en` | yes | English anatomical label (used as fallback and a11y hint). | +| `data-anno-category` | yes | One of: `articulation`, `charniere`, `spine-zone`, `os`, `os-overlay`, `head`, `cadran-crane`. | +| `data-anno-opens-detail` | no | Id of a detail popup SVG to open when the zone is clicked. The id must match a key in the species manifest's `details` map. | Reuse the equine SVG patterns: @@ -79,7 +79,7 @@ Required fields (see `src/domain/species/types.ts`): - `labelFr` — French display name shown in the species picker. - `mainSvg` — absolute path to the main anatomy SVG. - `details` — map of detail id → SVG path. Keys must match every distinct - `data-opens-detail` attribute used in the main SVG. + `data-anno-opens-detail` attribute used in the main SVG. - `vertebralFormula` — segment counts for the VertebraPicker (see step 5). - `pathologies` — lazy import returning `{ default: Pathology[] }` (step 6). @@ -182,7 +182,7 @@ Mirror `tests/unit/anatomy.horse.test.ts`. Create `public/species//` and asserts: - `parseSvgBones` does not throw and returns a non-empty map. -- Every required `data-category` you used is present at least once +- Every required `data-anno-category` you used is present at least once (especially the `spine-zone` count, the `head` zone with `opensDetail`, and any `charniere` hinges). - Detail SVGs (one test per detail id) parse cleanly and contain the diff --git a/docs/ANATOMY-SVG-CONVENTION.md b/docs/ANATOMY-SVG-CONVENTION.md index 783fd56d..7f7626a5 100644 --- a/docs/ANATOMY-SVG-CONVENTION.md +++ b/docs/ANATOMY-SVG-CONVENTION.md @@ -10,16 +10,16 @@ Every clickable zone element must carry all four attributes: | Attribute | Type | Description | |---|---|---| -| `data-bone-id` | `string` | Stable kebab-case identifier. Unique per bone. | -| `data-bone-fr` | `string` | French anatomical label (e.g. "Colonne cervicale"). | -| `data-bone-en` | `string` | English anatomical label (e.g. "Cervical spine"). | -| `data-category` | `BoneCategory` | One of the seven valid categories below. | +| `data-anno-id` | `string` | Stable kebab-case identifier. Unique per bone. | +| `data-anno-name-fr` | `string` | French anatomical label (e.g. "Colonne cervicale"). | +| `data-anno-name-en` | `string` | English anatomical label (e.g. "Cervical spine"). | +| `data-anno-category` | `BoneCategory` | One of the seven valid categories below. | ## Optional data attributes | Attribute | Type | Description | |---|---|---| -| `data-opens-detail` | `string` | Id of the detail popup SVG to open on click. Key must exist in `SpeciesManifest.details`. | +| `data-anno-opens-detail` | `string` | Id of the detail popup SVG to open on click. Key must exist in `SpeciesManifest.details`. | --- @@ -43,15 +43,15 @@ Every clickable zone element must carry all four attributes: Used for: `articulation`, `charniere`, `os-overlay`, `head`. -Two sibling SVG elements share the **same** `data-bone-id`: +Two sibling SVG elements share the **same** `data-anno-id`: ```xml @@ -91,8 +91,8 @@ One polygon carries everything: ## Parser behavior (`src/anatomy/svgConvention.ts`) -1. `parseSvgBones(svgRoot)` — walks all elements with `data-bone-id`. -2. Groups by `data-bone-id` → one `Bone` per id. +1. `parseSvgBones(svgRoot)` — walks all elements with `data-anno-id`. +2. Groups by `data-anno-id` → one `Bone` per id. 3. For each group, validates required attributes. 4. Classifies elements into `hitboxEls` (class contains "hitbox") and `visibleEls` (class contains "visible"). Elements in neither class land in `visibleEls` by default. 5. Returns `Map`. @@ -100,10 +100,10 @@ One polygon carries everything: ### Validated rules -- `data-bone-fr` must be non-empty. -- `data-bone-en` must be non-empty. -- `data-category` must be one of the seven valid values. -- If `data-opens-detail` is present, the value must be a non-empty string (runtime check against species manifest happens in the canvas component). +- `data-anno-name-fr` must be non-empty. +- `data-anno-name-en` must be non-empty. +- `data-anno-category` must be one of the seven valid values. +- If `data-anno-opens-detail` is present, the value must be a non-empty string (runtime check against species manifest happens in the canvas component). --- @@ -112,8 +112,8 @@ One polygon carries everything: A single `click` listener on the root `` element: ``` -event.target → walk up ancestors → find data-bone-id - → if data-opens-detail present → emit requestDetail({id}) +event.target → walk up ancestors → find data-anno-id + → if data-anno-opens-detail present → emit requestDetail({id}) → else if category === 'spine-zone' → open VertebraPicker → else → add bone to current observation ``` @@ -124,7 +124,7 @@ Never attach per-element click listeners — the SVG may have thousands of eleme ## Zone visual states -Applied as `data-state` attribute on all elements sharing a `data-bone-id`: +Applied as `data-state` attribute on all elements sharing a `data-anno-id`: | `data-state` | Condition | Visual | |---|---|---| @@ -140,7 +140,7 @@ terracotta → sauge → bleu canard → ambre → prune → ocre. ## Detail popup mechanism -When a zone has `data-opens-detail="head"`: +When a zone has `data-anno-opens-detail="head"`: 1. Canvas emits `requestDetail({ id: 'head' })`. 2. `DetailModal` resolves the path via `SpeciesManifest.details['head']`. @@ -152,7 +152,7 @@ When a zone has `data-opens-detail="head"`: ## Vertebra picker trigger -When a bone has `data-category="spine-zone"`, clicking it opens `VertebraPicker`: +When a bone has `data-anno-category="spine-zone"`, clicking it opens `VertebraPicker`: - Region tabs: Cervicales (C1–C7), Thoraciques (T1–T18), Lombaires (L1–L6), Sacrales (S1–S5), Caudales (Cd1–Cd18). - Multi-select chip grid, ≥40 px touch targets. diff --git a/docs/superpowers/plans/2026-05-18-osteo-report-mvp.md b/docs/superpowers/plans/2026-05-18-osteo-report-mvp.md index 6cbd126f..e63bb43b 100644 --- a/docs/superpowers/plans/2026-05-18-osteo-report-mvp.md +++ b/docs/superpowers/plans/2026-05-18-osteo-report-mvp.md @@ -34,7 +34,7 @@ Allowed scopes: `schema`, `store`, `anatomy`, `pdf`, `editor`, `home`, `new`, `u Examples: - `test(schema): cover Report version literal` - `feat(store): implement addObservation` -- `feat(anatomy): parse data-bone-id from SVG` +- `feat(anatomy): parse data-anno-id from SVG` ``` - [ ] **Step 2:** Commit @@ -453,19 +453,19 @@ function svgFromString(s: string): SVGSVGElement { const FIXTURE = ` - - - + + - + ` describe('parseSvgBones', () => { - it('groups hitbox + visible by data-bone-id', () => { + it('groups hitbox + visible by data-anno-id', () => { const map = parseSvgBones(svgFromString(FIXTURE)) const epaule = map.get('epaule') expect(epaule).toBeDefined() @@ -488,16 +488,16 @@ describe('parseSvgBones', () => { }) describe('parseSvgBones validation', () => { - it('throws on missing data-bone-fr', () => { + it('throws on missing data-anno-name-fr', () => { const bad = ` - + ` expect(() => parseSvgBones(svgFromString(bad))).toThrow(SvgConventionError) }) it('throws on unknown category', () => { const bad = ` - + ` expect(() => parseSvgBones(svgFromString(bad))).toThrow(SvgConventionError) }) @@ -554,36 +554,36 @@ function classList(el: Element): string[] { } export function validateBoneElement(el: Element): void { - const boneId = el.getAttribute('data-bone-id') ?? '' - for (const attr of ['data-bone-fr', 'data-bone-en', 'data-category']) { + const boneId = el.getAttribute('data-anno-id') ?? '' + for (const attr of ['data-anno-name-fr', 'data-anno-name-en', 'data-anno-category']) { if (!el.getAttribute(attr)) { throw new SvgConventionError( - `Element data-bone-id="${boneId}" missing attribute ${attr}`, + `Element data-anno-id="${boneId}" missing attribute ${attr}`, boneId, attr, ) } } - const cat = el.getAttribute('data-category') ?? '' + const cat = el.getAttribute('data-anno-category') ?? '' if (!isValidCategory(cat)) { throw new SvgConventionError( - `Element data-bone-id="${boneId}" has unknown data-category="${cat}"`, + `Element data-anno-id="${boneId}" has unknown data-anno-category="${cat}"`, boneId, - 'data-category', + 'data-anno-category', ) } } export function parseSvgBones(svgRoot: SVGSVGElement): Map { const map = new Map() - const all = svgRoot.querySelectorAll('[data-bone-id]') + const all = svgRoot.querySelectorAll('[data-anno-id]') all.forEach((el) => { validateBoneElement(el) - const id = el.getAttribute('data-bone-id') as string - const fr = el.getAttribute('data-bone-fr') as string - const en = el.getAttribute('data-bone-en') as string - const category = el.getAttribute('data-category') as BoneCategory - const opensDetail = el.getAttribute('data-opens-detail') ?? undefined + const id = el.getAttribute('data-anno-id') as string + const fr = el.getAttribute('data-anno-name-fr') as string + const en = el.getAttribute('data-anno-name-en') as string + const category = el.getAttribute('data-anno-category') as BoneCategory + const opensDetail = el.getAttribute('data-anno-opens-detail') ?? undefined const classes = classList(el) const isHitbox = classes.includes('hitbox') @@ -610,7 +610,7 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map { export function getBoneIdFromEvent(event: Event): string | null { let node = event.target as Element | null while (node && node.nodeType === 1) { - const id = node.getAttribute?.('data-bone-id') + const id = node.getAttribute?.('data-anno-id') if (id) return id node = node.parentElement } @@ -710,7 +710,7 @@ git commit -m "test(anatomy): cover real Horse.svg + Horse_head.svg parsing" import { describe, it, expect, vi, beforeEach } from 'vitest' import { loadSvg } from '@/anatomy/svgLoader' -const SVG = '' +const SVG = '' describe('loadSvg', () => { beforeEach(() => { @@ -1682,8 +1682,8 @@ body { .svg-canvas [data-state='current'] { fill: var(--color-accent) !important; fill-opacity: 0.85 !important; } .svg-canvas [data-state='linked'] { stroke-dasharray: 4 3; stroke: var(--color-accent); fill-opacity: 0.35 !important; } .svg-canvas [data-state='multi'] { fill: var(--color-accent) !important; fill-opacity: 0.65 !important; stroke: var(--color-ink); stroke-width: 1.5; } -.svg-canvas [data-bone-id] { cursor: pointer; } -.svg-canvas [data-bone-id]:hover { filter: brightness(1.05); } +.svg-canvas [data-anno-id] { cursor: pointer; } +.svg-canvas [data-anno-id]:hover { filter: brightness(1.05); } ``` - [ ] **Step 3:** Verify build @@ -1771,10 +1771,10 @@ vi.mock('@/anatomy/svgLoader', () => ({ loadSvg: vi.fn(async () => { const doc = new DOMParser().parseFromString( ` - - + + `, 'image/svg+xml', ) @@ -1788,7 +1788,7 @@ describe('AnatomyCanvas', () => { it('renders the loaded SVG inline', async () => { render( {}} />) await waitFor(() => - expect(document.querySelector('[data-bone-id="epaule"]')).not.toBeNull(), + expect(document.querySelector('[data-anno-id="epaule"]')).not.toBeNull(), ) }) @@ -1796,7 +1796,7 @@ describe('AnatomyCanvas', () => { const onZoneClick = vi.fn() render() await waitFor(() => screen.getByTestId('anatomy-canvas')) - ;(document.querySelector('[data-bone-id="epaule"]') as Element).dispatchEvent( + ;(document.querySelector('[data-anno-id="epaule"]') as Element).dispatchEvent( new Event('click', { bubbles: true }), ) await waitFor(() => expect(onZoneClick).toHaveBeenCalledWith('epaule')) @@ -1854,9 +1854,9 @@ export default function AnatomyCanvas({ useEffect(() => { const c = containerRef.current if (!c) return - const all = c.querySelectorAll('[data-bone-id]') + const all = c.querySelectorAll('[data-anno-id]') all.forEach((el) => { - const id = el.getAttribute('data-bone-id') as string + const id = el.getAttribute('data-anno-id') as string const state = boneStates.get(id) if (state && state !== 'default') el.setAttribute('data-state', state) else el.removeAttribute('data-state') @@ -4224,7 +4224,7 @@ git commit -m "test(qa): document MVP manual QA checklist outcome" - Modify: `docs/ADDING-A-SPECIES.md` - [ ] **Step 1:** Rewrite from the placeholder, covering: - 1. SVG convention (refer to `docs/ANATOMY-SVG-CONVENTION.md`): `data-bone-id`, `data-bone-fr`, `data-bone-en`, `data-category`, optional `data-opens-detail`. + 1. SVG convention (refer to `docs/ANATOMY-SVG-CONVENTION.md`): `data-anno-id`, `data-anno-name-fr`, `data-anno-name-en`, `data-anno-category`, optional `data-anno-opens-detail`. 2. Where to drop the SVG: `public/species//
.svg` + any detail SVGs. 3. Create the species manifest at `src/domain/species//index.ts` with `id`, `labelFr`, `mainSvg`, `details`, `vertebralFormula`, and a `pathologies` lazy import. 4. Wire the manifest into `src/domain/species/registry.ts`. diff --git a/docs/superpowers/specs/2026-05-18-osteo-report-mvp-design.md b/docs/superpowers/specs/2026-05-18-osteo-report-mvp-design.md index 2bd80bf1..3ecd20da 100644 --- a/docs/superpowers/specs/2026-05-18-osteo-report-mvp-design.md +++ b/docs/superpowers/specs/2026-05-18-osteo-report-mvp-design.md @@ -84,7 +84,7 @@ type Severity = 'légère' | 'modérée' | 'sévère'; type Vertebra = { region: 'C' | 'T' | 'L' | 'S' | 'Cd'; index: number }; type ObservationZone = { - boneId: string; // matches data-bone-id from SVG + boneId: string; // matches data-anno-id from SVG detailSourceId?: string; // when this zone came from a detail pop-up SVG vertebrae?: Vertebra[]; // when boneId is a spine-zone }; @@ -139,9 +139,9 @@ All JSON carries `version: 1`. Future migrations bump the version. ## SVG convention (source of truth) -A clickable zone is any element carrying `data-bone-id`. Required data -attributes: `data-bone-id`, `data-bone-fr`, `data-bone-en`, `data-category`. -Optional: `data-opens-detail=""`. +A clickable zone is any element carrying `data-anno-id`. Required data +attributes: `data-anno-id`, `data-anno-name-fr`, `data-anno-name-en`, `data-anno-category`. +Optional: `data-anno-opens-detail=""`. Categories: `articulation` · `charniere` · `spine-zone` · `os` · `os-overlay` · `head` · `cadran-crane`. @@ -149,29 +149,29 @@ Categories: `articulation` · `charniere` · `spine-zone` · `os` · `os-overlay Two rendering patterns are tolerated in the SVG: 1. **hitbox + visible twin** (articulation, charniere, os-overlay, head): - two elements share the same `data-bone-id`. One has `class*="hitbox"`, + two elements share the same `data-anno-id`. One has `class*="hitbox"`, transparent fill, `pointer-events: all`. The other has `class*="visible"`, colored fill, `pointer-events: none`. 2. **single element** (spine-zone, head zone): one polygon carries everything; `pointer-events: all` and `cursor: pointer` directly. Parser strategy (`src/anatomy/svgConvention.ts`): -- Walk all elements with `data-bone-id`. -- Group by `data-bone-id` → one logical `Bone`. +- Walk all elements with `data-anno-id`. +- Group by `data-anno-id` → one logical `Bone`. - Bone fields: `id`, `fr`, `en`, `category`, `opensDetail?`, `hitboxEls[]`, `visibleEls[]`. -- Validate: must have `data-bone-fr`, `data-bone-en`, `data-category` (in +- Validate: must have `data-anno-name-fr`, `data-anno-name-en`, `data-anno-category` (in the allowed enum). Throws structured `SvgConventionError` on missing attributes. Click handling: a single delegated listener on the root `` walks up -from `event.target` to the nearest element with `data-bone-id`. If -`data-opens-detail` is present → open the detail modal mapped via the +from `event.target` to the nearest element with `data-anno-id`. If +`data-anno-opens-detail` is present → open the detail modal mapped via the species manifest. If the bone's category is `spine-zone` → open the vertebra picker. Otherwise add the bone to the current observation. Colorization: when the current observation contains a bone, all elements -matching that `data-bone-id` get a `data-state` attribute toggled by JS: +matching that `data-anno-id` get a `data-state` attribute toggled by JS: `current` (solid accent), `linked` (faded dashed border, "in another observation"), `multi` (striped pattern, "in ≥2 observations"). @@ -193,7 +193,7 @@ export const equine = { }; ``` -When a zone with `data-opens-detail="head"` is clicked, the canvas +When a zone with `data-anno-opens-detail="head"` is clicked, the canvas emits a `requestDetail({id: 'head'})` event handled by `DetailModal`, which loads `/species/equine/Horse_head.svg` and renders it inline. Clicks inside the modal add zones with `detailSourceId: 'head'` to the current @@ -202,7 +202,7 @@ persisted in the report. ## Vertebra picker -Triggered when a clicked bone has `data-category="spine-zone"`. Modal with +Triggered when a clicked bone has `data-anno-category="spine-zone"`. Modal with region tabs (Cervicales C1–C7, Thoraciques T1–T18, Lombaires L1–L6, Sacrales S1–S5, Caudales Cd1–Cd18). Each region renders chips in a grid; multi-select; ≥40 px touch targets; per-region "Tout cocher / décocher". @@ -341,7 +341,7 @@ port. | SVG injection | Fetch text → DOMParser → inline render (consistent + CSS-controllable + sandboxing irrelevant since assets are local). | | Vertebra picker UX | Region tabs + chip grid, multi-select, ≥40 px touch targets. | | Multi-obs zone overlay | current / linked / multi states; striped pattern + tooltip. | -| Detail SVG trigger | `data-opens-detail` → modal with inline detail SVG, clicks add to current obs. | +| Detail SVG trigger | `data-anno-opens-detail` → modal with inline detail SVG, clicks add to current obs. | | SVG → PDF | canvg → canvas @ 2× → PNG → `embedPng`. | | Pathology sources in PDF | Abbreviated citation list below each obs, no raw URLs. | | Brand env vars | Runtime `window.__APP_CONFIG__` + Vite-define fallback. | diff --git a/public/species/equine/Horse.svg b/public/species/equine/Horse.svg index 7b5c146f..5629ff65 100644 --- a/public/species/equine/Horse.svg +++ b/public/species/equine/Horse.svg @@ -326,23 +326,23 @@ - Bassin / Pelvis + Bassin / Pelvis - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae - Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae - Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae @@ -351,17 +351,17 @@ - Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae - Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae - Fémur / Femur + Fémur / Femur @@ -386,7 +386,7 @@ - Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae @@ -397,20 +397,20 @@ - Cage thoracique / Ribcage + Cage thoracique / Ribcage - Cage thoracique / Ribcage + Cage thoracique / Ribcage - Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae @@ -433,64 +433,64 @@ - Carpe (genou ant.) / Carpus (knee) + Carpe (genou ant.) / Carpus (knee) - Radius / Radius + Radius / Radius - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Dents / Teeth - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae - Dents / Teeth + Dents / Teeth + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Dents / Teeth - Dents / Teeth + Dents / Teeth - Os malaire (joue) / Malar (cheek) - Crête faciale / Facial crest - Dents / Teeth + Os malaire (joue) / Malar (cheek) + Crête faciale / Facial crest + Dents / Teeth - Dents / Teeth - Dents / Teeth + Dents / Teeth + Dents / Teeth @@ -509,7 +509,7 @@ - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae @@ -524,7 +524,7 @@ - Métacarpe (canon ant.) / Metacarpal (cannon) + Métacarpe (canon ant.) / Metacarpal (cannon) @@ -539,62 +539,62 @@ - Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae - Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae - Vertèbres lombaires / Lumbar Vertebrae - Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Patella (rotule) / Patella - Tibia / Tibia - Calcanéus / Calcaneus - Talus / Talus + Vertèbres sacrales / Sacral Vertebrae + Patella (rotule) / Patella + Tibia / Tibia + Calcanéus / Calcaneus + Talus / Talus - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae - Dents / Teeth + Vertèbres cervicales / Cervical Vertebrae + Dents / Teeth - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Humérus / Humerus + Humérus / Humerus - Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae - Vertèbres caudales / Coccygeal Vertebrae - Vertèbres caudales / Coccygeal Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres lombaires / Lumbar Vertebrae - Vertèbres lombaires / Lumbar Vertebrae - Vertèbres lombaires / Lumbar Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Bassin / Pelvis - Métatarse (canon post.) / Metatarsal (cannon) + Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Bassin / Pelvis + Métatarse (canon post.) / Metatarsal (cannon) @@ -616,7 +616,7 @@ - Mandibule / Mandible + Mandibule / Mandible @@ -630,9 +630,9 @@ - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Dents / Teeth + Dents / Teeth @@ -642,7 +642,7 @@ - Péroné / Fibula + Péroné / Fibula @@ -655,9 +655,9 @@ - Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae - Dents / Teeth + Dents / Teeth @@ -665,7 +665,7 @@ - Os nasal / Nasal Bone + Os nasal / Nasal Bone @@ -679,20 +679,20 @@ - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Scapula / Scapula + Scapula / Scapula - Scapula / Scapula + Scapula / Scapula - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical VertebraeVertèbres thoraciques / Thoracic VertebraeVertèbres lombaires / Lumbar VertebraeVertèbres sacrales / Sacral VertebraeVertèbres caudales / Coccygeal VertebraeCharnière C7-T1 (cervico-thoracique) / C7-T1 (Cervicothoracic)Charnière C7-T1 (cervico-thoracique) / C7-T1 (Cervicothoracic)Charnière T18-L1 (dorso-lombaire) / T18-L1 (Thoracolumbar)Charnière T18-L1 (dorso-lombaire) / T18-L1 (Thoracolumbar)Charnière L6-S1 (lombo-sacrée) / L6-S1 (Lumbosacral)Charnière L6-S1 (lombo-sacrée) / L6-S1 (Lumbosacral)Épaule (scapulo-humérale) / Shoulder jointÉpaule (scapulo-humérale) / Shoulder jointCoude (huméro-radial) / Elbow jointCoude (huméro-radial) / Elbow jointBoulet ant. (métacarpo-phalangien) / Fore fetlockBoulet ant. (métacarpo-phalangien) / Fore fetlockHanche (coxo-fémorale) / Hip jointHanche (coxo-fémorale) / Hip jointGrasset (fémoro-tibial) / StifleGrasset (fémoro-tibial) / StifleJarret (tarsien) / HockJarret (tarsien) / HockBoulet post. (métatarso-phalangien) / Hind fetlockBoulet post. (métatarso-phalangien) / Hind fetlockArticulation Sacro-Iliaque / Sacroiliac JointArticulation Sacro-Iliaque / Sacroiliac JointSésamoïdes ant. (boulet) / Forelimb SesamoidsSésamoïdes ant. (boulet) / Forelimb SesamoidsCrane / Head \ No newline at end of file + Vertèbres cervicales / Cervical VertebraeVertèbres thoraciques / Thoracic VertebraeVertèbres lombaires / Lumbar VertebraeVertèbres sacrales / Sacral VertebraeVertèbres caudales / Coccygeal VertebraeCharnière C7-T1 (cervico-thoracique) / C7-T1 (Cervicothoracic)Charnière C7-T1 (cervico-thoracique) / C7-T1 (Cervicothoracic)Charnière T18-L1 (dorso-lombaire) / T18-L1 (Thoracolumbar)Charnière T18-L1 (dorso-lombaire) / T18-L1 (Thoracolumbar)Charnière L6-S1 (lombo-sacrée) / L6-S1 (Lumbosacral)Charnière L6-S1 (lombo-sacrée) / L6-S1 (Lumbosacral)Épaule (scapulo-humérale) / Shoulder jointÉpaule (scapulo-humérale) / Shoulder jointCoude (huméro-radial) / Elbow jointCoude (huméro-radial) / Elbow jointBoulet ant. (métacarpo-phalangien) / Fore fetlockBoulet ant. (métacarpo-phalangien) / Fore fetlockHanche (coxo-fémorale) / Hip jointHanche (coxo-fémorale) / Hip jointGrasset (fémoro-tibial) / StifleGrasset (fémoro-tibial) / StifleJarret (tarsien) / HockJarret (tarsien) / HockBoulet post. (métatarso-phalangien) / Hind fetlockBoulet post. (métatarso-phalangien) / Hind fetlockArticulation Sacro-Iliaque / Sacroiliac JointArticulation Sacro-Iliaque / Sacroiliac JointSésamoïdes ant. (boulet) / Forelimb SesamoidsSésamoïdes ant. (boulet) / Forelimb SesamoidsCrane / Head
\ No newline at end of file diff --git a/public/species/equine/Horse_head.svg b/public/species/equine/Horse_head.svg index d20c2024..a76fd13c 100644 --- a/public/species/equine/Horse_head.svg +++ b/public/species/equine/Horse_head.svg @@ -326,23 +326,23 @@ - Bassin / Pelvis + Bassin / Pelvis - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae - Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae - Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae @@ -351,17 +351,17 @@ - Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae - Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae - Fémur / Femur + Fémur / Femur @@ -386,7 +386,7 @@ - Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae @@ -397,20 +397,20 @@ - Cage thoracique / Ribcage + Cage thoracique / Ribcage - Cage thoracique / Ribcage + Cage thoracique / Ribcage - Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae @@ -433,64 +433,64 @@ - Carpe (genou ant.) / Carpus (knee) + Carpe (genou ant.) / Carpus (knee) - Radius / Radius + Radius / Radius - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Dents / Teeth - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae - Dents / Teeth + Dents / Teeth + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Dents / Teeth - Dents / Teeth + Dents / Teeth - Os malaire (joue) / Malar (cheek) - Crête faciale / Facial crest - Dents / Teeth + Os malaire (joue) / Malar (cheek) + Crête faciale / Facial crest + Dents / Teeth - Dents / Teeth - Dents / Teeth + Dents / Teeth + Dents / Teeth @@ -509,7 +509,7 @@ - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae @@ -524,7 +524,7 @@ - Métacarpe (canon ant.) / Metacarpal (cannon) + Métacarpe (canon ant.) / Metacarpal (cannon) @@ -539,62 +539,62 @@ - Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae - Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae - Vertèbres lombaires / Lumbar Vertebrae - Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Patella (rotule) / Patella - Tibia / Tibia - Calcanéus / Calcaneus - Talus / Talus + Vertèbres sacrales / Sacral Vertebrae + Patella (rotule) / Patella + Tibia / Tibia + Calcanéus / Calcaneus + Talus / Talus - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae - Dents / Teeth + Vertèbres cervicales / Cervical Vertebrae + Dents / Teeth - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Humérus / Humerus + Humérus / Humerus - Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae - Vertèbres caudales / Coccygeal Vertebrae - Vertèbres caudales / Coccygeal Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres sacrales / Sacral Vertebrae - Vertèbres lombaires / Lumbar Vertebrae - Vertèbres lombaires / Lumbar Vertebrae - Vertèbres lombaires / Lumbar Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Vertèbres thoraciques / Thoracic Vertebrae - Bassin / Pelvis - Métatarse (canon post.) / Metatarsal (cannon) + Vertèbres caudales / Coccygeal Vertebrae + Vertèbres caudales / Coccygeal Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres sacrales / Sacral Vertebrae + Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Vertèbres thoraciques / Thoracic Vertebrae + Bassin / Pelvis + Métatarse (canon post.) / Metatarsal (cannon) @@ -616,7 +616,7 @@ - Mandibule / Mandible + Mandibule / Mandible @@ -630,9 +630,9 @@ - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Dents / Teeth + Dents / Teeth @@ -642,7 +642,7 @@ - Péroné / Fibula + Péroné / Fibula @@ -655,9 +655,9 @@ - Vertèbres lombaires / Lumbar Vertebrae + Vertèbres lombaires / Lumbar Vertebrae - Dents / Teeth + Dents / Teeth @@ -665,7 +665,7 @@ - Os nasal / Nasal Bone + Os nasal / Nasal Bone @@ -679,20 +679,20 @@ - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Scapula / Scapula + Scapula / Scapula - Scapula / Scapula + Scapula / Scapula - Vertèbres cervicales / Cervical Vertebrae - Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae + Vertèbres cervicales / Cervical Vertebrae - Charnière C0-C1 (occipito-atloïdienne) / C0-C1 (Occipito-atlantal)Charnière C0-C1 (occipito-atloïdienne) / C0-C1 (Occipito-atlantal)Articulation Temporo-Mandibulaire (ATM) / Temporomandibular Joint (TMJ)Articulation Temporo-Mandibulaire (ATM) / Temporomandibular Joint (TMJ)Synchondrose Sphéno-Basilaire (SSB) / Spheno-Basilar Synchondrosis (SBS)Synchondrose Sphéno-Basilaire (SSB) / Spheno-Basilar Synchondrosis (SBS)Occipital / Occipital boneOccipital / Occipital bonePariétal / Parietal bonePariétal / Parietal boneFrontal / Frontal boneFrontal / Frontal boneTemporal / Temporal boneTemporal / Temporal boneSphénoïde / Sphenoid boneSphénoïde / Sphenoid boneOs hyoïde / Hyoid boneOs hyoïde / Hyoid bone \ No newline at end of file + Charnière C0-C1 (occipito-atloïdienne) / C0-C1 (Occipito-atlantal)Charnière C0-C1 (occipito-atloïdienne) / C0-C1 (Occipito-atlantal)Articulation Temporo-Mandibulaire (ATM) / Temporomandibular Joint (TMJ)Articulation Temporo-Mandibulaire (ATM) / Temporomandibular Joint (TMJ)Synchondrose Sphéno-Basilaire (SSB) / Spheno-Basilar Synchondrosis (SBS)Synchondrose Sphéno-Basilaire (SSB) / Spheno-Basilar Synchondrosis (SBS)Occipital / Occipital boneOccipital / Occipital bonePariétal / Parietal bonePariétal / Parietal boneFrontal / Frontal boneFrontal / Frontal boneTemporal / Temporal boneTemporal / Temporal boneSphénoïde / Sphenoid boneSphénoïde / Sphenoid boneOs hyoïde / Hyoid boneOs hyoïde / Hyoid bone \ No newline at end of file diff --git a/src/anatomy/svgConvention.ts b/src/anatomy/svgConvention.ts index 6b1e5798..c1fe09ac 100644 --- a/src/anatomy/svgConvention.ts +++ b/src/anatomy/svgConvention.ts @@ -20,22 +20,22 @@ function classList(el: Element): string[] { } export function validateBoneElement(el: Element): void { - const boneId = el.getAttribute('data-bone-id') ?? '' - for (const attr of ['data-bone-fr', 'data-bone-en', 'data-category']) { + const boneId = el.getAttribute('data-anno-id') ?? '' + for (const attr of ['data-anno-name-fr', 'data-anno-name-en', 'data-anno-category']) { if (!el.getAttribute(attr)) { throw new SvgConventionError( - `Element data-bone-id="${boneId}" missing attribute ${attr}`, + `Element data-anno-id="${boneId}" missing attribute ${attr}`, boneId, attr, ) } } - const cat = el.getAttribute('data-category') ?? '' + const cat = el.getAttribute('data-anno-category') ?? '' if (!isValidCategory(cat)) { throw new SvgConventionError( - `Element data-bone-id="${boneId}" has unknown data-category="${cat}"`, + `Element data-anno-id="${boneId}" has unknown data-anno-category="${cat}"`, boneId, - 'data-category', + 'data-anno-category', ) } } @@ -47,7 +47,7 @@ export function validateBoneElement(el: Element): void { * - its category is `head` (single entry-point polygon for a detail SVG). * * Decorative elements (e.g. individual vertebrae paths, teeth, malar bone) - * carry `data-bone-id` so their colorization can be controlled by JS, but + * carry `data-anno-id` so their colorization can be controlled by JS, but * must NOT intercept clicks. We mark them with `pointer-events: none` and * exclude them from the returned Bone map so the click handler ignores * them naturally. @@ -60,14 +60,14 @@ function isInteractiveBone(bone: Bone): boolean { export function parseSvgBones(svgRoot: SVGSVGElement): Map { const raw = new Map() - const all = svgRoot.querySelectorAll('[data-bone-id]') + const all = svgRoot.querySelectorAll('[data-anno-id]') all.forEach((el) => { validateBoneElement(el) - const id = el.getAttribute('data-bone-id') as string - const fr = el.getAttribute('data-bone-fr') as string - const en = el.getAttribute('data-bone-en') as string - const category = el.getAttribute('data-category') as BoneCategory - const opensDetail = el.getAttribute('data-opens-detail') ?? undefined + const id = el.getAttribute('data-anno-id') as string + const fr = el.getAttribute('data-anno-name-fr') as string + const en = el.getAttribute('data-anno-name-en') as string + const category = el.getAttribute('data-anno-category') as BoneCategory + const opensDetail = el.getAttribute('data-anno-opens-detail') ?? undefined const classes = classList(el) const isHitbox = classes.includes('hitbox') @@ -110,7 +110,7 @@ export function parseSvgBones(svgRoot: SVGSVGElement): Map { export function getBoneIdFromEvent(event: Event): string | null { let node = event.target as Element | null while (node && node.nodeType === 1) { - const id = node.getAttribute?.('data-bone-id') + const id = node.getAttribute?.('data-anno-id') if (id) return id node = node.parentElement } diff --git a/src/anatomy/types.ts b/src/anatomy/types.ts index 405af7db..547b284c 100644 --- a/src/anatomy/types.ts +++ b/src/anatomy/types.ts @@ -1,4 +1,4 @@ -/** Valid data-category values per the SVG convention. */ +/** Valid data-anno-category values per the SVG convention. */ export type BoneCategory = | 'articulation' | 'charniere' @@ -11,12 +11,12 @@ export type BoneCategory = /** A logical bone as parsed from an SVG — groups hitbox + visible elements. */ export interface Bone { id: string - /** French label from data-bone-fr */ + /** French label from data-anno-name-fr */ fr: string - /** English label from data-bone-en */ + /** English label from data-anno-name-en */ en: string category: BoneCategory - /** Detail popup id from data-opens-detail, if present */ + /** Detail popup id from data-anno-opens-detail, if present */ opensDetail?: string /** Elements with class containing "hitbox" */ hitboxEls: Element[] diff --git a/src/components/canvas/AnatomyCanvas.tsx b/src/components/canvas/AnatomyCanvas.tsx index bdbc9d26..4b89134a 100644 --- a/src/components/canvas/AnatomyCanvas.tsx +++ b/src/components/canvas/AnatomyCanvas.tsx @@ -44,9 +44,9 @@ export default function AnatomyCanvas({ useEffect(() => { const c = containerRef.current if (!c) return - const all = c.querySelectorAll('[data-bone-id]') + const all = c.querySelectorAll('[data-anno-id]') all.forEach((el) => { - const id = el.getAttribute('data-bone-id') as string + const id = el.getAttribute('data-anno-id') as string const state = boneStates.get(id) if (state && state !== 'default') el.setAttribute('data-state', state) else el.removeAttribute('data-state') diff --git a/src/domain/schema/observation.ts b/src/domain/schema/observation.ts index fb5962e9..b5386514 100644 --- a/src/domain/schema/observation.ts +++ b/src/domain/schema/observation.ts @@ -16,7 +16,7 @@ export const VertebraSchema = z.object({ export type Vertebra = z.infer export const ObservationZoneSchema = z.object({ - /** Must match data-bone-id attribute on the SVG element */ + /** Must match data-anno-id attribute on the SVG element */ boneId: z.string().min(1), /** Set when zone originates from a detail popup SVG */ detailSourceId: z.string().optional(), diff --git a/src/domain/species/types.ts b/src/domain/species/types.ts index 34b4a6df..b8f94ab9 100644 --- a/src/domain/species/types.ts +++ b/src/domain/species/types.ts @@ -21,7 +21,7 @@ export interface SpeciesManifest { mainSvg: string /** * Map of detail popup id → absolute public path to detail SVG. - * Keys match data-opens-detail attribute values in the main SVG. + * Keys match data-anno-opens-detail attribute values in the main SVG. */ details: Record vertebralFormula: VertebralFormula diff --git a/src/styles/index.css b/src/styles/index.css index 5ae69f66..9a46a3fc 100644 --- a/src/styles/index.css +++ b/src/styles/index.css @@ -12,5 +12,5 @@ body { .svg-canvas [data-state='current'] { fill: var(--color-accent) !important; fill-opacity: 0.85 !important; } .svg-canvas [data-state='linked'] { stroke-dasharray: 4 3; stroke: var(--color-accent); fill-opacity: 0.35 !important; } .svg-canvas [data-state='multi'] { fill: var(--color-accent) !important; fill-opacity: 0.65 !important; stroke: var(--color-ink); stroke-width: 1.5; } -.svg-canvas [data-bone-id] { cursor: pointer; } -.svg-canvas [data-bone-id]:hover { filter: brightness(1.05); } +.svg-canvas [data-anno-id] { cursor: pointer; } +.svg-canvas [data-anno-id]:hover { filter: brightness(1.05); } diff --git a/tests/unit/anatomy.svgConvention.test.ts b/tests/unit/anatomy.svgConvention.test.ts index baaf8542..2f283809 100644 --- a/tests/unit/anatomy.svgConvention.test.ts +++ b/tests/unit/anatomy.svgConvention.test.ts @@ -13,19 +13,19 @@ function svgFromString(s: string): SVGSVGElement { const FIXTURE = ` - - - + + - + ` describe('parseSvgBones', () => { - it('groups hitbox + visible by data-bone-id', () => { + it('groups hitbox + visible by data-anno-id', () => { const map = parseSvgBones(svgFromString(FIXTURE)) const epaule = map.get('epaule') expect(epaule).toBeDefined() @@ -48,16 +48,16 @@ describe('parseSvgBones', () => { }) describe('parseSvgBones validation', () => { - it('throws on missing data-bone-fr', () => { + it('throws on missing data-anno-name-fr', () => { const bad = ` - + ` expect(() => parseSvgBones(svgFromString(bad))).toThrow(SvgConventionError) }) it('throws on unknown category', () => { const bad = ` - + ` expect(() => parseSvgBones(svgFromString(bad))).toThrow(SvgConventionError) }) diff --git a/tests/unit/anatomy.svgLoader.test.ts b/tests/unit/anatomy.svgLoader.test.ts index 11af451e..a1510c1f 100644 --- a/tests/unit/anatomy.svgLoader.test.ts +++ b/tests/unit/anatomy.svgLoader.test.ts @@ -1,7 +1,7 @@ import { describe, it, expect, vi, beforeEach } from 'vitest' import { loadSvg } from '@/anatomy/svgLoader' -const SVG = '' +const SVG = '' describe('loadSvg', () => { beforeEach(() => { diff --git a/tests/unit/components.AnatomyCanvas.test.tsx b/tests/unit/components.AnatomyCanvas.test.tsx index 71af1f3d..714aaf25 100644 --- a/tests/unit/components.AnatomyCanvas.test.tsx +++ b/tests/unit/components.AnatomyCanvas.test.tsx @@ -6,10 +6,10 @@ vi.mock('@/anatomy/svgLoader', () => ({ loadSvg: vi.fn(async () => { const doc = new DOMParser().parseFromString( ` - - + + `, 'image/svg+xml', ) @@ -23,7 +23,7 @@ describe('AnatomyCanvas', () => { it('renders the loaded SVG inline', async () => { render( {}} />) await waitFor(() => - expect(document.querySelector('[data-bone-id="epaule"]')).not.toBeNull(), + expect(document.querySelector('[data-anno-id="epaule"]')).not.toBeNull(), ) }) @@ -31,7 +31,7 @@ describe('AnatomyCanvas', () => { const onZoneClick = vi.fn() render() await waitFor(() => screen.getByTestId('anatomy-canvas')) - ;(document.querySelector('[data-bone-id="epaule"]') as Element).dispatchEvent( + ;(document.querySelector('[data-anno-id="epaule"]') as Element).dispatchEvent( new Event('click', { bubbles: true }), ) await waitFor(() => expect(onZoneClick).toHaveBeenCalledWith('epaule'))