Skip to content

Center width-constrained figures and harden default image centering#180

Merged
hongyi-chen merged 3 commits into
mainfrom
fix/center-width-constrained-figures
Jun 5, 2026
Merged

Center width-constrained figures and harden default image centering#180
hongyi-chen merged 3 commits into
mainfrom
fix/center-width-constrained-figures

Conversation

@hongyi-chen
Copy link
Copy Markdown
Collaborator

What

Fixes the issue where many embedded images were not center-aligned on the page — most visibly on the Prompt queueing page.

Root cause

Images in the docs are wrapped in <figure>. The figure rule in src/styles/custom.css used margin: 1.5em 0. For figures with a constrained width (e.g. <figure style={{ maxWidth: "563px" }}>), the zero horizontal margins kept the box flush left. The existing text-align: center only centers content inside the figure box, not the box itself — so a narrow figure sat on the left edge of the content column.

This maxWidth figure pattern is used across ~17 pages (prompt queueing, Oz web app, Code Review panel, managing cloud agents, handoff, MCP, and more), so they were all affected.

Changes (src/styles/custom.css)

  • Center width-constrained figures: change the figure margin from 1.5em 0 to 1.5em auto. Full-width figures resolve auto margins to 0, so they're unaffected.
  • Center link-wrapped images (<p><a><img></a></p>): add a p:has(> a > img) rule that centers via the paragraph, since the inline <a> shrink-wraps the image and defeats margin: auto on the image alone.
  • Fix the table exclusion: the old :not(table) > img never actually excluded in-table images (an in-cell image's parent is <td>, not <table>). Replaced with :not(:where(table *)), which uses zero-specificity :where() so it doesn't fight the rest of the selector.

:has() and :where() are already used elsewhere in the same stylesheet, so this stays within the existing browser-support baseline.

Validation

  • npm run build passes.
  • No content/MDX files changed — CSS-only.

Conversation: https://staging.warp.dev/conversation/08538da7-499e-4217-b64e-22d6167af5be
Run: https://oz.staging.warp.dev/runs/019e9524-466c-7542-9e6e-954819f2b4b0

This PR was generated with Oz.

Width-constrained figures (e.g. `<figure style={{ maxWidth: "563px" }}>`)
were rendering flush left instead of centered. The figure rule used
`margin: 1.5em 0`, so a figure narrower than the content column kept zero
side margins; `text-align: center` only centers content inside the box,
not the box itself. Switch to `margin: 1.5em auto` so constrained figures
center on the page (full-width figures resolve auto margins to 0). This
fixes the prompt-queueing page and ~16 other pages using the same pattern.

Also harden the default image-centering rule:
- Center link-wrapped images (`<p><a><img></a></p>`) via the paragraph,
  since the inline `<a>` shrink-wraps the image and defeats auto margins.
- Make the "exclude images inside tables" intent actually work with
  `:not(:where(table *))` (the old `:not(table)` never matched, since an
  in-cell image's parent is `<td>`, not `<table>`).

Co-Authored-By: Oz <oz-agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Jun 5, 2026
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jun 5, 2026 12:29am

Request Review

@hongyi-chen hongyi-chen marked this pull request as ready for review June 5, 2026 00:23
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented Jun 5, 2026

@hongyi-chen

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR updates the docs stylesheet to center width-constrained figures and common image embed patterns. The figure margin change aligns with the stated goal, and this CSS-only change does not introduce security-relevant behavior.

Concerns

  • The table exclusion remains incomplete for paragraph-wrapped images: the p > img selector and the new link-wrapped p:has(> a > img) selector still match paragraphs inside tables, so table images can still inherit centering styles despite the new guard.

Verdict

Found: 0 critical, 2 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

Comment thread src/styles/custom.css Outdated
Comment thread src/styles/custom.css Outdated
@hongyi-chen hongyi-chen enabled auto-merge (squash) June 5, 2026 00:26
hongyi-chen and others added 2 commits June 4, 2026 17:26
Co-authored-by: oz-for-oss[bot] <277970191+oz-for-oss[bot]@users.noreply.github.com>
Co-authored-by: oz-for-oss[bot] <277970191+oz-for-oss[bot]@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

@rachaelrenk rachaelrenk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏🏼

@hongyi-chen hongyi-chen merged commit fa4c3f1 into main Jun 5, 2026
8 checks passed
@hongyi-chen hongyi-chen deleted the fix/center-width-constrained-figures branch June 5, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants