Skip to content
SprecherEast
Issue 636

feat: A shared Legend component that hangs from the image like a drawer

Back to our plan
Done
enhancementfrontendstylinguxpriority: medium

Problem

In plain words: under the interchange diagram, the numbered list that explains the markers (north and south entrance, eastbound, westbound, roundabouts) still looks like a separate box, not part of the picture. Any chart or annotated image will need the same thing, so it should be one shared component. That thing is called a legend (some people say "key").

Summary of the owner's request (2026-11-03, Claude voice session): the numbered list under the image reads as disconnected from it. It should look like a drawer sliding out from under the image: square top corners hidden behind the image, rounded corners at the bottom only, narrower than the image so it clears the image's rounded corners, a very small drop shadow, and no animation. It should also become the standard shared component for explaining things like graphs. This builds on #515 (the Diagram key block), #543 and #544.

Proposed fix

Make the legend a shared kit component, Legend in src/platform/ui/, and have the editorial DiagramKey (src/platform/richtext/editorial/DiagramKey.tsx) become a thin wrapper that passes its items to it, so there is still one implementation.

The look, as the owner described it (the "drawer"):

  • It sits flush under the image and looks like it slid out from beneath it: square top corners tucked under the image's bottom edge, rounded bottom corners only.
  • Narrower than the image, inset on both sides, so it never meets the image's rounded corners.
  • A tiny shadow (a theme token) so it reads as lying under the image. Shadows barely show in dark mode, so it keeps a hairline border too (docs/guidelines/ui-ux-design.md, Card Design).
  • No animation. Static.
  • Same numbered orange circles as today, two columns from sm, one on a phone. Order under the figure: image, legend, then the caption (#544 and the caption issue).

The first version has numbered markers. Its props are plain data (a marker, a label, a line of text), so a colour-swatch marker for charts can be added later without changing callers.

Implementation notes:

  • The image and the legend are separate blocks in the article. Today the legend uses -mt-4 to reach up to the image; that number must be tied to the image block's bottom margin (one definition, guard rail 1), not two numbers that happen to agree.
  • Both the legend and the image must stay inside the article column at 320 px.

Native first (checked): plain CSS (negative margin, z-index, rounded-b-*, token shadow) and semantic HTML; no plugin for this. The existing Card has no "attached" variant, so the legend either adds one to Card (preferred if it stays small) or composes its own surface from tokens.

Acceptance criteria

  • Not done: A Legend kit component exists with the drawer look above, a test, an axe check, a gallery entry and a row in docs/ui/component-set.md.
  • Not done: DiagramKey uses it; the old styling is gone from DiagramKey.
  • Not done: On the I-94 post, at 320, 430, 768, 1024, 1280 and 1920 px, in light and dark: the legend visibly hangs from the image, its top corners are hidden, it is narrower than the image, with no gap and no sideways scroll.
  • Not done: Marker numbers are announced as today ("Marker 2: …"); axe passes.
  • Not done: The overlap amount is defined once and shared with the image block.
  • Not done: The PR carries the shared-component label (it changes shared UI).

Area

frontend, styling, ux

Priority

priority: medium


Generated by Claude Code, opens in a new tab

See it on GitHub, opens in a new tab