VB Project Planning

<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.

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.

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.

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

The REST adapter expects standard REST endpoints: GET / to list, POST / to create, PATCH /:id to update, and DELETE /:id to remove.

Events

EventDetailDescription
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).

PropertyTypeDescription
.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".

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 with aria-label, aria-expanded, and aria-haspopup="dialog", grouped in an overlay with role="group" and the label “Review pins”
  • Comment popovers use role="dialog" with aria-labelledby; opening a pin moves focus into its popover, and closing it (button or Escape) returns focus to the pin
  • Toolbar uses role="toolbar" with aria-label
  • Annotate toggle uses aria-pressed to 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

↑