maverick-wave 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,158 @@
1
+ @use '../abstracts' as *;
2
+
3
+ @layer mw.layout {
4
+ // The image gets its own layer instead of `background-attachment: fixed`: that
5
+ // one is ignored on iOS and sizes against the viewport rather than the block.
6
+ // Here a transform runs on the browser's own scroll timeline - no listener, no
7
+ // repaint per frame. Without timeline support the image simply sits still.
8
+ //
9
+ // The min-height is what makes a band with nothing but an image work at all;
10
+ // content taller than that grows past it.
11
+ .mw-parallax {
12
+ --mw-parallax-depth: 10vh;
13
+ --mw-parallax-pattern-depth: 3.5vh;
14
+
15
+ position: relative;
16
+ display: flex;
17
+ align-items: center;
18
+ min-height: 42vh;
19
+ // `clip` and never `hidden`: hidden makes this a scroll container, and the
20
+ // view() timeline below would then resolve against this box instead of the
21
+ // viewport - the layer keeps its overhang and never moves
22
+ overflow: clip;
23
+ isolation: isolate;
24
+ }
25
+
26
+ // Overhangs the block by `depth` at the top and the bottom and travels exactly
27
+ // that distance, so no edge is ever uncovered. Works as an <img> and as a div
28
+ // carrying a background-image.
29
+ .mw-parallax-media {
30
+ position: absolute;
31
+ left: 0;
32
+ top: calc(-1 * var(--mw-parallax-depth));
33
+ width: 100%;
34
+ height: calc(100% + 2 * var(--mw-parallax-depth));
35
+ object-fit: cover;
36
+ background-position: center;
37
+ background-size: cover;
38
+ z-index: 0;
39
+ pointer-events: none;
40
+ }
41
+
42
+ .mw-parallax-content {
43
+ position: relative;
44
+ z-index: z-index('lift');
45
+ width: 100%;
46
+ padding: spacing('10') spacing('6');
47
+ }
48
+
49
+ // The other way to use a picture against the scroll: the block stays pinned to
50
+ // the top of the screen and the rest of the page rides up over it.
51
+ //
52
+ // Goes on whatever element the page content is a *sibling* of - the section
53
+ // around a hero, not the hero itself - because that is what the rule below
54
+ // reaches the covering content through.
55
+ .mw-parallax-sticky {
56
+ position: sticky;
57
+ top: 0;
58
+ z-index: 0;
59
+ }
60
+
61
+ // The picture holds still by default, so it needs neither overhang nor travel.
62
+ // Both selectors, because the class can sit on the block itself or on a
63
+ // section around one - and an inner .mw-parallax would hand the layer its own
64
+ // 10vh back through inheritance.
65
+ .mw-parallax-sticky,
66
+ .mw-parallax-sticky .mw-parallax {
67
+ --mw-parallax-depth: 0px;
68
+ --mw-parallax-pattern-depth: 0px;
69
+ }
70
+
71
+ // ...unless the picture should lift while the text stays put. 12vh over the
72
+ // first screen works out to the same travel per scrolled pixel as a drifting
73
+ // band at 20vh, which is measured against a much longer range.
74
+ .mw-parallax-rise,
75
+ .mw-parallax-rise .mw-parallax {
76
+ --mw-parallax-depth: 12vh;
77
+ --mw-parallax-pattern-depth: 4vh;
78
+ }
79
+
80
+ // A second layer on top of the first, added to the same media element. It
81
+ // travels a third of the distance, and it is that difference between the two
82
+ // that reads as depth - one layer alone only slides. What it carries is a
83
+ // pattern, because the travel is vertical and only an edge across it - a
84
+ // rule, a grid, a hatch - ever shows the movement. A gradient has none.
85
+ .mw-parallax-pattern {
86
+ --mw-parallax-depth: var(--mw-parallax-pattern-depth, 3.5vh);
87
+
88
+ background-image: var(--mw-parallax-pattern-image, none);
89
+ }
90
+
91
+ // Everything after it has to cover it, or the pinned picture shows through the
92
+ // gaps. The z-index needs the weight of a class to beat the plain
93
+ // `position: relative` those sections carry.
94
+ .mw-parallax-sticky ~ * {
95
+ position: relative;
96
+ z-index: 1;
97
+ }
98
+
99
+ // Zero specificity on purpose: it is a floor, not a rule. A section that
100
+ // paints its own surface - mw-section-alternate, a project's own band - has
101
+ // to win here, and this file is forwarded last.
102
+ :where(.mw-parallax-sticky ~ *) {
103
+ background: var(--mw-page-background);
104
+ }
105
+
106
+ // Ink on a photograph, the same pair the hero uses: the picture goes down, the
107
+ // text goes light. A band without content on it needs neither.
108
+ .mw-parallax-dimmed {
109
+ > .mw-parallax-media {
110
+ filter: brightness(0.5);
111
+ }
112
+
113
+ > .mw-parallax-content {
114
+ color: var(--mw-hero-text-color);
115
+
116
+ h1,
117
+ h2,
118
+ h3,
119
+ h4,
120
+ p {
121
+ text-shadow: 0 1px 4px rgb(0 0 0 / 65%);
122
+ }
123
+ }
124
+ }
125
+
126
+ // Longhands and never the shorthand, which esbuild collapses into one
127
+ // `animation:` that cannot carry a timeline. The default range is the whole
128
+ // cover pass, so the band keeps moving as long as any part of it is on screen.
129
+ @supports (animation-timeline: view()) {
130
+ @media (prefers-reduced-motion: no-preference) {
131
+ .mw-parallax-media {
132
+ animation-name: mw-parallax;
133
+ animation-timing-function: linear;
134
+ animation-fill-mode: both;
135
+ animation-timeline: view();
136
+ }
137
+
138
+ // A pinned block does not travel through the viewport, so its view()
139
+ // timeline stands still with it. The document's own scroll is what the
140
+ // picture has left to play against - over the first screen, because after
141
+ // that the page has covered it anyway.
142
+ .mw-parallax-sticky .mw-parallax-media {
143
+ animation-timeline: scroll(root);
144
+ animation-range: 0 100dvh;
145
+ }
146
+ }
147
+ }
148
+
149
+ @keyframes mw-parallax {
150
+ from {
151
+ transform: translate3d(0, var(--mw-parallax-depth), 0);
152
+ }
153
+
154
+ to {
155
+ transform: translate3d(0, calc(-1 * var(--mw-parallax-depth)), 0);
156
+ }
157
+ }
158
+ }