Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved from government-frontend for use in email-alert-frontend Also renames the namespace to `gem` Originally implemented in alphagov/government-frontend#568
- Loading branch information
Showing
7 changed files
with
77 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
@import "helpers/variables"; | ||
|
||
.gem-c-back-link { | ||
position: relative; | ||
display: inline-block; | ||
margin-top: $gem-spacing-scale-3; | ||
margin-bottom: $gem-spacing-scale-3; | ||
font-size: 16px; | ||
line-height: 1.25; | ||
|
||
text-decoration: none; | ||
border-bottom: 1px solid currentColor; | ||
|
||
&:link, | ||
&:link:focus, | ||
&:visited, | ||
&:active { | ||
color: currentColor; | ||
} | ||
|
||
&:hover { | ||
color: $link-colour; | ||
} | ||
|
||
&::before { | ||
content: ""; | ||
display: inline-block; | ||
margin-right: .3em; | ||
border-top: 0.3125em solid transparent; | ||
border-right: 0.375em solid currentColor; | ||
border-bottom: 0.3125em solid transparent; | ||
} | ||
} |
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,6 @@ | ||
<a | ||
class="gem-c-back-link" | ||
href="<%= href %>" | ||
> | ||
<%= t('components.back_link.back') %> | ||
</a> |
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,10 @@ | ||
name: Back link | ||
description: A link used to help users get back, useful when not using other navigation such as breadcrumbs | ||
accessibility_criteria: | | ||
- has a touch area easy for users to touch | ||
shared_accessibility_criteria: | ||
- link | ||
examples: | ||
default: | ||
data: | ||
href: '#' |
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 |
---|---|---|
|
@@ -2,3 +2,5 @@ cy: | |
components: | ||
radio: | ||
or: 'neu' | ||
back_link: | ||
back: "Yn ôl" |
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 |
---|---|---|
|
@@ -23,3 +23,5 @@ en: | |
components: | ||
radio: | ||
or: 'or' | ||
back_link: | ||
back: 'Back' |
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,23 @@ | ||
require 'rails_helper' | ||
|
||
describe "Back Link", type: :view do | ||
def render_component(locals) | ||
render file: "components/_back_link", locals: locals | ||
end | ||
|
||
it "fails to render a back link when no href is given" do | ||
assert_raises do | ||
render_component({}) | ||
end | ||
end | ||
|
||
it "renders a back link correctly" do | ||
render_component(href: '/back-me') | ||
assert_select ".gem-c-back-link[href=\"/back-me\"]", text: "Back" | ||
end | ||
|
||
it "can render in welsh" do | ||
I18n.with_locale(:cy) { render_component(href: '/back-me') } | ||
assert_select ".gem-c-back-link[href=\"/back-me\"]", text: "Yn ôl" | ||
end | ||
end |