-
Notifications
You must be signed in to change notification settings - Fork 334
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
Update accordion to use new WCAG 2.1 compliant focus style #1324
Conversation
bdfcf6d
to
339cd19
Compare
7790dd2
to
bdfcb67
Compare
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.
Needs a CHANGELOG entry
@@ -5,6 +5,10 @@ | |||
|
|||
@include govuk-exports("govuk/component/accordion") { | |||
|
|||
$govuk-accordion-link-colour: govuk-colour("blue"); |
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 these should probably reference $govuk-link-colour
/ ?$govuk-link-hover-colour
EDIT: As Hanna pointed out in #1326, ``$govuk-link-hover-colouris dark-blue, so that doesn't work, but
$govuk-link-colour` I think makes sense.
border-width: 0; | ||
color: $govuk-link-colour; | ||
background: none; | ||
cursor: pointer; | ||
-webkit-appearance: none; |
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.
Should we use appearance: none
here and let autoprefixer do the rest?
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 don't think that's actually real CSS right now? In our button CSS we use the webkit prefix too...
https://drafts.csswg.org/css-ui-4/#appearance-switching
I'd raise an issue to update all of them if you think it's worth doing.
@include govuk-not-ie8 { | ||
border-top-color: $govuk-focus-colour; | ||
} | ||
outline: $govuk-focus-width solid transparent; |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
@media (hover: none) { | ||
background-color: initial; | ||
// For devices that can't hover such as touch devices, | ||
// remove hover state as it can be stuck in that state (iOS). |
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.
The comment doesn't seem to match what the code's doing any 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.
It's still a hover state that can be stuck and needs to be removed, any ideas on how to improve it?
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.
Sorry, I think I mis-read this, makes sense.
padding-top: govuk-spacing(3); | ||
padding-bottom: 0; | ||
padding-left: 0; | ||
padding: 0; | ||
border-width: 0; | ||
// Headings in section headers have link colours as an additional affodance |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
} | ||
} | ||
|
||
.govuk-accordion__section:not(.govuk-accordion__section--expanded) .govuk-accordion__section-button:focus:not(:active) { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
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.
Great comment.
@@ -70,15 +74,24 @@ | |||
// This is styled to look like a link not a button | |||
.govuk-accordion__open-all { | |||
@include govuk-font($size: 16); | |||
@include govuk-link-common; | |||
display: inline; | |||
position: relative; |
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 am wondering whether the open all button meets colour contrast if the top-most section is already open when you go to focus it.
I think in this case the black underline 'blends in' with the blue top border, so I'm not sure it'd be perceivable, and the yellow alone does not meet contrast against the white page background.
@dashouse what do you think?
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.
@36degrees Blue to Black is 3.78:1. We're somewhat relying on this change being ok elsewhere. It also has the underline removed which is exclusive to the focus state. Go with it and see what comes up in the audit?
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.
Sounds good – I should've checked the contrast rather than just assuming, surprised it's that high! 👍
&:focus { | ||
background: none; | ||
// Remove default button focus outline in Firefox | ||
&::-moz-focus-inner { |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
bdfcb67
to
9610671
Compare
9610671
to
d0bd0b1
Compare
These focus styles are necessary to meet WCAG 2.1 non-text contrast requirements
765d3f6
to
3fb3de6
Compare
CHANGELOG.md
Outdated
|
||
- Update footer links to use new focus style |
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 has got lost in the rebase?
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.
Thanks, I had a bit of a mare in the rebase on this one
@media (hover: none) { | ||
background-color: initial; | ||
// For devices that can't hover such as touch devices, | ||
// remove hover state as it can be stuck in that state (iOS). |
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.
Sorry, I think I mis-read this, makes sense.
} | ||
} | ||
|
||
.govuk-accordion__section:not(.govuk-accordion__section--expanded) .govuk-accordion__section-button:focus:not(: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.
Great comment.
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.
Great work. Just left a couple of small comments.
@include govuk-link-common; | ||
display: inline; | ||
position: relative; | ||
z-index: 1; |
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.
It looks like this is used to float the button over the component so that the focus state is visible. In order to avoid setting z-index
, could we add a few pixels of bottom margin to .govuk-accordion__controls
so that it doesn't overlap the component?
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 Dave made these changes to intentionally overlap the accordion by the looks?
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.
Yeah, wanted this to overlap the top border and line up. It felt a bit untidy when it was almost overlapping.
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.
Thanks @dashouse
display: inline; | ||
position: relative; | ||
z-index: 1; | ||
margin: 0; |
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'm not sure if this is needed. Or is it guarding against some edge case?
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.
If you don't do this the open all button focus state renders below the border
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.
Sorry my comment refers to margin: 0
, not the z-index
. I still can't see setting margin: 0
making any difference. But this is non-blocking
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 it's just being explicit rather than relying on the user agent styles. The open all button is just using the default user agent padding at the minute, for example. Even if most (all?) browsers use margin: 0
it's still good to be clear that that's intentional.
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.
👍
border-width: 0; | ||
// Headings in section headers have link colours as an additional affodance | ||
color: $govuk-link-colour; | ||
color: inherit; |
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.
Non-blocking: Would it be more robust to set the colour directly on the button?
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.
The color is set on the header element which lets you group the CSS together so it's easier to understand
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.
Also the intent of our styling here is to make the button turn into the header, so inheriting feels more correct towards that effect.
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.
👍
@include govuk-not-ie8 { | ||
&:focus { | ||
outline: none; | ||
background: none; |
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.
Non-blocking: I can't see these two styles having any effect. Might be worth adding a comment?
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.
Sure thing
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 was left around before we had the new focus styles so can be removed thanks :)
3fb3de6
to
53c5a59
Compare
53c5a59
to
97eee6c
Compare
Updates the accordion component to use the new WCAG 2.1 compliant focus styles.
GIF demonstrations
IE8
IE9
IE10
IE11
Firefox with changed colours
Firefox
Safari
Chrome
Chrome mobile
Safari mobile
Closes #1307