feat: Shared floated figure with a figure badge, short caption and the key only in the lightbox
Back to our planNumbering: epic #813; banner #814; lightbox #815; figure #816; Payload block #817; blue tone #818; content edit #819; guidelines #820. Where the text below says 01 to 07, read these numbers (01=#815, 02=#816, 03=#817, 04=#819, 05=#814, 06=#818, 07=#820).
Problem
In plain words: an annotated image in an article is always as wide as the text column, with its numbered key hanging under it as a separate block (MediaBlock followed by DiagramKey, joined by LEGEND_GAP, #636/#658). A tall map then fills more than a screen. We have no shared way to show a picture small beside the text, label it "Figure 2-9", and keep the key and the long caption for when the reader asks for them.
Proposed fix
A new shared presentational component, Figure (working name), in src/platform/ui/. It takes plain props (decision 0013), so MediaBlock and the block in 03 only pass editor data in:
image(anImageRefforMedia),altlabel(optional): the figure label, drawn asBadge variant="neutral"(src/platform/ui/Badge.tsx:border border-border bg-muted text-muted-foreground, a pill). It shows above or at the start of the caption and again in the lightbox.caption: short, drawn withCaption as="figcaption" size="sm"(src/platform/ui/Caption.tsx)details(optional): the long caption, credit and conditions, shown only in the lightbox (CaptionwithfinePrintthere)legendItems(optional): the numbered key, drawn withLegend marker="number" attach="none" columns="one"(src/platform/ui/Legend.tsx), only in the lightboxalign:right(default) |left|none(full column, as today)size: the share of the text column the floated figure takes frommdup. One named value per allowed width, each a variable inglobals.cssread throughlayoutSizes.ts. See the [PUSHBACK] and [QUESTION] below for the default.
Layout:
- From
mdup,align="right"floats the figure right (float-right, withFIGURE_GAPspacing and a left margin token), so the following paragraphs wrap on its left. Headings and wide blocks clear the float (clear-both), so a heading never squeezes beside it. - Below
mdit stacks: full width, with the text above and below. This matchesui-ux-design.md's "stack before it wraps badly" rule. - The small view never shows the key. The figure opens in the lightbox from 01 with
large= the same image, larger, andaside= badge,Legend, long caption. - Image frame as in
MediaBlocktoday (border border-border rounded-[0.8rem]). Move that class string to one shared constant if a second place needs it (guard rail 1). - The figure keeps its link-preview and card behavior untouched: it is body content and doesn't change
heroImageormeta.image. 03 covers the card rule.
#654 decision (comment draft to post on #654):
[DECISION] An image and its legend become one presentational component
Settled under epic 00 by sub-issue 02. A small shared
Figureinsrc/platform/ui/holds the image, the caption, the figure badge and, for annotated images, the legend. The legend shows only in the lightbox, where the numbers can be read (owner's request, 2026-11-07, Claude in Chrome side panel, summarized on epic 00).MediaBlockand the new figure block only map editor data into its props. Nothing joins two blocks with a negative margin any more, for new content. The existingmediaBlock+diagramKeypair keeps rendering as it does, so no stored post breaks. Moving it is a content edit (04), and retiringLEGEND_GAPwaits until no live content uses the pair.Legendstays its own component, because charts use it without an image. The gallery spacing item from this issue is fixed in the same PR (the Legend sample getsblockflow). One PR closes one issue, so 02's PR saysClosesfor 02 only and links #654. #654 is closed by hand with a link to that PR once it merges.
[PUSHBACK] How wide the floated figure is
The owner asked for about half the text column. docs/guidelines/ui-ux-design.md says a two-element layout is text 60–65% and picture 35–40%, and #796 set the About map block to that range (text 5/8, picture 3/8). Half is outside the guideline. The key now lives only in the lightbox, so the small picture doesn't need to be large enough to read numbers. Its only job is to show what the figure is and invite a click. We recommend 2/5 of the text column (40%), which is inside the guideline. size is a prop, so half is one value away (size="half"), and no rebuild is needed if he prefers it. Changing the guideline itself is a policy change (docs/guidelines/ is a process path, AGENTS.md step 3). Because the owner asked for this layout, it follows the normal path with a summary of his answer recorded (07).
[QUESTION] Default width of a floated figure
Question: Should a floated figure take 2/5 (40%) of the text column by default, or half?
- 2/5 (recommended): inside the current design guideline and the same balance as the map block (#796). The key is in the lightbox, so the small picture only needs to be recognizable.
- Half: what was first asked for. It means changing the 35–40% rule in
ui-ux-design.mdfor figures (a policy change, recorded in 07).
Recommendation: 2/5, with half available per figure. Next: we build with 2/5 as the default and half as a value. His answer only sets the default and the guideline text in 07.
(Not labeled needs owner: the build doesn't wait for this answer, only the default value and 07's wording do.)
Native-first check:
- (1) Native: CSS
floatwithshape-outsideis the standard way to wrap text around an element, and Tailwind hasfloat-rightandclear-both, so we use those. HTMLfigure/figcaptionare the semantic elements, already used byMediaBlock. - (2) Official plugins: Payload's Lexical upload node has no alignment or lightbox on the front end.
- (3) Open source: no maintained library does figure + badge + legend + lightbox with our kit.
- Conclusion: compose our existing
Media,Caption,Badge,Legendand the zoom from 01. New code is layout only.
Acceptance criteria
- Not done: Tests come first: failing component tests for
Figure(the badge renders asBadge neutralwith the label text; the key and the long caption are not in the page's small view and are in the open lightbox;align="none"renders full width;sizemaps to the right class), then the code. - Not done: An axe check passes, closed and open (
expectAccessible). The image has its alt text, the figure has afigcaption, and the lightbox has an accessible name. - Not done: From
mdup, a right-aligned figure floats right at the default width, and the next paragraphs wrap on its left. Belowmdit stacks full width. Headings clear it. - Not done: Alignment e2e:
e2e/alignment.spec.ts(#678) gets a seeded post with a floated figure. At each of the six widths it checks that the figure's top lines up with the paragraph it starts beside, that no heading sits beside it, and that the text beside it is never narrower than a set minimum (so no column of one or two words). At 320 and 430 it checks the figure is stacked. - Not done: Text wraps well at all six widths: no line of one or two words beside the figure. If it happens at a width, the figure stacks at that width instead of squeezing the text.
- Not done: Keyboard: the Enlarge button is reachable, Escape closes, focus returns to it, and the key is readable in the lightbox.
- Not done: Colors and sizes come from theme tokens and
layoutSizes.tsvariables only. No literals. - Not done: A gallery entry shows
Figureright, left and none, with and without a key, anddocs/ui/component-set.mdhas a row for it, withBadge · neutralnoted as the figure label's look. - Not done: #654 has the [DECISION] comment above, and its gallery spacing item is fixed here.
- Not done: The width [PUSHBACK] and [QUESTION] are posted on this issue. The default is the answer when it comes, or 2/5 until then.
- Not done: Checked at 320, 430, 768, 1024, 1280 and 1920 px in light and dark (
visual-design-review). - Not done: Documentation follows behavior: the generated components reference is regenerated, and the figure rule (small view, lightbox, badge) is written in
docs/ui/component-set.mdin this PR. The guideline's width text is 07.
Files likely touched
- new
src/platform/ui/Figure.tsx(+ test) src/platform/ui/layoutSizes.ts,src/app/(frontend)/globals.css(figure width variables)src/platform/richtext/MediaBlock.tsx(only if its frame class moves to a shared constant)src/app/(frontend)/dev/gallery/(the entry, and the Legend sample fix from #654)e2e/alignment.spec.ts,e2e/seed.tsdocs/ui/component-set.md,docs/reference/components/(generated)
Must not touch
src/platform/ui/Legend.tsx,Caption.tsx,Badge.tsx: use them as they are. If one needs a variant, add it there and say so in the PR (use, configure or split).src/platform/ui/Alert.tsx,src/platform/theme/,src/themes/(05, 06)- Payload configs,
src/payload-types.ts,src/migrations/(03) docs/guidelines/ui-ux-design.md(07)
Area
frontend, ux, styling
Priority
priority: medium
Generated by Claude Code, opens in a new tab