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

Use text colour on focus for better contrast #982

Merged
merged 6 commits into from
Sep 10, 2018

Conversation

NickColley
Copy link
Contributor

@NickColley NickColley commented Sep 6, 2018

Closes #944

This pull request updates the focus styles of links in GOV.UK Frontend so they pass WCAG contrast requirements.

You can compare https://govuk-frontend-review-pr-982.herokuapp.com/examples/links vs https://govuk-frontend-review.herokuapp.com/examples/links

Screenshots

back link

Before After
image image

breadcrumbs

Before After
image image

details

Before After
image image

skip link

Before After
image image

header

Before After
screen shot 2018-09-06 at 15 07 20 screen shot 2018-09-06 at 15 07 06

govuk-link

Before After
govuk-frontend-review herokuapp com_examples_links govuk-frontend-review-pr-982 herokuapp com_examples_links

https://trello.com/c/XQPpwofN/1381-1-modify-focus-state-to-use-text-colour

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-982 September 6, 2018 11:41 Inactive
@NickColley NickColley changed the title [Do not merge] Use text colour on focus [Do not merge] Use text colour on focus for better contrast Sep 6, 2018

// When focussed, the text colour needs to be darker to ensure that colour
// contrast is still acceptable
&:focus {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried changing the focusable mixin and that led to ordering problems since focus was not the last selector.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think this would be easy to fix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just felt fragile having to move lots of code around to get the ordering right, we can explore it more, it would be nice to have it in the mixin.

I think one to do together if we decide to explore that.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-982 September 6, 2018 12:25 Inactive
@36degrees
Copy link
Contributor

'Active' links in the header component are still showing as light blue on yellow:

screen shot 2018-09-06 at 13 44 06

@36degrees
Copy link
Contributor

Through doing this I found that the .govuk-list core styles styles anchors, I have updated these to extend the govuk-link selector instead.

I have checked our documentation and we do not recommend our users do this, so maybe this should deprecated and removed instead, or in the future?

Yeah, we don't do it in any other component that might include links, so I agree we should be thinking about removing this.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-982 September 6, 2018 14:08 Inactive
@NickColley
Copy link
Contributor Author

@36degrees I have added an additional commit to address your feedback about the header component

@@ -137,18 +137,18 @@
<section class="govuk-!-margin-top-8">
<h2 class="govuk-heading-l govuk-!-padding-bottom-2" style="border-bottom: 4px solid;">Lists</h2>
<h3 class="govuk-heading-m">govuk-list</h3>
<ul class="govuk-list govuk">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're not sure about keeping the list link styling, do we want to keep these classes for now?

@@ -42,6 +42,9 @@
// -1px offset fixes gap between background and outline in Firefox
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking: I wonder if we should make it possible to pass an offset to the focusable helper, to avoid this duplication? As far as I can tell, the 1px offset is the only reason this isn't using the helper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the width of the outline itself is different too... I think best for another pull request.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

color: $govuk-error-colour;
text-decoration: underline;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just for consistency with the link styles, relying on the browser default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I could tell, this did nothing?

&:focus {
color: govuk-colour("black");
color: $govuk-text-colour;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I'm wondering if this should be a different application? Thinking about (admittedly future) things like whitelabelling, coupling focus text colour to always being the same as the text colour might not always be what users want to do? For example, depending on the focus colour, white might be a better choice.

$govuk-focus-text-colour: govuk-colour("black") !default;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I like that, we should definitely do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, maybe we could do this later to be honest, I've done a commit but wonder if thinking about theming holistically with everything else would be better than adding it piecemeal.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-982 September 6, 2018 15:35 Inactive
@NickColley NickColley added this to the v2.0.0 milestone Sep 6, 2018
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-982 September 6, 2018 15:54 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-982 September 6, 2018 16:00 Inactive
@NickColley NickColley changed the title [Do not merge] Use text colour on focus for better contrast Use text colour on focus for better contrast Sep 6, 2018
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have tested by fixing the linting error and running the app locally and this is looking good – just a couple of minor things to address and then I think we can merge this 🎉

@@ -127,4 +136,4 @@ $govuk-link-hover-colour: govuk-colour("light-blue") !default;
/// @type Colour
/// @access public

$govuk-link-active-colour: govuk-colour("light-blue") !default;
$govuk-link-active-colour: govuk-colour("light-blue") !default;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but looks like you've removed the new line from the end of this file.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the linter's picked up on this as well, which I think is why the tests (and the review app) are now failing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All hail the linter

/// Focused text colour
///
/// Ensure that the contrast between the text and background colour passes
/// WCAG Level AA contrast requirements.

This comment was marked as resolved.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-982 September 7, 2018 09:35 Inactive
@NickColley
Copy link
Contributor Author

@36degrees updated as per your feedback, thanks Ollie.

@NickColley
Copy link
Contributor Author

I think I've broken the 'no visited state', definitely have, so block merging until I resolve that.

@NickColley

This comment has been minimized.

@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-review-pr-982 September 10, 2018 09:29 Inactive
@NickColley
Copy link
Contributor Author

screen shot 2018-09-10 at 10 31 44

I managed to solve the issues by duplicating the pseudo selectors, which is unfortunate but I think is the simplest way for now, this is consistent with the other modifiers at least.

Makes this class consistent with the other selectors.

Unfortunately due to specificity we need to duplicate the pseudo selectors.

This also fixes the hover state for the no visited state links.
Copy link
Contributor

@36degrees 36degrees left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work 👏

@NickColley NickColley merged commit 5ce12b9 into master Sep 10, 2018
@NickColley NickColley deleted the use-text-colour-on-focus branch September 10, 2018 10:19
@paroxp
Copy link
Member

paroxp commented Sep 10, 2018

👏

paroxp added a commit to alphagov/paas-admin that referenced this pull request Oct 11, 2018
This reverts commit 6a007a7.

The issue in question has been beautifully handled by the Design System
Team[1] and no longer needs to exist in our codebase.

Going back to the standard GOV.UK Frontend for consistency and easier
upgrades.

[1]: alphagov/govuk-frontend#982
paroxp added a commit to alphagov/paas-admin that referenced this pull request Oct 11, 2018
This reverts commit 6a007a7.

The issue in question has been beautifully handled by the Design System
Team[1] and no longer needs to exist in our codebase.

Going back to the standard GOV.UK Frontend for consistency and easier
upgrades.

[1]: alphagov/govuk-frontend#982
AP-Hunt pushed a commit to alphagov/paas-admin that referenced this pull request Apr 17, 2019
This reverts commit 6a007a7.

The issue in question has been beautifully handled by the Design System
Team[1] and no longer needs to exist in our codebase.

Going back to the standard GOV.UK Frontend for consistency and easier
upgrades.

[1]: alphagov/govuk-frontend#982
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants