-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #424 from alphagov/create-banner-component
Add banner component
- Loading branch information
Showing
22 changed files
with
173 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.app-c-banner { | ||
@include responsive-bottom-margin; | ||
@include core-19; | ||
@include white-links; | ||
background: $govuk-blue; | ||
color: $white; | ||
padding: $gutter-half; | ||
clear: both; | ||
|
||
@include media(tablet) { | ||
padding: $gutter-two-thirds $gutter; | ||
} | ||
} | ||
|
||
.app-c-banner--grid { | ||
@include media(tablet) { | ||
padding: $gutter; | ||
} | ||
} | ||
|
||
.app-c-banner__main { | ||
margin-top: $gutter-half; | ||
|
||
@include media(tablet) { | ||
margin-top: 0; | ||
margin-left: -$gutter-one-third; | ||
padding-right: 0; | ||
border-left: 1px solid $white; | ||
} | ||
} | ||
|
||
.app-c-banner__aside { | ||
@include media(tablet) { | ||
padding-right: $gutter; | ||
} | ||
} | ||
|
||
.app-c-banner__text { | ||
@include bold-36; | ||
} | ||
|
||
.app-c-banner__title { | ||
@include bold-27; | ||
margin-bottom: $gutter-one-third; | ||
} | ||
|
||
.app-c-banner__desc { | ||
@include core-24; | ||
// Ensure the text has a line-length of around 60 characters | ||
max-width: 30em; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.speech { | ||
@include sidebar-with-body; | ||
@include history-notice; | ||
@include withdrawal-notice; | ||
|
||
.direction-rtl & { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
.statistical-data-set { | ||
@include sidebar-with-body; | ||
@include history-notice; | ||
@include withdrawal-notice; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<% | ||
title ||= false | ||
aside ||= false | ||
large_text = !title && !aside | ||
%> | ||
|
||
<% content_block = capture do %> | ||
<% if title %> | ||
<h2 class="app-c-banner__title"><%= title %></h2> | ||
<% end %> | ||
<p class="app-c-banner__<% if large_text %>text<% else %>desc<% end %>"> | ||
<%= text %> | ||
</p> | ||
<% end %> | ||
|
||
<% if aside %> | ||
<div class="app-c-banner app-c-banner--grid"> | ||
<div class="grid-row app-c-banner__aside"> | ||
<div class="column-third"> | ||
<p><%= aside %></p> | ||
</div> | ||
|
||
<div class="column-two-thirds app-c-banner__main"> | ||
<%= content_block %> | ||
</div> | ||
</div> | ||
</div> | ||
<% else %> | ||
<div class="app-c-banner"> | ||
<%= content_block %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Banner | ||
description: A page banner, designed to highlight important information | ||
body: Passing an aside to the banner will mean the banner renders in a grid layout. | ||
accessibility_criteria: | | ||
The banner must: | ||
- be visually distinct from other content on the page | ||
- have a contrast ratio higher than 4.5:1 against the background colour to meet WCAG AA | ||
fixtures: | ||
default: | ||
text: 'This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government' | ||
banner_with_title: | ||
title: 'Summary' | ||
text: 'This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government' | ||
banner_with_aside: | ||
title: 'Summary' | ||
text: 'This was published under the 2010 to 2015 Conservative and Liberal Democrat coalition government' | ||
aside: 'This consultation ran from 9:30am on 30 January 2017 to 5pm on 28 February 2017' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
<% if content_item.historically_political? %> | ||
<div class="history-notice"> | ||
<h2>This was published under the <%= content_item.publishing_government %></h2> | ||
</div> | ||
<%= render 'components/banner', text: "This was published under the #{content_item.publishing_government}" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'component_test_helper' | ||
|
||
class BannerTest < ComponentTestCase | ||
def component_name | ||
"banner" | ||
end | ||
|
||
test "fails to render a banner when no text is given" do | ||
assert_raise do | ||
render_component({}) | ||
end | ||
end | ||
|
||
test "renders a banner with text correctly" do | ||
render_component(title: 'Summary', text: 'This was published under the 2010 to 2015 Conservative government') | ||
|
||
assert_select ".app-c-banner--grid", false | ||
assert_select ".app-c-banner__desc", text: 'This was published under the 2010 to 2015 Conservative government' | ||
end | ||
|
||
test "renders a banner with title and text correctly" do | ||
render_component(title: 'Summary', text: 'This was published under the 2010 to 2015 Conservative government') | ||
|
||
assert_select ".app-c-banner--grid", false | ||
assert_select ".app-c-banner__title", text: 'Summary' | ||
assert_select ".app-c-banner__desc", text: 'This was published under the 2010 to 2015 Conservative government' | ||
end | ||
|
||
test "renders a banner with title, text and aside correctly" do | ||
render_component(title: 'Summary', | ||
text: 'This was published under the 2010 to 2015 Conservative government', | ||
aside: 'This consultation ran from 9:30am on 30 January 2017 to 5pm on 28 February 2017') | ||
|
||
assert_select ".app-c-banner--grid" | ||
assert_select ".app-c-banner__title", text: 'Summary' | ||
assert_select ".app-c-banner__desc", text: 'This was published under the 2010 to 2015 Conservative government' | ||
assert_select ".app-c-banner__aside p", text: 'This consultation ran from 9:30am on 30 January 2017 to 5pm on 28 February 2017' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.