StackExchange / Stacks

Stack Overflow’s Design System
https://stackoverflow.design
MIT License
607 stars 89 forks source link

fix(btn): improve focus style to meet WCAG 2.2 AA #1613

Closed dancormier closed 7 months ago

dancormier commented 7 months ago

Note The PR supersedes #1610 and all commits here are cherry-picked from that PR with the exception of the visual regression image generation. @CGuindon and @giamir I added you as reviewers for visibility.

Addresses STACKS-537, partially addresses A11Y-2.


This PR updates the focus styles for the button component to meet the WCAG AA requirements.

Technical notes

You'll notice that this PR achieves the focus style mainly with box-shadow:

   box-shadow: inset 0 0 0 var(--su-static2) var(--theme-secondary-400), inset 0 0 0 var(--su-static4) var(--black-050);
    …
   outline: var(--su-static2) solid transparent;

This is because box-shadow tends to align more consistently. Additionally, a transparent outline is used to ensure that an outline doesn't render when expected but can still be rendered in forced-color modes (see https://blogs.windows.com/msedgedev/2020/09/17/styling-for-windows-high-contrast-with-new-standards-for-forced-colors/#gist105426765).

netlify[bot] commented 7 months ago

Deploy Preview for stacks ready!

Name Link
Latest commit 6fc624b5538069ecdebd8dded579da7723cd79e3
Latest deploy log https://app.netlify.com/sites/stacks/deploys/65b2dd60031af30008fd40b7
Deploy Preview https://deploy-preview-1613--stacks.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.