Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
90 additions
and
0 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
5 changes: 5 additions & 0 deletions
5
app/assets/stylesheets/govuk_publishing_components/components/_inverse-header.scss
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,5 @@ | ||
.gem-c-inverse-header { | ||
width: 100%; | ||
background-color: $govuk-blue; | ||
padding: $gutter-half; | ||
} |
6 changes: 6 additions & 0 deletions
6
app/views/govuk_publishing_components/components/_inverse_header.html.erb
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,6 @@ | ||
<% block = yield %> | ||
<% unless block.empty? %> | ||
<header class="gem-c-inverse-header"> | ||
<%= block %> | ||
</header> | ||
<% end %> |
41 changes: 41 additions & 0 deletions
41
app/views/govuk_publishing_components/components/docs/inverse_header.yml
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,41 @@ | ||
name: Inverse header | ||
description: A wrapper to contain header content in white text | ||
body: | | ||
This component can be passed a block of template code and will wrap it in a blue header. This is as light-touch as possible and doesn't attempt to deal with the margins and paddings of its content, neither does it enforce the white text it requires. Implemented to accomodate topic and list page headings and breadcrumbs but unopinionated about its contents. | ||
accessibility_criteria: | | ||
The component must: | ||
* be used in conjunction with content that renders a text contrast ratio higher than 4.5:1 | ||
against the header colour to meet WCAG AA. | ||
examples: | ||
default: | ||
data: | ||
block: | | ||
<div class="pub-c-title pub-c-title--inverse"> | ||
<h1 class="pub-c-title__text "> | ||
Education, Training and Skills | ||
</h1> | ||
</div> | ||
with_breadcrumbs_and_paragraph: | ||
data: | ||
block: | | ||
<div class="govuk-breadcrumbs " data-module="track-click"> | ||
<ol> | ||
<li class=""> | ||
<a data-track-category="breadcrumbClicked" data-track-action="1" data-track-label="/section" data-track-options="{"dimension28":"2","dimension29":"Section"}" class="govuk-breadcrumbs--inverse" aria-current="false" href="/section">Section</a> | ||
</li> | ||
<li class=""> | ||
<a data-track-category="breadcrumbClicked" data-track-action="2" data-track-label="#content" data-track-options="{"dimension28":"2","dimension29":"Education of disadvantaged children"}" class="govuk-breadcrumbs--inverse breadcrumb-for-current-page " aria-current="page" href="#content">Education of disadvantaged children</a> | ||
</li> | ||
</ol> | ||
</div> | ||
<div class="pub-c-title pub-c-title--inverse"> | ||
<h1 class="pub-c-title__text "> | ||
Education, Training and Skills | ||
</h1> | ||
</div> | ||
<p class="pub-c-lead-paragraph pub-c-lead-paragraph--inverse"> | ||
Schools and academies, further and higher education, apprenticeships and other skills training, student funding, early years. | ||
</p> |
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,33 @@ | ||
require 'rails_helper' | ||
|
||
def component_path | ||
"govuk_publishing_components/components/inverse_header" | ||
end | ||
|
||
def block | ||
"<div class=\"pub-c-title pub-c-title--inverse\"> | ||
<p class=\"pub-c-title__context\"> | ||
Publication | ||
</p> | ||
<h1 class=\"pub-c-title__text \"> | ||
HTML publication page title | ||
</h1> | ||
</div>".html_safe | ||
end | ||
|
||
describe "Inverse header", type: :view do | ||
def component_name | ||
"inverse_header" | ||
end | ||
|
||
it "renders nothing when no data is given" do | ||
assert_empty render_component({}) | ||
end | ||
|
||
it "renders content within a wrapper when content is provided" do | ||
render(component_path, {}) { block } | ||
|
||
assert_select ".gem-c-inverse-header div.pub-c-title" | ||
assert_select ".gem-c-inverse-header h1", text: "HTML publication page title" | ||
end | ||
end |