feat(Spinner): add --spinner-arc-fraction public var - #5845
Open
HelloOjasMutreja wants to merge 1 commit into
Open
feat(Spinner): add --spinner-arc-fraction public var#5845HelloOjasMutreja wants to merge 1 commit into
HelloOjasMutreja wants to merge 1 commit into
Conversation
HelloOjasMutreja
requested review from
cixzhang and
imdreamrunner
as code owners
September 1, 2026 21:05
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
PR Analysis Report
Modified ComponentsSpinner (@astryxdesign/core)
Bundle Size Summary
Accessibility AuditStatus: No accessibility violations detected. Visual RegressionStatus: No visual change across 14 compared shot(s). Generated by PR Enrichment workflow | View full report |
The four existing public vars (diameter, stroke-width, color, track-color) all reach the ring's geometry or paint except one: how much of the circle the moving arc covers. That's the most visually distinctive property at a given size, and it looks explicitly permitted rather than excluded by the theming contract facebook#5771 is recording (ring geometry through the spinner target, no new target). Applies the exact precedent this component already sets for diameter: the CSS-side strokeDasharray composes the dash from the live var, and the inline attribute (the pre-stylesheet render) keeps using the compiled-in default, unchanged. A themed sweep applies once the stylesheet lands, the same way a themed diameter already does. Fixes facebook#5819.
HelloOjasMutreja
force-pushed
the
feat/spinner-arc-fraction-var
branch
from
September 2, 2026 11:50
e762bdb to
e7a9a06
Compare
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.
Fixes #5819.
What's missing
Spinnerexposes four public vars on thespinnertarget (--spinner-diameter,--spinner-stroke-width,--spinner-color,--spinner-track-color) so a theme can change size, stroke, and color. It cannot change how much of the circle the moving arc covers — that was a compiled-in constant (ARC_FRACTION = 0.375, a 135deg sweep).Why this was an issue and not immediately a PR
The catch the issue raised: the CSS side (
styles.arc.strokeDasharray) already composes its dash from acalc(), so making it themeable there is close to free. But there's also an inlinestrokeDasharraySVG attribute — the pre-stylesheet render, for SSR / no-JS — computed in JS, which can't read a CSS custom property. A themed sweep would draw the default 135deg in that frame and snap to the themed value once the stylesheet lands.Why this is safe: precedent already set
Checked how
--spinner-diameter(the var this issue explicitly compares itself to) already handles this exact split, since it's used in both places too:styles.arc,styles.circle.r, etc.): reads the live, themeableRESOLVED_DIAMETERvar.<circle r={diameter / 2}>presentation attributes, and the pre-CSSstrokeDasharray):const {diameter} = SIZES[size]— the hardcoded default, not the themed value.So a themed diameter already only takes visual effect once the stylesheet loads, and the pre-CSS frame already renders at the unthemed default. This isn't a new kind of box-vs-paint disagreement (the class of bug #5214 and #5484 dealt with) — it's applying the one this component already ships, to one more property.
Change
styles.arc.strokeDasharraynow composes the dash fromvar(--spinner-arc-fraction)(a live number multiplier) instead of the pre-multipliedARC_DASH/ARC_GAPconstants.--spinner-arc-fractiondeclares alongside--spinner-diameter/--spinner-stroke-widthinsizeStyles, same default (0.375) for every size, unregistered like the other three public vars (no length-arithmetic ambiguity to guard against — it's a pure multiplier, not summed with anything).strokeDasharrayattribute (the pre-stylesheet render) is untouched — stillARC_FRACTION, matching how the inline diameter attributes stay at their default too.Testing
npx vitest run packages/core/src/Spinner/Spinner.test.tsx— 48/48 pass, including a new test confirming a themedsize:xltarget scopes--spinner-arc-fractioncorrectly (mirroring the existing diameter/color scoping tests).@astryxdesign/coreand inspected the compileddist/astryx.cssdirectly: confirmed--spinner-arc-fraction:.375declares on the size-variant rule andstrokeDasharraycomposes fromvar(--spinner-arc-fraction)in the compiledcalc(), not just in source.Posted the precedent-based reasoning on the issue first; given how directly it settles the ambiguity the issue raised (and the reporter's own "happy to implement whichever"), opening this as the concrete proposal rather than waiting further — happy to adjust based on any maintainer feedback.