Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions configurator/src/components/panels/LayoutPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
let centerMax = $derived(parseRem(overrides["--sf-center-max"], 75));
let centerGutter = $derived(parseRem(overrides["--sf-center-gutter"], 1));
let gridMin = $derived(parseRem(overrides["--sf-grid-min"], 16));
let gridGap = $derived(parseRem(overrides["--sf-grid-gap"], 1));
let headerMobile = $derived(parseRem(overrides["--sf-header-height-mobile"], 3.5));
let headerDesktop = $derived(parseRem(overrides["--sf-header-height-desktop"], 5));
let sidebarWidth = $derived(parseRem(overrides["--sf-sidebar-width"], 18));
Expand Down Expand Up @@ -212,6 +213,22 @@
<span class="text-[10px] text-slate-500">{showAutoGrid ? "▲" : "▼"}</span>
</button>
{#if showAutoGrid}
<!-- step 0.0625rem (1px) intentionally matches the gap-token sliders in
SpacingPanel (--sf-gap / --sf-content-gap / --sf-gutter), which
--sf-grid-gap defaults to — finer than the size controls elsewhere
in this panel, so grid gap isn't tuned coarser than the token it
inherits from. -->
<SliderRow
label="Grid gap" value={gridGap} min={0} max={4} step={0.0625} unit="rem"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Step granularity inconsistent with peer gap controls

The Grid gap slider uses step={0.0625} (1/16 rem ≈ 1 px/step), while every other gap-style control in this file — center gutter (step={0.125}), imposter margin (step={0.125}), alternate inner gap (step={0.125}) — uses step={0.125} (2 px/step). If this finer resolution is intentional it should be called out in a comment; otherwise aligning it to 0.125 keeps the UX consistent.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The finer step is intentional, and I've added a code comment explaining it (e799111). --sf-grid-gap is a gap token that defaults to --sf-gap, so I mirrored the gap-token sliders in SpacingPanel (--sf-gap / --sf-content-gap / --sf-gutter), which all use step={0.0625}. The peer controls you cite (center gutter, imposter margin, alternate inner gap) aren't the closest analog here — tuning the grid gap more coarsely than the very token it inherits from would be the odd result. Keeping 0.0625 for consistency with the gap family rather than aligning to the panel's non-gap size controls.


Generated by Claude Code

help="--sf-grid-gap — gap between grid cells (.sf-grid, .sf-grid-flex, .sf-grid-cols-*); defaults to --sf-gap"
overridden={"--sf-grid-gap" in overrides}
onChange={(v) => onSet("--sf-grid-gap", `${v}rem`)}
onReset={() => onReset("--sf-grid-gap")}
rawDefault="var(--sf-gap)"
variableOptions={SPACE_SCALE}
currentRaw={overrides["--sf-grid-gap"]}
onRawSet={(v) => onSet("--sf-grid-gap", v)}
/>
<SliderRow
label="Grid min cell width" value={gridMin} min={8} max={40} step={0.5} unit="rem"
help="sf-grid minimum column width — browser auto-fills columns"
Expand Down Expand Up @@ -243,8 +260,8 @@
<div class="bg-black/4 dark:bg-white/4 rounded-xl border border-black/8 dark:border-white/8 p-3">
<div class="text-[9px] text-slate-400 dark:text-slate-600 mb-2 font-mono">Preview at 360px panel width</div>
<div
class="grid gap-1"
style={`grid-template-columns: repeat(auto-fill, minmax(${Math.min(gridMin * 16 * (360 / 1200), 120)}px, 1fr))`}
class="grid"
style={`grid-template-columns: repeat(auto-fill, minmax(${Math.min(gridMin * 16 * (360 / 1200), 120)}px, 1fr)); gap: ${gridGap * 16 * (360 / 1200)}px`}
>
{#each Array.from({ length: 8 }) as _, i (i)}
<div class="h-8 bg-indigo-500/20 border border-indigo-500/20 rounded text-[8px] font-mono text-indigo-600/60 dark:text-indigo-400/60 flex items-center justify-center">col</div>
Expand Down
32 changes: 32 additions & 0 deletions docs/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,35 @@ Override a single instance without new CSS:
```html
<div class="sf-cluster" style="--sf-cluster-gap: var(--sf-space-l)">…</div>
```

## Responsive gaps

Gaps are already fluid: `--sf-grid-gap` defaults to `--sf-gap`, which interpolates
between its mobile and desktop ends via the shared space scale. Retune the whole
rhythm at once with the space-scale endpoints (`--sf-space-base-min` /
`--sf-space-base-max`) rather than per-token knobs.

When one primitive needs a **different** gap on small vs large screens, override
its scoped token inside a `@container` query — the same container-driven model the
primitives themselves use, so the gap reacts to the same width that collapses the
columns. Endpoints stay live tokens, so they still follow any scale retuning:

```css
.product-grid { --sf-grid-gap: var(--sf-space-l); }

@container (min-width: 48rem) {
.product-grid { --sf-grid-gap: var(--sf-space-xl); }
}
```

```html
<div class="sf-container">
<div class="sf-grid product-grid">…</div>
</div>
```

The override needs a container ancestor (`.sf-container` or `.sf-cq`) — the same
requirement as `.sf-grid-cols-*`. The gap steps at the breakpoint rather than
interpolating across it; for a gap that single step is imperceptible in normal use.
The same pattern works for any scoped gap token (`--sf-gap`, `--sf-content-gap`,
`--sf-gutter`, `--sf-cluster-gap`, …).