Skip to content

feat(tree-list): add astryx-tree-list-chevron theme target - #4305

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

cixzhang merged 1 commit into
mainfrom
feat/treelist-chevron-theme-target

Conversation

@freddymeta

Copy link
Copy Markdown
Contributor

What

Adds a dedicated astryx-tree-list-chevron theme target to the TreeList expand/collapse toggle.

Why

The toggle chevron carries only the functional data-tree-toggle attribute (used internally by TreeList's activateItem selector) and no stable theme handle. Consumers who want to restyle the chevron — color, or a different treatment per open/closed state — can today only reach it through a fragile [data-tree-toggle] selector, which couples themes to an internal functional attribute rather than Astryx's sanctioned theming surface.

This mirrors the recently-added astryx-calendar-nav target: a themeProps() call that renders a stable class plus reflected state, documented in theming.targets, so defineTheme can scope overrides to exactly this element.

What changed

  • TreeListItem.tsx — themeProps('tree-list-chevron', {state}) spread (via mergeProps) onto the toggle. It lands on both rendered forms of the chevron: the interactive <button> (the primary themeable case) and the non-interactive fallback <span> (used only when toggling isn't wired up), so the target is stable regardless. Reflects open/closed as data-state="expanded" | "collapsed" plus the matching class token. The functional data-tree-toggle hook is untouched.
  • TreeList.doc.mjs — new {className: 'astryx-tree-list-chevron', states: ['state']} entry in theming.targets for both docs (EN) and docsZh (ZH). Keeps the themingTargets guard green.
  • TreeList.test.tsx — asserts the target class + data-state render on the toggle (collapsed and expanded), that data-tree-toggle and the <button> element are preserved, and that a defineTheme({ components: { 'tree-list-chevron': { base, 'state:expanded' } } }) resolves to .astryx-tree-list-chevron / .astryx-tree-list-chevron.expanded.
  • TreeList.stories.tsx — a ThemedChevron story demonstrating the defineTheme override channel.
  • Changeset ([feat], patch).

Notes

  • Purely additive: default rendering is byte-identical. The target only adds a class and a data-state attribute.
  • The existing astryx-tree-list-item target sits on the row's inner content <div> (not the <li role="treeitem">); this new chevron target is a sibling handle on the toggle control itself.
  • Chevron size was left as-is — it's already tokenized (--spacing-4), so no size change was needed. The point of this PR is the theme target.
  • StyleX-only; no raw CSS; no new hardcoded values.

The expand/collapse toggle carries only the functional data-tree-toggle
attribute and no stable theme handle, so consumers can theme the chevron
only via a fragile [data-tree-toggle] selector.

Add a themeProps('tree-list-chevron', {state}) surface on the toggle
(both the interactive button and the non-interactive fallback span) so it
renders a stable astryx-tree-list-chevron class and reflects the open/closed
state as data-state (expanded/collapsed). The functional data-tree-toggle
hook is unchanged; default rendering is byte-identical.

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 demonstrating the override.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jul 25, 2026
@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 2:07am

Request Review

@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

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 724 -
Complexity N/A Very High (76) -

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. The new themeProps('tree-list-chevron', {state}) call site on the expand/collapse control is recorded in TreeList.doc.mjs theming.targets (both docs and docsZh) as {className: 'astryx-tree-list-chevron', states: ['state']}, satisfying the SUBSET theming convention — every rendered astryx-* class and every prop key is documented. Functional data-tree-toggle hook is unchanged; the target is purely additive. Test asserting the class renders + 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 merged commit 68afe69 into main Jul 25, 2026
20 checks passed
@github-actions
github-actions Bot deleted the feat/treelist-chevron-theme-target branch July 25, 2026 06:50

This branch was successfully deployed

1 active deployment
Preview — 6032aa37 Deployed Jul 25, 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. 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