Repository navigation
spec(AST-087): icon variants, theme sizes, and componentIcons state resolvers - #7847
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
…esolvers
Draft record: Icon takes one optional variant; theme icon entries are fixed nodes or pure functions of {size, variant}; the four size names stay closed and a theme sets their dimensions through the Icon stylesheet target; componentIcons is the only component icon map and a slot may resolve from typed component state.
Co-authored-by: rubyycheung <[email protected]>
50aa1ad to
f07b799
Compare
Co-authored-by: rubyycheung <[email protected]>
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsIcon (@astryxdesign/core) · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: 1 accessibility violation(s) found — 1 serious. Icon - 1 issue(s)
Visual Regression46 of 486 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 26 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
This spec is on hold for an engineering owner: spec:AST-087 adds new icon-theming requirements but has no owner approval on the current head (the spec-owner-approval status is still pending). Its FR11, FR13 and FR14 also intentionally change architecture:icon-resolution-and-component-slots INV3 (a componentIcons value is only an IconName or null) and INV8 (slot size and state stay with the component). Approval needs an owner to approve the record on this exact head and to update INV3 and INV8 to match; architecture:knowledge-contracts asks for the owning record to change in the same pull request. Three record fixes are also needed:
- Say how state-resolver slots (FR14, DEC-5) relate to the existing
defineTheme({indicators})registry, which already themes marks such as Selector's selected-option check. - Narrow the non-goal "Theme styling for icon components passed directly to
Icon" so it no longer contradicts FR7 and FR8; directly passed glyphs carry theicontarget too. - Use a shared or namespaced key in FR1's example, because
staris not anIconName.
[Automated review]
| - Appearance or weight axes, or variant names defined by Astryx. | ||
| - New Icon size names. | ||
| - Additional component icon maps or an icon-role concept. | ||
| - Theme styling for icon components passed directly to `Icon`. |
There was a problem hiding this comment.
This non-goal reads as excluding theme styling of directly passed icon components, but those glyphs carry the icon theming target too (component:Icon FR2, DEC-1). FR7 guarantees width/height on that target, and FR8 sizes a component's icon box "so the glyph and its box match", for example a Button whose icon is <Icon icon={PhotoIcon} />. Consider narrowing it to "Theme artwork or variant selection for icon components passed directly to Icon".
| /> | ||
| ); | ||
|
|
||
| defineTheme({name: 'brand', icons: {star}}); |
There was a problem hiding this comment.
star is not a shared IconName and has no namespace, so this example does not type-check against ThemeIconOverrides (Partial<Record<IconName | NamespacedIconName, ReactNode>>), and FR1 itself limits entries to a semantic or namespaced key. A shared name such as check, or a key such as 'app:star', keeps the example copyable.
| - **FR14 — Themes set state-dependent icons through slots.** A component that | ||
| shows a state-dependent icon exposes that state through its slot so the theme | ||
| can resolve it. Per-state icon props passed by a caller, such as `pressedIcon` | ||
| or `selectedIcon`, act as caller-supplied icon content. |
There was a problem hiding this comment.
State-dependent marks are already themeable through defineTheme({indicators}), which replaces the check, checkbox and radio indicators with typed checked | unchecked | indeterminate state; Selector draws its selected-option check with useIndicator('check'). As written, FR14 and DEC-5 also cover those marks, and nothing says which wins when a theme sets both an indicator and a slot resolver. Could the record scope FR14 to glyphs no indicator draws, or state how the two compose?
…slot requests - Amend architecture:icon-resolution-and-component-slots (INV3, INV8, final function results, indicator boundary, slot state docs), theme-authoring-contract, theme-compilation, theme-application, component-theming-surface INV14, and component:Icon in the same change. - A theme lists its variant names once (iconVariants); the list types entries and requests, bounds build enumeration, and an unlisted variant renders the normal icon. - A missing request variant keeps the variant the component would request. - componentIcons also accepts a static partial request. - Slot functions are called only by slot resolution; public theme data shows a static view. - Indicators stay separate from componentIcons slots. - Owned icon boxes and default glyphs move to a separate record.
There was a problem hiding this comment.
This spec is on hold for an engineering owner. spec:AST-087 and its amendments to six current records, including architecture:icon-resolution-and-component-slots INV3 and INV8, need an owner's approval on this exact head, and spec-owner-approval is still pending. Five record fixes also remain:
- FR3 says no variant type combines themes, but the per-theme
theme buildaugmentations ofIconVariantMapmerge when an app loads two built themes. - Say whether the
icontarget reflectsvariant: component-theming-surface INV14 now calls it an extensible axis, whilecomponent:IconFR6 forbids forwarding it to the DOM. - Square theme-authoring INV13 (“Astryx resolution is their only caller”) with FR8, which lets build tooling call entries.
- Replace “runs once” (FR6, INV11) with “final for its resolution”, since server rendering and hydration both resolve the request.
- Name the withdrawn
selector-selected-optionslot in Current-state impact.
[Automated review]
| `IconVariant`, the names in the public, augmentable `IconVariantMap`. `theme | ||
| build` writes the augmentation for the theme it builds, the same way it | ||
| augments custom component values, and an application may augment the map | ||
| itself. No variant type is derived by combining themes. |
There was a problem hiding this comment.
With two built themes in one app, each theme build writes its own .variants.d.ts augmentation of IconVariantMap, and TypeScript merges them, so IconVariant becomes the union of both lists. Consider stating that merge, with FR4 covering a name the active theme does not list, and narrowing this sentence to the per-theme typing inside defineTheme.
| `Heading.type` qualifies because required `Heading.level` provides that | ||
| baseline. `Icon.size` does not: no missing custom size can be inferred without | ||
| silently changing geometry, alignment, or composition. Behavioral, structural, | ||
| baseline. `Icon.variant` qualifies because an unlisted variant renders the |
There was a problem hiding this comment.
Calling Icon.variant an extensible axis brings the wiring extensibleAxes.test.ts guards: a *VariantMap, themeProps() reflection and visualProps. But component:Icon FR6 forbids forwarding variant to the DOM. Could the record say whether the icon target reflects variant, or that this axis is an artwork request outside INV14's styling wiring?
| derive, or normalize input into a durable typed theme value used by a current | ||
| supported consumer; validating and returning the exact input unchanged is | ||
| insufficient. | ||
| - **INV13 — Theme functions stay behind resolution.** Function icon entries and |
There was a problem hiding this comment.
AST-087 FR8 and theme-compilation INV15 let build tooling call each entry, so “Astryx resolution is their only caller” needs to include that tooling, or FR8 needs to be scoped to Astryx's own build.
| - **INV11 — A selected function answers the request.** A function entry or slot | ||
| function runs once for its request, and its result is final. Public theme |
There was a problem hiding this comment.
Server rendering and hydration each resolve the same request (theme-application INV11), so an entry runs on both sides. “Final for its resolution” says what this rule needs, and the verification row's “a function runs twice” would fail a correct implementation.
| export interface ComponentIconSlotMap { | ||
| 'selector-selected-option': true; | ||
| } | ||
| export interface ComponentIconSlotMap {} |
There was a problem hiding this comment.
Emptying the map withdraws the approved selector-selected-option slot. It matches Selector's AV1 check-indicator replacement, but AST-087's Current-state impact should name the withdrawal.
…iant, callers, finality, withdrawn slot
There was a problem hiding this comment.
This spec is on hold for an engineering owner: spec:AST-087 and its amendments to six current records, including architecture:icon-resolution-and-component-slots INV3 and INV8, need an owner's approval on this exact head, and spec-owner-approval is still pending. The five record fixes from the previous review are resolved, and two remain:
architecture:component-theming-surfaceINV6, its Change coupling bullet and its INV14 verification row still requirethemeProps()reflection and avisualPropsentry for an extensible axis, whichIcon.variantdeliberately lacks, so record howextensibleAxes.test.tsexempts it.- Say what an inherited function entry receives when a child theme replaces
iconVariants, since it can otherwise be called with a name its own theme never listed, and a lookup-style entry would then render nothing under FR6.
[Automated review]
| artwork request, not a styling selector: the `icon` target does not reflect | ||
| it, so it has no `themeProps()` reflection, `visualProps` entry, or |
There was a problem hiding this comment.
This exempts Icon.variant from themeProps() reflection and visualProps, but INV6 ("Variant, size, selection, disabled, and interaction state are reflected as target capabilities through themeProps"), the Change coupling bullet and the INV14 verification row in this record still require that wiring, and extensibleAxes.test.ts fails any map-backed prop without it. Could the record amend those three places and say how the guard recognizes an artwork axis such as IconVariantMap?
| entry for the same key whole. An explicit `iconVariants` list replaces the | ||
| inherited list; an omitted list is inherited. |
There was a problem hiding this comment.
With a replaced list, inherited function entries stay (only a same-key entry replaces them) and Icon passes them the child's listed names, which their own theme never listed and their variant type excludes. A lookup-style entry then returns undefined, which FR6 makes final, so the icon disappears. Could this say what an inherited entry receives, for example a variant only when its defining theme also lists it?
… entries keep their own variant list
There was a problem hiding this comment.
This spec is on hold for an engineering owner: spec:AST-087 and its amendments to six current records, including architecture:icon-resolution-and-component-slots INV3 and INV8 and architecture:component-theming-surface INV6, need an owner's approval on this exact head, and spec-owner-approval is still pending. Both record fixes from the previous review are resolved, and one alignment remains:
component:IconFR6, its Owns line, its "Listed variant" row and its FR6 verification row still say an entry receives every variant the active theme lists, while AST-087 FR4 and the theme-authoring normalization now withhold a variant from an inherited entry whose defining theme does not list it.
[Automated review]
| | FR3 | Icon MUST apply the resolved size as width and height for every glyph, plus font size where needed for 1em-based icon sources. This sizing contract MUST NOT promise an HTML or SVG element type. | Human decision, current source, and tests. | Settled intent. | | ||
| | FR4 | Supported SVG and styling escape hatches MUST retain their established merge and override behavior. | Current source and regression tests. | Current compatibility behavior; verify before changing. | | ||
| | FR5 | An explicit Icon `size` MUST win. Without one, Icon MUST use the nearest default supplied by an owning Astryx component for its documented icon slot; without such a default, Icon MUST use `md`. | Component-size precedence and Button sizing decision. | Settled intent. | | ||
| | FR6 | In registry mode, Icon MUST pass `{size, variant}` to the selected entry, where `size` is the size resolved by ORD1 and `variant` is the requested variant when the active theme lists it, otherwise `undefined`. A supplied icon component MUST NOT receive `variant`, Icon MUST NOT forward `variant` to the DOM, and the `icon` target MUST NOT reflect it. | `spec:AST-087` FR1–FR5 and FR9. | Settled intent. | |
There was a problem hiding this comment.
FR6 passes the requested variant whenever the active theme lists it, but AST-087 FR4 and the theme-authoring normalization now add a second condition: for a theme-supplied entry, the theme that defined it must list the name too, so an inherited entry under a child with a replaced list receives undefined. As written, this row would hand a parent's lookup-style entry a name it never listed, and FR6 of AST-087 makes its undefined result final. Adding "and, for a theme-supplied entry, the theme that defined it lists it too" here, in the Owns line (line 56) and in the "Listed variant" row (line 125), plus an inherited-entry state in the FR6 verification row (line 198), would keep the two records in agreement.
There was a problem hiding this comment.
This spec is on hold for an engineering owner: spec:AST-087 and its amendments to six current records, including architecture:icon-resolution-and-component-slots INV3 and INV8 and architecture:component-theming-surface INV6, need an owner's approval on this exact head, and spec-owner-approval is still pending. The component:Icon FR6 alignment from the previous review is resolved, and one alignment remains:
architecture:theme-compilationINV15 and its verification row, and AST-087's FR8 verification row, still say build tooling enumerates every listed variant, while FR8 now limits it to the variants an entry can receive under FR4, which leaves out a name only a child theme lists for an entry it inherits.
[Automated review]
| icon request and slot request to the same node as its runtime theme, and its | ||
| public icon and slot exports are the same node-valued and static views. Build | ||
| tooling that generates or subsets icon artwork enumerates a theme's requests as | ||
| every key with each of the four sizes and either no variant or one listed |
There was a problem hiding this comment.
AST-087 FR8 now bounds this set by what an entry can receive under FR4 ("either no variant or one variant the entry can receive under FR4"), so an entry a child theme inherits never receives a name only the child lists. "One listed variant" here still includes that name; consider "one variant that entry can receive under spec:AST-087 FR4", plus an inherited-entry state in this record's INV15 verification row.
| | --------- | ------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ | | ||
| | FR1–FR7 | Registry type, resolver, and Icon render tests | node; function; null; omitted, listed, and unlisted variant; no active list; inherited entry under a replaced list; theme, global, default; direct | sources mix, an unlisted variant reaches an entry, `variant` reaches a component or the DOM | | ||
| | FR2–FR3 | Type tests and theme-build augmentation fixtures | listed names in entries and resolvers; child replaces list; built augmentation; unknown name | an entry sees an unlisted name type, a child merges lists, or Astryx derives one type from two themes' lists | | ||
| | FR8 | Build enumeration test against runtime resolution | every key × four sizes × no variant and each listed variant | an enumerated request differs from runtime output, or an unlisted variant is enumerated | |
There was a problem hiding this comment.
FR8's own text now limits the set to variants the entry can receive under FR4; this row still enumerates "each listed variant" and has no inherited-entry state. Adding "inherited entry under a replaced list" keeps the row in step with FR8.
There was a problem hiding this comment.
This spec is on hold for an engineering owner: spec:AST-087 and its amendments to six current records, including the intentional changes to architecture:icon-resolution-and-component-slots INV3 and INV8 and architecture:component-theming-surface INV6, need an owner's approval on the final head, and spec-owner-approval is still pending. The architecture:theme-compilation INV15 alignment from the previous review is resolved, and two record fixes remain:
- FR15 says every component that shows a state-dependent icon through
Iconexposes that state through its slot, which reaches shipped glyphs such as CodeBlock's copy feedback and Table's expansion chevron; scope it to slots, or amend those component contracts in this pull request. - FR3 and
architecture:theme-authoring-contractsay slot functions receivevariant, but FR12 gives a slot function only the slot's state; say which type a slot request's returnedvarianthas insidedefineTheme.
[Automated review]
| placement, color, interaction, and accessibility remain set by the component, | ||
| including any outer dimensions a family contract fixes across states. | ||
| - **FR15 — Themes set state-dependent icons through slots.** A component that | ||
| shows a state-dependent icon through `Icon` exposes that state through its slot |
There was a problem hiding this comment.
As written this reaches shipped components that pick a state-dependent shared name with no slot: CodeBlock and the Timestamp hover card swap copy for check, and Table row expansion swaps chevronRight for chevronDown, the "Expansion glyph" component:Table describes. Current-state impact does not list those owners. Could FR15 be scoped to components that expose the icon as a componentIcons slot (with components that pick a shared name today keeping that until their own contract adds a slot), or could their contracts change here?
| A child theme that sets `iconVariants` replaces the inherited list; one that | ||
| omits it inherits the list. | ||
| - **FR3 — The list types the theme and the request.** Inside `defineTheme`, entry | ||
| functions and slot resolvers receive `variant` typed as the theme's listed |
There was a problem hiding this comment.
A slot resolver receives only the slot's state (FR12: (state: Readonly<State>) => ComponentIconRequest | null | undefined), so it has no variant input, and the next sentence types a slot request's variant as IconVariant. Perhaps "entry functions receive variant, and slot values return it, typed as the theme's listed names", or keep IconVariant for slot requests and drop slot resolvers from this sentence.
| `{size: 'md'}`; `DefinedTheme['componentIcons']` is a static view of names, | ||
| `null`, and static requests, with resolver slots omitted; and | ||
| `DefinedTheme['iconVariants']` is the theme's list. Inside `defineTheme`, entry | ||
| functions and slot functions receive `variant` typed as that theme's listed |
There was a problem hiding this comment.
Same wording as AST-087 FR3: slot functions take the slot's state, not variant (icon-resolution-and-component-slots.md types them as (state) => ComponentIconRequest | null | undefined). Whichever typing FR3 settles on, this sentence should match it.
There was a problem hiding this comment.
This spec is on hold for an engineering owner: spec:AST-087 and its amendments to six current records, including the intentional changes to architecture:icon-resolution-and-component-slots INV3 and INV8 and architecture:component-theming-surface INV6, need an owner's approval on the final head, and spec-owner-approval is still pending. Both record fixes from the previous review are resolved, and two small ones remain before that approval:
- DEC-5 still says every state-dependent icon is a theme decision made through a slot resolver, while FR15 now limits that to icons a component exposes as a slot; scope DEC-5's first sentence the same way.
architecture:component-theming-surfaceexemptsIconVariantMapfromextensibleAxes.test.tswholesale, but FR3'stheme buildaugmentation relies on the guard's check that the map is declared in the component's publicindex.ts; limit the exemption to thethemeProps()reflection andvisualPropschecks.
[Automated review]
| A state-dependent icon is a theme decision made through a slot resolver, so every | ||
| instance follows one rule. Indicators keep stateful control marks, because they | ||
| draw a family's state rather than choose an icon. |
There was a problem hiding this comment.
This still reads as covering every state-dependent icon, but FR15 now limits the rule to icons a component exposes as a slot (a component that picks a shared name from its own state keeps doing so, as CodeBlock's copy feedback does). Since icon-resolution's deciding_specs cite DEC-5, could the first sentence be scoped the same way, for example "A state-dependent icon that a component exposes as a slot is a theme decision made through its resolver"?
| and consumer metadata. An artwork axis has none of that styling wiring: the | ||
| guard exempts it by an explicit list of artwork-request maps, currently | ||
| `IconVariantMap`, and its focused fallback test renders an unlisted name. |
There was a problem hiding this comment.
Icon.variant keeps the first piece of this wiring: FR3 makes IconVariantMap the public augmentable map, and the guard's first check (the map is declared in the component's index.ts, where theme build looks for it before it emits <theme>.variants.d.ts) is what keeps that augmentation working. Could the exemption cover only the themeProps() reflection and visualProps checks?
…flection checks only
There was a problem hiding this comment.
This spec is on hold for an engineering owner: spec:AST-087 and its amendments to six current records, including the intentional changes to architecture:icon-resolution-and-component-slots INV3 and INV8 and architecture:component-theming-surface INV6 and INV14, need an owner's approval on this exact head, and spec-owner-approval is still pending. Both record fixes from the previous review are resolved, and no other record defect remains, so approval of this head is the only open step. The failing pr-a11y check runs a test that exists on main but not on this branch, so it says nothing about these records.
[Automated review]
|
/approve-spec 0613ee9 |
Exact decision needed
Whether Astryx themes icons through:
variantrequest onIcon, with each theme listing its variant names once (iconVariants);componentIconsslots that accept a name,null, a static partial request, or a pure resolver of typed component state,instead of appearance and weight axes, per-library capability declarations, added size names, or an icon-role concept.
Record:
spec:AST-087(authority: currenton owner approval), plus the owning records it changes, amended in this PR.Existing authority searched
architecture:icon-resolution-and-component-slots(current), amended here: function entries and final function results;ComponentIconSlotMapvaluestrue | state shape; INV3 admits static requests and state resolvers; INV8 lets a slot request choose Icon size and variant while control geometry stays component-owned; new INV11 (a selected function answers the request; reads never return slot functions) and INV12 (indicators and slots do not overlap); slot state in component docs.architecture:theme-authoring-contract(current), amended here:iconVariantsandcomponentIconsinDefineThemeInput, same-key replacement onextends, node-valued and static public reads; new INV13–INV14.architecture:theme-compilation(current), amended here: built themes carry function entries, slot functions, and the variant list; new INV15 (built icon resolution matches runtime; tooling enumerates only listed variants).architecture:theme-application(current), amended here: function-bearing themes reachThemefrom client code; new INV11 (server and hydration agree).architecture:component-theming-surface(current), amended here: INV14 namesIcon.variantas a theme-extensible axis whose fallback (no variant) is theme-independent;Icon.sizestays closed.component:Icon(current), amended here: Variant concept, FR6 (size and listed variant reach registry entries only), FR7 (icontarget guaranteeswidth/heightonsize:*).defineTheme({indicators}): stateful control marks (selection check, radio, checkbox) stay indicators; FR15 and the architecture's INV12 keep one visual from being both.spec:AST-054) and its implementation PRs docs(authority): project complete AST-054 icon capabilities #7116, feat(core): add theme-defined Icon capabilities and build parity #7214, feat(core): add component icon role and state infrastructure #7219, feat(buttons): apply theme-owned icon styling to the Button family #7221, feat(core): add typed direct-icon library adapters #7222, feat(tooling): add generated icon role inventory and checks #7223 take the appearance/weight/capability/role direction. They are superseded by this record.spec:AST-088, draft): component-owned icon boxes following the theme dimension and default glyphs throughIcon, split out of this PR (formerly FR8–FR9) for a separate owner decision.astryx experimental icon, templates that use the installed set #7759 (spec:AST-084, icon set integrations) is CLI tooling and independent; its set data should align its terms withvariantandiconVariants.Decision
variant; a theme lists its names once; the list types the theme's entries and resolvers and, throughIconVariantMapaugmentation written bytheme build, product callsites; an unlisted variant reaches the entry asundefinedand renders the normal icon; Astryx never derives one type from several themes (TypeScript may merge the augmentations of several loaded themes; FR4 covers the rest).variantselects artwork only and is not a styling selector. Build tooling can enumerate every request (key × four sizes × no variant or a listed variant). Direct icon components never receivevariant.xsm | sm | md | lg; a theme sets their dimensions throughcomponents.icon['size:*'].IconName,null, a static{icon?, variant?, size?}, or a pure resolver of the slot's typed state. Fallback is field by field: a missingvariantkeeps the variant the component would otherwise request. A slot size changes only the Icon size.DefinedTheme['icons']stays node-valued,DefinedTheme['componentIcons']is a static view; runtime, built, extended, and server-rendered themes agree; malformed resolver fields degrade to missing with a development-only warning.Rejected alternatives
stringvariant; variant types derived by combining themes.Claim scope and non-goals
Out of scope: owned icon box sizing and default glyph routing (#7913); adapters for imported icon libraries; migrating the NumberInput namespaced key; removing released per-state icon props; replacing indicators.
Evidence and implementation relationship
Record originally authored by @imdreamrunner; this head keeps those commits and adds the owner-record amendments and the owner's edits (variant list, static slot requests, field-by-field variant fallback, static public view of slot data, indicator boundary).
Reusable groundwork from the superseded AST-054 implementation PRs by @rubyycheung: #7214 (theme build carrying icon functions, core-compatibility build tests) and #7221 (Button icon geometry fixtures) are the starting points for implementing FR19 and #7913. No implementation PR exists yet for this record.
Writing rubric results
Run over every record this PR touches (AST-087 and the six amended owners):
Rejected:line sits inside DEC-1, DEC-2, DEC-3, DEC-4, or DEC-9.#followed by digits,/pull/,/issues/).Scope
Validation
node scripts/check-knowledge.mjs: "Knowledge templates and records are aligned."--checkon all seven records: passes.git diff --check: clean.