Skip to content

Commit 35c8c7d

Browse files
committed
Render the webinar strip padding server-side so the hero clears the nav before Alpine runs
1 parent 0207dfa commit 35c8c7d

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎layouts/partials/banner-padding.html‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
{{- /* Returns the element's class attributes with the top padding that clears
22
the fixed nav and the active banners. The webinar banner hides itself
3-
client-side, so when it is the only strip the padding comes as an Alpine
4-
:class as well. Context: "context" (the page), "classes" (the element's other
5-
classes), "base", and optionally "thinStrip", "anniversary", and "both", which
6-
default to a flush hero's clearance. */ -}}
3+
client-side. When it is the only strip, the padding assumes the strip, which
4+
is the state before Alpine runs, and an Alpine :class on the body's webinar
5+
state swaps in the no-strip padding once the banner reports none. Context:
6+
"context" (the page), "classes" (the element's other classes), "base", and
7+
optionally "thinStrip", "anniversary", and "both", which default to a flush
8+
hero's clearance. */ -}}
79
{{- $showWebinarBanner := .context.Scratch.Get "webinarBannerActive" -}}
810
{{- $showSaleBanner := .context.Scratch.Get "saleBannerActive" -}}
911
{{- $showAnniversaryBanner := .context.Scratch.Get "anniversaryBannerActive" -}}
@@ -22,6 +24,10 @@
2224
{{- $attrs := printf "class=\"%s %s\"" .classes $padding -}}
2325
{{- if and $showWebinarBanner (not $showSaleBanner) -}}
2426
{{- $paddingNoStrip := cond $showAnniversaryBanner $anniversary .base -}}
25-
{{- $attrs = printf "class=\"%s\" :class=\"webinar.state === 'none' ? '%s' : '%s'\"" .classes $paddingNoStrip $padding -}}
27+
{{- /* Only the tokens that differ enter the Alpine object, so a token both
28+
paddings share stays in the static class and is never removed. */ -}}
29+
{{- $onlyNoStrip := delimit (complement (split $padding " ") (split $paddingNoStrip " ")) " " -}}
30+
{{- $onlyStrip := delimit (complement (split $paddingNoStrip " ") (split $padding " ")) " " -}}
31+
{{- $attrs = printf `%s :class="{ '%s': webinar.state === 'none', '%s': webinar.state !== 'none' }"` $attrs $onlyNoStrip $onlyStrip -}}
2632
{{- end -}}
2733
{{- return ($attrs | safeHTMLAttr) -}}

0 commit comments

Comments
 (0)