Skip to content

fix(core): theme padding with functions builds as written - #11347

Merged
josephfarina merged 3 commits into
mainfrom
core-padding-functions
Nov 12, 2026
Merged

josephfarina merged 3 commits into
mainfrom
core-padding-functions

Conversation

@josephfarina

@josephfarina josephfarina commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

User impact

A theme whose padding uses clamp(), calc(), min(), max() or var() with a fallback builds broken CSS: the theme compiler splits padding: clamp(8px, 2vw, 16px) on every space, including the spaces inside the function.

Problem and solution fit

generateThemeRules splits padding, paddingBlock and paddingInline into 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

  • New tests in generateThemeRules.test.ts cover clamp(), calc(), min(), max() and var() with a fallback, next to the plain cases that split as before.
  • New tests in tokenReferences.test.ts cover the shared scanner: quoted values, an escaped quote inside a string, nested functions, a quoted var() fallback, and an empty value.

Scope

Components: Core theme compiler

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

packages/core/src/theme/generateThemeRules.test.ts and tokenReferences.test.ts; the Core theme tests, typecheck, eslint and prettier pass.

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.
@vercel

vercel Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 12, 2026 4:41am UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 12, 2026
@astracat-bot

astracat-bot Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Nov 12, 2026, 5:02 AM UTC

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: the padding fix works, and two small things need to change before it lands.

  • splitTopLevelSpaces in generateThemeRules.ts re-implements the top-level CSS scan that splitTopLevelComma in tokenReferences.ts already 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 to tokenReferences.ts on one scanner shared with splitTopLevelComma and call it from parsePadding.
  • The description says the new tests cover max(), but no test row uses it; please add a max() row (Card padding: max(8px, 2vw) compiles to --astryx-card-padding: max(8px, 2vw);) or drop max() 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 a var() 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, paddingBlock and paddingInline only 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(), a var() fallback and quoted values. False for max() (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: no max() row (second finding); the other rows match the compiler output.

Automated review (maintainer link)

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · eeeb155

Storybook · Sandbox · built from this PR's head

Modified components

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

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.ts rows cover quoted values, but none of them uses a quote now that the quoted case lives in tokenReferences.test.ts; please move "quoted values" to the tokenReferences.test.ts bullet, or add a compiler row such as paddingBlock: 'var(--x, "a b")' that expects both block tokens to keep var(--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 a var() fallback builds as written. Verified from the compiler's padding output and the new test rows.
  • Claim: padding, paddingBlock and paddingInline split 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 became 2vw, 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 paddingInline also clears earlier inline longhands (non-blocking note).
  • Claim: the new compiler tests cover clamp(), calc(), min(), max() and a var() 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 empty paddingInline.
  • 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.

Automated review (maintainer link)

@astracat-bot astracat-bot Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 a var() fallback used to build broken CSS because the compiler split on every space. Verified on the base: the shorthand split was a whitespace regex, and clamp(8px, 2vw, 16px) became 2vw, 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 a var() 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/core that 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.

Automated review (maintainer link)

This branch was successfully deployed

1 active deployment
Preview — eeeb155d Deployed Nov 12, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant