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
9 changes: 6 additions & 3 deletions data/structures/section.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 14 additions & 12 deletions layouts/partials/utilities/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 -}}
Expand All @@ -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 }}
Expand Down