Repository navigation
feat(core): make TreeList per-level indent a themeable CSS variable - #4530
Merged
Merged
Conversation
The per-level indentation step was hardcoded to --spacing-4 and applied as an inline margin-inline-start on the row's content wrapper — the same element that carries the astryx-tree-list-item theme target. An inline longhand outranks every cascade layer, so the indent was unreachable from @layer astryx-theme. Publish the step as the public --tree-list-indent variable (default var(--spacing-4)) set on the tree-list root. Both the row margins and the guide-line offsets read it, so a theme can retune the indent metric (e.g. to var(--spacing-5)) via defineTheme on the tree-list target and the guides stay aligned. The computed per-row distance now rides the private --_tree-indent custom property instead of the inline longhand, so the margin-inline-start declaration lives in @layer astryx-base and the theme layer overrides it in normal cascade order (#4308).
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
github-actions
Bot
requested review from
cvkxx,
ernestt,
kentonquatman and
rubyycheung
July 29, 2026 23:54
Contributor
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
marked this pull request as ready for review
July 30, 2026 01:10
cixzhang
added a commit
that referenced
this pull request
Aug 24, 2026
… but unsettable (#5409) collectThemingVars joins collectThemingTargets as part of the one theming enumeration, and two checks ride on it. A documented public var no component reads compiles to a declaration that never applies (#5012). A var the component writes inline outranks every cascade layer, so no theme can reach it (#4530). Both shipped, and neither is visible in the generated theme CSS, which is the artifact the jsdom suites assert on.
cixzhang
added a commit
that referenced
this pull request
Aug 24, 2026
… in a production build (#5410) * test(cli): guard public component theme vars against being documented but unsettable collectThemingVars joins collectThemingTargets as part of the one theming enumeration, and two checks ride on it. A documented public var no component reads compiles to a declaration that never applies (#5012). A var the component writes inline outranks every cascade layer, so no theme can reach it (#4530). Both shipped, and neither is visible in the generated theme CSS, which is the artifact the jsdom suites assert on. * fix(build): theme component overrides now apply in a production build StyleX emits its rules into its own top-level @layer priority1...priorityN. The dev server re-serves those wrapped in astryx-base and the pre-compiled astryx.css ships them wrapped, but a Vite build did neither, so the priority layers sorted after astryx-theme and outranked it. Every components: {} override a theme sets was silently dropped in the built app while working in dev. All seven shipped themes carry components: blocks, so this changes what a built app renders. theme-var-reachability.js drives Chromium against the built Storybook and fails when a theme's declaration does not land on the element; it fails on all four documented public vars before this fix and passes after. * fix(build): split Astryx and product styles into their layers, do not wrap both The previous commit wrapped everything StyleX emitted in the library layer. That fixed the theme and broke the app: product StyleX landed below astryx-theme too, so a theme could silently restyle code it does not own. Partition by source file, the way the dev server always has. StyleX's shared rule store is reachable at build time and is keyed by absolute source path, which is the only place the origin survives — by the time the CSS is text it is gone, so the wrap had nothing sound to split on. Both plugins now call one renderSplitLayers helper; the lifecycles differ, the partition does not. The replacement runs the same lightningcss pass StyleX does, or the build would quietly lose the vendor prefixes the original output had. Tests: vite.build.test.ts runs a real Vite build of a fixture app that renders an Astryx component and authors its own StyleX, then reads the emitted stylesheet. theme-layer-cascade.js renders that build in Chromium and asserts Astryx < theme < product, which no jsdom test can. Both were watched failing against the unsplit and the wrapped builds. * chore(build): copyright header on the layer-split fixture page * ci: run the theme layer cascade guard in its own job It was in pr-a11y, which runs only when packages/core or packages/lab changed. What it guards is packages/build, so on this PR — the one that changes the splitting logic — it did not run at all. * fix(build): link the stylesheet StyleX writes when an app imports no CSS An app that imports no stylesheet of its own gives StyleX no bundle asset to append to, so it writes assets/stylex.css itself — outside Rollup's graph, which means Vite's HTML plugin never learns about it and emits no <link>. The app shipped every Astryx style correctly split into layers and a completely unstyled page. Importing any stylesheet hides it, which is why it survived: one line of the project's own CSS and the symptom disappears. Only orphans are linked. A stylesheet a page already references is Vite's, and touching it would load it twice; a build with no HTML at all — library mode — is left alone, because its consumer imports the CSS themselves. The build test now covers both emission paths as two fixtures running the same assertions, including that the page links the stylesheet exactly once. Verified across app shapes: css-import, no-css-import, no-product-StyleX (no empty product layer), multiple entries, library mode, write:false, minify on and off, and an app with no Astryx at all (no spurious build failure).
AKnassa
added a commit
to AKnassa/astryx
that referenced
this pull request
Aug 27, 2026
Conflicts: TreeList.tsx, TreeListItem.tsx, TreeListTypes.ts, index.ts — resolved as a union of main's TreeListVariant / Icon-rendered chevron / flush-leaf column logic (meta#4838, meta#4540, meta#4530, meta#4334) and this branch's renderExpandIcon. A leaf that renders its own indicator no longer reserves the chevron column. The four alignment tests now read the published --_tree-indent custom property instead of the removed inline marginLeft.
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
TreeListper-level indentation step was hardcoded to--spacing-4and applied as an inlinemargin-inline-starton the row's content wrapper — the same element that carries theastryx-tree-list-itemtheme target. Because an inline longhand outranks every cascade layer, the indent was unreachable from@layer astryx-theme, so a theme couldn't retune it (the exact problem RFC #4308 raised).This makes the step a public, documented, themeable CSS variable:
--tree-list-indent(defaultvar(--spacing-4)), set on thetree-listroot. A theme can now widen or tighten the indent — e.g. tovar(--spacing-5)— through the sanctioned channel:Both the row margins (
TreeListItem) and the guide-line offsets (TreeListBranches) read the same variable, so guides stay aligned when the step is retuned.How it works
--tree-list-indentis declared onstyles.root(thetree-listtarget) and documented inTreeList.doc.mjstheming.vars[], so it shows up inastryx component TreeListand the theming panel. It follows the--<component>-<property>naming convention (public → no--_prefix).calc(level * var(--tree-list-indent)), plus the fixed chevron-column offset for leaves) now rides the private--_tree-indentcustom property instead of the inline longhand. Themargin-inline-startdeclaration lives in@layer astryx-base(via StyleX), so the theme layer overrides it in normal cascade order. A custom property carries a value, not a declaration, so it doesn't create the same specificity floor.Rendering is unchanged at every nesting depth (same default
--spacing-4step, same leaf chevron offset).Relationship to #4448
#4448 implements Option A of the same RFC (moving the indent value off the inline longhand) but keeps the step hardcoded via the private
--_tree-indent. This PR does that cascade fix and exposes the step itself as the public, documented--tree-list-indentlever — which is the "one-line rename to a documented--astryx-*lever" that PR's author explicitly offered. If maintainers prefer to land these separately, this can be rebased on top of #4448; happy to defer.Tests
noGuidesindentation test to read the published--_tree-indentdistance instead of the removed inline longhand (intent unchanged: indent survivesnoGuidesand grows with depth).defineThemeoverride test proving--tree-list-indentreaches thetree-listtarget in generated CSS, and a test that rows consumevar(--tree-list-indent)in their published distance.All 66
TreeListtests pass, plus thetheming.vars/theming.targetsconsistency suites. Core typecheck, lint, build, and docsite generate are green.