-
Notifications
You must be signed in to change notification settings - Fork 346
[SPIKE-ISH] Add private variable and function for brand colours #6303
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
base: main
Are you sure you want to change the base?
Changes from all commits
4f24afd
4a9444a
f072b09
304bcda
101867f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -27,9 +27,11 @@ | |||||
| "removed in the next major version."); | ||||||
| } | ||||||
|
|
||||||
| // Sass parses unquoted colours as colours, so we need to turn them into | ||||||
| // strings before looking them up in the colour palette | ||||||
| // https://sass-lang.com/documentation/values/strings#unquoted | ||||||
| @if type-of($colour) == "color" { | ||||||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note Maybe better as:
Suggested change
|
||||||
| // stylelint-disable-next-line scss/function-quote-no-quoted-strings-inside | ||||||
| $colour: quote("#{$colour}"); | ||||||
| $colour: "#{$colour}"; | ||||||
| } | ||||||
|
|
||||||
| @if not map-has-key($govuk-colours, $colour) { | ||||||
|
|
@@ -39,6 +41,42 @@ | |||||
| @return map-get($govuk-colours, $colour); | ||||||
| } | ||||||
|
|
||||||
| /// Get brand colour | ||||||
| /// | ||||||
| /// @param {String | Colour} $colour - Name of brand colour from the palette | ||||||
| /// (`$govuk-colour`) | ||||||
| /// @param {String } $variant - Name of the colour variant from the palette | ||||||
| /// @return {Colour} Representation of the variant of the brand colour | ||||||
| /// | ||||||
| /// @throw if `$variant` is not a variant from the colour | ||||||
| /// @access private | ||||||
| @function _govuk-brand-colour($colour, $variant: null) { | ||||||
| // Sass parses unquoted colours as colours, so we need to turn them into | ||||||
| // strings before looking them up in the colour palette | ||||||
| // https://sass-lang.com/documentation/values/strings#unquoted | ||||||
| @if type-of($colour) == "color" { | ||||||
| $colour: "#{$colour}"; | ||||||
| } | ||||||
|
|
||||||
| @if $colour == "white" { | ||||||
| @return #fff; | ||||||
| } | ||||||
|
Comment on lines
+61
to
+63
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note Unless we have a long list of colours that don't fit the If the list starts to grow, we could store them in |
||||||
|
|
||||||
| $colour-variants: map-get($govuk-brand-colours, $colour); | ||||||
|
|
||||||
| @if not $colour-variants { | ||||||
| @error "Unknown colour `#{$colour}` (available colours: #{map-keys($govuk-brand-colours)}, white)"; | ||||||
| } | ||||||
|
|
||||||
| $result: map-get($colour-variants, $variant); | ||||||
|
|
||||||
| @if not $result { | ||||||
| @error "Unknown variant `#{$variant}` for colour `#{$colour}` (available variants: #{map-keys($colour-variants)})"; | ||||||
| } | ||||||
|
|
||||||
| @return $result; | ||||||
| } | ||||||
|
|
||||||
| /// Get the colour for a government organisation | ||||||
| /// | ||||||
| /// @param {String} $organisation - Organisation name, lowercase, hyphenated | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,3 +33,93 @@ $govuk-colours: ( | |
| "light-green": #85994b, | ||
| "turquoise": #28a197 | ||
| ) !default; | ||
|
|
||
| /// Colour palette | ||
| /// | ||
| /// @type Map | ||
| /// | ||
| /// @prop $colour.$variant - Representation for the given $variant of $colour, where $colour is the | ||
| /// friendly name for the colour, and $variant the friendly name for the variant | ||
| /// (e.g. `"red": ("primary": #ff0000)`) | ||
| /// @access private | ||
|
|
||
| $govuk-brand-colours: ( | ||
| "blue": ( | ||
| "primary": #1d70b8, | ||
| "tint-25": #5694ca, | ||
| "tint-50": #8eb8dc, | ||
| "tint-80": #d2e2f1, | ||
| "tint-95": #f4f8fb, | ||
| "shade-50": #0f385c | ||
| ), | ||
| "green": ( | ||
| "primary": #11875a, | ||
| "tint-25": #4da583, | ||
| "tint-50": #88c3ad, | ||
| "tint-80": #cfe7de, | ||
| "tint-95": #f3f9f7, | ||
| "shade-50": #09442d | ||
| ), | ||
| "teal": ( | ||
| "primary": #158187, | ||
| "tint-25": #50a1a5, | ||
| "tint-50": #8ac0c3, | ||
| "tint-80": #d0e6e7, | ||
| "tint-95": #f3f9f9, | ||
| "shade-50": #0b4144, | ||
| "accent": #00ffe0 | ||
| ), | ||
| "purple": ( | ||
| "primary": #54319f, | ||
| "tint-25": #7f65b7, | ||
| "tint-50": #aa98cf, | ||
| "tint-80": #ddd6ec, | ||
| "tint-95": #f6f5fa, | ||
| "shade-50": #2a1950 | ||
| ), | ||
| "magenta": ( | ||
| "primary": #ca357c, | ||
| "tint-25": #d7689d, | ||
| "tint-50": #e59abe, | ||
| "tint-80": #f4d7e5, | ||
| "tint-95": #fcf5f8, | ||
| "shade-50": #651b3e | ||
| ), | ||
| "red": ( | ||
| "primary": #ca3535, | ||
| "tint-25": #d76868, | ||
| "tint-50": #e59a9a, | ||
| "tint-80": #f4d7d7, | ||
| "tint-95": #fcf5f5, | ||
| "shade-50": #651b1b | ||
| ), | ||
| "orange": ( | ||
| "primary": #f47738, | ||
| "tint-25": #f7996a, | ||
| "tint-50": #fabb9c, | ||
| "tint-80": #fde4d7, | ||
| "tint-95": #fef8f5, | ||
| "shade-50": #7a3c1c | ||
| ), | ||
| "yellow": ( | ||
| "primary": #ffdd00, | ||
| "tint-25": #ffe640, | ||
| "tint-50": #ffee80, | ||
| "tint-80": #fff8cc, | ||
| "tint-95": #fffdf2, | ||
| "shade-50": #806f00 | ||
| ), | ||
| "brown": ( | ||
| "primary": #99704a, | ||
| "tint-25": #b39477, | ||
| "tint-50": #ccb8a5, | ||
| "tint-95": #faf8f6 | ||
| ), | ||
| "black": ( | ||
| "primary": #0b0c0c, | ||
| "tint-25": #484949, | ||
| "tint-50": #858686, | ||
| "tint-80": #cecece, | ||
| "tint-95": #f3f3f3 | ||
| ) | ||
| ) !default; | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note While the variable is private, this
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An alternative could be to pass the map of colours to the If we rename the function .govuk-link:hover {
color: govuk-colour-variant(link, hover, $govuk-applied-colours)
}
:focus {
govuk-colour-variant(focus, text, $govuk-applied-colours)
}That looks like a separate piece of work though, and doesn't change the situation with testing: either through parameters or |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
note Now we can access the brand colours, we can avoid re-using the colour of the template background for the Service Navigation.