Skip to content

fix(core): a side nav item's built-in icon has its own theme target, side-nav-item-icon - #12450

Closed
josephfarina wants to merge 37 commits into
mainfrom
fix/side-nav-item-icon-target
Closed

josephfarina wants to merge 37 commits into
mainfrom
fix/side-nav-item-icon-target

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Stack: #12378 → #12450

This pull request sits on #12378's head; #12378 lands first, and this one is judged on its own SideNavItem, SideNav and Icon files.

User impact

A theme can't color the icons in a side nav on their own. The icon a SideNavItem draws from its icon or selectedIcon prop carries only Icon's generic icon target. So a theme that wants accent-colored sidebar icons with neutral labels has to restyle every icon in the app, or write a structural selector. With this change, a theme styles side-nav-item-icon, and only side nav item icons change, in both the expanded and the collapsed rail.

Problem and solution fit

  • Why can't a theme reach it? The built-in icon is rendered by Icon, and it delegates to Icon's icon target. That target is shared by every icon in the product.
  • Why does it hurt the task? Side nav icons are a common place for a brand or accent color. The only ways to reach them recolor unrelated icons or depend on DOM structure.
  • Why does that matter? A theme that can't express "sidebar icons in the accent" either over-reaches or leaves the side nav at its default look.

The fix puts one target on the built-in icon's own element, the same way banner-icon works on Banner's status icon. It carries the row's selected and disabled states. It doesn't carry size, because the Icon reflects its own size on that element.

Expected behavior and authority

  • architecture:component-theming-surface INV4 (targets paint) and INV5 (composition keeps ownership unless the parent guarantees a distinct visual contract). component:SideNavItem now records that contract in AV2 and in the design relationships.
  • Same pattern as banner-icon in component:Banner.

Smallest restoration

  • SideNavItem draws its built-in icon with themeProps('side-nav-item-icon', {selected, disabled}) on the Icon element, once, for both rail modes. A ReactNode slot value is rendered as given, because Core doesn't inject props into consumer elements.
  • The check for "a value Icon draws" (a semantic name or an icon component) becomes drawsAsIcon in Icon.tsx, used by both renderIconSlot and SideNavItem, so they read a slot value the same way. It is Core-internal: the package entry does not export it, and no record names it. renderIconSlot's public signature and behavior are unchanged.
  • The target declares sitsOn: 'icon' and is listed among the compiler's shared-element parts, so a theme's side-nav-item-icon entry is written in the later parts sub-layer and wins over its icon entries on that element, keyed ones included (a test covers a keyed icon entry). This builds on the shared-element parts change in fix(core): a theme's entry for a part on another component's element wins over that component's entries #12378, which lands first; this branch sits on it.
  • The SideNav doc declares the target. The probe theme is regenerated, and the SideNavItem record is updated.
  • No StyleX change, no new prop, no new data attribute name.

Evidence

  • Reproduction before the change: no element in a rendered SideNav matches .astryx-side-nav-item-icon. The icon carries only astryx-icon.
  • Result after the change: each built-in item icon carries astryx-side-nav-item-icon, with data-selected="selected" or data-disabled="disabled" when the row has that state.
  • Representative unchanged path:
  • Regression test: SideNavItem.iconTarget.test.tsx checks both rail modes. The target sits on each built-in icon with the row's states. It never sits on a label, the row, the expand chevron, an icon outside the side nav, or a custom icon node.

Scope

Components: SideNavItem, SideNav (docs), Icon (internal check only)

Writing rubric results

  • R1 narration: AV2 and the design-relationships paragraph state what the system does, in the present tense. None found.
  • R2 research: none.
  • R3 evidence: no evidence cell names a pull request, issue or commit. The new AV2 verification row cites a test file, and the design-relationships row cites current source and public docs.
  • R4 rejected alternatives: none recorded.
  • R5 change references: none.
  • R6 open questions: none.
  • R7 project status: none.

Owner review

Owner review: component:SideNavItem is owned and approved by its design owner, so this change to its record (AV2, the design-relationships row and paragraph, the verification row, the compatibility class) needs the design owner's GitHub review. #12378 lands first.

