No.300 · Overlays
Context Lens
A context menu that is the object opened up, not a box beside it. The row becomes the lens's header and joins the panel through a narrow neck of the same material, and the panel grows out of that neck toward the side with room.
The prompt
Written for the variant you picked above: Paper
Build a reusable contextual menu primitive whose surface is continuous with the object that opened it. A render-prop API hands the consumer rowProps (spread on the row: right-click, Shift+F10 and the Menu key open it) and buttonProps (spread on an explicit ⋯ button: aria-haspopup=menu, aria-expanded, aria-controls). While open, the row takes on the lens surface colour and a hairline ring, so it becomes the lens's header — the panel does not repeat the object's name. The row and panel are joined by a neck: a 48×14 SVG hourglass (M0 0H48C35 0 35 14 48 14H0C13 14 13 0 0 0Z) filled with the surface colour, with its two concave sides stroked in the ring colour. It overlaps both shapes by a pixel so they read as one piece of material. The neck sits at the anchor point — the pointer x for right-click, the button centre for ⋯ — clamped inside the panel. Placement: below the row if it fits, otherwise above (the stack flips to column-reverse). The panel is clamped 12px from the viewport edges and goes full-width under 480px. It repositions on scroll and resize. Reveal: the neck scales in from the row (150ms), then the panel grows out of it with clip-path inset (240ms), then its contents fade in. Contents: a two-column dl of metadata (owner, modified, size, sharing) and a role=menu list of actions with icon, label and shortcut; danger and disabled (aria-disabled) states. Keyboard: focus moves to the first enabled item; ArrowUp/Down wrap; Home/End; type-ahead by first letter; Escape closes and returns focus; Tab closes and continues. Outside pointerdown closes. Paper and Night themes. Selected variant — Paper (paper): Apply the paper theme. Where the brief above gives no colour values for it, choose a restrained paper palette with text at 4.5:1 contrast or better. Keep the geometry, states and motion described above unchanged. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Right-click a file, press Shift+F10 on a focused row, or use its ⋯ button. Motion: Neck 150ms, then a clip-path grow of 240ms toward the free side, then content fades in. Closes with a 140ms fade. Accessibility: The trigger has aria-haspopup=menu, aria-expanded and aria-controls. The panel is role=menu, labelled with the object's name and described by its metadata. Roving focus, type-ahead, Escape returns focus, Tab closes. Disabled items use aria-disabled and stay discoverable. Reduced motion shows the lens at once with the neck already in place. Responsive behavior: Clamped 12px from the viewport; full-width under 480px; flips above when there is no room below. Rows show ⋯ permanently on narrow screens. Touch: The ⋯ button is always visible below the sm breakpoint. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.
Notes
- Interaction
- Right-click a file, press Shift+F10 on a focused row, or use its ⋯ button.
- Motion
- Neck 150ms, then a clip-path grow of 240ms toward the free side, then content fades in. Closes with a 140ms fade.
- Accessibility
- The trigger has aria-haspopup=menu, aria-expanded and aria-controls. The panel is role=menu, labelled with the object's name and described by its metadata. Roving focus, type-ahead, Escape returns focus, Tab closes. Disabled items use aria-disabled and stay discoverable. Reduced motion shows the lens at once with the neck already in place.
- Responsive
- Clamped 12px from the viewport; full-width under 480px; flips above when there is no room below. Rows show ⋯ permanently on narrow screens.
- On touch
- The ⋯ button is always visible below the sm breakpoint.