diff --git a/component-library/components/cta/cta.hugo.html b/component-library/components/cta/cta.hugo.html index 2cd26f0..b2602bb 100644 --- a/component-library/components/cta/cta.hugo.html +++ b/component-library/components/cta/cta.hugo.html @@ -64,6 +64,7 @@ "component-name" "cta" "id" .id "raw" $raw + "padding" .padding "background" .background "width" .width "justify" .justify diff --git a/component-library/components/panels/panels.hugo.html b/component-library/components/panels/panels.hugo.html index d9ff94f..bb422ca 100644 --- a/component-library/components/panels/panels.hugo.html +++ b/component-library/components/panels/panels.hugo.html @@ -108,6 +108,7 @@ "component-name" "panels" "id" .id "raw" $raw + "padding" .padding "background" .background "width" .width "justify" .justify diff --git a/data/structures/section.yml b/data/structures/section.yml index fd4f2c8..14736fe 100644 --- a/data/structures/section.yml +++ b/data/structures/section.yml @@ -24,6 +24,19 @@ arguments: bookshop folder. raw: passthrough: + padding: + type: int + 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. + 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 + omitted value indistinguishable from a supplied one and repad every + section. The inherited 0-5 range still applies. background: width: default: 12 diff --git a/layouts/partials/utilities/section.html b/layouts/partials/utilities/section.html index b9e3532..c399be2 100644 --- a/layouts/partials/utilities/section.html +++ b/layouts/partials/utilities/section.html @@ -18,6 +18,33 @@ {{ end }} {{- $padding := partial "utilities/GetPadding.html" -}} + +{{/* Optional per-section vertical padding override. + + The `padding` argument inherits the shared definition in mod-utils + `data/structures/_arguments.yml`, which carries `default: 3`. That default + would arrive whenever a caller omits the argument, making "not supplied" + indistinguishable from "supplied" and silently repadding every section. + `data/structures/section.yml` therefore redeclares `padding` with an empty + `default:`, which overrides the inherited one and restores a real nil. The + inherited `options` (0-5) still apply, so validation is unchanged. + + 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. */}} +{{- 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 -}} +{{- end -}} + {{- $page := or $args.page page -}} {{- $embed := $args.embed | default false }} {{- $paddingTop := and $embed (eq $args._ordinal 0) }}