Skip to content

feat(theme): a theme lists its icon variant names once - #8756

Merged
imdreamrunner merged 7 commits into
mainfrom
icons/ast087-icon-variants
Oct 28, 2026
Merged

imdreamrunner merged 7 commits into
mainfrom
icons/ast087-icon-variants

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Follows #8753 (function icon entries), which is merged; this PR is now based on main.

User need

A theme whose icon library draws several variants of one glyph (outline and filled, for example) needs one place to say which variant names it supports, and its icon entries need those names typed, so a misspelled 'filed' fails to compile instead of silently drawing the normal artwork.

Without a theme-level list, every entry would branch on a bare string with no type help. Tooling would also have no finite set of names to enumerate, and an application would have no public type for the names it may request. An extends child also needs a predictable rule for whether it keeps its base's names.

Problem and solution fit

  • iconVariants (primary). DefineThemeInput.iconVariants lists the variant names the whole theme supports. A child that sets it replaces the inherited list; a child that omits it inherits it. DefinedTheme['iconVariants'] reads the theme's list back.

  • Typed entries (supporting). Inside defineTheme, an entry function receives variant typed as the theme's listed names: its own list, else the list it inherits. Comparing with an unlisted name is a type error.

  • IconVariantMap / IconVariant (supporting). The public, augmentable IconVariantMap is declared in @astryxdesign/core/Icon, and IconVariant is its names. They type variant for process-wide registerIcons() entries, and the next PR's <Icon variant> prop.

  • Theme build keeps the artwork axis out of styling enrollment (supporting). astryx theme build finds augmentable maps by the <Component><Prop>Map naming convention, so declaring IconVariantMap made a components.icon['variant:<name>'] styling key count as an enrolled value: the root wrote an IconVariantMap augmentation, and an adaptation-only rule failed the build. Icon.variant has no component styling map (component-theming-surface INV14), so the build now skips an explicit artwork-request list and such a key stays unresolved pass-through, as before.

  • Built themes keep the list (supporting, built/runtime parity). astryx theme build writes iconVariants, an explicit [] included, into the built module's inheritable fields. A built theme, and a theme that extends it, read the same list as the runtime theme. No other theme-build output changes.

  • CLI goldens (supporting). The new Icon Variants docs section changes the icons topic tree and the search counts captured in packages/cli/test/__golden__/no-icon-set/*. They are regenerated.

Nothing passes a variant yet: entries still receive variant: undefined. The variant request, and the rule that only active-theme-listed names reach an entry, come in the next stacked PR.

Current specification

  • spec:AST-087 (current): FR2 (a theme lists its variant names once; a child that sets the list replaces it, one that omits it inherits it), FR3 (types only: entry functions inside defineTheme receive variant typed as the listed names; IconVariant is the names in the public, augmentable IconVariantMap), FR18 (DefinedTheme['iconVariants'] is the theme's list), and the iconVariants part of FR19 (a built theme carries the list, so built and runtime themes, and themes extending them, read the same list). DEC-9.
  • architecture:theme-compilation → System model item 7 (a built theme carries its iconVariants list in its JavaScript): the list part only.
  • architecture:theme-authoring-contract → System model (an explicit iconVariants list replaces the inherited list; an omitted list is inherited; entry functions receive variant typed as the theme's listed names), INV3, INV14 (the list is theme-level and never combined with another theme's list).
  • architecture:icon-resolution-and-component-slots → Owning code (the public @astryxdesign/core/Icon subpath declares the interface consumers augment).
  • architecture:component-theming-surface → INV14 (Icon.variant is an artwork axis whose names live in IconVariantMap).

Not in this PR: <Icon variant> and variant gating (next PR); the rest of theme build output (carrying function entries and per-entry defining lists, augmenting IconVariantMap from a built theme, INV15 enumeration); componentIcons slots; and FR8 enumeration.

Public delta and caller burden

New defineTheme field:

// Before: no way to declare variant names.
defineTheme({name: 'brand', icons: {info: <InfoIcon />}});

// After:
const brand = defineTheme({
  name: 'brand',
  iconVariants: ['outline', 'filled'],
  icons: {
    info: ({size, variant}) =>
      // variant: 'outline' | 'filled' | undefined
      variant === 'filled' ? <InfoFilledIcon /> : <InfoIcon bold={size === 'sm'} />,
  },
});
brand.iconVariants; // ['outline', 'filled']

defineTheme({name: 'brand-dense', extends: brand}).iconVariants; // inherited: ['outline', 'filled']
defineTheme({name: 'brand-bold', extends: brand, iconVariants: ['bold']}).iconVariants; // replaced: ['bold']

New public types in @astryxdesign/core/Icon (and the package root):

export interface IconVariantMap {}
export type IconVariant = keyof IconVariantMap & string;

// An application declares the names it uses:
declare module '@astryxdesign/core/Icon' {
  interface IconVariantMap {
    outline: true;
    filled: true;
  }
}

Changed types:

  • IconRequest<Variant extends string = IconVariant> and IconEntry<Variant extends string = IconVariant> gain a type parameter. With an empty map, IconVariant is never, so variant stays undefined-only, as in feat(Icon): a theme icon entry can be a function of the requested size #8753.
  • DefinedTheme['iconVariants']: ReadonlyArray<string> | undefined (new optional field).
  • defineTheme infers iconVariants (as a const list) and the extends base. It returns ResolvedDefinedTheme<Names>, where the new type parameter defaults to string, so existing ResolvedDefinedTheme annotations keep compiling.
  • DefineThemeInput gains two type parameters with defaults. An annotated const input: DefineThemeInput = {…} keeps working; its entries receive variant: string | undefined.
  • A base typed as plain DefinedTheme gives a child's entries variant: string | undefined, because its names are not known statically. A base from defineTheme gives its exact names.

Caller decisions: none for existing callers. A theme author who adopts variants chooses the names once per theme. An application that wants typed names augments IconVariantMap.

Compatibility: additive. A theme without iconVariants has no list (the field is absent) and behaves exactly as before. Assignability and comparison between theme types are unchanged: the exact names travel on a type-only, method-shaped optional marker of ResolvedDefinedTheme, never on DefinedTheme itself. So let active = defineTheme({name: 'app'}); active = defineTheme(shared); still compiles, as do assertions between DefinedTheme and resolved themes.

Theming and accessibility: no runtime rendering change.

Design and alternatives

  • The list is normalized like the other inherited theme data: the theme's own copy when it sets the field (later edits to the authored array do not leak in), otherwise the base's list.
  • Typing: defineTheme<const IconVariants, Base> infers the names from iconVariants and from extends only, never from an entry function's parameter annotation (a deferred indexed access blocks that inference without NoInfer, so older TypeScript versions read the declarations). A child's names are its own list when set, otherwise the base's.
  • Rejected by the spec (DEC-9): per-icon variant lists, an open string with no list, merging a child's list with its base's, and Astryx deriving one variant type from several themes' lists. Also rejected here: making DefinedTheme generic over the names. A list-less theme would then type iconVariants as ReadonlyArray<never>, and existing type assertions between DefinedTheme and a resolved theme would stop compiling.
  • IconVariantMap is declared literally in Icon/index.ts, the module consumers augment, as the record requires. No *Props field uses IconVariant yet, so the extensible-axis guard is unaffected until the next PR.

Evidence

  • defineTheme.test.ts (iconVariants suite): resolved themes with and without lists stay assignable to each other and to ResolvedDefinedTheme (this fails with a property-shaped marker); the list is kept as the theme's own copy; no list in the lineage → no field; a child inherits; a child replaces (including with []) without changing the base; type assertions for own, inherited, replaced, absent, and plain-DefinedTheme base names, plus @ts-expect-error for unlisted names ('bold' in a theme that lists outline/filled, and 'filled' after a child replaced the list with ['bold']); entries still receive no variant.
  • globalIconRegistry.test.tsx (variant names suite): an augmentation of IconVariantMap types IconVariant and registerIcons() entries, and an unaugmented name is a type error; listed themes still pass variant: undefined.
  • build.adaptation-enrollment.test.mjs: icon + variant:filled is accepted on the root without generating an augmentation, and is accepted rule-only. It fails without the build fix once the core declarations include IconVariantMap. build.test.mjs, build.icon-lineage, build.heading-core-compat, build.adaptation-core-compat: 74 passed.
  • build.icon-variants.test.mjs builds themes and imports the generated modules: a built theme reads the same list as its runtime theme; a theme extending the built one inherits the list or replaces it, matching the same child of the runtime theme; [] is kept and inherited; a list-less theme writes no field. Three of the four cases fail without the serialization. All packages/cli/api/theme/build suites pass.
  • packages/cli/test/experimental-isolation.test.mjs: 34/34 with regenerated goldens.
  • scripts/check-theme-template.test.mjs: the template documents iconVariants. The guard's interface regex now accepts the generic DefineThemeInput<…> declaration (supporting change, one line).

Scope

  • One capability is added.
  • Unrelated fixes, cleanup, and policy changes were removed or split.
  • Consumer docs, focused tests, and migration evidence ship with the feature.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run packages/core/src/Icon packages/core/src/theme scripts/check-theme-template.test.mjs: 1692 passed.
  • pnpm vitest run packages/core/src/IconButton packages/core/src/utils/touchPresentation.test.ts packages/core/src/theme packages/cli/api/theme/build/build.icon-lineage.test.mjs: 1606 passed.
  • pnpm vitest run packages/cli/api/docs scripts/check-theme-template.test.mjs: 176 passed. build.test.mjs -t "theme template" (the shipped template builds with no warnings): passed.
  • pnpm vitest run packages/core/src: 14455 passed. Of the failures, postinstall.test.mjs and the Markdown.fr23.perf.test.ts timing tests also fail on clean main here. The rest (DateTimeInputTouch, a MultiSelector bottom-sheet test, and the Table.perf budgets) fail only under the parallel full-suite load: 241 + 12 tests pass when those files run on their own.
  • pnpm -F @astryxdesign/core typecheck (including typecheck:docs): clean.
  • eslint on changed files: 0 errors, 0 warnings. prettier --check on changed TS/MD files: clean.
  • pnpm check:repo (pre-commit hook): passes. node scripts/check-changesets.mjs: passes.

@vercel

vercel Bot commented Oct 27, 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 Oct 28, 2026 3:37am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 28, 2026, 4:01 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 27, 2026
@imdreamrunner
imdreamrunner marked this pull request as ready for review October 27, 2026 22:54

@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.

Changes requested: the runtime iconVariants list and its typing match AST-087, but astryx theme build does not yet handle the new field consistently.

  • Built themes drop iconVariants, so a built theme and any theme extending it read no list; write it from inheritableFields in packages/cli/api/theme/build/build.mjs and add a build test that a built theme and its child keep the list.
  • Declaring IconVariantMap makes the build treat a components.icon['variant:<name>'] styling rule as an enrolled value (it now writes an IconVariantMap augmentation, and fails the build when the rule sits only under an adaptation); exclude artwork-request maps from component-value enrollment and cover that with a build test.

[Automated review]

* The icon variant names this theme supports: its own `iconVariants`, or
* the list it inherited. Absent when no theme in its lineage lists any.
*/
iconVariants?: ReadonlyArray<string>;

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.

