fix(wix-headless): numeric spacing scale — kill the max-w-<size> collision (CODEAI-696)#416
Conversation
…the max-w-<size> collision (CODEAI-696) Root cause: compose.mjs emitted a named --spacing-* scale using t-shirt sizes (md, 3xl, …). In Tailwind v4 the width family (max-w-/w-/min-w-) is generated from the --spacing-* namespace, so `max-w-3xl` resolved to --spacing-3xl (~96px) instead of --container-3xl — collapsing any LLM/author-written reading column to one word per line. Hand-written templates dodged it; generated layout (#411/#412) tripped it. Fix — adopt Tailwind v4's built-in numeric spacing (the skill's values already match it 1:1, e.g. md=1rem=`4`, 4xl=6rem=`24`), removing the named scale so nothing collides with width keys: - compose.mjs: stop emitting named --spacing-*; drop it from REQUIRED, the DESIGN.md read, and the container≠spacing check. Tailwind's --spacing base (numeric gap-4/py-24/…) is used directly. Containers kept — now max-w-md/3xl/6xl resolve to --container-* correctly. - emit-design-tokens.mjs: stop projecting named --spacing-* into design-tokens.css / site.d.ts. - Migrated 112 spacing utility classes (gap-md→gap-4, py-4xl→py-24, …) and 122 var(--spacing-*) refs (→ literal rem) across 27 template + instruction-doc files. - Spec docs (DESIGN_MD, DESIGN_SYSTEM, STYLING): dropped the spacing token group (Designer no longer authors spacing) and corrected STYLING's (wrong) claim that max-w-3xl maps to --container-3xl. Verified: compose emits 0 --spacing-* and the 4 --container-* tokens; 0 leftover t-shirt spacing classes/var refs across templates+docs; both scripts parse. Live compiled-CSS/Playwright proof pending a network-capable build env. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ift-cards COMPONENTS (CODEAI-696) The gift-cards component doc still told authors to fall back to var(--spacing-*), which no longer exists after the numeric-spacing migration. Point at Tailwind's numeric spacing instead. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
adimara
left a comment
There was a problem hiding this comment.
this fix only works because the custom spacing values happened to be identical to tailwind's defaults. if someone ever wants a truly custom spacing scale (different values), putting them under
--spacing-* will break max-w-* again. the namespace would need to change (e.g. --rhythm-*) to avoid the collision.
the CSS template files (components-bookings.css, components-ecom.css, components-gift-cards.css) now have hardcoded rem values like gap: 1.5rem
instead of var(--spacing-lg). That's intentional and correct given the fix — but it means these component styles are now not customizable through the spacing system at all. Before, a brand could technically override --spacing-lg and all components would follow. Now they can't. That's probably fine since the whole point was to remove the scale, but it's a subtle loss of flexibility worth being aware of.
There was a problem hiding this comment.
The --spacing-* no longer exist. An LLM reading this comment would think they're still emitted.
There was a problem hiding this comment.
These spacing tokens no longer exist.
There was a problem hiding this comment.
Fixed in d78da2f — removed the stale --spacing-{sm,md,lg,…} entry from the reused-tokens header.
| @@ -99,28 +99,28 @@ const seoTags = service.seoData?.tags ?? []; | |||
There was a problem hiding this comment.
After this fix, there is no spacing scale to fall back to, so max-w-4xl would fall back to Tailwind's default or undefined — not to a 7rem spacing value. The old warning made sense pre-fix; post-fix it's misleading.
There was a problem hiding this comment.
Fixed in d78da2f — the spacing-fallback rationale is obsolete post-fix. Reworded: bare max-w-* keys now resolve to Tailwind --container-*; container-reading remains the recommended prose width.
There was a problem hiding this comment.
--spacing-md no longer exists.
There was a problem hiding this comment.
Fixed in d78da2f — swapped the --spacing-md example for --radius-md and noted spacing is Tailwind-numeric. Applied the same fix to the identical line in ecom/COMPONENTS_CSS.md.
There was a problem hiding this comment.
spacing was removed from the DESIGN.md vocabulary.
There was a problem hiding this comment.
Fixed in d78da2f — dropped spacing from the DESIGN.md vocabulary list.
There was a problem hiding this comment.
Fixed in d78da2f — dropped spacing from the DESIGN.md vocabulary list.
There was a problem hiding this comment.
Fixed in d78da2f — dropped spacing from the DESIGN.md vocabulary list.
| @@ -103,7 +103,7 @@ All page scopes share common inputs and rules. Scope-specific details follow. | |||
| ``` | |||
| 8. **Comments in frontmatter.** Use `//` or `/* */` — never HTML `<!-- -->` comments in `.astro` frontmatter (it's TypeScript, not HTML). HTML comments in the template section are fine. | |||
| 9. **Responsive.** All pages must work at mobile (320px), tablet (768px), and desktop (1024px+). Use Tailwind responsive prefixes (`md:`, `lg:`) and the spacing scale from `@theme`. | |||
…rences (CODEAI-696) Review (adimara) flagged comments/docs that still referenced the removed named --spacing-* scale, plus a real breakage the main-merge re-introduced. Doc/comment fixes (stale references): - templates/global.css @theme comment: drop --spacing-* from the substituted list; reframe as "spacing is Tailwind numeric; never add --spacing-* (it powers the width utilities)". - gift-cards/components-gift-cards.css header: drop --spacing-{…} from reused tokens. - bookings/services/[slug].astro: the max-w warning's spacing-fallback rationale is obsolete post-fix — reframed (max-w-* now resolves to --container-*). - stores/ecom/COMPONENTS_CSS.md, shared/IMPLEMENTER.md: drop `spacing` from the DESIGN.md vocabulary list; swap the --spacing-md token example for --radius-md. - designer/INSTRUCTIONS.md: "spacing scale from @theme" → Tailwind numeric. Real functional fix: - bookings/components-bookings.css: the merged-in bookings rewrite (610d0ea) shipped 6 var(--spacing-sm/md/xl/xs) refs that resolve to nothing after the fix — migrated to literal rem (sm=.75 md=1 lg=1.5 xl=2 xs=.5). Forward guard (review point on namespace fragility): - STYLING.md: note that --spacing-* must never be reintroduced (it shadows max-w-*); custom spacing *values* should use a different namespace (e.g. --rhythm-*). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Thanks @adimara — all addressed in d78da2f. Stale One real bug your review surfaced indirectly: the recent On the two design points:
|
|
#skipreview |
main now contains #416 (numeric spacing fix) + the v1.10.0 release bump. Conflict resolution: - STYLING.md / designer/INSTRUCTIONS.md: took main's finalized #416 wording (the spacing-doc + the "never reintroduce --spacing-*" guard note); #412 only carried the pre-review-fix snapshot. - Navigation/Footer/index.astro: kept DELETED — the full-page branch generates header/footer/home via the LLM, so it has no templates for them. Full-page feature intact (compose nav/footer/home path inputs present); spacing fix intact (0 --spacing-* emitted, 0 var(--spacing-*) refs). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The root fix for the
max-w-3xlcollapseRoot cause:
compose.mjsemitted a named--spacing-*scale using t-shirt sizes (md,3xl, …). In Tailwind v4 the width family (max-w-/w-/min-w-) is generated from the--spacing-*namespace, somax-w-3xlresolved to--spacing-3xl(~96px) instead of--container-3xl— collapsing reading columns to one word per line. Hand-written templates dodged it by only usingmax-w-6xl/max-w-prose; LLM-generated layout (#411/#412) tripped it.Fix (chosen: Tailwind-native numeric): the skill's spacing values already match Tailwind's default scale 1:1 (
md=1rem=4,lg=1.5=6,4xl=6rem=24), so we drop the named scale and use Tailwind's built-in numeric spacing. With no named--spacing-<size>tokens, nothing collides with width keys, andmax-w-md/3xl/6xlresolve to--container-*correctly.Changes
scripts/compose.mjs— stop emitting named--spacing-*; remove it fromREQUIRED, theDESIGN.mdread, and the container≠spacing check. Containers kept.scripts/emit-design-tokens.mjs— stop projecting named--spacing-*.gap-md→gap-4,py-4xl→py-24, …) + 122var(--spacing-*)→literal-rem, across 27 template + instruction-doc files.DESIGN_MD.md,DESIGN_SYSTEM.md,STYLING.md) — drop thespacingtoken group (Designer no longer authors spacing) and correct STYLING's wrong claim thatmax-w-3xl→--container-3xl.Mapping
2xs→1·xs→2·sm→3·md→4·lg→6·xl→8·2xl→12·3xl→16·4xl→24Verification
--spacing-*and the 4--container-*tokens.var(--spacing-*)refs across templates + docs (only intentional explanatory mentions remain).max-w-3xl→--container-3xl) + Playwright render — pending a network-capable build env (sandbox here had no network forwix build).Scope note
Branched off
main. The feature branches (#408 fragments / #410 hybrid / #411 full-home / #412 full-page) carry extra files (e.g.fragments/**) that need the same mechanical migration when they rebase onto this — themax-w-*guardrail added to #411/#412 stays valid in the meantime.🤖 Generated with Claude Code
Before / After — live sites
Both are full-page LLM-generated sites (the LLM writes
max-w-3xlfreely). Same class, opposite outcome:max-w-3xlresolves to--spacing-*scale)var(--spacing-3xl)var(--container-3xl)Measured live in-browser (computed
max-widthon the.max-w-3xlwrappers). Compiled CSS on the "after" site:.max-w-3xl{max-width:var(--container-3xl)}, with0--spacing-*tokens in@theme.Tracked in Jira: CODEAI-704.