Testing

  • vitest run packages/core/src/SideNav packages/core/src/Icon packages/core/src/theme/sharedElementParts.test.ts: all pass (541).
  • typecheck-sharded --project tsconfig.json for core: clean. eslint on the touched files: no new findings.
  • check:changesets and check:knowledge pass.
  • Built CSS compared before and after for core and every official theme: identical.
  • pnpm size:pages --base 1ad0fd4e (fix(core): a theme's entry for a part on another component's element wins over that component's entries #12378's head), first-load JavaScript (minified / gzip), with two added pages for INV10: the shared-element parts module this change grows is imported by the theme compiler, which the public Theme component runs at render, and ToastViewport renders a Theme. (The theme and toast rows were measured with the script's module lookup pointed at theme/Theme.js and Toast/ToastViewport.js, since those components do not sit in a folder of their own name.) The +8 B on form, menu and table come from Icon's drawsAsIcon check; the +28 B on the theme and toast pages are the added map entry:
Page Change
docs +0 B / +0 B
form +8 B / −6 B
menu +8 B / +7 B
table +8 B / +4 B
theme (Theme) +28 B / +11 B
toast (ToastViewport) +28 B / +9 B

… icon and the timestamp copy button; record the public layered outputs and the stage order with parts; docsite reads sitsOn
…check are shared-element parts; record wording
@vercel

vercel Bot commented Nov 17, 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 Nov 21, 2026 4:30am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 21, 2026, 4:48 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 17, 2026
@josephfarina

Copy link
Copy Markdown
Contributor Author

Owner decision (engineering owner, covering this pull request): a side nav item's built-in icon gets its own theme target, side-nav-item-icon, with the item's selected, disabled and size states, like banner-icon. Custom icons are untouched, and the default look is byte-identical. The SideNavItem record names the target, and a test shows it reaches only side nav item icons in both rails.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 51feb2a

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 098e77f

⏳ Building… Until it's ready, Storybook · Sandbox open the branch's previous preview.

Current run: The current CI run concluded cancelled. Current analysis is unavailable.


Generated by PR Enrichment workflow | View current CI run

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

Needs an owner decision before approval. The new side-nav-item-icon target, its state reflection and the SideNavItem record change are owner-approved at this head, and the default look is unchanged; one public API change has no deciding record. The owner-decision note settles the target and its states but does not mention renderIconSlot, so the open question below still needs an answer.

  • An engineering owner needs to decide whether renderIconSlot, exported from @astryxdesign/core, gains the public target?: ThemeProps parameter (packages/core/src/Icon/Icon.tsx:476), because no current record covers it; an owner (the author qualifies) can answer the review question, or name the parameter in a record and approve that head with /approve-spec <full head SHA>.
  • The description says the theme target is the only public addition, but the exported renderIconSlot signature also changes, so correct the description and the changeset, or keep the signature unchanged, following the owner's answer.
  • Add the first-load gzip deltas on the four reference pages that architecture:component-import-boundaries INV10 asks for when a shared module such as Icon.tsx grows; a pnpm size:pages run gives docs +12 B / −3 B, form +12 B / +1 B, menu +12 B / −1 B and table +12 B / −1 B (minified / gzip).

Non-blocking: the target's base entry loses to icon state entries such as size:sm on the same element (see the inline note), and the owner-decision note lists a size state that the record and code leave out, since the Icon already reflects its own data-size on that element.

Claims and files checked

Review mode: same-head; reason: none

  • Claim: before the change no side-nav element carried an icon-specific target — verified (the new test fails on the base).
  • Claim: each built-in icon carries the new target with the row's selected or disabled state, in both rails — verified (test; rendered markup).
  • Claim: a custom icon node is left untouched — verified (test; rendered markup).
  • Claim: the target leaves size to the Icon's own attribute — verified (SideNavItem.tsx:628-633).
  • Claim: renderIconSlot takes an optional target that a node value never gets — verified (Icon.tsx:473-488).
  • Claim: the doc declares the target, the probe theme is regenerated and the record is updated — verified (SideNav.doc.mjs:25; probe-theme check current).
  • Claim: no styling change, no new prop, no new data attribute name — verified for styling and attribute names; the exported renderIconSlot gains a parameter.
  • Claim: the theme target is the only public addition — false (renderIconSlot signature, Icon.tsx:476).
  • Claim: built CSS of Core and the seven official themes is identical — verified (equal sha256).
  • Claim: rendered markup differs only by the class and state attributes on the four built-in icons — verified with a client render of the same fixture.
  • Claim: the regression test covers both rails and excludes labels, rows, chevrons, other icons and custom nodes — verified.
  • Claim: the listed tests, typecheck, lint, changeset and knowledge checks pass — verified (re-run).
  • Changeset: the default look does not change, and a theme can colour side-nav icons apart from labels and other icons — verified, with the base-entry caveat above.
  • File .changeset/core-side-nav-item-icon-target.md — omits the renderIconSlot change; otherwise clear.
  • File docs/specs/components/SideNav/SideNavItem.spec.md — clear; non-blocking: no AV2 verification row.
  • File packages/core/src/Icon/Icon.tsx — public signature change awaiting an owner; INV10 deltas missing.
  • File packages/core/src/SideNav/SideNav.doc.mjs — clear.
  • File packages/core/src/SideNav/SideNavItem.iconTarget.test.tsx — clear.
  • File packages/core/src/SideNav/SideNavItem.tsx — clear; non-blocking cascade note.
  • File packages/themes/probe/src/probeTheme.ts — clear (regenerated; generator check current).

Automated review (maintainer link)

Comment thread packages/core/src/Icon/Icon.tsx Resolved
@astracat-bot

astracat-bot Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

In reply to @josephfarina

I'll run a full review to re-check this with your note.

@josephfarina
josephfarina force-pushed the fix/side-nav-item-icon-target branch from 51feb2a to 926848b Compare November 17, 2026 22:56
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 926848b

@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: one record gap. The side-nav-item-icon target, its selected and disabled reflection and the component:SideNavItem change are owner-approved at this head, and the default look is unchanged. The earlier renderIconSlot question is settled, because its exported signature no longer changes.

  • packages/core/src/Icon/iconSlotValue.ts is a new internal module that SideNav/SideNavItem.tsx imports from outside the Icon folder, and no record names it (architecture:knowledge-contracts DEC-22), so name it (its path or isDrawnIconValue) in a record such as component:Icon or component:SideNavItem AV2, say why renderIconSlot is not enough, and approve that head with /approve-spec <full head SHA>.

Non-blocking: the target's base entry still loses to icon state entries such as size:sm on enabled, unselected icons (see the inline note); the comment at SideNavItem.tsx:635-637 can keep only its reason; and the record's verified_by could list the new test.

Claims and files checked

Review mode: full; reason: rebase

  • Claim: before the change no side-nav element carries an icon-specific target — verified (the new test's placement cases fail on the base).
  • Claim: each built-in icon carries the new target with the row's selected or disabled state, in both rails — verified (test; probe-theme captures).
  • Claim: the target leaves size to the Icon's own attribute — verified (SideNavItem.tsx:631-634).
  • Claim: it follows the Banner status-icon pattern — verified (Banner puts its target on the status Icon).
  • Claim: a custom icon node is rendered as given — verified (SideNavItem.tsx:650-652; test).
  • Claim: the slot check moves into a Core-internal helper that the package does not export, used by both callers — verified; no record names the helper (the blocking finding).
  • Claim: renderIconSlot's public signature and behavior are unchanged — verified (Icon.tsx:471-480; the API surface comparison lists no row for it).
  • Claim: the doc declares the target, the probe theme is regenerated and the record is updated — verified (SideNav.doc.mjs:25; probe check current).
  • Claim: no styling change, no new prop, no new data attribute name — verified.
  • Claim: the theme target is the only public addition and no exported function changes — verified (one added target, two reflection counts).
  • Claim: built CSS of Core and the seven official themes is identical — verified (equal sha256).
  • Claim: rendered markup differs only by the class and state attributes on the built-in icons, and a custom icon is unchanged — verified (render path and rendered DOM; the default-theme frame is pixel-identical).
  • Claim: the regression test covers both rails and excludes labels, rows, the chevron, other icons and custom nodes — verified.
  • Claim: the listed tests, typecheck, lint, changeset and knowledge checks pass — verified (re-run).
  • Claim: first-load JavaScript per reference page grows by at most 8 B minified — verified (re-measured; gzip within a few bytes of the stated numbers).
  • Changeset: the built-in icon carries the target with both states in both rails, a custom node is left as is, and the default look does not change — verified.
  • Changeset: a theme can colour side-nav icons apart from labels and other icons — verified, with the base-entry caveat above.
  • File .changeset/core-side-nav-item-icon-target.md — clear.
  • File docs/specs/components/SideNav/SideNavItem.spec.md — clear (owner-approved at this head); non-blocking: the new test is not in verified_by.
  • File packages/core/src/Icon/Icon.tsx — clear (behavior-preserving).
  • File packages/core/src/Icon/iconSlotValue.ts — blocking: no record names this internal module.
  • File packages/core/src/SideNav/SideNav.doc.mjs — clear.
  • File packages/core/src/SideNav/SideNavItem.iconTarget.test.tsx — clear.
  • File packages/core/src/SideNav/SideNavItem.tsx — clear; non-blocking comment wording and cascade note.
  • File packages/themes/probe/src/probeTheme.ts — clear (generated; generator check current).

Automated review (maintainer link)

Comment thread packages/core/src/Icon/iconSlotValue.ts Resolved
@josephfarina
josephfarina force-pushed the fix/side-nav-item-icon-target branch from 926848b to 24b71bc Compare November 17, 2026 23:37
@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 24b71bc

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

Approved pending CI. The side-nav-item-icon target, its selected and disabled reflection and the component:SideNavItem record change are owner-approved at this head, and the record now names the internal isDrawnIconValue helper, which closes the earlier gap. CI is still running on this head, so this approval waits on it.

Non-blocking: the target's base entry still loses to Icon's own color: and size: entries on enabled, unselected icons (see the inline note); a line in AV2 on that precedence would help theme authors.

Claims and files checked

Review mode: full; reason: rebase

  • Claim: on the base, no side-nav element carries an icon-specific target and the icon carries only the shared icon target — verified (the new test's placement cases fail on the base; base captures).
  • Claim: each built-in icon carries the new target with the row's selected or disabled state, in both rails — verified (new test; probe captures of the expanded and collapsed rails).
  • Claim: the target leaves size to the Icon's own attribute — verified (SideNavItem.tsx:629-634; the test checks data-size="sm").
  • Claim: it follows the Banner status-icon pattern — verified (Banner's test asserts its target on the status Icon element).
  • Claim: a custom icon node is rendered as given — verified (SideNavItem.tsx:650; test).
  • Claim: the slot check moves into a Core-internal helper that the package does not export, used by both callers — verified (Icon/iconSlotValue.ts; the ./Icon entry does not re-export it).
  • Claim: renderIconSlot's public signature and behavior are unchanged — verified (Icon.tsx:471-480; the API surface comparison lists no row for it).
  • Claim: the SideNav doc declares the target, the probe theme is regenerated and the record is updated — verified (SideNav.doc.mjs:25; the probe check is current; AV2).
  • Claim: no styling change, no new prop and no new data attribute name — verified.
  • Claim: the theme target is the only public addition and no exported function changes — verified (one added target and two reflection counts).
  • Claim: the built CSS of Core and the seven official themes is identical — verified (equal sha256 for every built stylesheet).
  • Claim: rendered markup differs only by the class and state attributes on the built-in icons, and a custom icon is unchanged — verified (render path and rendered DOM; the default-theme frame is pixel-identical).
  • Claim: the regression test covers both rails and excludes labels, rows, the chevron, other icons and custom nodes — verified (test file).
  • Claim: the listed tests, typecheck, lint, changeset and knowledge checks pass — verified (re-run).
  • Claim: first-load JavaScript per reference page grows by at most 8 B minified — verified (re-measured; gzip within 1 B of the stated numbers).
  • Claim: the writing rubric results are listed and the record text is in the present tense — verified (AV2 and the design-relationships paragraph).
  • Changeset: the built-in icon carries the target with both states in both rails, a custom node is left as is, and the default look does not change — verified.
  • Changeset: a theme can color side-nav icons apart from labels and other icons — verified, with the base-entry caveat above.
  • File .changeset/core-side-nav-item-icon-target.md — clear.
  • File docs/specs/components/SideNav/SideNavItem.spec.md — clear (owner-approved at this head).
  • File packages/core/src/Icon/Icon.tsx — clear (behavior-preserving).
  • File packages/core/src/Icon/iconSlotValue.ts — clear (named in the approved record).
  • File packages/core/src/SideNav/SideNav.doc.mjs — clear.
  • File packages/core/src/SideNav/SideNavItem.iconTarget.test.tsx — clear.
  • File packages/core/src/SideNav/SideNavItem.tsx — clear; non-blocking cascade note.
  • File packages/themes/probe/src/probeTheme.ts — clear (generated; the generator check is current).

Automated review (maintainer link)

@josephfarina
josephfarina force-pushed the fix/side-nav-item-icon-target branch from 790c119 to 098e77f Compare November 21, 2026 04:20
@github-actions
github-actions Bot requested a review from rubyycheung November 21, 2026 04:20
@josephfarina

Copy link
Copy Markdown
Contributor Author

Engineering owner's approval for the SideNavItem.spec.md changes at this head, so the repository's spec gate is clear. The design owner's GitHub review is still required before this merges.

@josephfarina

Copy link
Copy Markdown
Contributor Author

/approve-spec 098e77f

@github-actions github-actions Bot removed the needs:spec-owner-review Current knowledge records await owner approval label Nov 21, 2026

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

Approved pending CI for #12450: the build and test checks have not run on this head yet.

#12450 — approved pending CI

The side-nav-item-icon target lands on every built-in side-nav icon in both rails with the row's selected and disabled states, beats keyed icon entries unless an icon value is !important, and leaves the default look and the published themes' CSS unchanged; the component:SideNavItem record change has an engineering owner's approval for this head.

#12378 — needs an owner decision (its own review)

  • Its review at its current head waited on an engineering owner's /approve-spec for its record changes; that comment was posted after the review, so #12378's own re-review records it. No blocking finding.

Whole stack — passes: the two pull requests agree and merge cleanly into main. #12450 lands only when it and #12378 are both approved.

Claims and files checked

Review mode: full; reason: rebase

  • #12450 claim: before the change no side-nav element carries an icon target of its own — verified (browser reading on #12378's head: every icon carries only Icon's class).
  • #12450 claim: each built-in icon carries the target with the row's selected or disabled state, in both rails, and keeps its own size attribute — verified (new test; browser readings on three stories).
  • #12450 claim: the target sits on the Icon element as Banner's status icon target does — verified (Banner applies its icon target to its Icon the same way).
  • #12450 claim: the target is applied once for both rails, and a custom icon node is rendered as given — verified (source; test; server markup).
  • #12450 claim: the slot check is shared by the slot renderer and SideNavItem, is internal, unexported and named by no record, and the slot renderer keeps its signature and behaviour — verified (Icon entry exports; source; record search).
  • #12450 claim: the target sits on Icon in the compiler's parts list, so its entries beat keyed icon entries — verified (unit test; probe-theme readings on unselected rows).
  • #12450 claim: the SideNav doc declares the target, the probe theme is regenerated and the SideNavItem record is updated — verified (probe-theme check passes).
  • #12450 claim: no StyleX change, no new prop and no new attribute name; the theming target is the only public addition and no package export changes over #12378's head — verified (API comparison: one target row and two attribute reflection counts).
  • #12450 claim: over #12378's head, Core and the seven official themes build byte-identical CSS — verified (hashes of every built stylesheet).
  • #12450 claim: server markup of both rails differs only by the class and state attributes on the four built-in icons — verified (server-render comparison).
  • #12450 claim: the listed tests pass (541), ESLint, changeset and knowledge checks pass, and core typechecks — verified (all run here).
  • #12450 claim: first-load size deltas for the reference, Theme and toast pages — consistent: this review's own measurement finds the same few-byte changes on the four reference pages by a different build route; the Theme and toast rows were not re-measured.
  • #12450 changeset (the icon target as a feature, winning over icon entries except an important icon value, custom nodes untouched, default look unchanged) — verified.
  • #12378 claims and its two changesets — checked in its own review at its current head.
  • #12450 files: the SideNavItem component, its target test, the SideNav doc, the Icon component, the SideNavItem record, the parts list and its test, the probe theme, the changeset — clear.
  • #12378 files: the theme compiler, the parts list and its tests, the theme index and contract test, the browser precedence spec and story, the CLI build and family build and their tests, the doc type and theming-target test, the docsite generators, the theme-compilation and Pagination records, both changesets, 37 Core and 2 Lab component docs — clear in its own review; the CLI build repeats one comment (non-blocking).
  • Whole stack: the cumulative change is consistent, its API rows are the two records' rows, and nothing one pull request adds is removed by the other.

Automated review (maintainer link)

@josephfarina
josephfarina marked this pull request as draft November 22, 2026 22:52
@github-actions
github-actions Bot deleted the fix/side-nav-item-icon-target branch November 23, 2026 06:06

This branch was successfully deployed

1 active deployment
Preview — 098e77f4 Deployed Nov 21, 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. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants