refactor(anatomy): rename SVG data attrs (bone → anno) per new convention
User updated the clickable-zone convention in the source SVGs:
data-bone-id → data-anno-id
data-bone-fr → data-anno-name-fr
data-bone-en → data-anno-name-en
data-category → data-anno-category
data-opens-detail → data-anno-opens-detail
Bulk-renamed across:
- public/species/equine/Horse.svg + Horse_head.svg (86 anno-attrs each)
- src/anatomy/svgConvention.ts (parser + getBoneIdFromEvent)
- src/anatomy/types.ts (doc strings)
- src/components/canvas/AnatomyCanvas.tsx (querySelector + delegated click)
- src/styles/index.css (`[data-bone-id]` selectors → `[data-anno-id]`)
- src/domain/species/types.ts + schema/observation.ts (doc strings)
- docs/{ANATOMY-SVG-CONVENTION,ADDING-A-SPECIES,superpowers/specs,plans}.md
- CLAUDE.md + .claude/{memory/learnings,tasks/TODO}.md
- tests/unit/{anatomy.svgConvention,anatomy.svgLoader,components.AnatomyCanvas}.test.tsx
Internal TS type names and field names (Bone, boneId, parseSvgBones,
getBoneIdFromEvent) are kept intentionally — they're the application's
logical shape and the persisted JSON contract. ObservationZone.boneId is
the identifier seen in already-exported PDFs; renaming it would break
re-import of those PDFs. Only the SVG-side attribute names change.
90/90 tests pass, lint clean, build clean.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e8c29c1fdf
commit
1109e33383
18 files changed
+308
-308
No files matched your search
@@ -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
|
||||
<!-- hitbox: transparent fill, receives pointer events -->
|
||||
<polygon
|
||||
data-bone-id="cervical-spine"
|
||||
data-bone-fr="Colonne cervicale"
|
||||
data-bone-en="Cervical spine"
|
||||
data-category="spine-zone"
|
||||
data-anno-id="cervical-spine"
|
||||
data-anno-name-fr="Colonne cervicale"
|
||||
data-anno-name-en="Cervical spine"
|
||||
data-anno-category="spine-zone"
|
||||
class="bone-hitbox"
|
||||
fill="transparent"
|
||||
style="pointer-events: all; cursor: pointer"
|
||||
@@ -59,7 +59,7 @@ Two sibling SVG elements share the **same** `data-bone-id`:
|
||||
|
||||
<!-- visible twin: colored fill, no pointer events -->
|
||||
<polygon
|
||||
data-bone-id="cervical-spine"
|
||||
data-anno-id="cervical-spine"
|
||||
class="bone-visible"
|
||||
fill="#c8d8e8"
|
||||
style="pointer-events: none"
|
||||
@@ -68,7 +68,7 @@ Two sibling SVG elements share the **same** `data-bone-id`:
|
||||
|
||||
- Hitbox must have `class` containing `hitbox` (case-insensitive substring).
|
||||
- Visible twin must have `class` containing `visible`.
|
||||
- Order in DOM does not matter — parser groups by `data-bone-id`.
|
||||
- Order in DOM does not matter — parser groups by `data-anno-id`.
|
||||
|
||||
### Pattern 2 — Single element
|
||||
|
||||
@@ -78,10 +78,10 @@ One polygon carries everything:
|
||||
|
||||
```xml
|
||||
<polygon
|
||||
data-bone-id="thoracic-t1-t18"
|
||||
data-bone-fr="Thoracique T1-T18"
|
||||
data-bone-en="Thoracic T1-T18"
|
||||
data-category="spine-zone"
|
||||
data-anno-id="thoracic-t1-t18"
|
||||
data-anno-name-fr="Thoracique T1-T18"
|
||||
data-anno-name-en="Thoracic T1-T18"
|
||||
data-anno-category="spine-zone"
|
||||
fill="#d4e8d4"
|
||||
style="pointer-events: all; cursor: pointer"
|
||||
/>
|
||||
@@ -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<string, Bone>`.
|
||||
@@ -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 `<svg>` 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.
|
||||
|
||||
Reference in new issue
Block a user