Skip to content

feat(core): Avatar adopts Icon's abbreviated size scale - #4140

Merged
cixzhang merged 4 commits into
mainfrom
feat/avatar-size-scale
Jul 22, 2026
Merged

cixzhang merged 4 commits into
mainfrom
feat/avatar-size-scale

Conversation

@cixzhang

@cixzhang cixzhang commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

What

Avatar and AvatarGroup now use the same abbreviated size scale as Icon — size accepts xsm/sm/md/lg/xl instead of tiny/xsmall/small/medium/large. Pixel values are unchanged (20/24/36/48/128px); only the names move. The default shifts from small to md, which is the same 36px.

old name px new name
tiny 20 xsm
xsmall 24 sm
small 36 md ← default
medium 48 lg
large 128 xl

Why

Icon, Spinner, and Avatar each spoke a different size dialect (#2672), so composing them or generating code meant learning three vocabularies. This aligns Avatar's names with Icon's while keeping its larger values — avatars align with media, not glyphs, and these tiers match EPS's avatar sizes. Standardizing the default to md completes the alignment.

Risk

Breaking rename of a public prop's string values. Shipped with a v0.1.8 codemod (rename-avatar-size-scale) that migrates call sites via astryx upgrade. Because the values don't change, rendered output is identical; only the API surface moves. Callers relying on the default need no change (small → md, both 36px).

Codemod precision. small/medium/large are common English words (priorities, statuses, breakpoints), so the codemod renames those three only on a size JSX attribute of an Avatar/AvatarGroup element (alias-aware, import-scoped) — never blind in object properties or type unions, which would corrupt unrelated literals. The Avatar-unique names tiny/xsmall are additionally migrated in size-keyed props, Storybook options, and union types within files importing Avatar. Rare ambiguous object-property cases (e.g. args: {size: 'small'} where the component isn't statically known) are intentionally left for manual migration rather than risk a wrong rewrite.

Testing

pnpm test (Avatar, AvatarGroup, codemod, registry — all green), core + docs + template-docs typecheck, lint, and changeset checks pass. Added 10 codemod tests covering each rename, alias/import-source scoping, numeric passthrough, and negative cases (non-Avatar files and non-size strings left untouched). Repo call sites (stories, templates, example apps, docs) migrated with the codemod itself.

Rename Avatar/AvatarGroup named sizes tiny/xsmall/small/medium/large →
xsm/sm/md/lg/xl. Pixel values are unchanged (20/24/36/48/128px); the
default moves from small to md (same 36px). Avatar's tiers stay larger
than Icon's because avatars align with media rather than glyphs.

Adds a v0.1.8 codemod (rename-avatar-size-scale) so 'astryx upgrade'
migrates call sites automatically.
@vercel

vercel Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
astryx Ready Ready Preview, Comment Jul 21, 2026 1:34pm

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 21, 2026
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Jul 21, 2026
@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

Modified Components

Avatar · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 365 -
Complexity N/A Very High (36) -
AvatarGroup · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 223 -
Complexity N/A Medium (10) -
Chat · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 5231 -
Complexity N/A Very High (425) -
Item · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 357 -
Complexity N/A Very High (39) -
Table · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1905 -
Complexity N/A Very High (101) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 0B

Accessibility Audit

Status: 6 accessibility violation(s) found — 1 critical, 5 serious.

Avatar - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/12 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
AvatarGroup - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 1/12 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Chat - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/8 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
Item - 2 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 2/9 stories · Learn more
    • WCAG: 1.4.3 (Level AA)
  • 🔴 critical: Ensure an element's role supports its ARIA attributes
    • Rule: aria-allowed-attr · Affects 1/9 stories · Learn more
    • WCAG: 4.1.2 (Level A)
Table - 1 issue(s)
  • 🟠 serious: Ensure the contrast between foreground and background colors meets WCAG 2 AA minimum contrast ratio thresholds
    • Rule: color-contrast · Affects 4/24 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

The Avatar size-scale rename codemod incorrectly rewrote the 'medium'
literal in the TaskPriority union to 'lg', while all priority data and
the PRIORITY_COLOR/PRIORITY_LABEL record keys still use 'medium' — a
type error unrelated to Avatar sizing. TaskPriority is a task-tracker
enum, not an Avatar size, so revert that one token.
@cixzhang

Copy link
Copy Markdown
Contributor Author

The build/build-sandbox failure was collateral from the size-scale rename: it rewrote the 'medium' literal in the TaskPriority union to 'lg' in the table-grouped template, while all the priority data and record keys still use 'medium'. TaskPriority is a task-tracker enum (not an Avatar size), so I reverted that one token — checks should go green now.

The context-blind type-union and object-property passes renamed common
words (small/medium/large) in any file importing Avatar, which rewrote
an unrelated TaskPriority union and broke the sandbox build. Restrict
small/medium/large renames to Avatar/AvatarGroup `size` JSX attributes
(where the component is known); keep the broader passes only for the
Avatar-unique names tiny/xsmall. Adds precision-guard tests.
The precise/ambiguous split left size option arrays partially renamed
(unique tiny/xsmall migrated, ambiguous small/medium/large not), so the
codemod couldn't reproduce committed Storybook callsites. Treat an array
containing an Avatar-unique name (tiny/xsmall) as the full size enum and
rename all its members; add a standalone-array pass for `[...].map()`
size lists. Unrelated arrays/unions without a unique name stay untouched,
preserving the TaskPriority fix.
github-actions Bot added a commit that referenced this pull request Jul 21, 2026
@cixzhang
cixzhang merged commit 5baaa93 into main Jul 22, 2026
20 checks passed
@cixzhang
cixzhang deleted the feat/avatar-size-scale branch July 22, 2026 19:58
nynexman4464 added a commit that referenced this pull request Jul 22, 2026
…cale rename (#4221)

PR #4196 added a LongCount story with size="medium", but PR #4140 renamed
AvatarSize to the abbreviated Icon scale ("md" instead of "medium"). The
land order left a stale value that broke storybook typecheck on main.
cixzhang added a commit that referenced this pull request Aug 24, 2026
…d size scale

#3933 landed a story with size="small" after #4140 replaced Avatar's named
sizes with the abbreviated scale, so build-storybook's typecheck fails on
main and blocks every PR based on it.
cixzhang added a commit that referenced this pull request Aug 24, 2026
… widen it to the trigger line (#5377)

* refactor(MultiSelector): rename formatTriggerCount to formatValue and widen it to the trigger line

formatValue now receives the selected items ({value, label}[]) and formats
the trigger for triggerDisplay 'count' and 'labels'; 'badges' renders
elements, so it is excluded. The prop is unreleased, so no codemod or
deprecation is needed. Defaults are unchanged when the prop is absent.

* fix(storybook): Chat story uses Avatar size 'sm' after the abbreviated size scale

#3933 landed a story with size="small" after #4140 replaced Avatar's named
sizes with the abbreviated scale, so build-storybook's typecheck fails on
main and blocks every PR based on it.
cixzhang added a commit that referenced this pull request Aug 24, 2026
…tory (#5381)

Avatar's named scale became `xsm | sm | md | lg | xl` (#4140); the align story
landed afterwards with `size="small"` (#3933), so `pnpm -F
@astryxdesign/storybook typecheck` fails on main and takes the `build` job with
it. Every open PR is blocked behind it.

Every other Avatar in the file uses a token from the current scale.

This branch was successfully deployed

1 active deployment
Preview — 8e4c4acd Deployed Jul 21, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant