|
1 | 1 | {{- /* Returns the element's class attributes with the top padding that clears |
2 | 2 | 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. */ -}} |
7 | 9 | {{- $showWebinarBanner := .context.Scratch.Get "webinarBannerActive" -}} |
8 | 10 | {{- $showSaleBanner := .context.Scratch.Get "saleBannerActive" -}} |
9 | 11 | {{- $showAnniversaryBanner := .context.Scratch.Get "anniversaryBannerActive" -}} |
|
22 | 24 | {{- $attrs := printf "class=\"%s %s\"" .classes $padding -}} |
23 | 25 | {{- if and $showWebinarBanner (not $showSaleBanner) -}} |
24 | 26 | {{- $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 -}} |
26 | 32 | {{- end -}} |
27 | 33 | {{- return ($attrs | safeHTMLAttr) -}} |
0 commit comments