-
Notifications
You must be signed in to change notification settings - Fork 18
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 #19 from DFE-Digital/back-to-top-link
Adds back_to_top_link This is a common link on govuk sites to take the user back to the top of the page. It's in use on the design system site, though it's not actually documented.
- Loading branch information
Showing
6 changed files
with
54 additions
and
2 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,14 @@ | ||
module GovukBackToTopLinkHelper | ||
def govuk_back_to_top_link | ||
link_to '#top', class: 'govuk-link govuk-link--no-visited-state' do | ||
<<-HTML.squish.html_safe | ||
<svg class="app-back-to-top__icon" xmlns="http://www.w3.org/2000/svg" width="13" height="17" viewBox="0 0 13 17"> | ||
<path fill="currentColor" d="M6.5 0L0 6.5 1.4 8l4-4v12.7h2V4l4.3 4L13 6.4z"></path> | ||
</svg> | ||
Back to top | ||
HTML | ||
end | ||
end | ||
end | ||
|
||
ActiveSupport.on_load(:action_view) { include GovukBackToTopLinkHelper } |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe(GovukBackToTopLinkHelper, type: 'helper') do | ||
include ActionView::Helpers::UrlHelper | ||
include ActionView::Context | ||
subject { Capybara::Node::Simple.new(component) } | ||
|
||
describe '#govuk_back_to_top_link' do | ||
let(:component) { govuk_back_to_top_link } | ||
|
||
it { is_expected.to(have_link('Back to top', href: '#top', class: 'govuk-link govuk-link--no-visited-state')) } | ||
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