-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
style.scss
328 lines (294 loc) · 9.3 KB
/
style.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
.wp-block-cover-image,
.wp-block-cover {
min-height: 430px;
padding: 1em;
position: relative;
background-position: center center;
display: flex;
justify-content: center;
align-items: center;
// Prevent the `wp-block-cover__background` span from overflowing the container when border-radius is applied.
// `overflow: hidden` is provided as a fallback for browsers that don't support `overflow: clip`.
overflow: hidden;
// Use clip instead of overflow: hidden so that sticky position works on child elements.
overflow: clip;
// This block has customizable padding, border-box makes that more predictable.
box-sizing: border-box;
// Keep the flex layout direction to the physical direction (LTR) in RTL languages.
/*rtl:raw: direction: ltr; */
/**
* Set a default background color for has-background-dim _unless_ it includes another
* background-color class (e.g. has-green-background-color). The presence of another
* background-color class implies that another style will provide the background color
* for the overlay.
*
* See:
* - Issue with background color specificity: https://github.com/WordPress/gutenberg/issues/26545
* - Issue with alternative fix: https://github.com/WordPress/gutenberg/issues/26545
*/
// the first selector is required for old Cover markup
&.has-background-dim:not([class*="-background-color"]),
.has-background-dim:not([class*="-background-color"]) {
background-color: $black;
}
.has-background-dim.has-background-gradient {
background-color: transparent;
}
// the first selector is required for old Cover markup
&.has-background-dim::before {
content: "";
background-color: inherit;
}
// The first selector is required for old Cover markup/
// Keep .wp-block-cover__gradient-background for v8 deprecation.
&.has-background-dim:not(.has-background-gradient)::before,
.wp-block-cover__background,
.wp-block-cover__gradient-background {
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
opacity: 0.5;
}
// The following styles are needed to support legacy blocks added prior to the update
// that moved opacity to a nested span.
// https://github.com/WordPress/gutenberg/pull/35065
// https://github.com/WordPress/gutenberg/pull/38362
@for $i from 1 through 10 {
&.has-background-dim.has-background-dim-#{ $i * 10 } {
&:not(.has-background-gradient)::before,
.wp-block-cover__background,
.wp-block-cover__gradient-background {
opacity: $i * 0.1;
}
}
}
@for $i from 0 through 10 {
// Keep .wp-block-cover__gradient-background for v8 deprecation
.wp-block-cover__gradient-background.has-background-dim.has-background-dim-#{ $i * 10 },
.wp-block-cover__background.has-background-dim.has-background-dim-#{ $i * 10 } {
opacity: $i * 0.1;
}
}
// Apply max-width to floated items that have no intrinsic width
&.alignleft,
&.alignright {
max-width: $content-width * 0.5;
width: 100%;
}
// Aligned cover blocks should not use our global alignment rules
&.aligncenter,
&.alignleft,
&.alignright {
display: flex;
}
.wp-block-cover__inner-container {
position: relative; // Needed for the inner container to be positioned above other elements with absolute positioning.
width: 100%;
color: inherit;
// Reset the fixed LTR direction at the root of the block in RTL languages.
/*rtl:raw: direction: rtl; */
}
// Position: Top
&.is-position-top-left {
align-items: flex-start;
justify-content: flex-start;
}
&.is-position-top-center {
align-items: flex-start;
justify-content: center;
}
&.is-position-top-right {
align-items: flex-start;
justify-content: flex-end;
}
// Position: Center
&.is-position-center-left {
align-items: center;
justify-content: flex-start;
}
&.is-position-center-center {
align-items: center;
justify-content: center;
}
&.is-position-center-right {
align-items: center;
justify-content: flex-end;
}
// Position: Bottom
&.is-position-bottom-left {
align-items: flex-end;
justify-content: flex-start;
}
&.is-position-bottom-center {
align-items: flex-end;
justify-content: center;
}
&.is-position-bottom-right {
align-items: flex-end;
justify-content: flex-end;
}
&.has-custom-content-position.has-custom-content-position {
.wp-block-cover__inner-container {
margin: 0;
}
&.is-position-top-left,
&.is-position-top-right,
&.is-position-center-left,
&.is-position-center-right,
&.is-position-bottom-left,
&.is-position-bottom-right {
.wp-block-cover__inner-container {
margin: 0;
width: auto;
}
}
}
// Extra specificity for in edit mode where other styles would override it otherwise.
.wp-block-cover__image-background,
video.wp-block-cover__video-background {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
margin: 0;
padding: 0;
width: 100%;
height: 100%;
max-width: none;
max-height: none;
object-fit: cover;
outline: none;
border: none;
box-shadow: none;
}
}
.wp-block-cover-image,
.wp-block-cover,
.wp-block-cover__image-background,
video.wp-block-cover__video-background {
&.has-parallax {
background-attachment: fixed;
background-size: cover;
background-repeat: no-repeat;
// Mobile Safari does not support fixed background attachment properly.
// See also https://stackoverflow.com/questions/24154666/background-size-cover-not-working-on-ios
// Chrome on Android does not appear to support the attachment at all: https://issuetracker.google.com/issues/36908439
@supports (-webkit-touch-callout: inherit) {
background-attachment: scroll;
}
// Remove the appearance of scrolling based on OS-level animation preferences.
@media (prefers-reduced-motion: reduce) {
background-attachment: scroll;
}
}
&.is-repeated {
background-repeat: repeat;
background-size: auto;
}
}
// Styles below only exist to support older versions of the block.
// Versions that not had inner blocks and used an h2 heading had a section (and not a div) with a class wp-block-cover-image (and not a wp-block-cover).
// We are using the previous referred differences to target old versions.
section.wp-block-cover-image h2,
.wp-block-cover-image-text,
.wp-block-cover-text {
color: $white;
a,
a:hover,
a:focus,
a:active {
color: $white;
}
}
.wp-block-cover-image
.wp-block-cover {
&.has-left-content {
justify-content: flex-start;
}
&.has-right-content {
justify-content: flex-end;
}
}
section.wp-block-cover-image.has-left-content > h2,
.wp-block-cover-image.has-left-content .wp-block-cover-image-text,
.wp-block-cover.has-left-content .wp-block-cover-text {
margin-left: 0;
text-align: left;
}
section.wp-block-cover-image.has-right-content > h2,
.wp-block-cover-image.has-right-content .wp-block-cover-image-text,
.wp-block-cover.has-right-content .wp-block-cover-text {
margin-right: 0;
text-align: right;
}
section.wp-block-cover-image > h2,
.wp-block-cover-image .wp-block-cover-image-text,
.wp-block-cover .wp-block-cover-text {
font-size: 2em;
line-height: 1.25;
z-index: 1;
margin-bottom: 0;
max-width: $content-width;
padding: 0.44em;
text-align: center;
}
// If Cover block's text color has not been set adjust default color
// based on if overlay is light or not. The following styles leverage
// `:where` to allow for generic global styles that have a low specificity to
// still take precedence.
:where(.wp-block-cover:not(.has-text-color)),
:where(.wp-block-cover-image:not(.has-text-color)) {
color: $white;
}
:where(.wp-block-cover.is-light:not(.has-text-color)),
:where(.wp-block-cover-image.is-light:not(.has-text-color)) {
color: $black;
}
:root {
:where(.wp-block-cover p:not(.has-text-color)),
:where(.wp-block-cover h1:not(.has-text-color)),
:where(.wp-block-cover h2:not(.has-text-color)),
:where(.wp-block-cover h3:not(.has-text-color)),
:where(.wp-block-cover h4:not(.has-text-color)),
:where(.wp-block-cover h5:not(.has-text-color)),
:where(.wp-block-cover h6:not(.has-text-color)) {
color: inherit;
}
}
// Backward compatibility for v14 deprecation. Only applied to the frontend.
// Regarding the `.wp-block-cover__background + .wp-block-cover__inner-container`
// selector: When the `.wp-block-cover__inner-container` comes right after the
// `.wp-block-cover__background` , it means that it's using the new HTML
// structure or that it's using the color background or gradient (even in
// the deprecated version). In the color background or gradient option we don't
// need the z-index because the elements are in the expected order.
body:not(.editor-styles-wrapper) .wp-block-cover:not(
.wp-block-cover:has(
.wp-block-cover__background + .wp-block-cover__inner-container
)
) {
.wp-block-cover__video-background {
z-index: z-index(".wp-block-cover__video-background");
}
.wp-block-cover__image-background {
z-index: z-index(".wp-block-cover__image-background");
}
// The first selector is required for old Cover markup/
// Keep .wp-block-cover__gradient-background for v8 deprecation.
&.has-background-dim:not(.has-background-gradient)::before,
.wp-block-cover__background,
.wp-block-cover__gradient-background {
z-index: z-index(".wp-block-cover.has-background-dim::before");
}
.wp-block-cover__inner-container {
z-index: z-index(".wp-block-cover__inner-container");
// Reset the z-index to auto when the body has a modal open. So when the
// modal is inside the cover, it doesn't create a stacking context.
@at-root .has-modal-open & {
z-index: auto;
}
}
}