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

Add no-underline mixin and modifier class #2214

Merged
merged 2 commits into from
Apr 30, 2021
Merged

Conversation

36degrees
Copy link
Contributor

@36degrees 36degrees commented Apr 30, 2021

This is a fairly common thing for service teams to need to implement, and they’ll often do it using text-decoration which, as a shorthand property, results in the text-decoration-thickness being reset to auto for the hover state.

Provide a mixin and class which includes the correct behaviour. Add it to the ‘links’ examples page.

The underlying styles make use of :not, which means that the no-underline mixin / modifier will have no effect in IE8 which does not support :not.

Screenshot

Link without underline

Screenshot 2021-04-30 at 11 58 00

Link without underline (hovered / active)

Screenshot 2021-04-30 at 11 58 04

Split out from #2183.

Closes #2189

This is a fairly common thing for service teams to need to implement, and they’ll often do it using `text-decoration` which, as a shorthand property, results in the `text-decoration-thickness` being reset to auto for the hover state.

Provide a mixin and class which includes the correct behaviour. Add it to the ‘links’ examples page.

# Conflicts:
#	src/govuk/core/_links.scss
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2214 April 30, 2021 08:44 Inactive
IE11 does not support the CSS Text Decoration Module Level 3 ‘text-decoration styling’ properties [1] [2], and only recognises `text-decoration` as a regular property with values of none, underline, etc – as defined in CSS2 [3].

As such, using `text-decoration-line` to ‘unset’ the underline does not work in IE11. We want to avoid re-setting the `text-decoration` property because when treated as shorthand (in browsers that support `text-decoration-styling` this resets the `text-decoration-thickness` property to `auto`.

Instead, use `:not(:hover):not(:active)` to remove the text-decoration except when hovered/active. `:not` is supported in IE9 and above. This means that the `no-underline` mixin / modifier will have no effect in IE8.

Unfortunately the pseudo-class plugin we use to display links in different states does not correctly handle `:not` when used like this, so the examples in the links page do not render correctly. Revert the changes to this example, adding a simpler example instead.

[1]: https://www.w3.org/TR/css-text-decor-3/#text-decoration
[2]: https://caniuse.com/text-decoration
[3]: https://www.w3.org/TR/2009/CR-CSS2-20090908/text.html#propdef-text-decoration
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-2214 April 30, 2021 10:57 Inactive
@36degrees 36degrees merged commit 57d6bb9 into master Apr 30, 2021
@36degrees 36degrees deleted the no-underline-link-mixin branch April 30, 2021 12:33
@36degrees 36degrees mentioned this pull request May 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add 'no-underline' mixin and modifier class for links
3 participants