Skip to content

spec: define size-aware icon registry entries - #6244

Closed
freddymeta wants to merge 1 commit into
mainfrom
freddymeta/size-aware-icon-registry-spec
Closed

freddymeta wants to merge 1 commit into
mainfrom
freddymeta/size-aware-icon-registry-spec

Conversation

@freddymeta

Copy link
Copy Markdown
Contributor

Summary

  • propose backward-compatible size-aware icon registry entries
  • preserve existing theme, global, and built-in source precedence
  • keep existing React-node entries unchanged
  • keep SVG geometry and optical normalization owned by the selected icon library

Motivation

IconFromRegistry already knows the effective IconSize, but the registry resolves one static React node for every size. Themes backed by icon systems with separately authored 12px, 16px, 20px, and 24px assets cannot select the matching source without CSS or SVG-geometry workarounds.

Scope

Spec only. This PR does not change runtime behavior.

Test plan

  • pnpm check:repo

@vercel

vercel Bot commented Sep 11, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 11, 2026 6:29am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Sep 11, 2026
@astracat-bot

astracat-bot Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 9, 2026, 2:46 PM UTC

@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge spec-auto-merge Auto-merge was enabled by the spec owner gate labels Sep 11, 2026
@freddymeta
freddymeta marked this pull request as draft September 11, 2026 07:39
@github-actions github-actions Bot removed the spec-auto-merge Auto-merge was enabled by the spec owner gate label Sep 11, 2026
@ernestt ernestt mentioned this pull request Sep 21, 2026
7 of 8 tasks

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approval waits on an engineering owner's decision, and the record needs fixes whichever way it goes.

Since this draft was opened, spec:AST-087 (icon variants, theme sizes and component icon slots) became the current spec: a theme icon entry can already be a pure function of {size, variant}, so per-size artwork works today through icons[name]: ({size}) => .... This draft proposes a second, declarative {default, bySize} form, so an engineering owner needs to decide whether Astryx wants it beside AST-087's function entries, as an amendment to AST-087, or whether AST-087 supersedes this proposal. An engineering owner records an approval by commenting /approve-spec <full head SHA> on this pull request, and the author may do so if they are an engineering owner.

Required changes:

  • Regression: spec:AST-034 and docs/specs/AST-034/spec.md now belong to the theme family build spec on main, so this branch conflicts, and renaming only the directory still fails the knowledge check on a duplicate id; move the record to an unused AST id and update its DEC references.
  • Regression: DEC-1 and the matching non-goal reject the (size) => ReactNode entry that AST-087 FR1 and DEC-2 adopted, and FR5 and FR7 (size-less reads returning default, and a size input on getIcon, getExtendedIcon, getIconRegistry and useIcon) contradict AST-087 FR18 and DEC-7, which read entries at md and route size through Icon.
  • Regression: schema_version: 1 fails pnpm check:knowledge on current main, which requires schema version 4 for active system-spec records.
  • Regression: the Current-state impact section says main stores only React nodes and that IconFromRegistry drops the size, but main now passes {size, variant} to the registry, so the motivation needs to start from AST-087.
  • Newly live check: the description needs the docs/contributing/spec-writing.md rubric results under ## Writing rubric results, which architecture:knowledge-contracts requires for a pull request that adds a record.

[Automated review]

schema_version: 1
template_version: 1
kind: system-spec
id: spec:AST-034

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

spec:AST-034 and this path now belong to the current theme family build spec on main, so the branch conflicts, and renaming only the directory still fails the knowledge check on a duplicate id. Move the record to an unused AST id and update the DEC references at lines 157, 170 and 183.

@@ -0,0 +1,200 @@
---
schema_version: 1

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Current main requires schema_version: 4 for an active system-spec record; with version 1 pnpm check:knowledge fails (active system-spec records must use latest schema_version 4 for that kind).

Comment on lines +88 to +92
- **FR7 — Public resolvers expose the same optional size input.** `getIcon`,
`getExtendedIcon`, `getIconRegistry`, and `useIcon` MUST support resolving a
requested `IconSize` without changing existing calls. Omitted size uses FR5.
Resolver syntax MUST remain backward-compatible with each released argument
position. Resolver results remain React nodes, not registry descriptors.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

spec:AST-087 FR18 and DEC-7 keep public reads at {size: 'md'} and route size through Icon, so a size input on these four resolvers contradicts the current spec. FR5's size-less read returning default differs from it the same way.

Comment on lines +128 to +132
Current `main` stores `ReactNode` values in the shared registry. `IconFromRegistry`
already knows the effective `IconSize`, but calls `getIcon(name, themeName)` without
passing it. A theme therefore supplies one static node for every size. Themes backed
by icon systems with separately authored 12px, 16px, 20px, and 24px assets must pick
one source for all sizes or compensate inside that node.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This describes main before spec:AST-087: Icon now passes {size, variant} to the registry, and an entry can be a function of that request. The motivation needs to start from AST-087.

Comment on lines +164 to +166
Rejected: a render callback such as `(size) => ReactNode`. It permits arbitrary
render-time behavior, hides fallback completeness, and turns registry data into a
second component lifecycle.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

spec:AST-087 DEC-2 adopted exactly this alternative: a theme entry is a node or a pure synchronous function of the final size and optional variant. Rejecting it here reverses a current decision; drop the rejection or propose an explicit amendment to AST-087.

@imdreamrunner

Copy link
Copy Markdown
Contributor

Thanks for writing this up. The need here, choosing separately drawn artwork per IconSize, is now covered by AST-087 (docs/specs/AST-087-icon-variants/spec.md, merged in #7847, shipped in 0.7.5):

  • FR1, FR9: an icon entry, in a theme's icons or through registerIcons, can be a React node or a pure function of {size, variant}, and it receives the resolved size. So ({size}) => size === 'sm' ? <Info16 /> : <Info24 /> picks the matching asset.
  • FR6: the source (theme, then global, then built-in) is chosen before the size, as FR3 here proposed.
  • FR18: public reads stay node-valued, and size-aware resolution stays inside Icon. This is where AST-087 deliberately differs from FR7 here.

AST-087 uses a function rather than a declarative bySize map, so the entry decides its own fallback for sizes it doesn't draw.

Closing this as covered. If a case isn't served by function entries, please open an issue describing it.

@github-actions
github-actions Bot deleted the freddymeta/size-aware-icon-registry-spec branch November 10, 2026 06:04

This branch was successfully deployed

1 active deployment
Preview — be07b11c Deployed Sep 11, 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. community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants