Skip to content

Commit 034da4e

Browse files
committed
Blog (slash news) article hero
1 parent f488bda commit 034da4e

File tree

4 files changed

+164
-12
lines changed

4 files changed

+164
-12
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/*
2+
Blog hero. Similar to standard hero. Key differences:
3+
- image ratio (TODO – maybe?)
4+
- image goes inline at `lg`, not `md` (so the break-grid rules differ too)
5+
- image has a caption (like project hero)
6+
- text content – more of it
7+
*/
8+
9+
// has `.grid-standard`
10+
.blog-hero {
11+
--title-top-space: 40px;
12+
13+
margin-block-end: 56px;
14+
15+
// t = heading/intro (h1 title ad meta info)
16+
// d = description
17+
// i = img + credit
18+
19+
// Layout if there is _no_ image:
20+
grid-template-areas:
21+
't t t t t t t t t t t t'
22+
'd d d d d d d d d d d d';
23+
24+
@include sm {
25+
margin-block-end: 120px;
26+
}
27+
28+
@include md {
29+
--title-top-space: 32px;
30+
grid-template-areas:
31+
't t t t t t t t t t t t'
32+
'. d d d d d d d d d d d';
33+
}
34+
@include lg {
35+
--title-top-space: 64px;
36+
37+
grid-template-areas:
38+
'. t t t t t t t t t t .'
39+
'. . d d d d d d d d d .';
40+
}
41+
@include xl {
42+
--title-top-space: 104px;
43+
}
44+
@include xxl {
45+
--title-top-space: 160px;
46+
grid-template-areas:
47+
'. t t t t t t t t t . .'
48+
'. . d d d d d d d d . .';
49+
}
50+
51+
// Different layout if the hero has an image:
52+
&:has(img) {
53+
grid-template-areas:
54+
'i i i i i i i i i i i i'
55+
't t t t t t t t t t t t'
56+
'd d d d d d d d d d d d';
57+
58+
@include lg {
59+
grid-template-areas:
60+
'. t t t t t i i i i i i'
61+
'. . d d d d i i i i i i';
62+
}
63+
}
64+
}
65+
66+
.blog-hero__text {
67+
grid-area: t;
68+
line-height: 1.125;
69+
70+
:where(h1) {
71+
margin-block-start: var(--title-top-space);
72+
}
73+
74+
:where(ul) {
75+
margin-block-start: 16px;
76+
list-style-type: none;
77+
padding: 0;
78+
display: flex;
79+
flex-direction: column;
80+
gap: 8px;
81+
82+
@include lg {
83+
font-size: px2rem(20);
84+
}
85+
}
86+
:where(li) {
87+
margin: 0;
88+
}
89+
:where(.tag-list) {
90+
margin-block-start: 24px;
91+
92+
@include xl {
93+
margin-block-start: 40px;
94+
}
95+
}
96+
}
97+
98+
.blog-hero__date {
99+
font-weight: bold;
100+
margin: 16px 0 0;
101+
font-size: px2rem(16);
102+
103+
@include xl {
104+
font-size: px2rem(18);
105+
}
106+
}
107+
108+
.blog-hero__authors {
109+
font-size: px2rem(16);
110+
111+
@include xl {
112+
font-size: px2rem(18);
113+
}
114+
@include xl {
115+
font-size: px2rem(20);
116+
}
117+
}
118+
119+
.blog-hero__description {
120+
grid-area: d;
121+
margin-block-start: 32px;
122+
font-size: px2rem(20);
123+
124+
@include lg {
125+
margin-block-start: 40px;
126+
}
127+
@include xl {
128+
margin-block-start: 48px;
129+
font-size: px2rem(24);
130+
}
131+
}
132+
133+
.blog-hero__img {
134+
grid-area: i;
135+
136+
:where(img) {
137+
@include break-grid;
138+
139+
@include sm {
140+
@include undo-break-grid;
141+
}
142+
@include lg {
143+
@include break-grid-right;
144+
}
145+
@include xxxl {
146+
@include undo-break-grid;
147+
}
148+
}
149+
}

cdhweb/static_src/global/components/project-hero.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Similar to standard hero, but with a tag/chip thing that can show above the title,
3-
and some meta info that can appear below the description.
3+
and some meta info that can appear below the description (like blog hero).
44
*/
55

66
// has `.grid-standard`

cdhweb/static_src/styles.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
@import './global/components/project-hero.scss';
5757
@import './global/components/person-hero.scss';
5858
@import './global/components/event-hero.scss';
59+
@import './global/components/blog-hero.scss';
5960
@import './global/components/breadcrumbs.scss';
6061
@import './global/components/jumplinks.scss';
6162
@import './global/components/sidenav.scss';

templates/includes/blog_hero.html

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ <h1>{{ page.title }}</h1>
99
{{ page.first_published_at|date:"j F Y" }}
1010
</p>
1111

12-
{% if page.authors %}
13-
<div>
14-
<h2 class="sr-only"></h2>
12+
{% if page.authors.all %}
13+
<div class="blog-hero__authors">
14+
<h2 class="sr-only">Authors</h2>
1515
<ul>
1616
{% for author in page.authors.all %}
1717
<li>{{ author.person }}</li>
@@ -20,22 +20,24 @@ <h2 class="sr-only"></h2>
2020
</div>
2121
{% endif %}
2222

23-
{% if page.tags %}
23+
{% if page.tags.all %}
2424
<div class="tag-list">
2525
{% for tag in page.tags.all %}
2626
<div class="tag">{{ tag }}</div>
2727
{% endfor %}
2828
</div>
2929
{% endif %}
3030

31-
<div class="blog-hero__description">
32-
{% if page.description %}
33-
{{ page.description | richtext }}
34-
{% endif %}
3531
</div>
32+
33+
{% if page.description %}
34+
<div class="blog-hero__description">
35+
{{ page.description|richtext }}
36+
</div>
37+
{% endif %}
3638

3739
{% if page.image %}
38-
<figure class="event-hero__img">
40+
<figure class="blog-hero__img">
3941
{% comment %}
4042
All are cropped to a 16:9 ratio. This differs from design, as discussed.
4143
If changing this by image rendition, update aspect-ratio in the CSS instead
@@ -55,7 +57,7 @@ <h2 class="sr-only"></h2>
5557
style="aspect-ratio: {{ img_base.width|unlocalize }} / {{ img_base.height|unlocalize }}"
5658
/>
5759
</picture>
58-
60+
5961
{% if page.caption or page.credit %}
6062
<figcaption class="sk-image__text-content">
6163
{% if page.credit %}
@@ -71,7 +73,7 @@ <h2 class="sr-only"></h2>
7173
</figcaption>
7274
{% endif %}
7375
</figure>
74-
76+
7577
{% endif %}
7678

7779
</div>

0 commit comments

Comments
 (0)