-
Notifications
You must be signed in to change notification settings - Fork 932
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
USWDS - Windows High Contrast Mode Update #4610
Conversation
…uttons to allow checkmark to appear properly in high contrast mode
…ntrast visibility
USWDS: Range Slider - Fixes high contrast visibility
…let sizes and close icon in mobile sizes
USWDS: Radio Button & Checkbox - Windows High Contrast Support
USWDS - Pagination: Added stylings for Windows High Contrast mode
…-contrast-a11y
@@ -1697,3 +1697,23 @@ $system-color-shortcodes: ( | |||
"white-transparent-80": $color-white-transparent-80, | |||
"white-transparent-90": $color-white-transparent-90, | |||
); | |||
|
|||
$high-contrast-system-colors: ( |
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.
System Tokens
While it was possible to call the standard System Colors when declaring things like color
or background-color
, they were not able to be used in functions that required USWDS system tokens. This helps to implement these icons via place-icon()
where you need to declare an icon object which requires color to be defined.
Trying to fix without setting system colors
When setting the image map, you can only set the color to USWDS color tokens. Trying to set it to a high contrast system color (ButtonText in this example), the add-color-icon
function will fail
To get around this, you can set the color to currentColor
and changing the background color of the element to ButtonText
but often times the style gets overridden by another setting.
After setting system colors
After adding the new tokens, one can simply set the color to ButtonText
to get the desired effect
$contrast-bg | ||
$margin: "auto", | ||
$vertical-align: middle, | ||
$contrast-bg: "default" |
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.
place-icon()
and add-color-icon()
Defaults
Setting default values for these functions so users can simply set the icon object and direction while leaving the option to change the rest for optional specificity.
|
||
@media (forced-colors: active) { | ||
forced-color-adjust: 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.
Accordion
Accordion was missing the expand and collapse icons which implied there was collapsed content hidden. By setting forced-color-adjust: none
we can maintain original styling, which passes color contrast minimums.
Current High Contrast / High Contrast Fix: Dark Theme / High Contrast Fix: Light Theme
&::after { | ||
background-color: ButtonText; | ||
} | ||
} |
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.
Banner
The banner was missing chevrons, which implies there is content hidden behind the link. It was also missing the close icon on mobile which allows users to close the pane.
The icons were already placed as masks using place-icon()
, so the solution was simply setting the background color to an appropriate System Color
&--tile { | ||
background-color: ButtonText; | ||
} | ||
} |
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.
Checkbox and Radio Buttons
Currently, the radio button and checkbox components are missing important visual queues for users implementing Windows High Contrast mode including the buttons/boxes themselves, when a selection has been made, and a visual queue of disabled form options.
Because most of the stylings are shared between Radio + Checkbox, it was easiest to fix together.
Radio Buttons
Currently:
Default
Tile
After Fix:
// Note: Bolder border around Radio button / checkbox indicates focus
Default:
Tile:
Checkbox
Currently
Default:
Tile:
After Fix
Default:
Tile:
The checkmark will not show in both cases due to the limitations of forced-colors mode being able to determine light or dark themes, to switch between the light and dark versions of the checkmark.
Our thinking was that the dark high contrast themes are more frequently used than the light themes, so the broader user base will get the most similar checkboxes, stylistically speaking, while the light users still maintain a functional componen
height: 1.5rem; | ||
width: auto; | ||
top: 0.5rem; | ||
} |
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 add-color-icon($calendar); | ||
mask-size: units(3) !important; | ||
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.
Date Range Picker
Currently:
In it's current state, the calendar icon is missing, month & date arrows are missing, date selection and range are missing. This makes the component almost completely unusable for users utilizing High Contrast Mode
After Fix
_Note: the arrow to the left of March 2022 are hidden because it is out of the selection range _
</div> | ||
<div class="${CALENDAR_CELL_CLASS} ${CALENDAR_CELL_CENTER_ITEMS_CLASS}"> | ||
<button | ||
type="button" | ||
class="${CALENDAR_PREVIOUS_MONTH_CLASS}" | ||
aria-label="Navigate back one month" | ||
${prevButtonsDisabled ? `disabled="disabled"` : ""} | ||
> </button> | ||
></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.
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.
Wy was this
here in the first place? Does removing it cause any kind of regression in any other browser?
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've checked Chrome, Edge, and Firefox in both standard and High Contrast modes and have yet to find an error!
0.5, | ||
"auto", | ||
"default" | ||
); |
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.
Footer
Currently, social media icons and expand chevrons (mobile only) disappear in dark high contrast modes, causing the user to lose context and content.
This PR also fixes the disappearing chevrons in the big footer variant in mobile views.
Social Icons
Currently:
(Alternative color shows hover)
Default
High Contrast
After Fix:
Used forced-color-adjust: none
to set the background color for the social link icons to lightgrey. This is easy to see in all high contrast modes and keeps things consistent between versions
Mobile Chevrons
Currently:
After Fix:
|
||
&::after { | ||
position: absolute; | ||
right: 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.
outline: 2px solid buttonText; | ||
color: buttonText; | ||
} | ||
|
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.
Pagination
Before, the current page did not have depictive stylings so users could not easily see which page they are on, versus what is next or previous. This is mostly a problem in the unbounded variant where there are 4 page numbers grouped together.
Default:
Unbounded:
Current w/ high contrast:
Fix w/ high contrast:
|
||
@media (forced-colors: active) { | ||
outline: 2px solid transparent; | ||
} |
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.
|
||
&::before { | ||
@include at-media("mobile-lg") { | ||
content: 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.
USWDS - High Contrast CSS clean up
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.
Nice work!
Tested for regressions first across Chrome, Firefox, and Safari both on mobile and desktop. None found. High contrast styles look good on Edge.
There are slight issues with Firefox, but we expected that with limited support.
This is a masterpiece of PR documentation, thank you. |
USWDS - Windows High Contrast Mode Update
uswds/uswds#4610, released in uswds 2.13.3, made some changes to the implementation of theme colors that caused the nav bar to be rendered incorrectly.
High contrast mode component improvements. Adds high contrast mode specific styling to components to prevent information loss.
Description
In September 2020, Microsoft partnered with the CSS Working Group and the Chromium project, to set new web standards for developers to use to style their content for forced color modes like Windows high contrast. 1
While testing our USWDS components in Windows High Contrast mode, we found that there were important visual queues missing. This caused some components to be challenging to use for users who utilize this important feature. Pairing our
place-icon()
andadd-color-icon()
functions with system color defaults2 we are able to ensure maximum visibility of our components in Windows High Contrast mode or any mode that utilizesforced-color
properties.This PR affects the following:
place-icon()
andadd-color-icon()
mixinsDetails of the changes and results will be broken up by component and listed in the comments below
Before you hit Submit, make sure you’ve done whichever of these applies to you:
npm test
and make sure the tests for the files you have changed have passed.Footnotes
Styling for Windows high contrast with new standards for forced colors ↩
W3.org: System Colors ↩