Skip to content

feat(theme): add component icon mappings - #4647

Draft
cixzhang wants to merge 1 commit into
mainfrom
feat/component-icon-mapping
Draft

feat(theme): add component icon mappings#4647
cixzhang wants to merge 1 commit into
mainfrom
feat/component-icon-mapping

Conversation

@cixzhang

@cixzhang cixzhang commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Why

Some icon choices are component semantics rather than global glyph choices. Selector is a good example: its selected-option indicator defaults to check, but a theme may want that same purpose to render a different registry icon or no icon at all.

What

Adds themeable component icon mappings on top of the theme icon registry work:

  • Adds componentIcons to defineTheme() / DefinedTheme, inherited through extends.
  • Adds useIcon(slot, fallback) for component internals and getComponentIcon() / getComponentIconName() for explicit-source resolution.
  • Wires Selector's selected-option indicator through the selector-selected-option slot.
  • Documents component icon slots in component theming docs and CLI output.
  • Adds a Storybook demo with an ad hoc Selector theme remapping the selected-option slot.
  • Preserves componentIcons in astryx theme build output.

Risk

The default Selector selected option remains a check icon. Themes can now remap or suppress that purpose through componentIcons; this is additive unless a theme opts in.

Testing

  • pnpm exec vitest run --project ui packages/core/src/Icon/globalIconRegistry.test.tsx packages/core/src/Selector/Selector.test.tsx packages/core/src/theme/defineTheme.test.ts --reporter=dot
  • pnpm exec vitest run --project node packages/cli/clients/cli/lib/component-format.test.mjs packages/cli/api/theme/build/build.test.mjs --reporter=dot
  • pnpm -F @astryxdesign/core typecheck
  • pnpm -F @astryxdesign/core lint
  • pnpm -F @astryxdesign/cli typecheck:authoring
  • pnpm check:sync
  • pnpm check:package-boundaries
  • pnpm check:changesets
  • pnpm -F @astryxdesign/core build

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 2, 2026
@vercel

vercel Bot commented Aug 2, 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 Aug 3, 2026 2:51am

Request Review

targets: [
{className: 'astryx-selector', visualProps: ['size', 'status']},
{className: 'astryx-selector-option'},
{className: 'astryx-selector-selected-option-icon'},

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.

Should this leave a className?

{className: 'astryx-selector-clear-icon'},
{className: 'astryx-selector-indicator-icon', states: ['state']},
],
icons: [

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.

Let's also include a table for this in the docsite's canary theming section

Comment thread packages/core/src/Selector/Selector.tsx Outdated
</span>
{isSelected && <Icon icon="check" size="sm" color="accent" />}
{isSelected && selectedOptionIcon != null && (
<span

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.

Hmm should we handle most of this logic within Icon instead?

@cixzhang
cixzhang force-pushed the feat/component-icon-mapping branch from 35bbb09 to c6585c0 Compare August 2, 2026 17:37
@cixzhang
cixzhang force-pushed the feat/component-icon-mapping branch from c6585c0 to c740262 Compare August 2, 2026 17:51
@cixzhang
cixzhang changed the base branch from feat/ssr-theme-icon-registry to main August 2, 2026 17:51
@cixzhang
cixzhang force-pushed the feat/component-icon-mapping branch from c740262 to a6a370c Compare August 2, 2026 22:36
@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Aug 2, 2026
@cixzhang
cixzhang force-pushed the feat/component-icon-mapping branch from a6a370c to 769abee Compare August 3, 2026 01:54
@github-actions

github-actions Bot commented Aug 3, 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

Icon (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 588 -
Complexity N/A High (28) -
Selector (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 1324 -
Complexity N/A Very High (112) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.9KB 1.3KB

Accessibility Audit

Status: 1 accessibility violation(s) found — 1 serious.

Icon - 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/18 stories · Learn more
    • WCAG: 1.4.3 (Level AA)

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

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