Skip to content

Commit edb0130

Browse files
romaricpascalseaemsi36degrees
committed
Deprecate the govuk-text-colour mixin
As all it does is output a constant CSS declaration, we can ask users to write that `color` declaration instead of calling the mixin. Co-authored-by: seaemsi <50173207+seaemsi@users.noreply.github.com> Co-authored-by: Oliver Byford <36degrees@users.noreply.github.com>
1 parent d2cb12a commit edb0130

3 files changed

Lines changed: 53 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,31 @@ If you were using the `_<COMPONENT_NAME>.scss` files, use the component's `_inde
3232

3333
We made this change in [#6761: Deprecate `_<COMPONENT_NAME>.scss` files](https://github.com/alphagov/govuk-frontend/pull/6761).
3434

35+
#### Use `color: govuk-functional-colour(text)` to set the text colour
36+
37+
We've updated how the text colour changes to pure black when printing.
38+
39+
Before, an additional print media query was included every time you used `@include govuk-text-colour`:
40+
41+
````css
42+
.my-element {
43+
color: var(--govuk-text-colour, #0b0c0c);
44+
}
45+
46+
@media print {
47+
.my-element {
48+
color: var(--govuk-print-text-colour, #000);
49+
}
50+
}
51+
52+
This change allows you to simplify how the text colour is applied to your CSS rulesets.
53+
54+
Replace any instances of `@include govuk-text-colour` with `color: govuk-functional-colour(text)`.
55+
56+
We'll remove the `govuk-text-colour` mixin in a future breaking release.
57+
58+
We made this change in [pull request #6427: Use custom properties to switch print text to pure black](https://github.com/alphagov/govuk-frontend/pull/6427).
59+
3560
### Fixes
3661

3762
We've made fixes to GOV.UK Frontend in the following pull requests:
@@ -162,7 +187,7 @@ For example:
162187
$app-colour: govuk-colour('blue'); // Returns the 'Primary blue' colour
163188

164189
$component-colour: govuk-colour('red', $variant: 'tint-25') // Returns the 'Red tint 25%' colour
165-
```
190+
````
166191

167192
See the [GOV.UK web palette](https://design-system.service.gov.uk/styles/colour/#govuk-web-palette) on the GOV.UK Design System website for the list of available colours, tints and shades.
168193

packages/govuk-frontend/src/govuk/helpers/_typography.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,15 @@
3636
///
3737
/// Sets the text colour, including a suitable override for print.
3838
///
39+
/// @deprecated
3940
/// @access public
4041

4142
@mixin govuk-text-colour {
43+
@include _warning(
44+
"govuk-text-colour",
45+
"The `govuk-text-colour` mixin is deprecated. Use `color: govuk-colour(text)` instead."
46+
);
47+
4248
color: govuk-functional-colour(text);
4349
}
4450

packages/govuk-frontend/src/govuk/helpers/typography.unit.test.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,27 @@ describe('@mixin govuk-typography-common', () => {
135135
})
136136
})
137137

138+
describe('@mixin govuk-text-colour', () => {
139+
it('throws a deprecation warning if used', async () => {
140+
const sass = `
141+
${sassBootstrap}
142+
143+
.foo {
144+
@include govuk-text-colour;
145+
}
146+
`
147+
148+
await compileSassString(sass, sassConfig)
149+
150+
// Expect our mocked @warn function to have been called once with a single
151+
// argument, which should be the deprecation notice
152+
expect(mockWarnFunction).toHaveBeenCalledWith(
153+
'The `govuk-text-colour` mixin is deprecated. Use `color: govuk-colour(text)` instead. To silence this warning, update $govuk-suppressed-warnings with key: "govuk-text-colour"',
154+
expect.anything()
155+
)
156+
})
157+
})
158+
138159
describe('@mixin govuk-font-tabular-numbers', () => {
139160
it('enables tabular numbers opentype feature flags', async () => {
140161
const sass = `

0 commit comments

Comments
 (0)