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

Conversation

NickColley
Copy link
Contributor

@NickColley NickColley commented Aug 8, 2022

Expands the public API to include a new $govuk-button-background-colour and $govuk-button-text-colour scss variable.

Allows users who brand GOV.UK to do so without brittle selector overrides
which can break in future updates.

This variable naming matches other similar variables such as
$govuk-body-background-colour and $govuk-canvas-background-colour.

At the moment I have to do this sort of thing:

@import "node_modules/govuk-frontend/govuk/base";
@import "node_modules/govuk-frontend/govuk/components/button/index";

$app-button-colour: $app-primary-color;
$app-button-hover-colour: govuk-shade($app-button-colour, 20%);
$app-button-shadow-colour: govuk-shade($app-button-colour, 60%);
.govuk-button:not(.govuk-button--secondary):not(.govuk-button--warning) {
    background-color: $app-button-colour;
    box-shadow: 0 $govuk-border-width-form-element 0 $app-button-shadow-colour;
}

.govuk-button:not(.govuk-button--secondary):not(.govuk-button--warning):hover {
    background-color: $app-button-hover-colour;
}

After:

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

$govuk-button-background-colour: govuk-colour("blue");
@import "node_modules/govuk-frontend/govuk/components/button/index";

@NickColley NickColley changed the title Enable changing of button background colour Enable changing button background colour Aug 8, 2022
@NickColley NickColley changed the title Enable changing button background colour Change the primary button background colour Aug 8, 2022
@NickColley NickColley changed the title Change the primary button background colour Change the Button component's primary background colour Aug 8, 2022
@NickColley NickColley force-pushed the change-button-colour branch 3 times, most recently from 427340d to 8baa05e Compare August 8, 2022 15:31
@NickColley NickColley changed the title Change the Button component's primary background colour Change the Button component background colour Aug 8, 2022
@NickColley
Copy link
Contributor Author

Is it possible to get this considered for triage please?

@36degrees @vanitabarrett

@vanitabarrett vanitabarrett added feature request User requests a new feature button labels Aug 12, 2022
@NickColley
Copy link
Contributor Author

Thank you @vanitabarrett ! Appreciate it.

Copy link
Member

@querkmachine querkmachine left a comment

Choose a reason for hiding this comment

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

Couple of thoughts. Nothing explicitly blocking.

/// @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.

@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");
Copy link
Member

Choose a reason for hiding this comment

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

As we're allowing customisation of the background-color, it feels like we should also provide a mechanism to customise the text color so that it's possible to maintain accessible contrast.

Copy link
Contributor Author

@NickColley NickColley Aug 12, 2022

Choose a reason for hiding this comment

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

Agreed, this'll also be useful when either I or the GOV.UK Design System team writes about branding. My plan is to contribute these improvements based on real world usage of branding while doing client work. Then I will write guidance on how this is done that could be contributed back to the main GOV.UK Design System if it becomes useful to do so.

@NickColley NickColley changed the title Change the Button component background colour Change the Button component background and text colour Aug 12, 2022
@NickColley
Copy link
Contributor Author

@querkmachine pushed an update addressing your feedback.

@querkmachine
Copy link
Member

A commit from your accordion focus colour PR seems to have snuck in and caused a merge conflict. If you can fix that up, I'm happy to approve!

@NickColley
Copy link
Contributor Author

Ah yeah rouge rebase gone wrong, will sort that thanks.

@querkmachine
Copy link
Member

Hi @NickColley,

Sorry! This has ended up overlapping with some other work we're doing and we've inadvertently introduced a new merge conflict to your PR — the file at tasks/gulp/sassdoc.js has been moved to tasks/sassdoc.js on the main branch now.

If you're okay to take a look at it, please do. We're currently preparing a bugfix release of Frontend however, so it may be a few more days until this is approved and merged.

@NickColley NickColley force-pushed the change-button-colour branch 2 times, most recently from b6c5962 to 01e39bd Compare August 17, 2022 15:11
@NickColley
Copy link
Contributor Author

@querkmachine okay sorted that conflict thanks for the heads up. 👍🏻

Adds a new `$govuk-button-background-colour` and `$govuk-button-text-colour`
 public variable inside a new Component / Button section.

Allows users who brand GOV.UK to do so without brittle selector overrides
which can break in future updates.

This variable naming matches other similar variables such as
`$govuk-body-background-colour` and `$govuk-canvas-background-colour`.
@querkmachine
Copy link
Member

@NickColley I've just rebased your branch and moved the changelog entry to the right place now that the 4.3.1 release has gone out. Will approve once the tests have ran. Thanks for putting up with the faff!

Copy link
Contributor

@owenatgov owenatgov left a comment

Choose a reason for hiding this comment

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

🟢 🔴 🟡 👍🏻

@querkmachine querkmachine merged commit c24387e into alphagov:main Aug 18, 2022
@NickColley NickColley deleted the change-button-colour branch August 18, 2022 15:32
@NickColley
Copy link
Contributor Author

Thanks @querkmachine @owenatgov for your help getting this one in 👍🏻

@querkmachine querkmachine added this to the [NEXT] milestone Aug 18, 2022
@romaricpascal romaricpascal mentioned this pull request Nov 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
button feature request User requests a new feature
Projects
Development

Successfully merging this pull request may close these issues.

5 participants