From 5d175fb9dd8f7b8d12817bb8b056d5b3d14e0857 Mon Sep 17 00:00:00 2001 From: Mark Dumay <61946753+markdumay@users.noreply.github.com> Date: Fri, 31 Jul 2026 07:09:54 +0200 Subject: [PATCH] fix(section): apply a block padding override to both axes `padding: N` set the section's vertical padding and left the horizontal axis on the site default, so a block with an override rendered an asymmetric box -- 24px vertical against 48px horizontal at the default config. One number producing two values surprises authors, which is how this surfaced. Both axes now take the override, scoped to the inner content container: no override inner 48px all sides (site default, unchanged) padding: 4 inner 24px all sides padding: 0 inner 0px all sides The outer container keeps the site padding in every case, so an overridden section still lines its edge up with its neighbours -- all three fixture sections start at x=48 on desktop and x=16 on mobile, with identical outer padding. The author is repadding their content, not moving the section out of the page grid. The site-level mobile overrides are dropped with the values they refine. They exist to taper the *site* defaults, and an author naming one number for one section is not asking for a taper. At 390px with the site's `mobile.x = 3`, an unoverridden section renders 48px vertical / 16px horizontal while `padding: 4` renders 24px on all four sides -- and the outer container still tapers to 16px either way. This reverses the vertical-only scoping from #186, which avoided the horizontal axis because it also feeds the outer container. Splitting the two containers removes that constraint rather than trading against it. `pnpm test` passes: 40 pages, no errors. Verified on a 1119-page site across all three cases at 1440px and 390px. --- data/structures/section.yml | 9 ++++++--- layouts/partials/utilities/section.html | 26 +++++++++++++------------ 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/data/structures/section.yml b/data/structures/section.yml index 14736fe..1939575 100644 --- a/data/structures/section.yml +++ b/data/structures/section.yml @@ -29,9 +29,12 @@ arguments: optional: true default: comment: >- - Overrides the section's vertical padding, replacing the site-wide `y` - value from the `padding` configuration. Accepts 0 through 5. Horizontal - padding is unaffected: it is the page gutter, shared by every section. + Overrides the section's padding on both axes, replacing the site-wide + `x` and `y` values from the `padding` configuration. Accepts 0 through 5. + Applies at every breakpoint: the site-level mobile overrides are dropped + along with the values they refine. Scoped to the inner content container; + the outer container keeps the site padding, so an overridden section still + aligns with its neighbours. Falls back to the site setting when omitted. The empty `default:` above is load-bearing: it overrides the `default: 3` this argument would otherwise inherit from the shared definition in mod-utils, which would make an diff --git a/layouts/partials/utilities/section.html b/layouts/partials/utilities/section.html index c399be2..1fda345 100644 --- a/layouts/partials/utilities/section.html +++ b/layouts/partials/utilities/section.html @@ -19,7 +19,7 @@ {{- $padding := partial "utilities/GetPadding.html" -}} -{{/* Optional per-section vertical padding override. +{{/* Optional per-section padding override, applied to both axes. The `padding` argument inherits the shared definition in mod-utils `data/structures/_arguments.yml`, which carries `default: 3`. That default @@ -32,17 +32,18 @@ Compared against nil rather than tested for truthiness: 0 is a legitimate value that `with` or `| default` would silently discard. - The override replaces the y axis only. x is the page gutter — letting one - block change it would misalign that section against every other section on - the page, and it also feeds the outer container. Any mobile y override is - dropped along with it, since that value was derived from the site setting - the author is replacing; the override then applies at every width. */}} + `padding: N` means N on both axes, at every breakpoint. The site-level + mobile overrides are dropped with the values they refine: they exist to + taper the *site* defaults, and an author naming one number for this section + is not asking for a taper. + + The override reaches the inner content container only. The outer container + keeps the site padding, so a section with an override still lines its edge + up with every other section on the page -- the author is repadding their + content, not moving the section out of the page grid. */}} +{{- $sitePadding := $padding -}} {{- if ne $args.padding nil -}} - {{- $revised := dict "x" $padding.x "y" (int $args.padding) -}} - {{- if isset $padding "mobileX" -}} - {{- $revised = merge $revised (dict "mobileX" (index $padding "mobileX")) -}} - {{- end -}} - {{- $padding = $revised -}} + {{- $padding = dict "x" (int $args.padding) "y" (int $args.padding) -}} {{- end -}} {{- $page := or $args.page page -}} @@ -54,7 +55,8 @@ {{- $pxClasses := partial "utilities/PaddingClasses.html" (dict "padding" $padding "axis" "x") -}} {{- $pyClasses := partial "utilities/PaddingClasses.html" (dict "padding" $padding "axis" "y" "prefix" (cond $paddingTop "pb" "py")) -}} {{- $containerPadding := printf "%s %s%s" $pxClasses (cond $args.fluid "px-xxl-0 " "") $pyClasses -}} - {{- $paddingOuter := printf "px-xxl-0 %s py-0" $pxClasses -}} + {{- $pxOuter := partial "utilities/PaddingClasses.html" (dict "padding" $sitePadding "axis" "x") -}} + {{- $paddingOuter := printf "px-xxl-0 %s py-0" $pxOuter -}} {{ if $embed }} {{- $containerPadding = printf "px-0 %s" $pyClasses -}} {{ end }}