Skip to content

Commit

Permalink
Merge pull request #1288 from alphagov/update-colours
Browse files Browse the repository at this point in the history
Update colour palette
  • Loading branch information
36degrees authored Apr 29, 2019
2 parents 8370f97 + 272d903 commit 3d6f784
Show file tree
Hide file tree
Showing 12 changed files with 365 additions and 43 deletions.
90 changes: 88 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,100 @@

💥 Breaking changes:

- The colour palette has been updated.

**Note:** If you are using [compatibility mode], the existing palette will be
preserved.

Purple, red, yellow, green, blue and light blue have all been updated to new
colours.

Dark blue has been added, and bright red has been removed.

Greys 1-through-4 have been replaced with dark, mid and light-grey. As a
general rule of thumb, dark grey replaces grey-1 and is designed to be used as
a foreground colour; light grey replaces both grey-3 and grey-4 and is
designed to be used as a background colour, and mid-grey replaces grey-2 and
is designed to be used for borders.

To migrate you'll need to update any references to bright-red, grey-1, grey-2,
grey-3 or grey-4 to use the new colours from the palette.

| Colour | Before | After | Notes |
| ------------- | --------- | --------- | --------------------------------- |
| purple | `#2e358b` | `#4c2c92` | updated - matches visited links |
| light-purple | `#6f72af` | `#6f72af` | |
| bright-purple | `#912b88` | `#912b88` | |
| pink | `#d53880` | `#d53880` | |
| light-pink | `#f499be` | `#f499be` | |
| red | `#b10e1e` | `#d4351c` | updated |
| bright-red | `#df3034` | | removed - similar to the new red |
| orange | `#f47738` | `#f47738` | |
| brown | `#b58840` | `#b58840` | |
| yellow | `#ffbf47` | `#ffdd00` | updated |
| light-green | `#85994b` | `#85994b` | |
| green | `#006435` | `#00703c` | updated |
| turquoise | `#28a197` | `#28a197` | |
| light-blue | `#2b8cc4` | `#5694ca` | updated |
| blue | `#005ea5` | `#1d70b8` | updated |
| dark-blue | | `#003078` | added |
| black | `#0b0c0c` | `#0b0c0c` | |
| grey-1 | `#6f777b` | | removed |
| dark-grey | | `#6f777b` | added |
| grey-2 | `#bfc1c3` | | removed |
| mid-grey | | `#b1b4b6` | added |
| grey-3 | `#dee0e2` | | removed |
| grey-4 | `#f8f8f8` | | removed |
| light-grey | | `#f3f2f1` | added |
| white | `#ffffff` | `#ffffff` | |

