Repository navigation
feat(Icon): request a theme's alternate icon artwork with variant - #8758
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsIcon (@astryxdesign/core) · View in Storybook
Component Size
Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included. Bundle Size SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: No accessibility violations detected. Visual Regression57 of 506 shot(s) changed. A change here is a question, not a failure: check whether the after is the
and 37 more. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
Recommending approval: <Icon variant> follows AST-087 FR3-FR5 and the Icon contract's FR6, and the new tests cover listed, unlisted, inherited, process-wide and supplied-component requests. Nothing needs to change in this pull request; it can merge once #8753 and #8756 have landed. One follow-up for the stack: built themes do not carry iconVariants yet, so a theme used through astryx theme build output draws the normal artwork for every variant until the build carries the list and each inherited entry's defining list.
[Automated review]
c41a9a7 to
e59ac65
Compare
38acbbb to
4d0203f
Compare
e59ac65 to
5ddebb1
Compare
4d0203f to
da3e4da
Compare
There was a problem hiding this comment.
Recommending approval: <Icon variant> follows AST-087 FR3-FR5 and the Icon contract's FR6, and the new tests cover listed, unlisted, inherited, process-wide, node and supplied-component requests. Nothing needs to change in this pull request; it can merge once #8756 has landed. One follow-up for the stack: built themes do not carry iconVariants yet, so a theme used through astryx theme build output draws the normal artwork for every variant until the build carries the list and each inherited entry's defining list.
[Automated review]
da3e4da to
6039ec3
Compare
There was a problem hiding this comment.
Recommending approval: <Icon variant> follows AST-087 FR3-FR5 and the Icon contract's FR6, and the new tests, which fail without the change, cover listed, unlisted, inherited, process-wide, node and supplied-component requests. Nothing needs to change in this pull request; it can merge once #8756 has landed. One follow-up for the stack: built themes do not carry iconVariants yet, so a theme used through astryx theme build output draws the normal artwork for every variant until the build carries the list and each inherited entry's defining list.
[Automated review]
6039ec3 to
a6cee12
Compare
There was a problem hiding this comment.
Requesting changes: <Icon variant> and its runtime gating follow AST-087 FR3-FR5 and the Icon contract's FR6, but a theme built with astryx theme build loses each inherited entry's defining variant list. Now that the built module carries iconVariants, a built child that widens the list hands an inherited entry a variant its defining theme never listed (a base that lists only outline draws its filled artwork), while the runtime theme withholds it, against AST-087 FR4 and FR19 and theme-compilation INV15. Please write __iconEntryVariants into the built module beside iconVariants (storing a defining theme with no list as [], since JSON drops undefined) and add a CLI build test that compares built and runtime resolution for an inherited entry under a replaced list.
[Automated review]
| * variants its defining theme lists. Only Astryx icon resolution reads it. | ||
| * @internal | ||
| */ | ||
| __iconEntryVariants?: Record<string, ReadonlyArray<string> | undefined>; |
There was a problem hiding this comment.
astryx theme build does not write this record: generateBuiltModule's inheritableFields (packages/cli/api/theme/build/build.mjs:2153-2178) now writes iconVariants but not __iconEntryVariants, so a built child that widens its list hands an inherited function entry variants its defining theme never listed, and a theme extending the built child does the same (AST-087 FR4 and FR19, theme-compilation INV15). Writing it there needs a JSON-safe value for a defining theme with no list: JSON.stringify drops undefined, which falls back to the active list, while recording [] (line 829) gates the same way.
5597a3f to
e3d59ec
Compare
a6cee12 to
1d7ff90
Compare
Icon takes an optional variant (an IconVariant name). In registry mode, the selected entry receives the requested variant only when the active theme lists it and, for a theme-supplied entry, the theme that defined the entry lists it too: an inherited function entry keeps its defining theme's list. Otherwise the entry receives undefined and draws its normal artwork. A process-wide registration receives the variants the active theme lists; node entries ignore variant. A directly supplied icon component never receives variant, and variant is never written to the DOM. It selects artwork only, so the icon theming target does not reflect it; the extensible-axis guard exempts IconVariantMap from the themeProps reflection and visualProps checks and asserts it stays unreflected. Implements spec:AST-087 FR4 and FR5, component:Icon FR6.
The icons topic gains the requesting-a-variant prose; the guard's artwork-request list now names the theme build's matching list.
1d7ff90 to
be4de55
Compare
Icon.doc.mjs now documents variant (IconVariant). The native contract generator keeps a prop whose type has no portable definition on the web, so Icon's web-only list is variant and xstyle; the contract test now names both with their reasons.
There was a problem hiding this comment.
Requesting changes: <Icon variant> and its runtime gating follow AST-087 FR3-FR5 and the Icon contract's FR6, but a theme built with astryx theme build loses each inherited entry's defining variant list. The built module carries iconVariants but not the new __iconEntryVariants, so a built child that widens its list hands an inherited entry a variant its defining theme never listed (a base that lists only outline draws its filled artwork) while the runtime theme withholds it, against AST-087 FR4 and FR19 and theme-compilation INV15. Please write __iconEntryVariants into the built module beside iconVariants (recording a defining theme with no list as [], since JSON drops undefined) and add the INV15 build fixture that compares built and runtime resolution for an inherited entry under a replaced list.
[Automated review]
|
Not adding |
…riant list theme build wrote iconVariants but not __iconEntryVariants, so a built child that widens its list passed an inherited function entry a variant its defining theme never listed, while the runtime theme withheld it. The built module now carries the per-entry lists as an inheritable field, a defining theme with no list written as [] (JSON drops undefined), so built and runtime themes pass an inherited entry the same variants (spec:AST-087 FR4, FR19; architecture:theme-compilation INV15).
|
Added in adf6421, for parity between built and runtime themes. The owner revised the scope for this one field. |
There was a problem hiding this comment.
Recommending approval: <Icon variant> follows AST-087 FR3-FR5 and the Icon contract's FR6, and astryx theme build now writes each inherited entry's defining variant list, so a built theme resolves variants exactly as its runtime theme does (AST-087 FR19, theme-compilation INV15). The new build fixture covers an inherited entry under a widened list and under a list-less base, and it fails without the change. Nothing else needs to change in this pull request.
[Automated review]
Follows #8753 (function icon entries) and #8756 (theme icon variant list), both merged; this PR is now based on
main.User need
A product shows the same semantic icon in two looks, for example an outline
infonormally and a filled one for emphasis or a selected state, and wants the active theme to supply both from its own icon library. With #8753 and #8756 a theme can listoutline/filledand map them to artwork, but nothing can ask for a variant yet, so every icon still renders the normal artwork.The request has to be safe across themes. One app may load several themes that list different names, and a theme an app does not control must still render something sensible when it lacks the requested name. Composition does not cover this: swapping in a different icon component at the call site bypasses the theme entirely, so the theme cannot decide.
Problem and solution fit
<Icon variant>(primary).Icontakesvariant?: IconVariant. In registry mode, the selected entry receives it.undefinedand draws its normal artwork: an omitted variant, an unlisted variant, and no active list all behave this way. A process-wide registration receives the variants the active theme lists. A node entry ignoresvariant.variant, andvariantis never written to the DOM. Theicontheming target does not reflect it, so it has no styling selector.astryx theme buildwrites the per-entry defining lists (__iconEntryVariants) besideiconVariantsas an inheritable field. A defining theme with no list is written as[], because JSON dropsundefined. A built child that widens its list then passes an inherited entry only its defining theme's variants, as the runtime theme does.architecture:component-theming-surfaceINV14 change coupling).IconVariantMapnow types a component prop, so the extensible-axis guard discovers it. The guard keeps its public-map check and exempts it from thethemeProps()reflection andvisualPropschecks by an explicit artwork-request list. It also asserts the axis stays unreflected.Current specification
spec:AST-087(current): FR4 (an unlisted variant renders the normal icon; the active-theme and defining-theme lists; process-wide registrations; node entries), FR5 (novariantfor supplied components or the DOM; the target does not reflect it), and the defining-list part of FR19 (a built theme passes an inherited entry the same variants as its runtime theme). DEC-1, DEC-9.architecture:theme-compilationINV15 (built icon resolution matches runtime): the inherited-entry defining-list part only.component:Icon(current): FR6 (registry mode passes{size, variant}under those rules; a supplied component never receivesvariant; no DOM forwarding; no target reflection). The Public concepts row for Variant: names inIconVariantMap; registry glyphs only; default none; unknown names are a type error; unlisted names render normal artwork.architecture:component-theming-surfaceINV6 and INV14 (Icon.variantis an artwork request with a theme-independent fallback, nothemeProps()reflection, and novisualPropsentry), plus its change-coupling rule for artwork axes inextensibleAxes.test.ts.architecture:icon-resolution-and-component-slots→ Shared icon resolution (a theme-supplied entry, including an inherited one, receives a variant only when its defining theme also lists it).architecture:theme-authoring-contract→ System model (an inherited function entry keeps the list of the theme that defined it).Not in this PR:
componentIconsslots and slot requests; FR8 enumeration; FR10 size dimensions; the rest of theme build output (node-valued built public reads, such as theiconsexport read at{size: 'md'}); and FR20 malformed-output warnings.Public delta and caller burden
New
Iconprop:variant?: IconVariant, whereIconVariant = keyof IconVariantMap & string. Without an augmentation it isnever, so only augmented names type-check.undefined).{size, variant}when the variant is receivable, otherwise{size}.Behavior matrix:
registerIcons()entryundefinedundefinedundefinedundefinedUnchanged: public reads (
getIcon,getExtendedIcon,getIconRegistry,useIcon,theme.icons) still read at{size: 'md'}with no variant. Theicontarget'sdata-size/data-color, sizing, color, label semantics, and every Icon withoutvariantrender as before.Caller decisions: a product decides when to request a variant and, to type it, augments
IconVariantMap(#8756). It does not need to know which themes list the name: an unlisted request renders the normal icon.Compatibility: additive.
variantwas not previously accepted. Existing usages, direct components, and themes withouticonVariantsbehave identically.Accessibility: no change.
variantadds no semantics and does not affectlabel/aria-*.Design and alternatives
Icondestructuresvariant, so it never reaches the supplied component or the span's props. It passes{size, variant}to the internal resolver, which selects one source and then decides receivability from the selection: theme entry → the active list and the defining list; process-wide → the active list; built-in default → none.defineThemerecords, for each inherited function entry, its defining theme's list only where that differs from the theme's own list (an internal field). An entry the theme defines uses the theme's own list. A list-less theme, or a child that inherits its base's list unchanged, records nothing. The record carries through several levels ofextends.variantas a styling selector (FR4, FR5,component-theming-surfaceINV14).Evidence
Icon.test.tsx(newvariantsuite): listed ({size: 'sm', variant: 'filled'}reaches the entry); omitted; unlisted (the INV14 focused fallback test renders an unlisted name); no active list; an inherited entry under a child that widened the list (filled→ normal artwork,outlinepasses, the child's own entry getsfilled); an inherited entry under a child that narrowed the list, and under a child that inherited it; process-wide registration under a listing theme, a non-listing theme, and no theme; node entries; a supplied component receives novariantprop; neither render mode writesvariant/data-variantto the DOM;@ts-expect-errorfor a name not inIconVariantMap.globalIconRegistry.test.tsx: resolver gating for theme, process-wide, and built-in default entries; the defining list kept through twoextendslevels; public reads never pass a variant even when listed.extensibleAxes.test.ts:Icon.variant (IconVariantMap)keeps the augmentable-index check; it is exempt from the reflection andvisualPropschecks; the exemption list matches discovered axes; the artwork axis is asserted unreflected and undocumented as a visual prop.packages/cli/test/experimental-isolation.test.mjs: 34/34 with goldens regenerated for the requesting-a-variant prose inastryx docs icons.build.icon-entry-variants.test.mjs(INV15 fixture) builds a base theme listingoutlinewith a function entry, and a child widening the list tooutlineandfilled. It renders<Icon variant>under the built and runtime children in a native ESM load: both passoutlineand draw normal artwork forfilled. A list-less base under a child listingfilledpasses no variant either way. The first assertion fails without the serialized field, the second without the[]. Allpackages/cli/api/theme/buildsuites pass (269).packages/native/src/contract/contracts.test.ts: the native contract generator keepsvarianton the web, becauseIconVarianthas no portable definition yet. Icon's web-only list is nowvariantandxstyle, each with its reason. No generated Swift changes.Native support for
variantis not part of AST-087 and is not added here.Scope
Testing
pnpm vitest run packages/core/src/Icon packages/core/src/theme: 1698 passed.pnpm vitest run packages/cli/api/component packages/cli/api/docs: 259 passed.pnpm vitest run packages/cli/api/api-docs-parse.test.mjs packages/cli/api/discover packages/cli/api/icon packages/core/src/theme/themingTargets.test.ts: 810 passed.pnpm vitest run packages/core/src: 14474 passed. Of the failures,postinstall.test.mjsand theMarkdown.fr23.perf.test.tstiming tests also fail on cleanmainhere. TheTable.perfrender budgets fail only under parallel full-suite load and pass when the file runs alone (12/12).pnpm vitest run packages/lab/src/Comments packages/richtext/src(consumers ofgetExtendedIcon): 665 passed.pnpm -F @astryxdesign/core typecheck(includingtypecheck:docs): clean.eslinton changed files: 0 errors, 0 warnings.prettier --checkon changed TS/TSX/MD files: clean.pnpm check:repo(pre-commit hook): passes.node scripts/check-changesets.mjs: passes.