Skip to content

Commit 2b3d059

Browse files
Merge pull request #2304 from NCCE/2963-strapi-banner-component
Strapi banner component
2 parents e5025e9 + f639cec commit 2b3d059

File tree

11 files changed

+206
-32
lines changed

11 files changed

+206
-32
lines changed

app/components/cms/full_width_banner_component.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Cms::FullWidthBannerComponent < ViewComponent::Base
44
delegate :cms_image, to: :helpers
55

6-
def initialize(text_content:, image:, image_side:, image_link:, title:, background_color: nil, buttons: [], show_bottom_border: false)
6+
def initialize(text_content:, image:, image_side:, image_link:, title:, background_color: nil, buttons: [], show_bottom_border: false, i_belong_flag: false, corner_flourish: false)
77
@text_content = text_content
88
@image = image
99
@image_side = image_side
@@ -12,6 +12,8 @@ def initialize(text_content:, image:, image_side:, image_link:, title:, backgrou
1212
@background_color = background_color
1313
@buttons = buttons
1414
@show_bottom_border = show_bottom_border
15+
@i_belong_flag = i_belong_flag
16+
@corner_flourish = corner_flourish
1517
end
1618

1719
def wrapper_classes

app/components/cms/full_width_banner_component/full_width_banner_component.html.erb

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@
99

1010
<% if @image %>
1111
<div class="cms-full-width-banner__media">
12+
<% if @i_belong_flag %>
13+
<%= content_tag(:div, nil, class: "cms-full-width-banner__media--with-flag") %>
14+
<% end %>
15+
<% if @corner_flourish %>
16+
<%= content_tag(:div, nil, class: "cms-full-width-banner__media--with-flourish-#{@image_side}") %>
17+
<% end %>
1218
<%= render Cms::ImageComponent.new(@image, show_caption: false, link: @image_link) %>
1319
</div>
1420
<% end %>
1521

16-
<div class="cms-full-width-banner__content">
22+
<div class="cms-full-width-banner__content white-bg">
1723
<%= render @text_content.render %>
1824

1925
<% if @buttons %>
@@ -24,6 +30,7 @@
2430
</div>
2531
<% end %>
2632
</div>
33+
2734
<% end %>
2835
<% end %>
2936
<% end %>

app/components/cms/full_width_banner_component/full_width_banner_component.scss

Lines changed: 54 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,81 @@
1212
}
1313

1414
.cms-full-width-banner {
15+
display: flex;
16+
flex-direction: row;
1517

1618
&.right-align {
1719
flex-direction: row-reverse;
1820
}
1921

20-
display: flex;
21-
22-
flex-direction: row;
23-
gap: 15px;
24-
2522
@include govuk-media-query($until: tablet) {
2623
flex-direction: column;
27-
gap: 0px;
24+
25+
&.right-align {
26+
flex-direction: column;
27+
}
2828
}
2929

3030
&__media {
3131
flex: 0 0 calc(100% * 1/3);
32-
padding: 10px;
32+
position: relative;
33+
34+
&--with-flag {
35+
position: absolute;
36+
top: 0;
37+
left: 5px;
38+
height: 97px;
39+
width: 79px;
40+
display: block;
41+
background-image: url("../images/logos/i_belong_flag.svg");
42+
background-size: 100%;
43+
background-repeat: no-repeat;
44+
}
45+
46+
&--with-flourish {
47+
position: relative;
48+
49+
&-left,
50+
&-right {
51+
position: absolute;
52+
bottom: 0;
53+
height: 163px;
54+
width: 162px;
55+
display: block;
56+
background-image: url("../images/components/cms/full_width_banner_component/flourish.svg");
57+
}
58+
59+
&-left {
60+
left: 0;
61+
}
62+
63+
&-right {
64+
right: 0;
65+
transform: scaleX(-1);
66+
}
67+
}
68+
69+
.cms-image {
70+
display: flex;
71+
width: 100%;
72+
height: 100%
73+
}
3374

3475
img {
3576
width: 100%;
77+
height: 100%;
78+
object-fit: cover;
3679
}
80+
3781
}
38-
82+
3983
&__content {
4084
flex: 1 1 calc(100% * 2/3);
41-
padding: 20px 0px;
85+
padding: 20px 20px;
4286

4387
.govuk-button {
4488
min-width: 300px;
4589
}
46-
4790
}
4891

49-
}
92+
}

app/components/cms/question_and_answer_component/question_and_answer_component.scss

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ $avatar_size: 32px;
5353
bottom: 12px;
5454
left: -7px;
5555
box-sizing: border-box;
56-
56+
5757
border: 8px solid black;
5858
border-color: transparent transparent white white;
59-
59+
6060
transform-origin: center;
6161
transform: rotate(45deg);
6262
box-shadow: -4px 4px 6px -3px #0000004D;
@@ -116,10 +116,10 @@ $avatar_size: 32px;
116116
bottom: 12px;
117117
right: -7px;
118118
box-sizing: border-box;
119-
119+
120120
border: 8px solid black;
121121
border-color: transparent transparent white white;
122-
122+
123123
transform-origin: center;
124124
transform: rotate(-135deg);
125125
box-shadow: -4px 4px 6px -3px #0000004D;
@@ -133,7 +133,7 @@ $avatar_size: 32px;
133133
}
134134

135135
&.answer-with-background {
136-
background-image: url("../images/components/cms_question_and_answer_component/background_triangle.svg");
136+
background-image: url("../images/components/cms/question_and_answer_component/background_triangle.svg");
137137
background-position: top right;
138138
background-repeat: no-repeat;
139139
}
@@ -168,4 +168,4 @@ $avatar_size: 32px;
168168
}
169169
}
170170

171-
}
171+
}

app/services/cms/dynamic_components/full_width_banner.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module Cms
22
module DynamicComponents
33
class FullWidthBanner
4-
attr_accessor :text_content, :image, :image_side, :buttons, :image_link, :title, :background_color, :show_bottom_border
4+
attr_accessor :text_content, :image, :image_side, :buttons, :image_link, :title, :background_color, :show_bottom_border, :i_belong_flag, :corner_flourish
55

6-
def initialize(text_content:, title:, image: nil, image_side: :left, image_link: nil, background_color: :white, buttons: [], show_bottom_border: false)
6+
def initialize(text_content:, title:, image: nil, image_side: :left, image_link: nil, background_color: :white, buttons: [], show_bottom_border: false, i_belong_flag: false, corner_flourish: false)
77
@text_content = text_content
88
@image = image
99
@image_side = image_side
@@ -12,6 +12,8 @@ def initialize(text_content:, title:, image: nil, image_side: :left, image_link:
1212
@title = title
1313
@buttons = buttons
1414
@show_bottom_border = show_bottom_border
15+
@i_belong_flag = i_belong_flag
16+
@corner_flourish = corner_flourish
1517
end
1618

1719
def render
@@ -23,7 +25,9 @@ def render
2325
background_color:,
2426
buttons:,
2527
title:,
26-
show_bottom_border:
28+
show_bottom_border:,
29+
i_belong_flag:,
30+
corner_flourish:
2731
)
2832
end
2933
end

app/services/cms/providers/strapi/factories/blocks_factory.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ def self.to_full_width_banner(strapi_data)
154154
image_link: strapi_data[:imageLink],
155155
buttons: strapi_data[:buttons] ? strapi_data[:buttons].map { to_ncce_button(_1) } : [],
156156
title: strapi_data[:sectionTitle],
157-
show_bottom_border: strapi_data[:showBottomBorder]
157+
show_bottom_border: strapi_data[:showBottomBorder],
158+
i_belong_flag: strapi_data[:iBelongFlag],
159+
corner_flourish: strapi_data[:imageCornerFlourish]
158160
)
159161
end
160162

app/services/cms/providers/strapi/mocks/full_width_banner.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class FullWidthBanner < StrapiMock
1010
attribute(:backgroundColor) { {name: "white"} }
1111
attribute(:imageSide) { "right" }
1212
attribute(:buttons) { nil }
13+
attribute(:i_belong_flag) { false }
14+
attribute(:corner_flourish) { false }
1315
end
1416
end
1517
end
Lines changed: 19 additions & 0 deletions
Loading

previews/components/cms/full_width_banner_component_preview.rb

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def default
77
title: "Banner title",
88
background_color: :white,
99
image: Cms::Mocks::Image.as_model,
10-
image_side: :left,
10+
image_side: "left",
1111
image_link: nil,
1212
buttons: []
1313
))
@@ -19,9 +19,35 @@ def with_button
1919
text_content: Cms::Mocks::RichBlocks.as_model,
2020
background_color: :white,
2121
image: Cms::Mocks::Image.as_model,
22-
image_side: :left,
22+
image_side: "left",
2323
image_link: nil,
2424
buttons: [Cms::Mocks::NcceButton.as_model]
2525
))
2626
end
27+
28+
def with_i_belong_flag
29+
render(Cms::FullWidthBannerComponent.new(
30+
title: "Banner title",
31+
text_content: Cms::Mocks::RichBlocks.as_model,
32+
background_color: :white,
33+
image: Cms::Mocks::Image.as_model,
34+
image_side: "right",
35+
image_link: nil,
36+
buttons: [Cms::Mocks::NcceButton.as_model],
37+
i_belong_flag: true
38+
))
39+
end
40+
41+
def with_corner_flourish
42+
render(Cms::FullWidthBannerComponent.new(
43+
title: "Banner title",
44+
text_content: Cms::Mocks::RichBlocks.as_model,
45+
background_color: :white,
46+
image: Cms::Mocks::Image.as_model,
47+
image_side: "left",
48+
image_link: nil,
49+
buttons: [Cms::Mocks::NcceButton.as_model],
50+
corner_flourish: true
51+
))
52+
end
2753
end

0 commit comments

Comments
 (0)