From ccf4eca761ebce5f68a2ca7c3b0a271a5df20904 Mon Sep 17 00:00:00 2001 From: Dilwoar Hussain Date: Wed, 9 Dec 2020 11:08:06 +0000 Subject: [PATCH] Add support for secondary solid buttons Solid secondary buttons styles from GOVUK design systems User research has shown that solid secondary buttons worked well --- CHANGELOG.md | 4 ++++ .../govuk_publishing_components/components/docs/button.yml | 4 ++++ lib/govuk_publishing_components/presenters/button_helper.rb | 3 +++ spec/components/button_spec.rb | 6 ++++++ 4 files changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1849db8198..0ef8807d98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ useful summary for people upgrading their application, not a replication of the commit log. +## Unreleased + +* Add support for secondary solid buttons ([PR #1814](https://github.com/alphagov/govuk_publishing_components/pull/1814)) + ## 23.8.0 * Add password reveal component ([PR #1794](https://github.com/alphagov/govuk_publishing_components/pull/1794)) diff --git a/app/views/govuk_publishing_components/components/docs/button.yml b/app/views/govuk_publishing_components/components/docs/button.yml index afb8220fbb..6dbcad44bc 100644 --- a/app/views/govuk_publishing_components/components/docs/button.yml +++ b/app/views/govuk_publishing_components/components/docs/button.yml @@ -52,6 +52,10 @@ examples: data: text: "Secondary quiet button" secondary_quiet: true + secondary_solid_button: + data: + text: "Secondary solid button" + secondary_solid: true destructive_button: data: text: "Destructive button" diff --git a/lib/govuk_publishing_components/presenters/button_helper.rb b/lib/govuk_publishing_components/presenters/button_helper.rb index edef116cfc..25c92ef1a6 100644 --- a/lib/govuk_publishing_components/presenters/button_helper.rb +++ b/lib/govuk_publishing_components/presenters/button_helper.rb @@ -17,6 +17,7 @@ class ButtonHelper :start, :secondary, :secondary_quiet, + :secondary_solid, :destructive, :name, :value, @@ -41,6 +42,7 @@ def initialize(local_assigns) @start = local_assigns[:start] @secondary = local_assigns[:secondary] @secondary_quiet = local_assigns[:secondary_quiet] + @secondary_solid = local_assigns[:secondary_solid] @destructive = local_assigns[:destructive] @name = local_assigns[:name] @value = local_assigns[:value] @@ -77,6 +79,7 @@ def css_classes css_classes << "govuk-button--start" if start css_classes << "gem-c-button--secondary" if secondary css_classes << "gem-c-button--secondary-quiet" if secondary_quiet + css_classes << "govuk-button--secondary" if secondary_solid css_classes << "govuk-button--warning" if destructive css_classes << "gem-c-button--bottom-margin" if margin_bottom && !info_text css_classes << "gem-c-button--inline" if inline_layout diff --git a/spec/components/button_spec.rb b/spec/components/button_spec.rb index a34038dc78..f1583a33d8 100644 --- a/spec/components/button_spec.rb +++ b/spec/components/button_spec.rb @@ -52,6 +52,12 @@ def component_name assert_select ".gem-c-button--secondary-quiet" end + it "renders secondary solid button" do + render_component(text: "Secondary solid", href: "#", secondary_solid: true) + assert_select ".govuk-button--secondary[href='#']", text: "Secondary solid" + assert_select ".govuk-button--secondary" + end + it "renders destructive button" do render_component(text: "Warning", href: "#", destructive: true) assert_select ".govuk-button--warning[href='#']", text: "Warning"