Skip to content

Commit d8ab476

Browse files
committed
Prototype impact header different image size
- modify the impact header on desktop to remove the specific sizing of the image to be square - the best way to do this without breaking any existing images seems to be to remove the height specifications and rely on the image dimensions - to allow for this we remove the vertical centering of the text on the left, and apply top padding instead - this allows us to refactor the caption markup so it sits beneath the image (previously this had to be separate because the expanded details element would cause the text on the left to move with the changing height of the overall component)
1 parent b9e2a90 commit d8ab476

5 files changed

Lines changed: 47 additions & 50 deletions

File tree

60.7 KB
Loading
222 KB
Loading

app/assets/stylesheets/components/_impact-header.scss

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,6 @@ $gap: 30px;
55
margin-bottom: 30px;
66
}
77

8-
.app-c-impact-header__caption-wrapper {
9-
max-width: 1020px;
10-
margin: 0 auto;
11-
12-
@include govuk-media-query($from: desktop) {
13-
display: flex;
14-
gap: $gap;
15-
16-
&::before {
17-
content: "";
18-
display: block;
19-
height: 1px;
20-
width: 50%;
21-
flex-shrink: 1;
22-
max-width: 495px;
23-
}
24-
}
25-
}
26-
278
.app-c-impact-header__caption {
289
padding: 15px;
2910

@@ -33,8 +14,7 @@ $gap: 30px;
3314

3415
@include govuk-media-query($from: desktop) {
3516
box-sizing: border-box;
36-
width: 50%;
37-
padding-left: 0;
17+
padding: 30px 0;
3818
}
3919
}
4020

@@ -47,17 +27,13 @@ $gap: 30px;
4727
@include govuk-media-query($from: desktop) {
4828
flex-direction: row;
4929
gap: $gap;
50-
min-height: $box-size;
5130
}
5231
}
5332

5433
.app-c-impact-header__detail {
5534
padding: 15px;
5635
flex-shrink: 1;
5736
flex-grow: 0;
58-
display: flex;
59-
flex-direction: column;
60-
justify-content: center;
6137

6238
@include govuk-media-query($from: tablet) {
6339
padding: 30px;
@@ -66,25 +42,25 @@ $gap: 30px;
6642
@include govuk-media-query($from: desktop) {
6743
box-sizing: border-box;
6844
width: 50%;
69-
padding: 30px 0 30px 30px;
45+
padding: 60px 0 30px 30px;
7046
}
7147
}
7248

7349
.app-c-impact-header__image-wrapper {
7450
flex-shrink: 1;
7551
flex-grow: 0;
76-
overflow: hidden;
77-
display: flex;
78-
align-items: center;
79-
justify-content: flex-start;
80-
aspect-ratio: 16 / 9;
8152
box-sizing: border-box;
8253

8354
@include govuk-media-query($from: desktop) {
8455
width: 50%;
85-
aspect-ratio: auto;
8656
max-width: $box-size;
87-
align-self: flex-end;
57+
align-self: flex-start;
58+
}
59+
}
60+
61+
.app-c-impact-header__image-thing {
62+
@include govuk-media-query($from: desktop) {
63+
overflow: hidden;
8864
}
8965
}
9066

@@ -94,7 +70,6 @@ $gap: 30px;
9470
margin: 0 auto;
9571

9672
@include govuk-media-query($from: desktop) {
97-
max-height: $box-size;
9873
max-width: none;
9974
}
10075
}

app/views/components/_impact_header.html.erb

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,32 +36,40 @@
3636
} %>
3737
<% end %>
3838

39+
<% caption = capture do %>
40+
<% if show_caption %>
41+
<div class="app-c-impact-header__caption">
42+
<%= render "govuk_publishing_components/components/details", {
43+
title: "Image details",
44+
theme: ("black" unless inverse),
45+
inverse: inverse,
46+
margin_bottom: 0,
47+
} do %>
48+
<%= image[:caption] %>
49+
<% end %>
50+
</div>
51+
<% end %>
52+
<% end %>
53+
3954
<%= tag.div(**component_helper.all_attributes) do %>
4055
<% if image %>
4156
<div class="app-c-impact-header__container">
4257
<div class="app-c-impact-header__detail">
4358
<%= text %>
4459
</div>
4560

46-
<%= render "flexible_page/flexible_sections/shared/picture",
47-
image: image,
48-
style: "app-c-impact-header",
49-
alt_text: "" %>
50-
</div>
51-
<% if show_caption %>
52-
<div class="app-c-impact-header__caption-wrapper">
53-
<div class="app-c-impact-header__caption">
54-
<%= render "govuk_publishing_components/components/details", {
55-
title: "Image details",
56-
theme: ("black" unless inverse),
57-
inverse: inverse,
58-
margin_bottom: 0,
59-
} do %>
60-
<%= image[:caption] %>
61+
<div class="app-c-impact-header__image-wrapper">
62+
<div class="app-c-impact-header__image-thing">
63+
<%= picture_tag(class: "") do %>
64+
<%= tag.source srcset: srcset_string(:desktop, image), media: "(min-width: 769px)" %>
65+
<%= tag.source srcset: srcset_string(:tablet, image), media: "(min-width: 641px) and (max-width: 768px)" %>
66+
<%= tag.source srcset: srcset_string(:mobile, image), media: "(max-width: 640px)" %>
67+
<%= image_tag(image[:sources][:desktop], class: "app-c-impact-header__image", alt: "") %>
6168
<% end %>
6269
</div>
70+
<%= caption %>
6371
</div>
64-
<% end %>
72+
</div>
6573
<% else %>
6674
<div class="app-c-impact-header__grid">
6775
<div class="govuk-grid-row">

app/views/components/docs/impact_header.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,20 @@ examples:
3232
tablet_2x: "/assets/frontend/flexible-pages/example_tablet_2x.jpg"
3333
context:
3434
full_width: true
35+
with_smaller_image:
36+
data:
37+
heading: This is the title of the impact header
38+
description: This is the description of the impact header, containing words that form a paragraph of text.
39+
image:
40+
sources:
41+
desktop: "/assets/frontend/flexible-pages/example_desktop_1x_landscape.jpg"
42+
desktop_2x: "/assets/frontend/flexible-pages/example_desktop_2x_landscape.jpg"
43+
mobile: "/assets/frontend/flexible-pages/example_mobile_1x.jpg"
44+
mobile_2x: "/assets/frontend/flexible-pages/example_mobile_2x.jpg"
45+
tablet: "/assets/frontend/flexible-pages/example_tablet_1x.jpg"
46+
tablet_2x: "/assets/frontend/flexible-pages/example_tablet_2x.jpg"
47+
context:
48+
full_width: true
3549
with_image_caption:
3650
data:
3751
heading: With image caption

0 commit comments

Comments
 (0)