Repository navigation
fix(core): theme padding with functions builds as written - #11347
Conversation
generateThemeRules split padding, paddingBlock and paddingInline on every space, so clamp(), calc(), min() and var() with a fallback broke into invalid parts. It now splits on top-level spaces only, outside parentheses and quotes.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
Requesting changes: the padding fix works, and two small things need to change before it lands.
splitTopLevelSpacesingenerateThemeRules.tsre-implements the top-level CSS scan thatsplitTopLevelCommaintokenReferences.tsalready provides and leaves out its backslash-escape handling, so a quoted string that holds an escaped quote is still split inside the string; please add the whitespace split totokenReferences.tson one scanner shared withsplitTopLevelCommaand call it fromparsePadding.- The description says the new tests cover
max(), but no test row uses it; please add amax()row (Cardpadding: max(8px, 2vw)compiles to--astryx-card-padding: max(8px, 2vw);) or dropmax()from that line.
Non-blocking: an empty padding: '' now emits no padding token where it used to emit --astryx-card-padding: ;, and a test that pins the intended result would make that explicit.
Claims and files checked
- Claim: theme padding written with
clamp(),calc(),min(),max()or avar()fallback builds as written. Verified for all five from the compiler output; four are also covered by the new tests. - Claim: the compiler splits
padding,paddingBlockandpaddingInlineonly between values, never inside parentheses or quotes. Verified for parentheses and plain quoted strings; false for a string that holds an escaped quote (first finding). - Claim:
padding: clamp(8px, 2vw, 16px)stays one value instead of becoming broken CSS. Verified by the new test row; before the fix both block sides were dropped with warnings. - Claim: no API changes. Verified: the new helper is not reachable from any package entry point.
- Claim: before the fix, function padding built broken CSS because every space was a separator. Verified against the compiler output before the change.
- Claim: values without functions split as before. Verified for every value with at least one component; an empty value differs (non-blocking note).
- Claim: the new tests cover
clamp(),calc(),min(),max(), avar()fallback and quoted values. False formax()(second finding). - Claim: no new public API, default or interaction model hides under the fix, and the public text carries no internal context. Verified.
- File
.changeset/core-padding-functions.md: its quote wording does not hold for escaped quotes (first finding); otherwise it matches the code. - File
packages/core/src/theme/generateThemeRules.ts: first finding. - File
packages/core/src/theme/generateThemeRules.test.ts: nomax()row (second finding); the other rows match the compiler output.
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| SideNav | 118.3 kB (+40 B) · 11.4 kB CSS (0) | — | — · — · — |
| AlertDialog | 109.2 kB (+39 B) · 14.6 kB CSS (0) | — | — · — · — |
| SegmentedControl | 100.2 kB (+39 B) · 6.9 kB CSS (0) | — | — · — · — |
118 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| ChatComposer | 82.9 kB (+38 B) · 12.1 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 80.6 kB (+37 B) · 11.3 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 80.6 kB (+37 B) · 11.3 kB CSS (0) | — | — · — · — |
| CheckboxListItem | 74.5 kB (+37 B) · 11.5 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 89.9 kB (+36 B) · 12.1 kB CSS (0) | — | — · — · — |
| ChatDictationButton | 64.0 kB (+36 B) · 10.1 kB CSS (0) | — | — · — · — |
| DropdownMenuCheckboxItem | 23.8 kB (+36 B) · 6.6 kB CSS (0) | — | — · — · — |
| ChatLayoutScrollButton | 64.0 kB (+35 B) · 10.2 kB CSS (0) | — | — · — · — |
| CodeBlock | 78.7 kB (+35 B) · 11.3 kB CSS (0) | — | — · — · — |
| Collapsible | 28.9 kB (+35 B) · 4.5 kB CSS (0) | — | — · — · — |
| DrawerHeader | 66.5 kB (+35 B) · 12.9 kB CSS (0) | — | — · — · — |
| Calendar | 74.5 kB (+34 B) · 10.6 kB CSS (0) | — | — · — · — |
| ChatSendButton | 63.8 kB (+34 B) · 10.0 kB CSS (0) | — | — · — · — |
| lab/TransferListSelector | 114.5 kB (+34 B) · 1.4 kB CSS (0) | — | — · — · — |
| Button | 63.4 kB (+33 B) · 10.0 kB CSS (0) | — | — · — · — |
| DateInput | 192.8 kB (+33 B) · 17.0 kB CSS (0) | — | — · — · — |
| DialogHeader | 66.3 kB (+33 B) · 11.5 kB CSS (0) | — | — · — · — |
| IconButton | 63.5 kB (+33 B) · 10.0 kB CSS (0) | — | — · — · — |
| List | 19.0 kB (+33 B) · 790 B CSS (0) | — | — · — · — |
| MobileNavToggle | 63.8 kB (+33 B) · 10.0 kB CSS (0) | — | — · — · — |
| Thumbnail | 67.8 kB (+33 B) · 11.6 kB CSS (0) | — | — · — · — |
| TimeInput | 167.6 kB (+33 B) · 16.0 kB CSS (0) | — | — · — · — |
| Tokenizer | 102.1 kB (+33 B) · 19.1 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 91.0 kB (+33 B) · 2.1 kB CSS (0) | — | — · — · — |
| lab/TransferList | 105.7 kB (+33 B) · 1.2 kB CSS (0) | — | — · — · — |
| Banner | 65.4 kB (+32 B) · 10.5 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 76.7 kB (+32 B) · 10.9 kB CSS (0) | — | — · — · — |
| ListItem | 73.7 kB (+32 B) · 11.5 kB CSS (0) | — | — · — · — |
| Outline | 25.2 kB (+32 B) · 4.1 kB CSS (0) | — | — · — · — |
| AppShell | 95.3 kB (+31 B) · 13.5 kB CSS (0) | — | — · — · — |
| Markdown | 193.5 kB (+31 B) · 20.8 kB CSS (0) | — | — · — · — |
| TopNavMenu | 79.7 kB (+31 B) · 11.2 kB CSS (0) | — | — · — · — |
| lab/SelectableCardGroup | 67.6 kB (+31 B) · 162 B CSS (0) | — | — · — · — |
| CommandPalette | 75.2 kB (+30 B) · 12.7 kB CSS (0) | — | — · — · — |
| Link | 55.2 kB (+30 B) · 7.1 kB CSS (0) | — | — · — · — |
| RadioList | 59.6 kB (+30 B) · 7.3 kB CSS (0) | — | — · — · — |
| Switch | 106.9 kB (+30 B) · 10.0 kB CSS (0) | — | — · — · — |
| lab/ListInput | 91.5 kB (+30 B) · 922 B CSS (0) | — | — · — · — |
| ContextMenuItem | 33.3 kB (+29 B) · 6.3 kB CSS (0) | — | — · — · — |
| FieldLabel | 54.3 kB (+29 B) · 5.7 kB CSS (0) | — | — · — · — |
| PowerSearch | 299.3 kB (+29 B) · 24.7 kB CSS (0) | — | — · — · — |
| RadioListItem | 70.7 kB (+29 B) · 10.3 kB CSS (0) | — | — · — · — |
| SideNavItem | 75.2 kB (+29 B) · 11.1 kB CSS (0) | — | — · — · — |
| Stepper | 65.2 kB (+29 B) · 10.1 kB CSS (0) | — | — · — · — |
| TextInput | 71.1 kB (+29 B) · 11.2 kB CSS (0) | — | — · — · — |
| ToggleButton | 90.1 kB (+29 B) · 10.1 kB CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 110.7 kB (+29 B) · 773 B CSS (0) | — | — · — · — |
| lab/Comments | 358.9 kB (+29 B) · 2.5 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 352.1 kB (+29 B) · 2.4 kB CSS (0) | — | — · — · — |
| lab/TabBar | 82.3 kB (+29 B) · 1.8 kB CSS (0) | — | — · — · — |
| SideNavCollapseButton | 64.3 kB (+28 B) · 10.1 kB CSS (0) | — | — · — · — |
| lab/EmojiPicker | 90.4 kB (+28 B) · 751 B CSS (0) | — | — · — · — |
| AvatarGroupOverflow | 50.9 kB (+27 B) · 5.7 kB CSS (0) | — | — · — · — |
| CheckboxInput | 67.5 kB (+27 B) · 9.3 kB CSS (0) | — | — · — · — |
| Field | 58.2 kB (+27 B) · 7.3 kB CSS (0) | — | — · — · — |
| Slider | 112.4 kB (+27 B) · 8.8 kB CSS (0) | — | — · — · — |
| Tab | 14.9 kB (+27 B) · 4.2 kB CSS (0) | — | — · — · — |
| TableSelectionToolbar | 73.7 kB (+27 B) · 13.2 kB CSS (0) | — | — · — · — |
| TabMenu | 77.0 kB (+27 B) · 11.1 kB CSS (0) | — | — · — · — |
| Timestamp | 35.1 kB (+27 B) · 10.2 kB CSS (0) | — | — · — · — |
| TopNav | 75.7 kB (+27 B) · 10.9 kB CSS (0) | — | — · — · — |
| TopNavItem | 14.4 kB (+27 B) · 4.0 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 74.4 kB (+27 B) · 11.8 kB CSS (0) | — | — · — · — |
| CheckboxList | 71.9 kB (+26 B) · 7.8 kB CSS (0) | — | — · — · — |
| ClickableCard | 18.5 kB (+26 B) · 7.3 kB CSS (0) | — | — · — · — |
| DropdownMenuItem | 23.0 kB (+26 B) · 6.2 kB CSS (0) | — | — · — · — |
| Toast | 101.3 kB (+26 B) · 10.3 kB CSS (0) | — | — · — · — |
| lab/DialogHeroHeader | 86.5 kB (+26 B) · 372 B CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 284.4 kB (+26 B) · 454 B CSS (0) | — | — · — · — |
| ComplexSelector | 75.8 kB (+25 B) · 11.8 kB CSS (0) | — | — · — · — |
| InputGroup | 59.9 kB (+25 B) · 7.9 kB CSS (0) | — | — · — · — |
| SegmentedControlItem | 18.8 kB (+25 B) · 4.3 kB CSS (0) | — | — · — · — |
| SideNavHeading | 80.7 kB (+25 B) · 11.3 kB CSS (0) | — | — · — · — |
| TextArea | 65.6 kB (+24 B) · 9.4 kB CSS (0) | — | — · — · — |
| Token | 29.3 kB (+24 B) · 4.8 kB CSS (0) | — | — · — · — |
| DateTimeInput | 215.5 kB (+23 B) · 18.7 kB CSS (0) | — | — · — · — |
| DropdownMenuRadioItem | 23.8 kB (+23 B) · 6.6 kB CSS (0) | — | — · — · — |
| Item | 18.1 kB (+23 B) · 5.5 kB CSS (0) | — | — · — · — |
| MoreMenu | 102.6 kB (+23 B) · 17.6 kB CSS (0) | — | — · — · — |
| SelectorOption | 21.6 kB (+23 B) · 6.0 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 111.9 kB (+23 B) · 1.1 kB CSS (0) | — | — · — · — |
| CommandPaletteItem | 13.4 kB (+22 B) · 3.6 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 73.2 kB (+22 B) · 9.7 kB CSS (0) | — | — · — · — |
| TopNavMegaMenuItem | 14.2 kB (+22 B) · 4.2 kB CSS (0) | — | — · — · — |
| ButtonGroup | 43.6 kB (+21 B) · 3.7 kB CSS (0) | — | — · — · — |
| Carousel | 73.2 kB (+21 B) · 10.9 kB CSS (0) | — | — · — · — |
| DropdownMenu | 102.3 kB (+21 B) · 17.6 kB CSS (0) | — | — · — · — |
| Overlay | 23.0 kB (+21 B) · 3.9 kB CSS (0) | — | — · — · — |
| Pagination | 115.5 kB (+21 B) · 17.8 kB CSS (0) | — | — · — · — |
| lab/CommentPin | 59.3 kB (+21 B) · 1.2 kB CSS (0) | — | — · — · — |
| BottomSheet | 69.4 kB (+20 B) · 7.7 kB CSS (0) | — | — · — · — |
| Lightbox | 126.1 kB (+20 B) · 10.6 kB CSS (0) | — | — · — · — |
| MobileNav | 74.0 kB (+20 B) · 10.6 kB CSS (0) | — | — · — · — |
| TopNavHeading | 80.2 kB (+20 B) · 11.2 kB CSS (0) | — | — · — · — |
| FileInput | 72.4 kB (+19 B) · 10.9 kB CSS (0) | — | — · — · — |
| NumberInput | 75.0 kB (+19 B) · 11.4 kB CSS (0) | — | — · — · — |
| ToggleButtonGroup | 40.9 kB (+19 B) · 3.7 kB CSS (0) | — | — · — · — |
| Typeahead | 85.8 kB (+18 B) · 12.5 kB CSS (0) | — | — · — · — |
| lab/TabBarMoreList | 96.0 kB (+18 B) · 1.8 kB CSS (0) | — | — · — · — |
| ChatLayout | 86.3 kB (+17 B) · 10.5 kB CSS (0) | — | — · — · — |
| lab/Schedule | 109.8 kB (+16 B) · 3.9 kB CSS (0) | — | — · — · — |
| SelectableCard | 18.7 kB (+15 B) · 7.5 kB CSS (0) | — | — · — · — |
| Step | 31.5 kB (+15 B) · 5.6 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditor | 301.7 kB (+15 B) · 2.6 kB CSS (0) | — | — · — · — |
| richtext/RichTextView | 279.9 kB (+15 B) · 2.3 kB CSS (0) | — | — · — · — |
| DateRangeInput | 97.6 kB (+14 B) · 12.5 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 156.4 kB (+14 B) · 1.9 kB CSS (0) | — | — · — · — |
| Table | 130.4 kB (+13 B) · 18.5 kB CSS (0) | — | — · — · — |
| Selector | 105.4 kB (+11 B) · 17.4 kB CSS (0) | — | — · — · — |
| TreeList | 46.1 kB (+11 B) · 5.6 kB CSS (0) | — | — · — · — |
| charts/Chart | 209.6 kB (+10 B) · 516 B CSS (0) | — | — · — · — |
| ContextMenu | 113.2 kB (+10 B) · 17.5 kB CSS (0) | — | — · — · — |
| MultiSelector | 99.7 kB (+10 B) · 16.9 kB CSS (0) | — | — · — · — |
| lab/TourStep | 101.7 kB (+8 B) · 590 B CSS (0) | — | — · — · — |
| TableCell | 114.5 kB (+7 B) · 18.0 kB CSS (0) | — | — · — · — |
| Popover | 95.4 kB (+4 B) · 14.2 kB CSS (0) | — | — · — · — |
| TableHeaderCell | 114.0 kB (+1 B) · 17.7 kB CSS (0) | — | — · — · — |
| lab/TabBarItem | 3.9 kB (0) · 1.8 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.37 MB packed (+860 B); no new dependencies.
Wide change (shared styles: packages/core/src/theme/generateThemeRules.ts, packages/core/src/theme/tokenReferences.ts): add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Requesting changes: the shared scanner and the new max() row fix both earlier points, and one line of the description needs correcting before this lands.
- The description's Evidence section says the new
generateThemeRules.test.tsrows cover quoted values, but none of them uses a quote now that the quoted case lives intokenReferences.test.ts; please move "quoted values" to thetokenReferences.test.tsbullet, or add a compiler row such aspaddingBlock: 'var(--x, "a b")'that expects both block tokens to keepvar(--x, "a b").
Non-blocking: Miss: an empty paddingInline that follows paddingInlineStart or paddingInlineEnd now clears them (generateThemeRules.ts:307-309), and returning early when the split finds no parts keeps the earlier longhands. A short wording suggestion for the scanTopLevel comment is inline.
Claims and files checked
- Claim: theme padding written with
clamp(),calc(),min(),max()or avar()fallback builds as written. Verified from the compiler's padding output and the new test rows. - Claim:
padding,paddingBlockandpaddingInlinesplit only between values, never inside parentheses or quotes, escaped quotes included. Verified by the scanner tests and the compiler's padding output. - Claim:
padding: clamp(8px, 2vw, 16px)stays one value instead of becoming broken CSS. Verified; before the fix the inline token became2vw,and both block sides were dropped. - Claim: no API changes. Verified: the new helper is reachable from no package entry point, and the generated API diff lists no change.
- Claim: the split shares one scanner with the existing top-level comma split. Verified; the comma split returns the same results as before.
- Claim: values without functions split as before. Verified for every non-empty plain value.
- Claim: an empty padding value emits no token. Verified; an empty
paddingInlinealso clears earlier inline longhands (non-blocking note). - Claim: the new compiler tests cover
clamp(),calc(),min(),max()and avar()fallback. Verified. - Claim: the new compiler tests also cover quoted values. False (blocking finding).
- Claim: the new scanner tests cover an escaped quote, nested functions, a quoted
var()fallback and an empty value. Verified. - Claim: one defect, no tagalong, no hidden API, visual, default or interaction change, and no internal context. Verified.
- Claim: the Core theme tests, typecheck, eslint and prettier pass. Verified by CI on this head.
- File
.changeset/core-padding-functions.md: clear. - File
packages/core/src/theme/generateThemeRules.ts: non-blocking note on an emptypaddingInline. - File
packages/core/src/theme/generateThemeRules.test.ts: the rows are correct; the description overstates them (blocking finding). - File
packages/core/src/theme/tokenReferences.ts: comment wording suggestion; otherwise clear. - File
packages/core/src/theme/tokenReferences.test.ts: clear.
There was a problem hiding this comment.
Approving: the description now lists quoted values under the scanner tests that cover them, and an empty paddingInline or paddingBlock now keeps the longhands written before it, so both earlier points are fixed.
Claims and files checked
- Claim: theme padding written with
clamp(),calc(),min(),max()or avar()fallback used to build broken CSS because the compiler split on every space. Verified on the base: the shorthand split was a whitespace regex, andclamp(8px, 2vw, 16px)became2vw,plus two dropped sides. - Claim: a theme's padding value now builds as written, the way CSS reads it. Verified from the new compiler rows and the padding output.
- Claim: the split happens only between top-level values, never inside parentheses or quotes, escaped quotes included. Verified by the scanner and its tests.
- Claim: the split shares one scanner with the existing top-level comma split. Verified; the comma split returns the same results as before.
- Claim: values without functions split as before. Verified for plain one-, two- and three-value inputs.
- Claim: an empty padding value emits no token. Verified; an empty shorthand also keeps the longhands written before it.
- Claim: the new compiler tests cover
clamp(),calc(),min(),max()and avar()fallback, next to the plain cases. Verified. - Claim: the new scanner tests cover quoted values, an escaped quote, nested functions, a quoted
var()fallback and an empty value. Verified. - Claim: one defect, no tagalong, no hidden API, visual, default or interaction change, and no internal context. Verified.
- Claim: the Core theme tests, typecheck, eslint and prettier pass. Verified by CI on this head.
- Changeset: a patch for
@astryxdesign/corethat fixes function padding, splits only between values, and changes no API. Verified. - File
.changeset/core-padding-functions.md: clear. - File
packages/core/src/theme/generateThemeRules.ts: clear. - File
packages/core/src/theme/generateThemeRules.test.ts: clear. - File
packages/core/src/theme/tokenReferences.ts: clear. - File
packages/core/src/theme/tokenReferences.test.ts: clear.
User impact
A theme whose padding uses
clamp(),calc(),min(),max()orvar()with a fallback builds broken CSS: the theme compiler splitspadding: clamp(8px, 2vw, 16px)on every space, including the spaces inside the function.Problem and solution fit
generateThemeRulessplitspadding,paddingBlockandpaddingInlineinto their sides by spaces. A space inside parentheses or quotes is not a separator between values.Expected behavior and authority
A theme's padding value builds as written, the way CSS reads it.
Smallest restoration
The split happens only on spaces between top-level values, never on a space inside parentheses or quotes (escaped quotes included). It uses one scanner shared with the existing top-level comma split in
tokenReferences.ts. Values without functions split as before, and an empty padding value emits no token.Evidence
generateThemeRules.test.tscoverclamp(),calc(),min(),max()andvar()with a fallback, next to the plain cases that split as before.tokenReferences.test.tscover the shared scanner: quoted values, an escaped quote inside a string, nested functions, a quotedvar()fallback, and an empty value.Scope
Components: Core theme compiler
Testing
packages/core/src/theme/generateThemeRules.test.tsandtokenReferences.test.ts; the Core theme tests, typecheck, eslint and prettier pass.