feat(tree-list): add astryx-tree-list-item-label theme target#4306
Conversation
|
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, 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.
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.
b2ed3f0 to
417ee22
Compare
…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.
What
Adds a dedicated
astryx-tree-list-item-labeltheme target to the TreeList item's label text.Why
The item's label (
styles.labelspan 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 likebutton: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 theastryx-tree-list-item/astryx-calendar-*precedent, sodefineThemecan scope overrides to the label alone.What changed
TreeListItem.tsx—themeProps('tree-list-item-label', {selected})spread (viamergeProps) onto the label<span>. Renders a stableastryx-tree-list-item-labelclass and reflects the row's selected state asdata-selected="selected"plus the matching class token, so a theme can target the selected label specifically viadefineTheme.TreeList.doc.mjs— new{className: 'astryx-tree-list-item-label', states: ['selected']}entry intheming.targetsfor bothdocs(EN) anddocsZh(ZH). Keeps thethemingTargetsguard green.TreeList.test.tsx— asserts the target class renders on the label,data-selectedreflects only for the selected item, the label keeps theidits row references viaaria-labelledby, and that adefineTheme({ components: { 'tree-list-item-label': { base, selected } } })resolves to.astryx-tree-list-item-label/.astryx-tree-list-item-label.selected.TreeList.stories.tsx— aThemedItemLabelstory showing a selected-label weight (bold) override viadefineTheme.[feat], patch).Notes
data-selectedattribute.<span>itself. Note the existingastryx-tree-list-itemtarget 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.selectedstate (not its own) so themes can scope to the selected item's label without a descendant selector.