forked from ampproject/amp-wp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle.php
460 lines (385 loc) · 10.4 KB
/
style.php
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
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
<?php
/**
* Style template.
*
* 🚫🚫🚫
* DO NOT EDIT THIS FILE WHILE INSIDE THE PLUGIN! Changes You make will be lost when a new version
* of the AMP plugin is released. You need to copy this file out of the plugin and put it into your
* custom theme, for example. To learn about how to customize these Reader-mode AMP templates, please
* see: https://amp-wp.org/documentation/how-the-plugin-works/classic-templates/
* 🚫🚫🚫
*
* @package AMP
*/
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped
/**
* Context.
*
* @var AMP_Post_Template $this
*/
$content_max_width = absint( $this->get( 'content_max_width' ) );
$theme_color = $this->get_customizer_setting( 'theme_color' );
$text_color = $this->get_customizer_setting( 'text_color' );
$muted_text_color = $this->get_customizer_setting( 'muted_text_color' );
$border_color = $this->get_customizer_setting( 'border_color' );
$link_color = $this->get_customizer_setting( 'link_color' );
$header_background_color = $this->get_customizer_setting( 'header_background_color' );
$header_color = $this->get_customizer_setting( 'header_color' );
$alignwide_max = $content_max_width > 0 ? $content_max_width * 2 : 1920
?>
/* Generic WP styling */
.alignnone,
.aligncenter,
.alignleft,
.alignright,
.alignwide {
margin-top: 1em;
margin-right: auto;
margin-bottom: 1em;
margin-left: auto;
}
.alignright {
float: right;
}
.alignleft {
float: left;
}
.aligncenter {
display: block;
text-align: center;
margin-left: auto;
margin-right: auto;
}
.alignwide {
width: 100%;
}
@media (min-width: 792px) {
.alignwide {
width: calc(100vw - 48px);
max-width: calc(100vw - 48px);
margin-left: calc(50% - 50vw + 24px);
margin-right: calc(50% - 50vw + 24px);
}
}
@media (min-width: <?php echo sprintf( '%dpx', $alignwide_max ); ?>) {
.alignwide {
width: calc(<?php echo sprintf( '%dpx', $alignwide_max ); ?> - 48px);
max-width: calc(<?php echo sprintf( '%dpx', $alignwide_max ); ?> - 48px);
margin-left: calc(calc(50% - <?php echo sprintf( '%dpx', $alignwide_max ); ?> / 2) + 24px);
margin-right: calc(calc(50% - <?php echo sprintf( '%dpx', $alignwide_max ); ?> / 2) + 24px);
}
}
.alignfull {
width: 100vw;
max-width: 100vw;
margin-left: calc(50% - 50vw);
margin-right: calc(50% - 50vw);
}
.amp-wp-enforced-sizes {
/** Our sizes fallback is 100vw, and we have a padding on the container; the max-width here prevents the element from overflowing. **/
max-width: 100%;
margin: 0 auto;
}
.amp-wp-article-content > p.has-background {
/*
* The 2.375 value comes from the $block-bg-padding--h SCSS variable:
* https://github.com/WordPress/gutenberg/blob/22ca90c/packages/base-styles/_variables.scss#L98-L104
* https://github.com/WordPress/gutenberg/blob/22ca90c/packages/block-library/src/paragraph/style.scss#L41-L43
*/
margin-left: -2.375em;
margin-right: -2.375em;
margin-block-start: 0;
margin-block-end: 16px;
}
/* Template Styles */
.amp-wp-content,
.amp-wp-title-bar div {
<?php if ( $content_max_width > 0 ) : ?>
margin: 0 auto;
max-width: <?php echo sprintf( '%dpx', $content_max_width ); ?>;
<?php endif; ?>
}
html {
background: <?php echo sanitize_hex_color( $header_background_color ); ?>;
}
body {
background: <?php echo sanitize_hex_color( $theme_color ); ?>;
color: <?php echo sanitize_hex_color( $text_color ); ?>;
font-family: Georgia, 'Times New Roman', Times, Serif;
font-weight: 300;
line-height: 1.75;
}
p,
ol,
ul,
figure {
margin: 0 0 1em;
padding: 0;
}
a,
a:visited {
color: <?php echo sanitize_hex_color( $link_color ); ?>;
}
a:hover,
a:active,
a:focus {
color: <?php echo sanitize_hex_color( $text_color ); ?>;
}
/* Quotes */
blockquote {
color: <?php echo sanitize_hex_color( $text_color ); ?>;
background: rgba(127,127,127,.125);
border-<?php echo is_rtl() ? 'right' : 'left'; ?>: 2px solid <?php echo sanitize_hex_color( $link_color ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
margin: 8px 0 24px 0;
padding: 16px;
}
blockquote p:last-child {
margin-bottom: 0;
}
/* UI Fonts */
.amp-wp-meta,
.amp-wp-header div,
.amp-wp-title,
.wp-caption-text,
.amp-wp-tax-category,
.amp-wp-tax-tag,
.amp-wp-comments-link,
.amp-wp-footer p,
.back-to-top {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen-Sans", "Ubuntu", "Cantarell", "Helvetica Neue", sans-serif;
}
/* Header */
.amp-wp-header {
background-color: <?php echo sanitize_hex_color( $header_background_color ); ?>;
}
.amp-wp-header div {
color: <?php echo sanitize_hex_color( $header_color ); ?>;
font-size: 1em;
font-weight: 400;
margin: 0 auto;
max-width: calc(840px - 32px);
padding: .875em 16px;
position: relative;
}
.amp-wp-header a {
color: <?php echo sanitize_hex_color( $header_color ); ?>;
text-decoration: none;
}
.amp-wp-header .amp-wp-site-icon {
/** site icon is 32px **/
background-color: <?php echo sanitize_hex_color( $header_color ); ?>;
border: 1px solid <?php echo sanitize_hex_color( $header_color ); ?>;
border-radius: 50%;
position: absolute;
<?php echo is_rtl() ? 'left' : 'right'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>: 18px;
top: 10px;
}
/* Article */
.amp-wp-article {
color: <?php echo sanitize_hex_color( $text_color ); ?>;
font-weight: 400;
margin: 1.5em auto;
max-width: 840px;
overflow-wrap: break-word;
word-wrap: break-word;
}
/* Article Header */
.amp-wp-article-header {
align-items: center;
align-content: stretch;
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin: 1.5em 16px 0;
}
.amp-wp-title {
color: <?php echo sanitize_hex_color( $text_color ); ?>;
display: block;
flex: 1 0 100%;
font-weight: 900;
margin: 0 0 .625em;
width: 100%;
}
/* Article Meta */
.amp-wp-meta {
color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
display: inline-block;
flex: 2 1 50%;
font-size: .875em;
line-height: 1.5em;
margin: 0 0 1.5em;
padding: 0;
}
.amp-wp-article-header .amp-wp-meta:last-of-type {
text-align: <?php echo is_rtl() ? 'left' : 'right'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
}
.amp-wp-article-header .amp-wp-meta:first-of-type {
text-align: <?php echo is_rtl() ? 'right' : 'left'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
}
.amp-wp-byline amp-img,
.amp-wp-byline .amp-wp-author {
display: inline-block;
vertical-align: middle;
}
.amp-wp-byline amp-img {
border: 1px solid <?php echo sanitize_hex_color( $link_color ); ?>;
border-radius: 50%;
position: relative;
margin-<?php echo is_rtl() ? 'left' : 'right'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>: 6px;
}
.amp-wp-posted-on {
text-align: <?php echo is_rtl() ? 'left' : 'right'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>;
}
/* Featured image */
.amp-wp-article-featured-image {
margin: 0 0 1em;
}
.amp-wp-article-featured-image img:not(amp-img) {
max-width: 100%;
height: auto;
margin: 0 auto;
}
.amp-wp-article-featured-image amp-img {
margin: 0 auto;
}
.amp-wp-article-featured-image.wp-caption .wp-caption-text {
margin: 0 18px;
}
/* Article Content */
.amp-wp-article-content {
margin: 0 16px;
}
.amp-wp-article-content ul,
.amp-wp-article-content ol {
margin-<?php echo is_rtl() ? 'right' : 'left'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>: 1em;
}
.amp-wp-article-content .wp-caption {
max-width: 100%;
}
.amp-wp-article-content amp-img {
margin: 0 auto;
}
.amp-wp-article-content amp-img.alignright,
.amp-wp-article-content .wp-block-cover.alignright {
margin: 0 0 1em 16px;
}
.amp-wp-article-content amp-img.alignleft,
.amp-wp-article-content .wp-block-cover.alignleft {
margin: 0 16px 1em 0;
}
/* Captions */
.wp-caption {
padding: 0;
}
.wp-caption.alignleft {
margin-right: 16px;
}
.wp-caption.alignright {
margin-left: 16px;
}
.wp-caption .wp-caption-text {
border-bottom: 1px solid <?php echo sanitize_hex_color( $border_color ); ?>;
color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
font-size: .875em;
line-height: 1.5em;
margin: 0;
padding: .66em 10px .75em;
}
/* AMP Media */
.alignwide,
.alignfull {
clear: both;
}
amp-carousel {
background: <?php echo sanitize_hex_color( $border_color ); ?>;
margin: 0 -16px 1.5em;
}
amp-iframe,
amp-youtube,
amp-instagram,
amp-vine {
background: <?php echo sanitize_hex_color( $border_color ); ?>;
margin: 0 -16px 1.5em;
}
.amp-wp-article-content amp-carousel amp-img {
border: none;
}
amp-carousel > amp-img > img {
object-fit: contain;
}
.amp-wp-iframe-placeholder {
background: <?php echo sanitize_hex_color( $border_color ); ?> url( <?php echo esc_url( $this->get( 'placeholder_image_url' ) ); ?> ) no-repeat center 40%;
background-size: 48px 48px;
min-height: 48px;
}
/* Article Footer Meta */
.amp-wp-article-footer .amp-wp-meta {
display: block;
}
.amp-wp-tax-category,
.amp-wp-tax-tag {
color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
font-size: .875em;
line-height: 1.5em;
margin: 1.5em 16px;
}
.amp-wp-comments-link {
color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
font-size: .875em;
line-height: 1.5em;
text-align: center;
margin: 2.25em 0 1.5em;
}
.amp-wp-comments-link a {
border-style: solid;
border-color: <?php echo sanitize_hex_color( $border_color ); ?>;
border-width: 1px 1px 2px;
border-radius: 4px;
background-color: transparent;
color: <?php echo sanitize_hex_color( $link_color ); ?>;
cursor: pointer;
display: block;
font-size: 14px;
font-weight: 600;
line-height: 18px;
margin: 0 auto;
max-width: 200px;
padding: 11px 16px;
text-decoration: none;
width: 50%;
-webkit-transition: background-color 0.2s ease;
transition: background-color 0.2s ease;
}
/* AMP Footer */
.amp-wp-footer {
border-top: 1px solid <?php echo sanitize_hex_color( $border_color ); ?>;
margin: calc(1.5em - 1px) 0 0;
}
.amp-wp-footer div {
margin: 0 auto;
max-width: calc(840px - 32px);
padding: 1.25em 16px 1.25em;
position: relative;
}
.amp-wp-footer h2 {
font-size: 1em;
line-height: 1.375em;
margin: 0 0 .5em;
}
.amp-wp-footer p {
color: <?php echo sanitize_hex_color( $muted_text_color ); ?>;
font-size: .8em;
line-height: 1.5em;
margin: 0 85px 0 0;
}
.amp-wp-footer a {
text-decoration: none;
}
.back-to-top {
bottom: 1.275em;
font-size: .8em;
font-weight: 600;
line-height: 2em;
position: absolute;
<?php echo is_rtl() ? 'left' : 'right'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>: 16px;
}