Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the 'Start now' button component #1

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<a href="<%= @href %>" role="button" draggable="false" class="govuk-button govuk-button--start" data-module="govuk-button">
<%= @text %>
<svg class="govuk-button__start-icon" xmlns="http://www.w3.org/2000/svg" width="17.5" height="19" viewBox="0 0 33 40" aria-hidden="true" focusable="false">
<path fill="currentColor" d="M0 0h13l20 20-20 20H0l20-20z" />
</svg>
</a>
8 changes: 8 additions & 0 deletions app/components/start_now_button/start_now_button_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class StartNowButton::StartNowButtonComponent < ViewComponent::Base
attr_accessor :text, :href

def initialize(text:, href:)
@text = text
@href = href
end
end
14 changes: 14 additions & 0 deletions spec/components/panel/start_now_button_component_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
require 'spec_helper'

RSpec.describe(StartNowButton::StartNowButtonComponent, type: :component) do
let(:text) { 'Department for Education' }
let(:href) { 'https://www.gov.uk/government/organisations/department-for-education' }
let(:component) { StartNowButton::StartNowButtonComponent.new(text: text, href: href) }
subject { Capybara::Node::Simple.new(render_inline(component).to_html) }

specify 'should have a title and body with the correct contents' do
expect(subject).to have_css('a', text: text, class: %w(govuk-button govuk-button--start)) do
expect(page).to have_css('svg')
end
end
end