Skip to content

Commit

Permalink
Merge pull request #804 from alphagov/suppress-subscription-heading
Browse files Browse the repository at this point in the history
Suppress subscription components heading
  • Loading branch information
aliuk2012 authored Mar 28, 2019
2 parents 60db19a + 3fa4132 commit 60fb415
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Control when checkboxes change event sends Google Analytics tracking info (PR #801)
* Updates govuk-frontend from 2.5.1 to 2.9.0 (PR #794)
* Adds small form option to subscription component (PR #803)
* Suppress subscription components heading (PR #804)

## 16.8.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@
css_classes << (shared_helper.get_margin_bottom) unless local_assigns[:margin_bottom] == 0
css_classes << brand_helper.brand_class
data = {"module": "gem-toggle"} if sl_helper.feed_link_box_value
hide_heading ||= false
%>
<% if sl_helper.component_data_is_valid? %>
<%= tag.section class: css_classes, data: data do %>
<h2 class="gem-c-subscription-links__hidden-header visuallyhidden"><%= t("govuk_component.subscription_links.subscriptions", default: "Subscriptions") %></h2>
<% unless hide_heading %>
<h2 class="gem-c-subscription-links__hidden-header visuallyhidden"><%= t("govuk_component.subscription_links.subscriptions", default: "Subscriptions") %></h2>
<% end %>
<ul
class="gem-c-subscription-links__list<%= ' gem-c-subscription-links__list--small' if local_assigns[:small_form] == true %>"
<%= "data-module=track-click" if sl_helper.tracking_is_present? %>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
name: Subscription links
description: Links to ‘Get email alerts’ and ‘Subscribe to feed’
body: |
<strong>NOTE: This component includes a h2 heading by default but can be suppressed by using `hide_heading` option (see below)<strong>
accessibility_criteria: |
Icons in subscription links must be presentational and ignored by screen readers.
Expand Down Expand Up @@ -77,4 +79,11 @@ examples:
email_signup_link: '/foreign-travel-advice/singapore/email-signup'
feed_link: '/foreign-travel-advice/singapore.atom'
small_form: true

without_heading:
description: |
By default the component includes an h2 heading. The component could be used anywhere on the page and could mean
that it produces invalid markup or make the site unaccessible.
data:
email_signup_link: '/foreign-travel-advice/singapore/email-signup'
feed_link: '/foreign-travel-advice/singapore.atom'
hide_heading: true
17 changes: 17 additions & 0 deletions spec/components/subscription_links_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,21 @@ def component_name
render_component(email_signup_link: 'email-signup', feed_link: 'singapore.atom', small_form: true)
assert_select ".gem-c-subscription-links__list--small"
end

describe 'component heading' do
it 'renders a heading by default' do
render_component(email_signup_link: 'email-signup', feed_link: 'singapore.atom')
assert_select "h2.gem-c-subscription-links__hidden-header"
end

it 'renders a heading by default' do
render_component(email_signup_link: 'email-signup', feed_link: 'singapore.atom', hide_heading: false)
assert_select "h2.gem-c-subscription-links__hidden-header"
end

it 'renders without a heading' do
render_component(email_signup_link: 'email-signup', feed_link: 'singapore.atom', hide_heading: true)
assert_select "h2.gem-c-subscription-links__hidden-header", false
end
end
end

0 comments on commit 60fb415

Please sign in to comment.