Skip to content

Commit

Permalink
Add support for inverse buttons
Browse files Browse the repository at this point in the history
Inverse buttons were added to govuk-frontend in PR #3556[0]

[0] alphagov/govuk-frontend#3556
  • Loading branch information
peteryates committed May 23, 2023
1 parent 15e152b commit 1d4e571
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/govuk_design_system_formbuilder/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ def govuk_check_box_divider(text = config.default_check_box_divider_text)
# @param text [String,Proc] the button text. When a +Proc+ is provided its contents will be rendered within the button element
# @param warning [Boolean] makes the button red ({https://design-system.service.gov.uk/components/button/#warning-buttons warning}) when true
# @param secondary [Boolean] makes the button grey ({https://design-system.service.gov.uk/components/button/#secondary-buttons secondary}) when true
# @param inverse [Boolean] inverts the colours of the button. Note this isn't yet part of the design system.
# @param prevent_double_click [Boolean] adds JavaScript to safeguard the
# form from being submitted more than once
# @param validate [Boolean] adds the formnovalidate to the submit button when true, this disables all
Expand All @@ -881,8 +882,8 @@ def govuk_check_box_divider(text = config.default_check_box_divider_text)
# = f.govuk_submit "Proceed", prevent_double_click: true do
# = link_to 'Cancel', some_other_path, class: 'govuk-button__secondary'
#
def govuk_submit(text = config.default_submit_button_text, warning: false, secondary: false, prevent_double_click: true, validate: config.default_submit_validate, disabled: false, **kwargs, &block)
Elements::Submit.new(self, text, warning: warning, secondary: secondary, prevent_double_click: prevent_double_click, validate: validate, disabled: disabled, **kwargs, &block).html
def govuk_submit(text = config.default_submit_button_text, warning: false, secondary: false, inverse: false, prevent_double_click: true, validate: config.default_submit_validate, disabled: false, **kwargs, &block)
Elements::Submit.new(self, text, warning: warning, secondary: secondary, inverse: inverse, prevent_double_click: prevent_double_click, validate: validate, disabled: disabled, **kwargs, &block).html
end

# Generates three inputs for the +day+, +month+ and +year+ components of a date
Expand Down
4 changes: 3 additions & 1 deletion lib/govuk_design_system_formbuilder/elements/submit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Submit < Base
include Traits::HTMLClasses
include Traits::HTMLAttributes

def initialize(builder, text, warning:, secondary:, prevent_double_click:, validate:, disabled:, **kwargs, &block)
def initialize(builder, text, warning:, secondary:, inverse:, prevent_double_click:, validate:, disabled:, **kwargs, &block)
super(builder, nil, nil)

fail ArgumentError, 'buttons can be warning or secondary' if warning && secondary
Expand All @@ -14,6 +14,7 @@ def initialize(builder, text, warning:, secondary:, prevent_double_click:, valid
@prevent_double_click = prevent_double_click
@warning = warning
@secondary = secondary
@inverse = inverse
@validate = validate
@disabled = disabled
@html_attributes = kwargs
Expand Down Expand Up @@ -68,6 +69,7 @@ def classes
"button--warning" => @warning,
"button--secondary" => @secondary,
"button--disabled" => @disabled,
"button--inverse" => @inverse,
).prefix(brand)
end
end
Expand Down

0 comments on commit 1d4e571

Please sign in to comment.