Skip to content

UI: Document the Avatar footprint of each size - #87892

Merged
ciampo merged 5 commits into
trunkfrom
docs/ui-avatar-footprint
Dec 3, 2026
Merged

ciampo merged 5 commits into
trunkfrom
docs/ui-avatar-footprint

Conversation

@ciampo

@ciampo ciampo commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

What?

Follow-up to #87841 (step 3).

Documents the dimension token behind each Avatar size, and how to compute the outer footprint from it.

Why?

The Avatar reserves 3px for the activity ring, so its footprint is larger than its size. Consumers need the footprint to lay out content around the avatar, but the docs only said that the footprint "reserves room" for the ring. The collaborator UI in the editor is moving to this Avatar and has to adjust its offsets to the new box.

The footprint can't be exposed as a custom property on the Avatar: a parent can't read a custom property that is set on its child. So the docs give the rule, in terms of tokens. If the token values change, the docs stay accurate.

How?

The size JSDoc now:

  • maps each size to its token: xs to --wpds-dimension-size-2xs, sm, md and lg to the matching --wpds-dimension-size-*, and xl to twice --wpds-dimension-size-md.
  • says that the footprint is the size plus 3px, for example calc(var(--wpds-dimension-size-sm) + 3px), and that it stays the same whether or not the avatar is active, at every display density.
  • says that the image fills the footprint minus twice --wpds-border-width-focus.

The 3px is a fixed value in the CSS: the ring at its high-DPI width (2 × 1.5px). It is not twice --wpds-border-width-focus, which is 2px on standard-density screens.

Testing Instructions

  1. In Storybook, open Components / @wordpress-ui / Avatar, on the Docs page.
  2. In the props table, the size description should list the token of each size and the footprint rule.
  3. Open the Sizes story and inspect each avatar. Its box should be the token value plus 3px, for example 27px for sm.

Testing Instructions for Keyboard

No UI change.

Use of AI Tools

Written with Claude Code (Claude Opus 5.5), at my direction: Claude made the change and drafted this description.

🤖 Generated with Claude Code

Consumers lay out content around the avatar against its outer footprint,
which adds 3px for the activity ring. List the image size and footprint
of each size, and test the footprint so the numbers stay accurate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ciampo ciampo added [Type] Developer Documentation Documentation for developers [Package] UI /packages/ui labels Dec 3, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: aduth <aduth@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: 0 B

Total Size: 8.85 MB

871211a Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 59a8b28 trunk % Change
timeToFirstByte 56.15 ms +10.6% -4.19% 60.5 ms +7.19% -6.12% -7.19%
largestContentfulPaint 92 ms +8.7% -8.7% 92 ms +4.35% -4.35% 0%
lcpMinusTtfb 30.65 ms +24.47% -6.69% 31.2 ms +6.57% -6.89% -1.76%
wpBeforeTemplate 29.61 ms +10.81% -2.9% 31.45 ms +5.98% -4.8% -5.85%
wpTemplate 22.37 ms +5.5% -3.89% 24.7 ms +2.11% -7.57% -9.43%
wpTotal 52.34 ms +10.7% -4.47% 56.51 ms +7.2% -6.46% -7.38%
wpMemoryUsage 7.76 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 59a8b28 trunk % Change
timeToFirstByte 48.25 ms +5.6% -3.11% 48.65 ms +9.25% -2.36% -0.82%
largestContentfulPaint 84 ms +7.14% -2.38% 84 ms +4.76% -0% 0%
lcpMinusTtfb 35.5 ms +5.63% -3.24% 35.8 ms +3.07% -3.91% -0.84%
wpBeforeTemplate 27.79 ms +8.6% -1.48% 28.08 ms +11.11% -2.31% -1.03%
wpTemplate 16.35 ms +6.18% -2.57% 17.3 ms +6.88% -3.35% -5.49%
wpTotal 44.78 ms +6.54% -2.55% 45.46 ms +8.03% -2.71% -1.5%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 59a8b28 trunk % Change
mediaProcessingJpeg 400.45 ms +1.92% -0.7% 408.37 ms +0.82% -0.92% -1.94%
mediaProcessingAvif 6152.93 ms +0.18% -0.47% 6182.02 ms +0.21% -0.47% -0.47%
mediaProcessingJpegToAvif 4243.86 ms +0.18% -0.51% 4249.91 ms +0.43% -0.03% -0.14%

media-upload

Metric 59a8b28 trunk % Change
jpegUploadProcessing 2023.75 ms +1.1% -2.45% 1997.31 ms +1.15% -20.61% 1.32%
pngUploadProcessing 271.94 ms +3.79% -1.84% 281.23 ms +1.03% -3.26% -3.3%
largeJpegUploadProcessing 1975.45 ms +0.5% -22.97% 1999.86 ms +0.52% -0.64% -1.22%
multipleImageUploadProcessing 2098.65 ms +0.19% -1.25% 2107.99 ms +0.71% -1.6% -0.44%

post-editor

Metric 59a8b28 trunk % Change
serverResponse 266.99 ms +2.78% -4.57% 278.28 ms +2.08% -10% -4.06%
firstPaint 280.3 ms +8.79% -7.84% 276.29 ms +9.65% -7.66% 1.45%
domContentLoaded 535.99 ms +2.46% -1.49% 578.76 ms +1.9% -1.25% -7.39%
loaded 537.13 ms +2.46% -1.49% 580.08 ms +1.91% -1.24% -7.4%
firstContentfulPaint 303.6 ms +1.01% -1.57% 327.14 ms +2.12% -1.09% -7.2%
firstBlock 1441.3 ms +6.1% -0.64% 1552.64 ms +0.62% -1.45% -7.17%
type 13.21 ms +12.49% -8.1% 16.45 ms +6.93% -11.67% -19.7%
typeWithoutInspector 14.1 ms +4.33% -12.77% 14.66 ms +6.41% -6.41% -3.82%
typeWithTopToolbar 16.63 ms +8.84% -1.8% 19.05 ms +10.08% -7.93% -12.7%
typeContainer 6.75 ms +4.59% -8.59% 6.52 ms +11.5% -5.06% 3.53%
focus 70.87 ms +9.51% -9.02% 74.4 ms +6.37% -2.97% -4.74%
firstFocus 188.88 ms +0% -0% 196.52 ms +0% -0% -3.89%
selectAll 243.16 ms +3.03% -1.37% 242.14 ms +20.68% -1.26% 0.42%
undo 21.8 ms +6.33% -4.95% 20.73 ms +4.58% -3.38% 5.16%
listViewOpen 29.5 ms +5.53% -3.73% 24.84 ms +12.16% -5.68% 18.76%
inserterOpen 28.79 ms +10.56% -2.88% 26.73 ms +9.32% -4.86% 7.71%
inserterHover 9.23 ms +7.48% -7.48% 8.99 ms +6.34% -6.45% 2.67%
inserterSearch 6.67 ms +8.1% -5.1% 7.16 ms +9.5% -4.47% -6.84%
loadPatterns 470.32 ms +4.04% -2.14% 475.79 ms +3.52% -3.12% -1.15%
wpTotal 260.05 ms +2.8% -4.64% 270.79 ms +1.96% -10.18% -3.97%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 59a8b28 trunk % Change
serverResponse 477.81 ms +0.45% -8.35% 476.5 ms +1.14% -8.18% 0.27%
firstPaint 424.94 ms +13.22% -11.15% 467.05 ms +1.57% -14.68% -9.02%
domContentLoaded 836.75 ms +1.23% -0.73% 849.83 ms +1.34% -1.28% -1.54%
loaded 838.34 ms +1.22% -0.71% 851.4 ms +1.37% -1.29% -1.53%
firstContentfulPaint 467.5 ms +2.92% -4.19% 476.56 ms +1.78% -1.61% -1.9%
firstBlock 2641.12 ms +0.51% -1.15% 2641.51 ms +0.51% -0.91% -0.01%
type 20.8 ms +13.03% -15.53% 17.42 ms +8.84% -4.71% 19.4%
navigate 115.29 ms +8.46% -3.08% 114.1 ms +6.03% -1.31% 1.04%
loadPatterns 1593.7 ms +7.63% -11.62% 1726.39 ms +8.68% -19.59% -7.69%
loadPages 967.46 ms +4.26% -0.55% 1011.28 ms +2.85% -1.56% -4.33%
wpTotal 468.33 ms +0.47% -8.54% 466.94 ms +1.18% -8.38% 0.3%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

871211a Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

As a user I want to be able to add multiple close buttons so that users can close the overlay from different positions in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
Error: expect(locator).toHaveCount(expected) failed

Locator:  getByRole('button', { name: 'Close' })
Expected: 2
Received: 1
Timeout:  5000ms

Call log:
  - Expect "toHaveCount" getByRole('button', { name: 'Close' }) with timeout 5000ms
  - waiting for getByRole('button', { name: 'Close' })
    14 × locator resolved to 1 element
       - unexpected value "1"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:228:33
Navigates the items list via UP/DOWN arrow keys in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByLabel('Page Two')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByLabel('Page Two') with timeout 5000ms
  - waiting for getByLabel('Page Two')
    14 × locator resolved to <button type="button" tabindex="-1" aria-pressed="false" id="view-list-0-200-item-wrapper" class="dataviews-view-list__item" aria-labelledby="view-list-0-200-label" aria-describedby="view-list-0-200-description"></button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:146:49
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:image -->
- <figure class="wp-block-image"><img alt=""/></figure>
+ <!-- wp:image {"id":32,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8889/wp-content/uploads/2026/12/4766a9e3-2987-44b2-a36c-c6384432d94e.png" alt="" class="wp-image-32"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:432:49

871211a Run

List the dimension token of each size and the rule for the footprint,
instead of pixel values, so the docs stay accurate if the tokens change.
Remove the footprint test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ciampo ciampo self-assigned this Dec 3, 2026
@ciampo
ciampo marked this pull request as ready for review December 3, 2026 10:40
@ciampo
ciampo requested a review from a team as a code owner December 3, 2026 10:40
@github-actions
github-actions Bot requested a review from aduth December 3, 2026 10:40
ciampo and others added 2 commits December 3, 2026 11:42
The changelog validator expects Documentation to be the last Unreleased
section.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@aduth aduth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍 I think this will help set clearer expectations around its size. It does also create a bit of a "contract" and potential future burden for us if we change how this works (e.g. changing 3px, or the high-DPI focus ring width).

@ciampo

ciampo commented Dec 3, 2026

Copy link
Copy Markdown
Contributor Author

Yes, although I assume we'll log it as a change. I find that, without it, it may get harder for consumers to lay Avatar out correctly

@ciampo
ciampo merged commit 263c614 into trunk Dec 3, 2026
89 checks passed
@ciampo
ciampo deleted the docs/ui-avatar-footprint branch December 3, 2026 16:21
@github-actions github-actions Bot added this to the Gutenberg 24.7 milestone Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] UI /packages/ui [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants