Skip to content

Commit

Permalink
Clarify "header notice" is just "brexit notice"
Browse files Browse the repository at this point in the history
Previously we had a generic "header notice" component that was only
actually used once. While we should aim for generic components, the
behaviour of this one is clearly coupled to the needs of Brexit. By
clearly marking it as a "brexit thing", we:

- Make it easier to identify for removal, along with other bits of
code that were only added around the transition period.

- Make it more flexible, without having to worry about accomodating
other use cases (since there are none).
  • Loading branch information
Ben Thorner committed Dec 29, 2020
1 parent 1106817 commit a494556
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 56 deletions.
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
.app-c-header-notice {
.app-c-brexit-notice {
margin-bottom: govuk-spacing(8);
}

.app-c-header-notice__header {
.app-c-brexit-notice__header {
background-color: govuk-colour("black");
padding: govuk-spacing(4);
}

.app-c-header-notice__title {
.app-c-brexit-notice__title {
@extend %govuk-heading-m;
color: govuk-colour("white");
margin: 0;
}

.app-c-header-notice__content {
.app-c-brexit-notice__content {
border-left: $govuk-border-width solid govuk-colour("black");
border-right: $govuk-border-width solid govuk-colour("black");
border-bottom: $govuk-border-width solid govuk-colour("black");
padding: govuk-spacing(4);
}

.app-c-header-notice__text {
.app-c-brexit-notice__text {
margin-bottom: govuk-spacing(2);
}

.app-c-header-notice__links {
.app-c-brexit-notice__links {
margin-bottom: govuk-spacing(2);
}

.app-c-header-notice__list {
.app-c-brexit-notice__list {
margin-top: -5px;
margin-bottom: 0;
}

.app-c-header-notice__link-intro {
.app-c-brexit-notice__link-intro {
margin-bottom: govuk-spacing(2);
}

.app-c-header-notice__link {
.app-c-brexit-notice__link {
@extend %govuk-link;
font-weight: bold;
}

.app-c-header-notice__content .app-c-header-notice__text:last-child {
.app-c-brexit-notice__content .app-c-brexit-notice__text:last-child {
margin-bottom: 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
featured_link ||= false
%>
<% if title && description %>
<section class="app-c-header-notice" aria-label="notice" role="region" lang="en">
<div class="app-c-header-notice__header">
<h2 class="app-c-header-notice__title"><%= title %></h2>
<section class="app-c-brexit-notice" aria-label="notice" role="region" lang="en">
<div class="app-c-brexit-notice__header">
<h2 class="app-c-brexit-notice__title"><%= title %></h2>
</div>

<div class="app-c-header-notice__content">
<div class="app-c-brexit-notice__content">
<% if description.is_a? Array %>
<% description.map do |line| %>
<p class="app-c-header-notice__text govuk-body"><%= line %></p>
<p class="app-c-brexit-notice__text govuk-body"><%= line %></p>
<% end %>
<% else %>
<p class="app-c-header-notice__text govuk-body"><%= description %></p>
<p class="app-c-brexit-notice__text govuk-body"><%= description %></p>
<% end %>
<% if featured_link %>
<p class="app-c-header-notice__text govuk-body"><%= featured_link %></p>
<p class="app-c-brexit-notice__text govuk-body"><%= featured_link %></p>
<% end %>
<% if links.any? %>
<div class="app-c-header-notice__links">
<div class="app-c-brexit-notice__links">
<% if links.count == 1 %>
<p class="govuk-body app-c-header-notice__link-intro">
<p class="govuk-body app-c-brexit-notice__link-intro">
<% if link_intro %><%= link_intro %><% end %>
<%= link_to(links[0][:title], links[0][:href], data: links[0][:data_attributes], class: "app-c-header-notice__link") %>
<%= link_to(links[0][:title], links[0][:href], data: links[0][:data_attributes], class: "app-c-brexit-notice__link") %>
</p>
<% else %>
<% if link_intro %><p class="govuk-body app-c-header-notice__link-intro"><%= link_intro %></p><% end %>
<ul class="app-c-header-notice__list govuk-list">
<% if link_intro %><p class="govuk-body app-c-brexit-notice__link-intro"><%= link_intro %></p><% end %>
<ul class="app-c-brexit-notice__list govuk-list">
<% links.each do |link| %>
<li><%= link_to(link[:title], link[:href], data: link[:data_attributes], class: "app-c-header-notice__link") %></li>
<li><%= link_to(link[:title], link[:href], data: link[:data_attributes], class: "app-c-brexit-notice__link") %></li>
<% end %>
</ul>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Header Notice
name: Brexit Notice
description: A bolder style of notice
shared_accessibility_criteria:
- link
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/case_study.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<%= render 'shared/publisher_metadata_with_logo' %>
<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
<%= render 'components/header-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>
<%= render 'components/brexit-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds content-bottom-margin">
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/detailed_guide.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<%= render 'shared/publisher_metadata_with_logo' %>
<%= render 'shared/history_notice', content_item: @content_item %>
<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
<%= render 'components/header-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>
<%= render 'components/brexit-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/document_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="govuk-grid-column-two-thirds">
<%= render 'govuk_publishing_components/components/lead_paragraph', text: @content_item.description %>
<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
<%= render 'components/header-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>
<%= render 'components/brexit-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>
<%= render 'shared/history_notice', content_item: @content_item %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/html_publication.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
<% end %>

<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
<%= render 'components/header-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>
<%= render 'components/brexit-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>

<div
class="govuk-grid-row sidebar-with-body"
Expand Down
2 changes: 1 addition & 1 deletion app/views/content_items/publication.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<%= render 'shared/history_notice', content_item: @content_item %>

<%= render 'govuk_publishing_components/components/notice', @content_item.withdrawal_notice_component %>
<%= render 'components/header-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>
<%= render 'components/brexit-notice', @content_item.brexit_notice_component unless @content_item.withdrawal_notice_component %>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds responsive-bottom-margin">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
require "component_test_helper"

class HeaderNoticeTest < ComponentTestCase
class BrexitNoticeTest < ComponentTestCase
def component_name
"header-notice"
"brexit-notice"
end

test "doesn't render a header notice when no params are given" do
test "doesn't render a brexit notice when no params are given" do
assert_empty render_component({})
end

test "doesn't render a header notice when no title is given" do
test "doesn't render a brexit notice when no title is given" do
assert_empty render_component(links: [{ title: "test", href: "/test" }], description: "description")
end

test "doesn't render a header notice when no description is given" do
test "doesn't render a brexit notice when no description is given" do
assert_empty render_component(links: [{ title: "test", href: "/test" }], title: "title")
end

test "renders a header notice with text correctly" do
test "renders a brexit notice with text correctly" do
render_component(title: "This is an important notice", description: "This is some important information about the content.")

assert_select ".app-c-header-notice__title", text: "This is an important notice"
assert_select ".app-c-header-notice__content p", text: "This is some important information about the content."
assert_select ".app-c-brexit-notice__title", text: "This is an important notice"
assert_select ".app-c-brexit-notice__content p", text: "This is some important information about the content."
end

test "renders a header notice with text correctly with a multi-line description" do
test "renders a brexit notice with text correctly with a multi-line description" do
render_component(title: "This is an important notice", description: ["This is some important information about the content.", "It runs on to two lines."])

assert_select ".app-c-header-notice__title", text: "This is an important notice"
assert_select ".app-c-header-notice__content p", text: "This is some important information about the content."
assert_select ".app-c-header-notice__content p", text: "It runs on to two lines."
assert_select ".app-c-brexit-notice__title", text: "This is an important notice"
assert_select ".app-c-brexit-notice__content p", text: "This is some important information about the content."
assert_select ".app-c-brexit-notice__content p", text: "It runs on to two lines."
end

test "renders a header notice with an aria label" do
test "renders a brexit notice with an aria label" do
render_component(title: "This is an important notice", description: "This is some important information about the content.")
assert_select "section[aria-label=notice]"
end

test "renders a header notice with no link" do
test "renders a brexit notice with no link" do
render_component(title: "This is an important notice", description: "This is a description", link_intro: "This should not be shown", links: [])

assert_select ".app-c-header-notice__title", text: "This is an important notice"
assert_select ".app-c-header-notice__content p", text: "This is a description"
assert_select ".app-c-header-notice__link-intro", false, "A link intro shouldn't be shown when no links are provided"
assert_select ".app-c-brexit-notice__title", text: "This is an important notice"
assert_select ".app-c-brexit-notice__content p", text: "This is a description"
assert_select ".app-c-brexit-notice__link-intro", false, "A link intro shouldn't be shown when no links are provided"
end

test "renders a header notice with one link" do
test "renders a brexit notice with one link" do
render_component(title: "This is an important notice", description: "This is a description", links: [{ title: "test", href: "/test" }])

assert_select ".app-c-header-notice__title", text: "This is an important notice"
assert_select ".app-c-header-notice__content p", text: "This is a description"
assert_select ".app-c-header-notice__link[href='/test']", text: "test"
assert_select ".app-c-brexit-notice__title", text: "This is an important notice"
assert_select ".app-c-brexit-notice__content p", text: "This is a description"
assert_select ".app-c-brexit-notice__link[href='/test']", text: "test"
end

test "renders a header notice with multiple links" do
test "renders a brexit notice with multiple links" do
render_component(title: "This is an important notice", description: "This is a description", link_intro: "Look at these links: ", links: [{ title: "test", href: "/test" }, { title: "test2", href: "/test2" }])

assert_select ".app-c-header-notice__title", text: "This is an important notice"
assert_select ".app-c-header-notice__content p", text: "This is a description"
assert_select ".app-c-header-notice__link-intro", text: "Look at these links:"
assert_select ".app-c-header-notice__list .app-c-header-notice__link[href='/test']", text: "test"
assert_select ".app-c-header-notice__list .app-c-header-notice__link[href='/test2']", text: "test2"
assert_select ".app-c-brexit-notice__title", text: "This is an important notice"
assert_select ".app-c-brexit-notice__content p", text: "This is a description"
assert_select ".app-c-brexit-notice__link-intro", text: "Look at these links:"
assert_select ".app-c-brexit-notice__list .app-c-brexit-notice__link[href='/test']", text: "test"
assert_select ".app-c-brexit-notice__list .app-c-brexit-notice__link[href='/test2']", text: "test2"
end
end

0 comments on commit a494556

Please sign in to comment.