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

Update focus outline color to meet WCAG 2.2 contrast standards #6854

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

evansjohnson
Copy link
Contributor

@evansjohnson evansjohnson commented Jun 18, 2024

Fixes no issue

Checklist

  • [n/a] Includes tests
  • [n/a] Update documentation

Changes proposed in this pull request:

Update color of focus outline to meet 3:1 contrast standard for UI component focus states

https://webaim.org/resources/contrastchecker/

Reviewers should focus on:

  • Our default focus indicator won't meet contrast standards for all background colors - but should we provide any buffer so that the default focus indicator meets standards up to a certain shade of background color? I currently went with an option that meets contrast standards against all light-gray colors in light theme, and all dark-gray colors when in dark theme
  • Should be good in light and dark themes

WCAG Guidelines

From what I can tell, WCAG did not require minimum contrast in 2.1, but in 2.2 has a section on focus appearance which specifies the 3:1 minimum ratio

Screenshot

Current:
Screenshot 2024-06-21 at 8 28 04 AM
Screenshot 2024-06-21 at 8 27 54 AM

This PR:
TODO

@changelog-app
Copy link

changelog-app bot commented Jun 18, 2024

Generate changelog in packages/core/changelog/@unreleased

What do the change types mean?
  • feature: A new feature of the service.
  • improvement: An incremental improvement in the functionality or operation of the service.
  • fix: Remedies the incorrect behaviour of a component of the service in a backwards-compatible way.
  • break: Has the potential to break consumers of this service's API, inclusive of both Palantir services
    and external consumers of the service's API (e.g. customer-written software or integrations).
  • deprecation: Advertises the intention to remove service functionality without any change to the
    operation of the service itself.
  • manualTask: Requires the possibility of manual intervention (running a script, eyeballing configuration,
    performing database surgery, ...) at the time of upgrade for it to succeed.
  • migration: A fully automatic upgrade migration task with no engineer input required.

Note: only one type should be chosen.

How are new versions calculated?
  • ❗The break and manual task changelog types will result in a major release!
  • 🐛 The fix changelog type will result in a minor release in most cases, and a patch release version for patch branches. This behaviour is configurable in autorelease.
  • ✨ All others will result in a minor version release.

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

[WIP] Update focus outline color to meet contrast standards

Check the box to generate changelog(s)

  • Generate changelog entry

@svc-palantir-github

This comment was marked as outdated.

Copy link
Contributor Author

@evansjohnson evansjohnson left a comment

Choose a reason for hiding this comment

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

this feels like a borderline breaking change, since it has the potential to make UI snapshots fail. I don't think it could cause some cases to have worse contrast because the current focus color already does not have enough contrast with the extremes of the color spectrum

packages/core/src/components/forms/_common.scss Outdated Show resolved Hide resolved
packages/core/src/components/forms/_controls.scss Outdated Show resolved Hide resolved
@evansjohnson evansjohnson changed the title [WIP] Update focus outline color to meet contrast standards Update focus outline color to meet WCAG 2.2 contrast standards Jun 21, 2024
@svc-palantir-github

This comment was marked as outdated.

@svc-palantir-github

This comment was marked as outdated.

@evansjohnson

This comment was marked as duplicate.

@svc-palantir-github

This comment was marked as outdated.

packages/core/src/common/_color-aliases.scss Outdated Show resolved Hide resolved
Comment on lines 95 to 104
// this should become default in bp6, providing new behavior as a class for now to avoid breaking changes
// to focus colors
/* stylelint-disable-next-line @blueprintjs/no-prefix-literal */
.bp5-focus-enhanced-contrast & {
outline: $pt-focus-indicator-color solid 2px;
}
/* stylelint-disable-next-line @blueprintjs/no-prefix-literal */
.#{$ns}-dark.bp5-focus-enhanced-contrast & {
outline-color: $pt-dark-focus-indicator-color;
}
Copy link
Member

Choose a reason for hiding this comment

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

I think we should just do it. I wouldn't call this a breaking change. If we do introduce this class, you should use #{$ns} instead of bp5, which is what this lint rule is trying to tell you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay cool, I wasn't sure the history of how careful we've been with minor things like this that could be viewed as a break.

Ack on the prefix - I hard coded bp5 since this was only intended to work for the bp5 version and removed in bp6, but will just remove this.

packages/core/src/docs/accessibility.md Outdated Show resolved Hide resolved
@svc-palantir-github

This comment was marked as outdated.

Copy link
Contributor Author

@evansjohnson evansjohnson left a comment

Choose a reason for hiding this comment

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

TODO:

Comment on lines 95 to 104
// this should become default in bp6, providing new behavior as a class for now to avoid breaking changes
// to focus colors
/* stylelint-disable-next-line @blueprintjs/no-prefix-literal */
.bp5-focus-enhanced-contrast & {
outline: $pt-focus-indicator-color solid 2px;
}
/* stylelint-disable-next-line @blueprintjs/no-prefix-literal */
.#{$ns}-dark.bp5-focus-enhanced-contrast & {
outline-color: $pt-dark-focus-indicator-color;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay cool, I wasn't sure the history of how careful we've been with minor things like this that could be viewed as a break.

Ack on the prefix - I hard coded bp5 since this was only intended to work for the bp5 version and removed in bp6, but will just remove this.

packages/core/src/docs/accessibility.md Outdated Show resolved Hide resolved
packages/core/src/common/_color-aliases.scss Outdated Show resolved Hide resolved
@@ -25,6 +25,10 @@ $pt-app-elevated-background-color: $light-gray4 !default;
$pt-dark-app-elevated-background-color: $dark-gray3 !default;

$pt-outline-color: rgba($blue3, 0.6) !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.

Not changing this color because of the comment at the top of this file stating that is generally considered a breaking change. Perhaps we want to make an exception here...

@svc-palantir-github
Copy link

comment

Build artifact links for this commit: documentation | landing | table | demo

This is an automated comment from the deploy-preview CircleCI job.

@@ -25,6 +25,11 @@ $pt-app-elevated-background-color: $light-gray4 !default;
$pt-dark-app-elevated-background-color: $dark-gray3 !default;

$pt-outline-color: rgba($blue3, 0.6) !default;
// 0.752 opacity to meet WCCAG 2.2 minimum contrast guidelines with all light-gray backgrounds in light theme
// and all dark-gray backgrounds in dark theme
$pt-focus-indicator-color: rgba($blue2, 0.752) !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.

$blue2 on $white - 3.77:1 contrast
$blue2 on $light-gray1 - 3:1 contrast

// and all dark-gray backgrounds in dark theme
$pt-focus-indicator-color: rgba($blue2, 0.752) !default;
// dark theme opacity could be less and still meet minimum contrast, but keep 0.752 to stay consistent
$pt-dark-focus-indicator-color: rgba($blue5, 0.752) !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.

$blue5 on $black - 5.77:1 contrast
$blue5 on $dark-gray5 - 3.39:1 contrast


for comparison - $blue4 on $dark-gray5 - 2.24:1 contrast

@@ -15,14 +15,14 @@ $input-color-disabled: $button-color-disabled !default;
$input-placeholder-color: $pt-text-color-muted !default;
$input-background-color: $white !default;
$input-background-color-disabled: rgba($light-gray1, 0.5) !default;
$input-shadow-color-focus: $pt-intent-primary !default;
$input-shadow-color-focus: $pt-focus-indicator-color;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if this can't be relied on externally - remove and use $pt-focus-indicator-color directly in the handful of places it's used. Same for dark theme version below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants