-
Notifications
You must be signed in to change notification settings - Fork 332
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
Defend against a:link:focus in GOV.UK Template #609
Conversation
GOV.UK Template includes a specific a:link:focus selector [1] designed to make unvisited links a slightly darker blue when focussed, so we need to override the text colour for that combination of selectors so that the links within the various components do not end up with dark blue text when focussed when that is not the desired behaviour. [1]: https://github.com/alphagov/govuk_template/blob/73cf50c02ae335159ae241387d2ddd61f50d1b23/source/assets/stylesheets/_accessibility.scss#L63-L66
GOV.UK Template includes a specific `a:link:focus` selector [1] designed to make unvisited links a slightly darker blue when focussed, so we need to override the text colour for that combination of selectors so that the links within the muted link variant do not end up with dark blue text when focussed.
I would like to add something to this. The GOV.UK template selector was meant to make links slightly darker when focused - regardless of them being visited or not - as it says in the comment above that line I raised #325 months ago for this to be fixed, but it got lost in translation. Defending the links from such situations (chaining pseudo-classes) is a good thing, but if we defend against My opinion is that the first action should be to fix govuk_template issue, and then figure out if, how and in what degree we defend components, especially when chaining pseudo-classes. |
I think in this case the implementation is actually right and the comment is wrong (or, at least, not clear) – from Ed's comment here the intention was just to make the unvisited links darker – leaving the visited links purple which already meets colour contrast - that being the case
Because this is a specific fix against an issue integrating Frontend into a service that uses GOV.UK Template, where these selectors are found. Other combinations (thankfully!) don't exist, and I wouldn't look to defend against those either.
I don't think we can assume that those looking to move to GOV.UK Frontend will always be running the latest version of GOV.UK Template – some users might still be on the current version, in which case they would need Frontend to compensate accordingly (especially as it's something that's easy to miss in testing, as we've seen). |
If the intention was just to make the unvisited links darker then my PR's not solving it, so I'll close it for now. The fact that other combinations don't exist, doesn't mean they won't be in anytime soon.. but got your point. |
From memory, I was trying to specifically target unvisited links as these were the ones that failed contrast checks - not visited links. |
src/breadcrumbs/_breadcrumbs.scss
Outdated
&:link, | ||
&:visited, | ||
&:hover, | ||
&:active { | ||
&:active, |
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.
Could we break these out into their own sections and do something like
.class {
&:link,
&:visited,
&:hover,
&:active {
color: $govuk-text-colour;
}
if ($with-govuk-template) {
... overrides here
}
}
This would mean if we wanted to do 'pure' builds we could.
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.
I like this in principle, but not sure how it'll work in practise – especially for users that are not compiling the Sass themselves. I'm not sure what we'd do for the dist
build, for example?
Also, I'm not sure that we have the tooling in place to have confidence in this when introducing yet more complexity into the builds. In the example above we'd need to set color: $govuk-text-colour;
in two places, and I could e.g. foresee one being changed without the other which could lead to inconsistent and hard to reproduce problems.
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.
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.
For general builds we would set these to on by default, as is the same as your current code.
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.
Low-fi is just to make sure each selector that overrides for govuk-template has a comment next to it, which most of these do?
src/back-link/_back-link.scss
Outdated
@@ -22,10 +22,18 @@ | |||
// Underline is provided by a bottom border | |||
text-decoration: none; | |||
|
|||
// Override link colour to use text colour | |||
// | |||
// GOV.UK Template includes a specific a:link:focus selector designed to |
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.
Instead of 'GOV.UK Template' should we use 'alphagov/govuk_template' which is less ambiguous for people in the future?
If we intend to deprecate GOV.UK Template there will be people in the future that don't even know what this is.
Allow Frontend to selectively output styles only if another ‘product’ (Template, Frontend Toolkit, Elements) is also identified as being used in the project.
Create a new ‘text style link’ macro for the breadcrumbs, back link and skip link components to use. Abstract other link styles into mixins for consistency. Update breadcrumb, back link and skip link to use the new mixins.
this looks good. 👍 |
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.
I think this can go in as it is for now if there are no blockers from the other reviewers.
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.
Looks good to me 🙂
Two non-blocking thoughts:
- It would be good if the useful code comments, especially from
/globals/core/_links.scss
, could at some point make their way into our docs as instructions on how to set up correctly styled links in your service. - Out of the remit of this PR as not introduced by it... but I wonder if error summary links should come with a different hover colour. It would be good to understand/document why they don't, maybe it's something from user research.
Is https://govuk-design-system-production.cloudapps.digital/styles/typography/#links the sort of thing you're thinking of? |
Yes that's capturing some of it but maybe on a slightly higher level 👍 I'm thinking about adding something about the compatibility modes and how to use things like the mixins together with each other such as this comment from
However I wonder if some of this is too low level for the Design System and should live in GOV.UK Frontend I might be making too many assumptions here and we should just take this to user research. |
changelog :) |
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.
Feels like the abstraction makes it confusing but I think I understand what's going on.
Otherwise looks good 👍 🚢
Which abstraction, sorry? |
@36degrees the compatibility one makes sense, the other ones add more layers, we should merge this. |
GOV.UK Template includes a specific
a:link:focus
selector designed to make unvisited links a slightly darker blue when focussed, so we need to override the text colour for that combination of selectors so that the links within the various components do not end up with dark blue text when focussed when that is not the desired behaviour.https://trello.com/c/rD8KRQle/816-remove-blue-colour-on-unvisited-button-coming-from-govuk-template
https://trello.com/c/fOiHvIjh/817-remove-blue-colour-on-unvisited-back-link-coming-from-govuk-template
https://trello.com/c/N3sczGfq/818-remove-blue-colour-on-unvisited-muted-link-coming-from-govuk-template