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
1 change: 1 addition & 0 deletions component-library/components/cta/cta.hugo.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"component-name" "cta"
"id" .id
"raw" $raw
"padding" .padding
"background" .background
"width" .width
"justify" .justify
Expand Down
1 change: 1 addition & 0 deletions component-library/components/panels/panels.hugo.html
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
"component-name" "panels"
"id" .id
"raw" $raw
"padding" .padding
"background" .background
"width" .width
"justify" .justify
Expand Down
13 changes: 13 additions & 0 deletions data/structures/section.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 27 additions & 0 deletions layouts/partials/utilities/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down