([PR #1288](https://github.com/alphagov/govuk-frontend/pull/1288))

- The button component now uses the green from the colour palette, instead of
a custom green used only for the button.

**Note:** If you are using [compatibility mode], the existing button colour
will be preserved.

([PR #1288](https://github.com/alphagov/govuk-frontend/pull/1288))

- The confirmation panel now uses a green background rather than a turquoise
background.

**Note:** If you are using [compatibility mode], the existing turquoise panel
colour will be preserved.

([PR #1288](https://github.com/alphagov/govuk-frontend/pull/1288))

- Links now get darker when hovered, rather than lighter.

**Note:** If you are using [compatibility mode], the existing link hover style
will be preserved.

([PR #1288](https://github.com/alphagov/govuk-frontend/pull/1288))

- Pull Request Title goes here

Description goes here (optional)

To migrate you need to change: X

([PR #N](https://github.com/alphagov/govuk-frontend/pull/N))

🆕 New features:

- A new setting `$govuk-use-legacy-palette` has been added, which by default
will be true if any of the `$govuk-compatibility-*` settings are true.

When set to `true`, the existing colour palette from v2.x of GOV.UK Frontend
will be used.

([PR #1288](https://github.com/alphagov/govuk-frontend/pull/1288))

- The `govuk-colour` function has been updated to add a `$legacy` argument,
which allows you to specify a colour (either a literal, or a name of a colour
from the legacy palette) to use when `$govuk-use-legacy-palette` is true.

([PR #1288](https://github.com/alphagov/govuk-frontend/pull/1288))

- Pull Request Title goes here

Description goes here (optional)
Expand All @@ -28,6 +112,8 @@

([PR #N](https://github.com/alphagov/govuk-frontend/pull/N))

[compatibility mode]: https://github.com/alphagov/govuk-frontend/blob/master/docs/installation/installing-with-npm.md#compatibility-mode

## 2.11.0 (Feature release)

🆕 New features:
Expand Down
3 changes: 2 additions & 1 deletion src/components/accordion/_accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@

// Section headers have a grey background on hover as an additional affodance
.govuk-accordion__section-header:hover {
background-color: govuk-colour("grey-4");
background-color: govuk-colour("light-grey", $legacy: "grey-4");

// For devices that can't hover such as touch devices,
// remove hover state as it can be stuck in that state (iOS).
@media (hover: none) {
Expand Down
5 changes: 2 additions & 3 deletions src/components/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
@import "../../helpers/all";

@include govuk-exports("govuk/component/button") {
// Primary button variables
$govuk-button-colour: #00823b; // sass-lint:disable no-color-literals
$govuk-button-colour: govuk-colour("green", $legacy: #00823b); // sass-lint:disable no-color-literals
$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");

// Secondary button variables
$govuk-secondary-button-colour: govuk-colour("grey-3");
$govuk-secondary-button-colour: govuk-colour("light-grey", $legacy: "grey-3");
$govuk-secondary-button-hover-colour: govuk-shade($govuk-secondary-button-colour, 10%);
$govuk-secondary-button-shadow-colour: govuk-shade($govuk-secondary-button-colour, 40%);
$govuk-secondary-button-text-colour: govuk-colour("black");
Expand Down
44 changes: 33 additions & 11 deletions src/components/footer/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,24 @@
@include govuk-exports("govuk/component/footer") {

$govuk-footer-background: $govuk-canvas-background-colour;
$govuk-footer-border-top: #a1acb2;
$govuk-footer-border: govuk-colour("grey-2");
$govuk-footer-text: #454a4c;
$govuk-footer-border: $govuk-border-colour;
// This variable can be removed entirely once the legacy palette goes away,
// as it'll just be the same as $govuk-footer-border.
$govuk-footer-border-top: $govuk-border-colour;
$govuk-footer-text: $govuk-text-colour;
$govuk-footer-link: $govuk-footer-text;
$govuk-footer-link-hover: #171819;
$govuk-footer-link-hover: false;

@if ($govuk-use-legacy-palette) {
// sass-lint:disable no-color-literals
$govuk-footer-border-top: #a1acb2;
$govuk-footer-border: govuk-colour("grey-2");
$govuk-footer-text: #454a4c;
$govuk-footer-link: $govuk-footer-text;

// Only used with the legacy palette
$govuk-footer-link-hover: #171819;
}

// Based on the govuk-crest-2x.png image dimensions.
$govuk-footer-crest-image-width-2x: 250px;
Expand All @@ -33,14 +46,23 @@
.govuk-footer__link {
@include govuk-focusable-fill;

&:link,
&:visited {
color: $govuk-footer-link;
}
@if ($govuk-use-legacy-palette) {
&:link,
&:visited {
color: $govuk-footer-link;
}

&:hover,
&:active {
color: $govuk-footer-link-hover;
&:hover,
&:active {
color: $govuk-footer-link-hover;
}
} @else {
&:link,
&:visited,
&:hover,
&:active {
color: $govuk-footer-link;
}
}

// When focussed, the text colour needs to be darker to ensure that colour
Expand Down
2 changes: 1 addition & 1 deletion src/components/panel/_panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

.govuk-panel--confirmation {
color: govuk-colour("white");
background: govuk-colour("turquoise");
background: govuk-colour("green", $legacy: "turquoise");
}

.govuk-panel__title {
Expand Down
2 changes: 1 addition & 1 deletion src/components/tabs/_tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
padding-left: govuk-spacing(4);
float: left;
color: govuk-colour("black");
background-color: govuk-colour("grey-4");
background-color: govuk-colour("light-grey", $legacy: "grey-4");
text-align: center;
text-decoration: none;

Expand Down
2 changes: 1 addition & 1 deletion src/components/tag/_tag.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@
}

.govuk-tag--inactive {
background-color: govuk-colour("grey-1");
background-color: govuk-colour("dark-grey", $legacy: "grey-1");
}
}
24 changes: 23 additions & 1 deletion src/helpers/_colour.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import "../settings/compatibility";
@import "../settings/colours-palette";
@import "../settings/colours-organisations";

Expand All @@ -9,11 +10,32 @@
///
/// @param {String} $colour - Name of colour from the colour palette
/// (`$govuk-colours`)
/// @param {String} $legacy - Either the name of colour from the legacy palette
/// or a colour literal, to return instead when in 'legacy mode' - matching
/// the palette from GOV.UK Template, Elements or Frontend Toolkit
/// @return {Colour} Representation of named colour
///
/// @example scss - Using legacy colours from the palette
/// .foo {
/// background-colour: govuk-colour("mid-grey", $legacy: "grey-2");
/// }
///
/// @example scss - Using legacy colour literals
/// .foo {
/// background-colour: govuk-colour("green", $legacy: #BADA55);
/// }
///
/// @throw if `$colour` is not a colour from the colour palette
/// @access public

@function govuk-colour($colour) {
@function govuk-colour($colour, $legacy: false) {
@if ($govuk-use-legacy-palette and $legacy) {
@if (type-of($legacy) == "color") {
@return $legacy;
}
$colour: $legacy;
}

$colour: quote($colour);

@if not map-has-key($govuk-colours, $colour) {
Expand Down
Loading

0 comments on commit 3d6f784

Please sign in to comment.