-
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 #20 from DFE-Digital/skip-link
Skip link Adds a helper for the skip link https://design-system.service.gov.uk/components/skip-link/
- Loading branch information
Showing
6 changed files
with
82 additions
and
4 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,6 @@ | ||
module GovukSkipLinkHelper | ||
def govuk_skip_link(text: 'Skip to main content', href: '#main-content') | ||
link_to text, href, class: 'govuk-skip-link' | ||
end | ||
end | ||
ActiveSupport.on_load(:action_view) { include GovukSkipLinkHelper } |
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,31 @@ | ||
require 'spec_helper' | ||
|
||
RSpec.describe(GovukSkipLinkHelper, type: 'helper') do | ||
include ActionView::Helpers::UrlHelper | ||
|
||
let(:text) { 'Get straight to the important stuff' } | ||
let(:href) { '#skip-link-target' } | ||
subject { Capybara::Node::Simple.new(component) } | ||
|
||
describe '#govuk_skip_link' do | ||
context 'when text not provided' do | ||
let(:component) { govuk_skip_link } | ||
it { is_expected.to(have_link('Skip to main content', href: '#main-content', class: 'govuk-skip-link')) } | ||
end | ||
|
||
context 'when text provided' do | ||
let(:component) { govuk_skip_link text: text } | ||
it { is_expected.to(have_link(text, href: '#main-content', class: 'govuk-skip-link')) } | ||
end | ||
|
||
context 'when href not provided' do | ||
let(:component) { govuk_skip_link } | ||
it { is_expected.to(have_link('Skip to main content', href: '#main-content', class: 'govuk-skip-link')) } | ||
end | ||
|
||
context 'when href provided' do | ||
let(:component) { govuk_skip_link href: href } | ||
it { is_expected.to(have_link('Skip to main content', href: href, class: 'govuk-skip-link')) } | ||
end | ||
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