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 #290 from alphagov/add-subscription-links-component
Add subscription links component
- Loading branch information
Showing
10 changed files
with
114 additions
and
1 deletion.
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
40 changes: 40 additions & 0 deletions
40
app/assets/stylesheets/govuk_publishing_components/components/_subscription-links.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,40 @@ | ||
.gem-c-subscription-links { | ||
@include bold-19; | ||
|
||
.gem-c-subscription-links__list { | ||
list-style: none; | ||
margin-left: -$gutter-half / 2; | ||
margin-right: -$gutter-half / 2; | ||
} | ||
|
||
.gem-c-subscription-links__list-item { | ||
display: inline-block; | ||
margin-left: $gutter-half / 2; | ||
margin-right: $gutter-half / 2; | ||
margin-bottom: $gutter-half; | ||
} | ||
|
||
.gem-c-subscription-links__link { | ||
text-decoration: none; | ||
padding-left: 28px; | ||
background-repeat: no-repeat; | ||
background-position: 0 20%; | ||
|
||
@include media(tablet) { | ||
background-position: 0 35%; | ||
} | ||
} | ||
|
||
.gem-c-subscription-links__link--feed { | ||
background-image: image-url("govuk_publishing_components/feed-icon-black.png"); | ||
} | ||
|
||
.gem-c-subscription-links__link--email-alerts { | ||
background-image: image-url("govuk_publishing_components/mail-icon.png"); | ||
|
||
@include device-pixel-ratio() { | ||
background-image: image-url("govuk_publishing_components/mail-icon-x2.png"); | ||
background-size: 20px 14px; | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/views/govuk_publishing_components/components/_subscription-links.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,21 @@ | ||
<% | ||
email_signup_link ||= false | ||
feed_link ||= false | ||
%> | ||
<% if email_signup_link || feed_link %> | ||
<section class="gem-c-subscription-links"> | ||
<h2 class="visuallyhidden">Subscriptions</h2> | ||
<ul class="gem-c-subscription-links__list"> | ||
<% if email_signup_link.present? %> | ||
<li class="gem-c-subscription-links__list-item"> | ||
<%= link_to "Get email alerts", email_signup_link, class: "gem-c-subscription-links__link gem-c-subscription-links__link--email-alerts" %> | ||
</li> | ||
<% end %> | ||
<% if feed_link.present? %> | ||
<li class="gem-c-subscription-links__list-item"> | ||
<%= link_to "Subscribe to feed", feed_link, class: "gem-c-subscription-links__link gem-c-subscription-links__link--feed" %> | ||
</li> | ||
<% end %> | ||
</ul> | ||
</section> | ||
<% end %> |
17 changes: 17 additions & 0 deletions
17
app/views/govuk_publishing_components/components/docs/subscription-links.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,17 @@ | ||
name: Subscription links | ||
description: Links to ‘Get email alerts’ and ‘Subscribe to feed’ | ||
accessibility_criteria: | | ||
Icons in subscription links must be presentational and ignored by screen readers. | ||
shared_accessibility_criteria: | ||
- link | ||
examples: | ||
default: | ||
data: | ||
email_signup_link: '/foreign-travel-advice/singapore/email-signup' | ||
feed_link: '/foreign-travel-advice/singapore.atom' | ||
with_only_email_signup_link: | ||
data: | ||
email_signup_link: '/foreign-travel-advice/singapore/email-signup' | ||
with_only_feed_link: | ||
data: | ||
feed_link: '/foreign-travel-advice/singapore.atom' |
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,9 @@ | ||
Rails.application.config.assets.precompile += %w( | ||
govuk_publishing_components/component_guide.css | ||
component_guide/all_components.css | ||
component_guide/all_components_print | ||
component_guide/all_components_print.css | ||
govuk_publishing_components/search-button.png | ||
govuk_publishing_components/feed-icon-black.png | ||
govuk_publishing_components/mail-icon-x2.png | ||
govuk_publishing_components/mail-icon.png | ||
) |
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,27 @@ | ||
require 'rails_helper' | ||
|
||
describe "subscription links", type: :view do | ||
def component_name | ||
"subscription-links" | ||
end | ||
|
||
it "renders nothing when no parameters are given" do | ||
assert_empty render_component({}) | ||
end | ||
|
||
it "renders an email signup link" do | ||
render_component(email_signup_link: '/email-signup') | ||
assert_select ".gem-c-subscription-links__link--email-alerts[href=\"/email-signup\"]", text: "Get email alerts" | ||
end | ||
|
||
it "renders a feed link" do | ||
render_component(feed_link: 'singapore.atom') | ||
assert_select ".gem-c-subscription-links__link--feed[href=\"singapore.atom\"]", text: "Subscribe to feed" | ||
end | ||
|
||
it "renders both email signup and feed links" do | ||
render_component(email_signup_link: 'email-signup', feed_link: 'singapore.atom') | ||
assert_select ".gem-c-subscription-links__link--email-alerts[href=\"email-signup\"]", text: "Get email alerts" | ||
assert_select ".gem-c-subscription-links__link--feed[href=\"singapore.atom\"]", text: "Subscribe to feed" | ||
end | ||
end |