Skip to content

Commit

Permalink
Add an example of inverse buttons to the guide
Browse files Browse the repository at this point in the history
The $button-shadow-size variable in the upstream commit caused some Sass
compilation problems because it's using the old / format rather than
math.div, so that value is hardcoded to 2px.
  • Loading branch information
peteryates committed May 23, 2023
1 parent 1d4e571 commit 73328a4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
4 changes: 4 additions & 0 deletions guide/content/form-elements/submit.slim
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ p.govuk-body
caption: 'Generating a warning submit button',
code: warning_button)

== render('/partials/example.*',
caption: 'Generating submit button with inverted colours',
code: inverse_button)

== render('/partials/example.*',
caption: 'Generating a submit button with a custom class',
code: custom_classes_button)
Expand Down
34 changes: 34 additions & 0 deletions guide/content/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,37 @@ $x-govuk-brand-colour: #28a;
background: govuk-tint(govuk-colour("purple"), 10%);
}
}

// inverse buttons, this can be removed once the functionality is supported by
// the design system. https://github.com/alphagov/govuk-frontend/pull/3556
$govuk-inverse-button-colour: govuk-colour("white");
$govuk-inverse-button-text-colour: govuk-colour("blue");
$govuk-inverse-button-hover-colour: govuk-tint($govuk-inverse-button-text-colour, 90%);
$govuk-inverse-button-shadow-colour: govuk-shade($govuk-inverse-button-text-colour, 30%);

.govuk-button--inverse {
background-color: $govuk-inverse-button-colour;
box-shadow: 0 2px 0 $govuk-inverse-button-shadow-colour;

&,
&:link,
&:visited,
&:active,
&:hover {
color: $govuk-inverse-button-text-colour;
}

@include _govuk-compatibility(govuk_template) {
&:link:focus {
color: $govuk-inverse-button-text-colour;
}
}

&:hover {
background-color: $govuk-inverse-button-hover-colour;

&[disabled] {
background-color: $govuk-inverse-button-colour;
}
}
}
4 changes: 4 additions & 0 deletions guide/lib/examples/submit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def warning_button
"= f.govuk_submit 'Delete all records', warning: true"
end

def inverse_button
"= f.govuk_submit 'Find out more', inverse: true"
end

def custom_classes_button
"= f.govuk_submit 'Big purple button', class: 'big-purple-button'"
end
Expand Down

0 comments on commit 73328a4

Please sign in to comment.