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:
Bastien ChanotandClaude Opus 4.7 committed 2026-05-19 03:10:06 +02:00
1 parent e8c29c1fdf
commit 1109e33383
18 files changed
+308 -308

No files matched your search

+12 -12
View File
@@ -13,19 +13,19 @@ function svgFromString(s: string): SVGSVGElement {
const FIXTURE = `
<svg xmlns="http://www.w3.org/2000/svg">
<circle data-bone-id="epaule" data-bone-fr="Épaule" data-bone-en="Shoulder"
data-category="articulation" class="bone osteo articulation hitbox bone-epaule" />
<circle data-bone-id="epaule" data-bone-fr="Épaule" data-bone-en="Shoulder"
data-category="articulation" class="bone osteo articulation visible bone-epaule" />
<polygon data-bone-id="cervical-vertebrae-spine-zone" data-bone-fr="Vertèbres cervicales"
data-bone-en="Cervical Vertebrae" data-category="spine-zone"
<circle data-anno-id="epaule" data-anno-name-fr="Épaule" data-anno-name-en="Shoulder"
data-anno-category="articulation" class="bone osteo articulation hitbox bone-epaule" />
<circle data-anno-id="epaule" data-anno-name-fr="Épaule" data-anno-name-en="Shoulder"
data-anno-category="articulation" class="bone osteo articulation visible bone-epaule" />
<polygon data-anno-id="cervical-vertebrae-spine-zone" data-anno-name-fr="Vertèbres cervicales"
data-anno-name-en="Cervical Vertebrae" data-anno-category="spine-zone"
class="bone osteo spine-zone bone-cervical-vertebrae" />
<polygon data-bone-id="zone-head" data-bone-fr="Crane" data-bone-en="Head"
data-category="head" data-opens-detail="head" />
<polygon data-anno-id="zone-head" data-anno-name-fr="Crane" data-anno-name-en="Head"
data-anno-category="head" data-anno-opens-detail="head" />
</svg>`
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 = `<svg xmlns="http://www.w3.org/2000/svg">
<circle data-bone-id="x" data-bone-en="X" data-category="os" />
<circle data-anno-id="x" data-anno-name-en="X" data-anno-category="os" />
</svg>`
expect(() => parseSvgBones(svgFromString(bad))).toThrow(SvgConventionError)
})
it('throws on unknown category', () => {
const bad = `<svg xmlns="http://www.w3.org/2000/svg">
<circle data-bone-id="x" data-bone-fr="X" data-bone-en="X" data-category="bogus" />
<circle data-anno-id="x" data-anno-name-fr="X" data-anno-name-en="X" data-anno-category="bogus" />
</svg>`
expect(() => parseSvgBones(svgFromString(bad))).toThrow(SvgConventionError)
})
+1 -1
View File
@@ -1,7 +1,7 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { loadSvg } from '@/anatomy/svgLoader'
const SVG = '<svg xmlns="http://www.w3.org/2000/svg"><g data-bone-id="x"/></svg>'
const SVG = '<svg xmlns="http://www.w3.org/2000/svg"><g data-anno-id="x"/></svg>'
describe('loadSvg', () => {
beforeEach(() => {
+6 -6
View File
@@ -6,10 +6,10 @@ vi.mock('@/anatomy/svgLoader', () => ({
loadSvg: vi.fn(async () => {
const doc = new DOMParser().parseFromString(
`<svg xmlns="http://www.w3.org/2000/svg">
<circle data-bone-id="epaule" data-bone-fr="Épaule" data-bone-en="Shoulder"
data-category="articulation" class="bone osteo articulation hitbox bone-epaule" />
<circle data-bone-id="epaule" data-bone-fr="Épaule" data-bone-en="Shoulder"
data-category="articulation" class="bone osteo articulation visible bone-epaule" />
<circle data-anno-id="epaule" data-anno-name-fr="Épaule" data-anno-name-en="Shoulder"
data-anno-category="articulation" class="bone osteo articulation hitbox bone-epaule" />
<circle data-anno-id="epaule" data-anno-name-fr="Épaule" data-anno-name-en="Shoulder"
data-anno-category="articulation" class="bone osteo articulation visible bone-epaule" />
</svg>`,
'image/svg+xml',
)
@@ -23,7 +23,7 @@ describe('AnatomyCanvas', () => {
it('renders the loaded SVG inline', async () => {
render(<AnatomyCanvas src="/x.svg" boneStates={new Map()} onZoneClick={() => {}} />)
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(<AnatomyCanvas src="/x.svg" boneStates={new Map()} onZoneClick={onZoneClick} />)
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'))