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

Show focus outlines when customising colours settings on Radios and Checkboxes #854

Merged
merged 3 commits into from
Jul 9, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@

- Fixes a bug where the phase banner incorrectly uses a font-size of 19px when
global styles are enabled
([PR #877}])https://github.com/alphagov/govuk-frontend/pull/877
([PR #877](https://github.com/alphagov/govuk-frontend/pull/877))

- Add outlines to Radios and Checkboxes for customised colour users

Now when a [user customises their colours](https://accessibility.blog.gov.uk/2017/03/27/how-users-change-colours-on-websites/),
they should see a focus state on both Radios and Checkboxes.
([PR #854](https://github.com/alphagov/govuk-frontend/pull/854))

🏠 Internal:

Expand Down
5 changes: 5 additions & 0 deletions src/components/checkboxes/_checkboxes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@

// Focused state
.govuk-checkboxes__input:focus + .govuk-checkboxes__label::before {
// Since box-shadows are removed when users customise their colours
// We set a transparent outline that is shown instead.
// https://accessibility.blog.gov.uk/2017/03/27/how-users-change-colours-on-websites/
outline: $govuk-focus-width solid transparent;
outline-offset: $govuk-focus-width;
box-shadow: 0 0 0 $govuk-focus-width $govuk-focus-colour;
}

Expand Down
10 changes: 9 additions & 1 deletion src/components/radios/_radios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
@include govuk-exports("govuk/component/radios") {
$govuk-radios-size: govuk-spacing(7);
$govuk-radios-label-padding-left-right: govuk-spacing(3);
// When the default focus width is used on a curved edge it looks visually smaller.
// So for the circular radios we bump the default to make it look visually consistent.
$govuk-radios-focus-width: $govuk-focus-width + 1px;

.govuk-radios__item {
@include govuk-font($size: 19);
Expand Down Expand Up @@ -99,7 +102,12 @@

// Focused state
.govuk-radios__input:focus + .govuk-radios__label::before {
box-shadow: 0 0 0 4px $govuk-focus-colour;
// Since box-shadows are removed when users customise their colours
// We set a transparent outline that is shown instead.
// https://accessibility.blog.gov.uk/2017/03/27/how-users-change-colours-on-websites/
outline: $govuk-focus-width solid transparent;
outline-offset: $govuk-focus-width;
Copy link

@timja timja Jul 23, 2018

Choose a reason for hiding this comment

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

I assume you're aware but outline-offset doesn't exist in IE (just came across that recently)

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, the offset is for mainly aesthetic reasons as this approach does not rely on the gap between the focus and control, having the offset just makes it a bit more clearer that this is a focus and not a thicker border.

box-shadow: 0 0 0 $govuk-radios-focus-width $govuk-focus-colour;
}

// Selected state
Expand Down