Skip to content

Commit 95e634f

Browse files
committed
fix: deduplicate grid column/shadow width into --nc-column-width
The content-width + 2*spacing formula was repeated independently in grid-template-columns, body::before shadow, and .bleed-edge. If a consumer overrode only the grid column, the shadow width diverged. Introduce --nc-column-width on body as the single source of truth; shadow and bleed-edge now reference it instead of recalculating.
1 parent 0384ab9 commit 95e634f

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

src/_document.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
// On narrow viewports min(..., 100%) caps at viewport width; the real
2626
// padding-inline on children provides the spacing — no pseudo-padding.
2727
body {
28+
#{$prefix}column-width: #{string.unquote('calc(var(#{$prefix}content-width) + 2 * var(#{$prefix}spacing))')};
2829
display: grid;
2930
grid-template-columns:
3031
1fr
31-
#{string.unquote('min(calc(var(#{$prefix}content-width) + 2 * var(#{$prefix}spacing)), 100%)')}
32+
#{string.unquote('min(var(#{$prefix}column-width), 100%)')}
3233
1fr;
3334
min-height: 100dvh;
3435
padding-block: var(#{$prefix}spacing);

src/_shadow.scss

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@
5454
}
5555

5656
// Content shadow: fixed-position pseudo spanning the full viewport height.
57-
// Width matches column 2 (content-width + 2*spacing) — the shadow tightly
58-
// wraps the padded column. The real padding-inline on body children creates
57+
// Width matches column 2 (--nc-column-width) — the shadow tightly wraps
58+
// the padded column. The real padding-inline on body children creates
5959
// the visual gap between content and shadow edge.
6060
// The clamp() formula handles visibility: shadow shows when there's at
6161
// least spacing of clearance on each side between shadow and viewport edge,
@@ -68,8 +68,8 @@
6868
left: 50%;
6969
transform: translateX(-50%);
7070
width: clamp(0px,
71-
#{string.unquote('calc((100% - var(#{$prefix}content-width) - 4 * var(#{$prefix}spacing)) * 9999)')},
72-
#{string.unquote('calc(var(#{$prefix}content-width) + 2 * var(#{$prefix}spacing))')}
71+
#{string.unquote('calc((100% - var(#{$prefix}column-width) - 2 * var(#{$prefix}spacing)) * 9999)')},
72+
var(#{$prefix}column-width)
7373
);
7474
box-shadow: var(#{$prefix}content-shadow);
7575
pointer-events: none;
@@ -78,7 +78,7 @@
7878

7979
}
8080

81-
// Break out to shadow/column edge (content-width + 2*spacing).
81+
// Break out to shadow/column edge (--nc-column-width).
8282
// Uses the same shadow-visibility condition as the body::before pseudo:
8383
// when shadow is visible, caps at column width (shadow boundary);
8484
// when shadow is hidden (narrow viewport), goes full width.
@@ -91,8 +91,8 @@
9191
grid-column: 1 / -1;
9292
width: 100%;
9393
max-width: clamp(
94-
#{string.unquote('calc(var(#{$prefix}content-width) + 2 * var(#{$prefix}spacing))')},
95-
#{string.unquote('calc((100% - var(#{$prefix}content-width) - 4 * var(#{$prefix}spacing)) * -9999)')},
94+
var(#{$prefix}column-width),
95+
#{string.unquote('calc((100% - var(#{$prefix}column-width) - 2 * var(#{$prefix}spacing)) * -9999)')},
9696
100%
9797
);
9898
margin-inline: auto;

0 commit comments

Comments
 (0)