Repository navigation
feat(tree-list): add astryx-tree-list-chevron theme target - #4305
Conversation
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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR Analysis Report📚 Storybook PreviewView Storybook for this PR 🧪 Sandbox PreviewView Sandbox for this PR Modified ComponentsTreeList · View in Storybook
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
cixzhang
left a comment
There was a problem hiding this comment.
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.
What
Adds a dedicated
astryx-tree-list-chevrontheme target to the TreeList expand/collapse toggle.Why
The toggle chevron carries only the functional
data-tree-toggleattribute (used internally by TreeList'sactivateItemselector) 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-navtarget: athemeProps()call that renders a stable class plus reflected state, documented intheming.targets, sodefineThemecan scope overrides to exactly this element.What changed
TreeListItem.tsx—themeProps('tree-list-chevron', {state})spread (viamergeProps) 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 asdata-state="expanded" | "collapsed"plus the matching class token. The functionaldata-tree-togglehook is untouched.TreeList.doc.mjs— new{className: 'astryx-tree-list-chevron', states: ['state']}entry intheming.targetsfor bothdocs(EN) anddocsZh(ZH). Keeps thethemingTargetsguard green.TreeList.test.tsx— asserts the target class +data-staterender on the toggle (collapsed and expanded), thatdata-tree-toggleand the<button>element are preserved, and that adefineTheme({ components: { 'tree-list-chevron': { base, 'state:expanded' } } })resolves to.astryx-tree-list-chevron/.astryx-tree-list-chevron.expanded.TreeList.stories.tsx— aThemedChevronstory demonstrating thedefineThemeoverride channel.[feat], patch).Notes
data-stateattribute.astryx-tree-list-itemtarget 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.--spacing-4), so no size change was needed. The point of this PR is the theme target.