astryx theme build does not serialize this new DefinedTheme field: inheritableFields in packages/cli/api/theme/build/build.mjs (lines 2131–2154, whose comment asks to stay in sync with DefinedTheme) writes no iconVariants. A built defineTheme({name: 'probe', iconVariants: ['outline', 'filled']}) reads iconVariants as undefined, and a theme extending the built module inherits no list. architecture:theme-compilation (System model, item 7) requires built JavaScript to carry the list; please write it there and add a build test for the built theme and a child of it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Declining this in this PR: it is built output, not this PR's scope. This PR implements spec:AST-087 FR2, the FR3 types, and the iconVariants part of FR18 for defineTheme themes. Serializing the list into built JavaScript belongs to FR19 and architecture:theme-compilation (System model item 7, INV15). That is the separate theme-build change, which FR3 also gives the job of writing the IconVariantMap augmentation from a built theme's list. Built output carrying function entries, the per-entry defining lists that <Icon variant> uses, and the list is one coherent change; serializing only the list here would ship half of it. This PR changes no build output for existing themes (the enrollment fix above keeps it that way), and the PR description lists built output under "Not in this PR". I have flagged the gap to the owner.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added in e920fdb, for parity between built and runtime themes, following the owner's standing rule that every new theme setting also works in built themes. iconVariants is now an inheritable field of the built module, an explicit [] included. The new build.icon-variants.test.mjs builds themes and imports the generated modules. It checks that a built theme reads the same list as its runtime theme, that a theme extending the built one inherits the list or replaces it exactly as it would extending the runtime theme, that [] is kept and inherited, and that a list-less theme writes no field. Three of the four cases fail without the serialization. Nothing else in theme build changes: carrying function entries and the per-entry defining lists, and the INV15 enumeration, stay with the later theme-build change.

* ```
*/
// eslint-disable-next-line @typescript-eslint/no-empty-object-type -- augmentation point
export interface IconVariantMap {}

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.

Declaring this interface makes astryx theme build treat components.icon['variant:<name>'] as an enrolled custom value: classifyComponentValue (packages/cli/api/theme/build/build.mjs:1403) accepts any <Prefix><Prop>Map declared in @astryxdesign/core/<Component>. With this change, a theme with components: {icon: {'variant:filled': {…}}} gets a generated IconVariantMap augmentation for 'filled', and the same rule placed only under an adaptation fails the build; on the base neither happens. Icon.variant has no component styling map (architecture:component-theming-surface INV14), so the build should exclude this map from component-value enrollment.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in be6f60f. classifyComponentValue and the augmentation lookup in generateVariantDeclarationsAsync now skip an explicit artwork-request list (IconVariantMap), so a components.icon['variant:<name>'] key stays unresolved pass-through, as it was before the map existed. It writes no augmentation, and an adaptation-only rule builds. build.adaptation-enrollment.test.mjs adds the paired root/rule case; it fails without the fix once the core declarations include IconVariantMap.

@github-actions

github-actions Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Icon (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 758B 1.5KB +745B
Lines of Code 659 667 -
Complexity High High (26) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
charts/Chart N/A 64.1KB N/A N/A 20B N/A
charts/ChartTooltip N/A 53.3KB N/A N/A 20B N/A
core/AppShell 58.4KB 58.4KB 0B 11.8KB 11.8KB 0B
core/Banner 48.3KB 48.3KB 0B 10.1KB 10.1KB 0B
core/BaseTypeahead 54.8KB 54.8KB 0B 10.1KB 10.1KB 0B
core/BreadcrumbItem 66.9KB 66.9KB 0B 11.2KB 11.2KB 0B
core/Calendar 55.4KB 55.4KB 0B 10.2KB 10.2KB 0B
core/Carousel 50.7KB 50.7KB 0B 10.3KB 10.3KB 0B
core/ChatComposer 61.2KB 61.2KB 0B 11.0KB 11.0KB 0B
core/ChatDictationButton 47.0KB 47.0KB 0B 9.6KB 9.6KB 0B
core/ChatLayout 49.3KB 49.3KB 0B 10.1KB 10.1KB 0B
core/ChatLayoutScrollButton 46.9KB 46.9KB 0B 9.7KB 9.7KB 0B
core/ChatMessageMetadata 26.3KB 26.3KB 0B 4.0KB 4.0KB 0B
core/ChatSendButton 46.2KB 46.2KB 0B 9.3KB 9.3KB 0B
core/ChatToolCalls 32.3KB 32.3KB 0B 9.1KB 9.1KB 0B
core/CheckIndicator 9.0KB 9.0KB 0B 3.7KB 3.7KB 0B
core/CheckboxInput 50.4KB 50.4KB 0B 9.5KB 9.5KB 0B
core/CheckboxList 46.5KB 46.5KB 0B 8.3KB 8.3KB 0B
core/CheckboxListItem 54.5KB 54.5KB 0B 10.6KB 10.6KB 0B
core/Citation 26.4KB 26.4KB 0B 4.3KB 4.3KB 0B
core/CodeBlock 61.0KB 61.0KB 0B 10.8KB 10.8KB 0B
core/Collapsible 17.0KB 17.0KB 0B 4.4KB 4.4KB 0B
core/CommandPalette 51.4KB 51.4KB 0B 12.0KB 12.0KB 0B
core/CommandPaletteInput 32.8KB 32.8KB 0B 8.3KB 8.3KB 0B
core/ComplexSelector 56.3KB 56.3KB 0B 10.8KB 10.8KB 0B
core/ContextMenu 75.1KB 75.1KB 0B 14.8KB 14.8KB 0B
core/ContextMenuItem 53.4KB 53.4KB 0B 9.8KB 9.8KB 0B
core/DateInput 100.0KB 100.0KB 0B 14.9KB 14.9KB 0B
core/DateRangeInput 69.9KB 69.9KB 0B 11.4KB 11.4KB 0B
core/DateTimeInput 110.3KB 110.3KB 0B 15.4KB 15.4KB 0B
core/DialogHeader 49.3KB 49.3KB 0B 10.0KB 10.0KB 0B
core/DrawerHeader 49.4KB 49.4KB 0B 11.4KB 11.4KB 0B
core/DropdownMenu 73.2KB 73.2KB 0B 15.0KB 15.0KB 0B
core/DropdownMenuCheckboxItem 16.2KB 16.2KB 0B 5.7KB 5.7KB 0B
core/DropdownMenuItem 15.5KB 15.5KB 0B 5.3KB 5.3KB 0B
core/DropdownMenuRadioItem 16.3KB 16.3KB 0B 5.7KB 5.7KB 0B
core/DropdownMenuSubMenu 58.5KB 58.5KB 0B 9.7KB 9.7KB 0B
core/Field 44.7KB 44.7KB 0B 8.1KB 8.1KB 0B
core/FieldLabel 40.2KB 40.2KB 0B 6.7KB 6.7KB 0B
core/FieldStatus 10.4KB 10.4KB 0B 4.4KB 4.4KB 0B
core/FileInput 54.6KB 54.6KB 0B 10.5KB 10.5KB 0B
core/Icon 8.8KB 8.8KB 0B 3.7KB 3.7KB 0B
core/InputGroup 45.3KB 45.3KB 0B 8.2KB 8.2KB 0B
core/LayerProvider 63.9KB 63.9KB 0B 10.3KB 10.3KB 0B
core/Lightbox 51.7KB 51.7KB 0B 10.0KB 10.0KB 0B
core/Link 43.9KB 43.9KB 0B 7.7KB 7.7KB 0B
core/ListItem 54.0KB 54.0KB 0B 10.6KB 10.6KB 0B
core/Markdown 144.9KB 144.9KB 0B 17.6KB 17.6KB 0B
core/MobileNav 51.5KB 51.5KB 0B 10.2KB 10.2KB 0B
core/MobileNavToggle 46.7KB 46.7KB 0B 9.6KB 9.6KB 0B
core/MoreMenu 73.6KB 73.6KB 0B 15.0KB 15.0KB 0B
core/MultiSelector 73.4KB 73.4KB 0B 14.8KB 14.8KB 0B
core/NumberInput 56.2KB 56.2KB 0B 10.9KB 10.9KB 0B
core/Overlay 19.5KB 19.5KB 0B 3.8KB 3.8KB 0B
core/Pagination 85.3KB 85.3KB 0B 15.5KB 15.5KB 0B
core/PowerSearch 164.8KB 164.8KB 0B 20.1KB 20.1KB 0B
core/RadioList 46.0KB 46.0KB 0B 8.2KB 8.2KB 0B
core/RadioListItem 52.7KB 52.7KB 0B 9.8KB 9.8KB 0B
core/Selector 76.9KB 76.9KB 0B 15.2KB 15.2KB 0B
core/SelectorOption 14.5KB 14.5KB 0B 5.2KB 5.2KB 0B
core/SideNav 58.5KB 58.5KB 0B 10.7KB 10.7KB 0B
core/SideNavCollapseButton 47.2KB 47.2KB 0B 9.6KB 9.6KB 0B
core/SideNavHeading 55.2KB 55.2KB 0B 10.3KB 10.3KB 0B
core/SideNavItem 55.0KB 55.0KB 0B 10.3KB 10.3KB 0B
core/Slider 48.9KB 48.9KB 0B 8.7KB 8.7KB 0B
core/Step 32.9KB 32.9KB 0B 5.5KB 5.5KB 0B
core/Stepper 47.9KB 47.9KB 0B 9.7KB 9.7KB 0B
core/Switch 48.8KB 48.8KB 0B 9.5KB 9.5KB 0B
core/TabList 40.5KB 40.5KB 0B 7.3KB 7.3KB 0B
core/TabMenu 52.1KB 52.1KB 0B 10.2KB 10.2KB 0B
core/Table 84.4KB 84.4KB 0B 15.3KB 15.3KB 0B
core/TableCell 76.2KB 76.2KB 0B 15.1KB 15.1KB 0B
core/TableHeaderCell 75.9KB 75.9KB 0B 15.0KB 15.0KB 0B
core/TextArea 49.8KB 49.8KB 0B 9.5KB 9.5KB 0B
core/TextInput 54.1KB 54.1KB 0B 10.6KB 10.6KB 0B
core/Thumbnail 51.2KB 51.2KB 0B 11.1KB 11.1KB 0B
core/TimeInput 87.3KB 87.3KB 0B 13.9KB 13.9KB 0B
core/Timestamp 27.9KB 27.9KB 0B 9.7KB 9.7KB 0B
core/Toast 60.4KB 60.4KB 0B 9.9KB 9.9KB 0B
core/Token 30.0KB 30.0KB 0B 4.6KB 4.6KB 0B
core/Tokenizer 69.1KB 69.1KB 0B 16.7KB 16.7KB 0B
core/TopNav 52.4KB 52.4KB 0B 10.5KB 10.5KB 0B
core/TopNavHeading 54.7KB 54.7KB 0B 10.1KB 10.1KB 0B
core/TopNavMegaMenu 54.7KB 54.7KB 0B 11.0KB 11.0KB 0B
core/TopNavMenu 54.1KB 54.1KB 0B 10.3KB 10.3KB 0B
core/TreeList 38.7KB 38.7KB 0B 4.8KB 4.8KB 0B
core/Typeahead 62.0KB 62.0KB 0B 11.4KB 11.4KB 0B
lab/ChatEmojiPicker N/A 65.6KB N/A N/A 773B N/A
lab/ChatReactionBar N/A 66.2KB N/A N/A 1.1KB N/A
lab/CommentComposer N/A 94.6KB N/A N/A 1.9KB N/A
lab/CommentPin N/A 47.8KB N/A N/A 1.2KB N/A
lab/CommentThread N/A 216.5KB N/A N/A 2.4KB N/A
lab/Comments N/A 221.1KB N/A N/A 2.5KB N/A
lab/DiffViewer N/A 46.0KB N/A N/A 2.1KB N/A
lab/EmojiPicker N/A 63.4KB N/A N/A 722B N/A
lab/InfoTip N/A 21.8KB N/A N/A 458B N/A
lab/ListInput N/A 75.7KB N/A N/A 1.6KB N/A
lab/MobilePowerSearch N/A 147.1KB N/A N/A 1.4KB N/A
lab/MobileTokenizer N/A 92.6KB N/A N/A 809B N/A
lab/Schedule N/A 60.3KB N/A N/A 3.9KB N/A
lab/TransferList N/A 67.3KB N/A N/A 1.7KB N/A
lab/TransferListSelector N/A 72.8KB N/A N/A 1.9KB N/A
richtext/RichTextEditor N/A 271.3KB N/A N/A 2.6KB N/A
richtext/RichTextEditorToolbar N/A 212.9KB N/A N/A 454B N/A
richtext/RichTextView N/A 251.7KB N/A N/A 2.3KB N/A

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 Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 35.1KB 35.1KB 0B

Accessibility Audit

Status: No accessibility violations detected.

Visual Regression

57 of 504 shot(s) changed.

A change here is a question, not a failure: check whether the after is the
picture you intended. Record that review on the PR. Baseline maintenance is an
explicit dispatch of CI; this report never rewrites the baseline or adds a release gate.

component story theme mode pixels
Selector Indicator Space Bottom Sheet Narrow End RTL neutral light 753,933
Selector Indicator Space Bottom Sheet Wide Start neutral light 740,072
RichTextEditor Markdown parity: side by side probe dark 558,840
RichTextEditor Markdown parity: side by side probe light 540,756
Chat Full AI Chat probe light 230,823
Chat Full AI Chat probe dark 229,805
AppShell With Mobile Nav probe light 217,010
AppShell With Mobile Nav probe dark 216,960
Collapsible Dividers probe dark 66,445
Collapsible Dividers probe light 66,445
AppShell Playground neutral dark 65,198
AppShell Playground neutral light 63,788
Chat Default neutral dark 36,304
Chat Default neutral light 35,767
Chat Empty State probe light 23,531
Chat Empty State probe dark 22,622
ChatAutoScroll Scroll Behavior Comparison neutral dark 15,378
ChatAutoScroll Scroll Behavior Comparison neutral light 14,107
Chat With Attachments probe light 13,406
Chat With Attachments probe dark 11,232

and 37 more.


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

@imdreamrunner
imdreamrunner force-pushed the icons/ast087-icon-variants branch from e59ac65 to 5ddebb1 Compare October 28, 2026 01:29
@imdreamrunner
imdreamrunner changed the base branch from icons/ast087-function-entries to main October 28, 2026 01:29

@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.

Changes requested: the iconVariants list and its typing match AST-087 at runtime, but two fixes are needed before this can land.

  • astryx theme build still drops iconVariants, so a built theme and any theme that extends it have no list (architecture:theme-compilation System model item 7); please write it from inheritableFields in packages/cli/api/theme/build/build.mjs and add a build test for a built theme and a theme extending it.
  • A defineTheme() call with no list now returns ResolvedDefinedTheme<never>, so let active = defineTheme({name: 'app'}); active = defineTheme(shared); with shared: DefineThemeInput stops compiling, which a patch release must not do (AST-017 FR25); keeping list-less results assignable from ResolvedDefinedTheme, for example with a method-shaped __iconVariant marker, plus a type test for that reassignment, would fix it.

[Automated review]

Comment thread packages/core/src/theme/defineTheme.ts Outdated
* one types its icon entries by the list it inherits. Never set.
* @internal
*/
readonly __iconVariant?: IconVariant;

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.

readonly __iconVariant?: IconVariant makes defineTheme() return ResolvedDefinedTheme<never> for a theme with no list, so a variable inferred from such a call no longer accepts a ResolvedDefinedTheme value:

const shared: DefineThemeInput = {name: 'base'};
let active = defineTheme({name: 'app'});
active = defineTheme(shared); // TS2322 here; compiles on main

A useState(defineTheme({name: 'app'})) setter fails the same way. Declaring the marker as a method, __iconVariant?(variant: IconVariant): void, and reading it in BaseThemeIconVariant with __iconVariant?(variant: infer Variant): void, keeps these compiling while this PR's type tests still pass; a type test for the reassignment would lock it in.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 1323957. __iconVariant is now method-shaped (__iconVariant?(variant: IconVariant): void), and BaseThemeIconVariant infers from its parameter, so resolved themes with and without lists are mutually assignable again while extends still infers the exact names. The new type test in defineTheme.test.ts covers your reassignment (defineTheme(shared) into a list-less result), a listed result into a list-less one, a list-less result into a listed one, and either into ResolvedDefinedTheme. It fails with the property-shaped marker.

@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.

Changes requested: the iconVariants list, its typing, and the assignability of defineTheme() results now match AST-087 and AST-017, but astryx theme build still drops the list. A built theme and any theme that extends it have no iconVariants (architecture:theme-compilation System model item 7, architecture:theme-authoring-contract INV1), so please write the field from inheritableFields in packages/cli/api/theme/build/build.mjs, keeping an explicit [], and add a build test for a built theme and a theme extending it. At this revision the list is the only icon data that built and runtime themes need to share, so this fix does not wait on the later function-entry and variant-gating work.

[Automated review]

@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.

No further changes requested: the iconVariants list, its typing and the assignability of defineTheme() results match AST-087 and AST-017, and astryx theme build now keeps the list, with build.icon-variants.test.mjs showing that built and runtime themes, and themes extending them, read the same list. As an optional follow-up with the theme-build change that writes the IconVariantMap augmentation, consider typing a built theme's declaration by its list: a theme that extends a built theme currently sees variant as string, so a misspelled name compiles there.

[Automated review]

DefineThemeInput.iconVariants lists the variant names the whole theme
supports, and DefinedTheme['iconVariants'] reads the list back. A child
theme that sets the list replaces the inherited one; one that omits it
inherits it.

Inside defineTheme, icon entry functions receive variant typed as the
theme's listed names (or the inherited list). @astryxdesign/core/Icon
declares the augmentable IconVariantMap and its IconVariant names, which
type variant for process-wide registerIcons entries. No variant source
exists yet, so entries still receive variant: undefined.

Implements spec:AST-087 FR2, FR3 (types) and the iconVariants part of
FR18.
Declaring IconVariantMap in @astryxdesign/core/Icon made theme build's
<Component><Prop>Map convention treat a components.icon['variant:<name>']
styling key as an enrolled value: the root wrote an IconVariantMap
augmentation and an adaptation-only rule failed the build. Icon.variant
selects artwork and has no component styling map
(architecture:component-theming-surface INV14), so the build excludes
artwork-request maps from component-value enrollment; such a key stays
unresolved pass-through, as before the map existed.
…assignable

The type-only __iconVariant marker on ResolvedDefinedTheme was a
property, so a list-less defineTheme() result (ResolvedDefinedTheme<never>)
no longer accepted a ResolvedDefinedTheme value:
let active = defineTheme({name}); active = defineTheme(shared) stopped
compiling. The marker is now method-shaped, which keeps resolved themes
mutually assignable as before while extends still infers the exact names.
theme build wrote no iconVariants into the built module, so a built theme
and any theme extending it read no list while the runtime theme did. The
list is now an inheritable field of the built module, an explicit []
included, so built and runtime themes agree
(architecture:theme-compilation System model item 7; spec:AST-087 FR2,
FR18).

@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.

No changes requested: the iconVariants list, its typing and the built-theme copy match AST-087, existing defineTheme() callers still compile, and the new build tests guard both theme-build fixes. Two optional follow-ups for the later theme-build work: a theme that extends a built theme still sees variant as string because the built declaration is plain DefinedTheme, and two defineTheme() results whose lists differ are not assignable to each other (for example useState(brandA) followed by setTheme(brandB)), so theme-switching state needs a DefinedTheme annotation.

[Automated review]

* other, as they were before the list existed.
* @internal
*/
__iconVariant?(variant: IconVariant): void;

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.

Optional, non-blocking: because this marker carries the exact names, two defineTheme() results whose lists differ are not assignable to each other. With brandA listing ['outline', 'filled'], const [theme, setTheme] = useState(brandA); setTheme(brandB); fails (TS2345) for a brandB listing ['bold'], and the message points at __iconVariant. Code that compiles on main is unaffected and a DefinedTheme annotation on the state works; if this trade-off is intended, a line in the icons docs or a type test would make it explicit.

@imdreamrunner
imdreamrunner merged commit dae1747 into main Oct 28, 2026
76 checks passed
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 28, 2026
The search golden for "icon set" counted 370 on both sides: main's icon
variants section (meta#8756, meta#8758) and this pull request's keyboard section
each moved it from 369, so the merge kept 370 with no conflict while the
merged docs return 371. Regenerated with the test's --update.
@github-actions
github-actions Bot deleted the icons/ast087-icon-variants branch October 28, 2026 06:17
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 28, 2026
Main's icon changes (meta#8753, meta#8756, meta#8758, meta#8759) moved the `icon set` search
golden. Regenerated with `vitest run
packages/cli/test/experimental-isolation.test.mjs --update`: only the two
count lines differ from main.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 28, 2026
The no-icon-set search goldens conflicted: main's icon variants (meta#8756,
meta#8758) and the keyboard section this branch carries from meta#8559 both moved
the "icon set" count. Regenerated with the test's --update.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 28, 2026
The no-icon-set search goldens conflicted: main's icon variants (meta#8756,
meta#8758) and the keyboard section this branch carries from meta#8559 both moved
the "icon set" count. Regenerated with the test's --update.
vjeux added a commit to vjeux/astryx that referenced this pull request Oct 28, 2026
The no-icon-set search goldens conflicted: main's icon variants (meta#8756,
meta#8758) and the keyboard section this branch carries from meta#8559 both moved
the "icon set" count. Regenerated with the test's --update.

This branch was successfully deployed

1 active deployment
Preview — e3d59ecd Deployed Oct 28, 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant