Skip to content

Commit 8857d38

Browse files
Refactor hero video
- Update fallback text content - Improve play/pause button appearance
1 parent 62e76f7 commit 8857d38

File tree

3 files changed

+43
-34
lines changed

3 files changed

+43
-34
lines changed

assets-src/styles/sass/50-core-components/_hero.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,21 @@
5555
}
5656

5757
.hero .button {
58+
align-items: center;
5859
align-self: flex-start;
60+
display: inline-flex;
61+
justify-content: center;
62+
}
63+
64+
65+
.hero--video .sidebar__video {
66+
margin-inline: auto;
67+
max-inline-size: rem(500);
68+
position: relative;
69+
}
70+
71+
.hero--video video {
72+
display: block;
5973
}
6074

6175
.hero--listing {

assets-src/styles/sass/60-advanced-components/_hero.scss

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,27 @@
88
}
99
}
1010

11-
.js .hero video {
12-
display: block;
13-
margin-left: auto;
14-
margin-right: auto;
15-
}
16-
17-
@media screen and (min-width: 48em) {
18-
.js .hero video {
19-
max-width: 31.25rem;
20-
}
11+
12+
13+
14+
.js .hero--video [data-video-control="hero"] {
15+
margin-block-start: 1rem;
2116
}
2217

23-
[data-video-control="hero"] > * {
18+
.js .hero--video [data-video-control="hero"] > * {
2419
pointer-events: none;
2520
}
2621

27-
[data-video-control="hero"] .pause-icon {
22+
.js .hero--video [data-video-control="hero"] .pause-icon {
2823
display: none;
2924
}
3025

31-
[data-video-control="hero"].js-play-video .pause-icon {
32-
display: block;
33-
}
26+
.js .hero--video [data-video-control="hero"].js-play-video {
27+
.pause-icon {
28+
display: block;
29+
}
3430

35-
[data-video-control="hero"].js-play-video .play-icon {
36-
display: none;
31+
.play-icon {
32+
display: none;
33+
}
3734
}

templates/components/styles/hero.html.twig

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="u-full-width hero">
1+
<div class="u-full-width hero {% if page.heroVideo is defined and page.heroVideo %}hero--video{% endif %}">
22
<div class="l-center">
33
<div class="l-sidebar">
44
<div>
@@ -13,23 +13,21 @@
1313
</div>
1414
{% if page.heroVideo is defined and page.heroVideo %}
1515
<div class="sidebar">
16-
<div class="l-frame l-frame--16-9">
17-
<video controls loop muted playsinline preload="metadata" data-video="hero">
18-
<source src="{{ page.heroVideo[0].url }}" type="video/mp4">
19-
Sorry, your browser does not support embedded videos. This is an animation of the W3C logo morphing into a new design.
20-
</video>
16+
<div class="sidebar__video">
17+
<div class="l-frame l-frame--16-9">
18+
<video controls loop muted playsinline preload="metadata" data-video="hero">
19+
<source src="{{ page.heroVideo[0].url }}" type="video/mp4">
20+
Sorry, your browser does not support embedded videos. Here is a <a href="{{ page.heroVideo[0].url }}">link to the video</a> instead.
21+
</video>
22+
</div>
23+
<button class="button" data-video-control="hero" hidden>
24+
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 640 640" height="20" width="20" aria-hidden="true" focusable="false">
25+
<!--!Font Awesome Free v7.0.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.-->
26+
<path class="play-icon" d="M187.2 100.9c-12.4-6.8-27.4-6.5-39.6.7-12.2 7.2-19.6 20.3-19.6 34.4v368c0 14.1 7.5 27.2 19.6 34.4 12.1 7.2 27.2 7.5 39.6.7l336-184c12.8-7 20.8-20.5 20.8-35.1 0-14.6-8-28.1-20.8-35.1l-336-184z"/>
27+
<path class=pause-icon d="M176 96c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h64c26.5 0 48-21.5 48-48V144c0-26.5-21.5-48-48-48h-64zm224 0c-26.5 0-48 21.5-48 48v352c0 26.5 21.5 48 48 48h64c26.5 0 48-21.5 48-48V144c0-26.5-21.5-48-48-48h-64z"/></svg>
28+
<span class="visuallyhidden">Play</span>
29+
</button>
2130
</div>
22-
<button class="button" data-video-control="hero" hidden>
23-
<svg xmlns="http://www.w3.org/2000/svg" viewbox="0 0 47 47" height="45" width="45" aria-hidden="true" focusable="false">
24-
<defs/>
25-
<g fill="none" fill-rule="evenodd">
26-
<path fill="#1E3773" fill-rule="nonzero" stroke="#FFF" stroke-opacity=".8" stroke-width="3.75" d="M23.914 2.818a21.222 21.222 0 0114.937 6.108c3.813 3.762 6.173 8.956 6.173 14.695 0 4.204-1.286 8.201-3.555 11.55a21.036 21.036 0 01-9.48 7.668 21.405 21.405 0 01-12.222 1.183 21.205 21.205 0 01-10.82-5.706 20.685 20.685 0 01-5.77-10.65 20.489 20.489 0 011.206-12.008 20.855 20.855 0 017.78-9.335 21.335 21.335 0 0111.751-3.505z" opacity=".8"/>
27-
<path class="play-icon" fill="#FFF" fill-rule="nonzero" d="M20.065 31.18l12.748-7.57-12.748-7.548z"/>
28-
<path class="pause-icon" fill="#FFF" d="M26.232 16.062h5v15h-5zM16.232 16.062h5v15h-5z"/>
29-
</g>
30-
</svg>
31-
<span class="visuallyhidden">Play</span>
32-
</button>
3331
</div>
3432
{% elseif page.heroIllustration is defined and page.heroIllustration %}
3533
<div class="sidebar">

0 commit comments

Comments
 (0)