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

Better handle cases where govuk-text-colour is set to a non-colour value #2573

Merged
merged 7 commits into from
Mar 28, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

### Fixes

[#2549: Fix header with product name focus and hover state length](https://github.com/alphagov/govuk-frontend/pull/2549)
- [#2549: Fix header with product name focus and hover state length](https://github.com/alphagov/govuk-frontend/pull/2549)
- [#2573: Reinstate support for 'inherit' as a text colour](https://github.com/alphagov/govuk-frontend/pull/2573)
vanitabarrett marked this conversation as resolved.
Show resolved Hide resolved

## 4.0.1 (Fix release)

Expand Down
4 changes: 3 additions & 1 deletion src/govuk/helpers/_links.scss
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,9 @@
// Force a colour change on hover to work around a bug in Safari
// https://bugs.webkit.org/show_bug.cgi?id=224483
&:hover {
color: rgba($govuk-text-colour, .99);
@if (type-of($govuk-text-colour) == color) {
color: rgba($govuk-text-colour, .99);
}
}

&:active,
Expand Down
36 changes: 36 additions & 0 deletions src/govuk/helpers/links.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,39 @@ describe('@mixin govuk-link-hover-decoration', () => {
})
})
})

describe('@mixin govuk-link-style-text', () => {
vanitabarrett marked this conversation as resolved.
Show resolved Hide resolved
describe('when $govuk-text-colour is a colour', () => {
it('applies the rgba function', async () => {
const sass = `
$govuk-text-colour: black;
@import "base";

a {
@include govuk-link-style-text;
}`

const results = await renderSass({ data: sass, ...sassConfig })

expect(results.css.toString()).toContain(':hover')
expect(results.css.toString()).toContain('color:')
expect(results.css.toString()).toContain('rgba(')
})
})

describe('when $govuk-text-colour is inherit', () => {
it('does NOT apply the rgba function', async () => {
const sass = `
$govuk-text-colour: inherit;
@import "base";

a {
@include govuk-link-style-text;
}`

const results = await renderSass({ data: sass, ...sassConfig })

expect(results.css.toString()).not.toContain('rgba(')
})
})
})