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

Change the Button component background and text colour #2752

Merged
merged 3 commits into from
Aug 18, 2022
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
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

## Unreleased

### New features

#### Change the Button component background and text colour

For non-GOV.UK branded websites, you can now change the Button component background and text colour.

To change the Button component background colour set the `$govuk-button-background-colour` Sass variable.

To change the Button component text colour set the `$govuk-button-text-colour` Sass variable.

```scss
@import "node_modules/govuk-frontend/govuk/base";

$govuk-button-background-colour: govuk-colour("yellow");
$govuk-button-text-colour: govuk-colour("black");
@import "node_modules/govuk-frontend/govuk/components/button/index";
```

This was added in [pull request #2752: Change the Button component background and text colour](https://github.com/alphagov/govuk-frontend/pull/2752). Thanks to [Nick Colley](https://github.com/NickColley) for this contribution.

### Recommended changes

#### Remove `aria-labelledby`, remove `id="error-summary-title"` from title and move `role="alert"` to child container on the error summary component
Expand Down
22 changes: 20 additions & 2 deletions src/govuk/components/button/_index.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
////
/// @group components/button
////

/// Button component background colour
///
/// @type Colour
/// @access public

$govuk-button-background-colour: govuk-colour("green", $legacy: #00823b) !default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this line be better placed in src/govuk/settings/_colours-applied.scss? That's where other default variables definitions seem to be located.

I'm conscious that this variable is specific to the button component, however, and we don't seem to have precedent for where to put them specifically. Happy to keep it here if we think that makes more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking over time I can contribute the different high level component variables based on me branding the GOV.UK Design System so it'll make more sense.


/// Button component text colour
///
/// @type Colour
/// @access public

$govuk-button-text-colour: govuk-colour("white") !default;

@include govuk-exports("govuk/component/button") {
$govuk-button-colour: govuk-colour("green", $legacy: #00823b);
$govuk-button-colour: $govuk-button-background-colour;
$govuk-button-hover-colour: govuk-shade($govuk-button-colour, 20%);
$govuk-button-shadow-colour: govuk-shade($govuk-button-colour, 60%);
$govuk-button-text-colour: govuk-colour("white");
$govuk-button-text-colour: $govuk-button-text-colour;

// Secondary button variables
$govuk-secondary-button-colour: govuk-colour("light-grey", $legacy: "grey-3");
Expand Down
1 change: 1 addition & 0 deletions tasks/sassdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ function buildSassdocs (cb) {
sassdoc([paths.src + '**/**/*.scss', `!${paths.src}/vendor/*`], {
dest: paths.sassdoc,
groups: {
'components/button': 'Components / Button',
'helpers/accessibility': 'Helpers / Accessibility',
'helpers/colour': 'Helpers / Colour',
'helpers/layout': 'Helpers / Layout',
Expand Down