From cf8dc3559fe41321d0e0cf3cc2c7898fd8dcf45a Mon Sep 17 00:00:00 2001 From: Marcel Date: Sun, 12 Apr 2026 15:30:27 +0200 Subject: [PATCH] feat(frontend): extract AnnotationShape component with polygon support - AnnotationShape.svelte: renders a single annotation as either a rectangle or a polygon-clipped div (via CSS clip-path: polygon()) - AnnotationLayer.svelte: refactored to delegate rendering to AnnotationShape, keeping draw logic and hover state management - Annotation type: added optional polygon field ([number, number][] | null) - Polygon coordinates are converted from page-normalized to bounding-box-relative percentages for clip-path All 687 existing frontend tests pass. Refs #227 Co-Authored-By: Claude Sonnet 4.6 --- .../src/lib/components/AnnotationLayer.svelte | 90 ++---------- .../src/lib/components/AnnotationShape.svelte | 136 ++++++++++++++++++ frontend/src/lib/types.ts | 1 + 3 files changed, 147 insertions(+), 80 deletions(-) create mode 100644 frontend/src/lib/components/AnnotationShape.svelte diff --git a/frontend/src/lib/components/AnnotationLayer.svelte b/frontend/src/lib/components/AnnotationLayer.svelte index ec1c29c0..65e87b42 100644 --- a/frontend/src/lib/components/AnnotationLayer.svelte +++ b/frontend/src/lib/components/AnnotationLayer.svelte @@ -1,5 +1,6 @@ + +
{ + if (e.key === 'Enter' || e.key === ' ') onclick(); + }} + onpointerenter={onpointerenter} + onpointerleave={onpointerleave} + style={shapeStyle} +> + {#if !dimmed && blockNumber} +
+ {blockNumber} +
+ {/if} +
+ + diff --git a/frontend/src/lib/types.ts b/frontend/src/lib/types.ts index 7ddfd95c..adb2aec3 100644 --- a/frontend/src/lib/types.ts +++ b/frontend/src/lib/types.ts @@ -49,4 +49,5 @@ export type Annotation = { color: string; createdAt: string; fileHash?: string | null; + polygon?: [number, number][] | null; };