<review-surface>
Pin-based annotation overlay for collaborative design review — wraps any content and adds interactive comment pins with pluggable persistence.
Overview
A web component that wraps any HTML content and adds a transparent overlay for placing review comment pins. Click anywhere in annotate mode to drop a numbered pin, then add a comment and replies. Supports pluggable persistence via memory, localStorage, or REST adapters. Designed for design reviews, sprint demos, and stakeholder presentations.
<review-surface editable adapter="local" storage-key="my-review" author="Sarah Chen"> <img src="/comps/landing-v3.png" alt="Landing page design comp" /></review-surface>
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
src |
string (URL) | — | Path to a JSON file containing pin data |
editable |
boolean | — | Enables the annotate toolbar, pin creation, and reply input |
adapter |
string | "memory" |
Persistence backend: memory, local, or rest |
endpoint |
string (URL) | — | REST endpoint URL (required when adapter="rest") |
storage-key |
string | "review-surface" |
localStorage key (when adapter="local") |
author |
string | "Anonymous" |
Default author name for new pins and replies |
compact |
boolean | — | Reduces pin size, popover width, and toolbar spacing |
show-resolved |
boolean | — | Display resolved pins (hidden by default) |
pin-count |
number | 0 |
Reflected count of visible pins (read-only) |
Annotate Mode
Add the editable attribute to show the review toolbar. Click the Annotate button to enter annotate mode — the cursor changes to a crosshair and clicking the content area places a new pin. The pin's popover opens immediately so you can type your comment.
<review-surface editable adapter="local" storage-key="sprint-4-empathy" author="Design Lead"> <empathy-map persona="Sarah Chen"> <h2 slot="title">Developer Onboarding</h2> <p slot="summary">Q1 research insights</p> <ul slot="says"><li>"I just want it to work"</li></ul> <ul slot="thinks"><li>There must be a simpler way</li></ul> <ul slot="does"><li>Searches Stack Overflow first</li></ul> <ul slot="feels"><li>frustrated</li></ul> </empathy-map></review-surface>
Press Escape to close an open popover (focus returns to its pin) or, with no popover open, to exit annotate mode. Pins are always clickable in both view and annotate modes.
Data Mode
Load pin data from a JSON file via the src attribute, or set the .pins property programmatically.
{ "pins": [ { "id": "pin-1", "x": 42.5, "y": 67.3, "text": "Fix alignment on the header", "author": "Sarah Chen", "createdAt": "2026-04-06T14:30:00Z", "resolved": false, "replies": [ { "id": "reply-1", "text": "Agreed, padding needs 8px", "author": "Tom Rivera", "createdAt": "2026-04-06T14:45:00Z" } ] } ]}
const surface = document.querySelector('review-surface'); // Add a pinconst pin = await surface.addPin({ x: 42, y: 67, text: 'Fix alignment here', author: 'Sarah'}); // Resolve itawait surface.resolvePin(pin.id); // Export all pins as JSONconst data = surface.exportPins();console.log(JSON.stringify(data, null, 2));
Adapters
Adapters control how pins are persisted. Three built-in adapters are available, or provide a custom one via the .adapter property.
| Adapter | Persistence | Use Case |
|---|---|---|
memory |
Ephemeral (lost on page refresh) | Demos, throwaway reviews |
local |
Browser localStorage | Solo dev review, prototyping |
rest |
Server via REST API | Team collaboration, persistent reviews |
<review-surface editable adapter="rest" endpoint="/api/reviews/landing-page"> <img src="/comps/landing.png" alt="Landing page" /></review-surface>
The REST adapter expects standard REST endpoints: GET / to list, POST / to create, PATCH /:id to update, and DELETE /:id to remove.
const surface = document.querySelector('review-surface'); surface.adapter = { async load() { /* return Pin[] */ }, async save(pin) { /* persist and return pin with id */ }, // `pin` is the component's full copy, so a pin this adapter has never // seen (loaded via src or .pins) can be created rather than rejected. async update(id, changes, pin) { /* merge (or upsert), return updated pin */ }, async remove(id) { /* delete pin */ },};
Events
| Event | Detail | Description |
|---|---|---|
review-surface:upgraded | — | Fired once, on first connect, after the adapter is resolved and before the initial pin load. Not re-fired when the element is moved. |
review-surface:ready | { pinCount } | Fired once, after the initial pins (from src, the adapter, or a pre-connect .pins assignment) have loaded and rendered. Not re-fired on later renders. |
review-surface:add | { pin } | Fired when a pin is created (annotate-mode click or addPin()) |
review-surface:update | { pin, changes } | Fired when a pin is modified (reply added, text set, re-opened) |
review-surface:remove | { pin } | Fired when a pin is deleted |
review-surface:resolve | { pin } | Fired when a pin is marked resolved |
review-surface:select | { pin } | Fired when a pin popover is opened |
review-surface:mode | { mode: 'view' | 'annotate' } | Fired when view/annotate mode toggles |
review-surface:pins-changed | { pins, source: 'property' } | Fired after a .pins assignment (not for adapter loads or addPin()) |
JavaScript API
<review-surface> follows the
HTML-first + JS-first dual-mode contract.
Assign .pins any time after the element is defined —
before or after it is connected. Pins assigned before the first
connect win over the adapter's initial load, and pins (and any
.adapter you set) survive the element being moved in the
DOM. Pin x/y are percentages
(0–100) of the wrapped content's width and height; other values
are clamped. review-surface:ready fires once, after the
initial pins have rendered. For server-backed pin storage, use the
.adapter hook instead (see "Adapters" above).
| Property | Type | Description |
|---|---|---|
.pins |
Pin[] |
Replace the pin set with an array of
{ id, x, y, text, resolved?, replies? } records.
Idempotent; round-trips through the getter.
|
.adapter |
Adapter |
Persistence hook for CRUD operations. See "Adapters". |
const surface = document.querySelector('review-surface');await customElements.whenDefined('review-surface');surface.pins = [ { id: 'p1', x: 34, y: 62, text: 'Logo too small here', resolved: false },];
CSS Custom Properties
| Variable | Default | Description |
|---|---|---|
--review-surface-bg |
#ffffff |
Popover and input background |
--review-surface-card |
#f8f9fa |
Toolbar and input area background |
--review-surface-text |
#1a1a1a |
Primary text color |
--review-surface-muted |
#666666 |
Secondary text (timestamps, pin count) |
--review-surface-border |
#e0e0e0 |
Popover, toolbar, and input borders |
--review-surface-accent |
#0066cc |
Focus rings, submit button, annotate mode toggle |
--review-surface-pin-bg |
#0066cc |
Pin marker background color |
--review-surface-pin-text |
#ffffff |
Pin marker text/number color |
--review-surface-pin-size |
28px |
Pin marker diameter |
--review-surface-resolved |
#16a34a |
Resolved pin and badge color |
Accessibility
- Pin markers are
<button>elements witharia-label,aria-expanded, andaria-haspopup="dialog", grouped in an overlay withrole="group"and the label “Review pins” - Comment popovers use
role="dialog"witharia-labelledby; opening a pin moves focus into its popover, and closing it (button or Escape) returns focus to the pin - Toolbar uses
role="toolbar"witharia-label - Annotate toggle uses
aria-pressedto communicate state - A single persistent
aria-live="polite"region announces pin creation, deletion, resolution, and replies - Keyboard: Tab navigates pins, Enter/Space opens popover, Escape closes popover or exits annotate mode
- All transitions respect
prefers-reduced-motion: reduce - Print styles hide pins, overlay, and toolbar — only the wrapped content prints
Related
<empathy-map>— Frequently wrapped for design review sessions<user-journey>— Journey maps wrapped for annotation<user-persona>— Persona cards that pair with review surfaces<impact-effort>— Prioritize feedback from review sessions<kanban-board>— Track review feedback as cards- vb-project-planning — the whole package:
import '@profpowell/vb-project-planning'registers every component