From 86fd7a71bc0936efb49f3d5ffa447cb2ad19f4e2 Mon Sep 17 00:00:00 2001 From: Andy Sellick Date: Tue, 14 Jan 2025 15:28:28 +0000 Subject: [PATCH] WIP --- .../components/_button.scss | 10 +--------- .../components/_button.html.erb | 19 ++++++------------- .../presenters/button_helper.rb | 14 +++++++++----- spec/components/button_spec.rb | 19 ++++--------------- 4 files changed, 20 insertions(+), 42 deletions(-) diff --git a/app/assets/stylesheets/govuk_publishing_components/components/_button.scss b/app/assets/stylesheets/govuk_publishing_components/components/_button.scss index 698ddf0d1e..6681b90224 100644 --- a/app/assets/stylesheets/govuk_publishing_components/components/_button.scss +++ b/app/assets/stylesheets/govuk_publishing_components/components/_button.scss @@ -2,20 +2,12 @@ @import "govuk/components/button/button"; // Because govuk-frontend adds a responsive bottom margin by default for each component -// we reset it to zero so we can set it separately using `gem-c-button--bottom-margin` +// we reset it to zero so we can set it separately using margin classes // If we decide to use responsive margins consistently across components we can remove this .gem-c-button { margin-bottom: 0; } -// this will be moved and extended into a model for general component spacing -// once this has been decided upon and other work completed, see: -// https://trello.com/c/KEkNsxG3/142-3-implement-customisable-spacing-for-components -.gem-c-button--bottom-margin, -.gem-c-button__info-text--bottom-margin { - @include responsive-bottom-margin; -} - .gem-c-button--inline { display: block; width: 100%; diff --git a/app/views/govuk_publishing_components/components/_button.html.erb b/app/views/govuk_publishing_components/components/_button.html.erb index 0c6c94c7e7..ba6eeeee26 100644 --- a/app/views/govuk_publishing_components/components/_button.html.erb +++ b/app/views/govuk_publishing_components/components/_button.html.erb @@ -1,26 +1,19 @@ <% add_gem_component_stylesheet("button") - disable_ga4 ||= false - local_assigns[:type] ||= "submit" unless local_assigns[:href].present? - text ||= "" - - # shared_helper = GovukPublishingComponents::Presenters::SharedHelper.new(local_assigns) - # local_assigns[:classes] = shared_helper.classes button = GovukPublishingComponents::Presenters::ButtonHelper.new(local_assigns) component_helper = GovukPublishingComponents::Presenters::ComponentWrapperHelper.new(local_assigns) component_helper.add_class(button.classes) component_helper.set_margin_bottom(0) if local_assigns[:info_text] component_helper.add_data_attribute({ module: "govuk-button" }) if local_assigns[:href] - - # if margin_bottom && !info_text - # margin_class = get_margin_bottom(margin_bottom, false) - # css_classes << margin_class - # end + component_helper.add_data_attribute({ ga4_attributes: button.ga4_attributes }) + component_helper.set_type(button.type) + component_helper.add_aria_attribute({ labelledby: button.aria_labelledby }) + component_helper.set_draggable("false") if local_assigns[:href] %> <% start_button_text = capture do %> - <%= text %> + <%= button.text %>