Skip to content

feat(tree-list): add astryx-tree-list-item-label theme target#4306

Merged
cixzhang merged 1 commit into
mainfrom
feat/treelist-label-theme-target
Jul 25, 2026
Merged

feat(tree-list): add astryx-tree-list-item-label theme target#4306
cixzhang merged 1 commit into
mainfrom
feat/treelist-label-theme-target

Conversation

@freddymeta

Copy link
Copy Markdown
Contributor

What

Adds a dedicated astryx-tree-list-item-label theme target to the TreeList item's label text.

Why

The item's label (styles.label span inside the row's content) has no stable class. A theme that wants to style just the label — for example, bolding the selected item's label — can today only reach it through a fragile structural selector like button:not([data-tree-toggle]) > span. That couples themes to internal DOM structure and breaks the moment the row's markup changes.

This adds a stable target the sanctioned way (themeProps + theming.targets), matching the astryx-tree-list-item / astryx-calendar-* precedent, so defineTheme can scope overrides to the label alone.

What changed

  • TreeListItem.tsxthemeProps('tree-list-item-label', {selected}) spread (via mergeProps) onto the label <span>. Renders a stable astryx-tree-list-item-label class and reflects the row's selected state as data-selected="selected" plus the matching class token, so a theme can target the selected label specifically via defineTheme.
  • TreeList.doc.mjs — new {className: 'astryx-tree-list-item-label', states: ['selected']} entry in theming.targets for both docs (EN) and docsZh (ZH). Keeps the themingTargets guard green.
  • TreeList.test.tsx — asserts the target class renders on the label, data-selected reflects only for the selected item, the label keeps the id its row references via aria-labelledby, and that a defineTheme({ components: { 'tree-list-item-label': { base, selected } } }) resolves to .astryx-tree-list-item-label / .astryx-tree-list-item-label.selected.
  • TreeList.stories.tsx — a ThemedItemLabel story showing a selected-label weight (bold) override via defineTheme.
  • Changeset ([feat], patch).

Notes

  • Purely additive: default rendering is byte-identical. The target only adds a class and a data-selected attribute.
  • Which element: this lands on the label <span> itself. Note the existing astryx-tree-list-item target sits on the row's inner content <div> (not the <li role="treeitem">), so these are distinct handles — the row vs. the label text within it.
  • The label reflects the row's selected state (not its own) so themes can scope to the selected item's label without a descendant selector.
  • StyleX-only; no raw CSS; no new hardcoded values.

@vercel

vercel Bot commented Jul 25, 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, Comment Jul 25, 2026 3:53am

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 25, 2026
@github-actions github-actions Bot added community Authored by a community contributor (not on the eng/design team) needs:code-review High-risk change (new package/component/API) — needs human code review before merge labels Jul 25, 2026
github-actions Bot added a commit that referenced this pull request Jul 25, 2026
@github-actions

github-actions Bot commented Jul 25, 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

TreeList · View in Storybook
Metric Before After Delta
Bundle Size (ESM) N/A N/A N/A
Lines of Code N/A 731 -
Complexity N/A Very High (77) -

Bundle Size Summary

Package Size (ESM) Size (CJS) Gzipped
@astryxdesign/core N/A 4.7KB 0B

Accessibility Audit

Status: No accessibility violations detected.


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

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

Clean, contained theme-target addition, same shape as the chevron target. The new themeProps('tree-list-item-label', {selected}) call site on the label span is recorded in TreeList.doc.mjs theming.targets (both docs and docsZh) as {className: 'astryx-tree-list-item-label', states: ['selected']}, satisfying the SUBSET theming convention. The label keeps its aria-labelledby linkage (verified by test); the target is purely additive. Test asserting the class renders + selected reflection + generated-CSS reachability, a story, and a changeset are all present. No new public API surface. CI green. Approving.

@github-actions github-actions Bot removed the needs:code-review High-risk change (new package/component/API) — needs human code review before merge label Jul 25, 2026
@cixzhang
cixzhang enabled auto-merge (squash) July 25, 2026 03:38
The item's label text carries no themeable handle, so a theme can only
reach it through a fragile structural selector (the content button's
first span). That couples themes to internal DOM structure and can't
scope to, e.g., just the selected item's label.

Add a themeProps('tree-list-item-label', {selected}) surface on the
label span so it renders a stable astryx-tree-list-item-label class and
reflects the row's selected state as data-selected. Default rendering is
byte-identical; the label keeps the id its row references via
aria-labelledby.

Documents the new target in TreeList.doc.mjs (docs + docsZh), adds tests
asserting the class/state render and a defineTheme override resolves to
the expected selectors, and a Storybook story showing a selected-label
weight override.
@cixzhang
cixzhang force-pushed the feat/treelist-label-theme-target branch from b2ed3f0 to 417ee22 Compare July 25, 2026 03:51
@cixzhang
cixzhang merged commit 33a6cdc into main Jul 25, 2026
19 checks passed
github-actions Bot added a commit that referenced this pull request Jul 25, 2026
HelloOjasMutreja pushed a commit to HelloOjasMutreja/astryx that referenced this pull request Jul 25, 2026
…ok#4306)

The item's label text carries no themeable handle, so a theme can only
reach it through a fragile structural selector (the content button's
first span). That couples themes to internal DOM structure and can't
scope to, e.g., just the selected item's label.

Add a themeProps('tree-list-item-label', {selected}) surface on the
label span so it renders a stable astryx-tree-list-item-label class and
reflects the row's selected state as data-selected. Default rendering is
byte-identical; the label keeps the id its row references via
aria-labelledby.

Documents the new target in TreeList.doc.mjs (docs + docsZh), adds tests
asserting the class/state render and a defineTheme override resolves to
the expected selectors, and a Storybook story showing a selected-label
weight override.
@github-actions
github-actions Bot deleted the feat/treelist-label-theme-target branch July 25, 2026 06:50
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. community Authored by a community contributor (not on the eng/design team)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants