feat(ui): Grid columns 1-12 plus responsive object form#1416
Merged
Conversation
Bring Grid's React/Astro variants up to parity with the Web Component (which
already supports cols=12) and add a responsive columns API surfaced by
dogfooding @rafters/mail's marketing landing.
API additions:
- gridColumnClasses extended to 7-12
- gridColSpanClasses extended to 5-12
- ResponsiveColumns type: number | 'auto' | { base?, sm?, md?, lg?, xl?, '2xl'? }
- resolveColumnsClasses(cols) helper produces the class string
- columnsResolvesToAuto(cols) keeps the existing auto-fit fallback intact
Grid.astro and Grid.tsx accept the new ResponsiveColumns type for `columns`.
Grid.Item.tsx and grid-item.astro accept colSpan 1-12.
Example:
<Grid columns={{ base: 2, md: 4 }}>...</Grid>
emits `grid-cols-2 md:grid-cols-4`.
Tests: 10 new cases in grid.classes.test.ts covering column/span ranges,
single-value resolution, base + breakpoint composition, and the auto fallback.
All 65 grid tests pass.
Surfaced by /Volumes/store/projects/rafters-studio/shingle PR #59
(mail.rafters.studio Claude Design handoff translation), where the 8-cell
modules grid needed 12 columns and the footer/hero needed responsive
breakpoint variants.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
Brings Grid's React/Astro variants up to parity with the Web Component (which already supports
cols=12) and adds a responsivecolumnsAPI. Surfaced by dogfooding @rafters/mail's marketing landing in shingle#59, where the 8-cell modules grid needed 12 columns and the footer/hero needed responsive breakpoint variants.API additions
gridColumnClassesextended to 7-12gridColSpanClassesextended to 5-12ResponsiveColumnstype:number | 'auto' | { base?, sm?, md?, lg?, xl?, '2xl'? }resolveColumnsClasses(cols)helper produces the class stringcolumnsResolvesToAuto(cols)keeps the existing auto-fit fallback intactGrid.tsxandgrid.astroboth accept the newResponsiveColumnsforcolumnsGrid.Item(React) andgrid-item.astroacceptcolSpan1-12Example
emits
grid-cols-2 md:grid-cols-4.Tests
10 new cases in
grid.classes.test.tscovering:All 65 grid tests pass; full preflight clean.
Notes
gridResponsiveColumnClassescontains 5 per-breakpoint maps (60 literal class strings). Tailwind v4's JIT scanner needs literal strings — generating them via template literals would make them invisible to the toolchain.Test plan
pnpm --filter=@rafters/ui test grid— 65/65 passpnpm preflight— clean<Grid columns={12}>emitsgrid-cols-12<Grid columns={{ base: 2, md: 4 }}>emitsgrid-cols-2 md:grid-cols-4<Grid.Item colSpan={8}>works<Grid columns={3}>callers unchanged<Grid columns="auto">still triggerssm:grid-cols-2 lg:grid-cols-3fallback