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

a11y high contrast mode and focus state bug fixes for web components #28717

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7f9af9e
radio init
brianchristopherbrady Mar 3, 2023
70c55e0
styles radio
brianchristopherbrady Mar 3, 2023
f3cb7f4
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Mar 3, 2023
a72d10f
reverts branch
brianchristopherbrady Mar 3, 2023
2941fa7
Merge branch 'web-components-v3' of https://github.com/brianchristoph…
brianchristopherbrady Mar 3, 2023
9b350fc
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Mar 20, 2023
2cf59ce
input spec init
brianchristopherbrady Mar 20, 2023
79b6bff
cleans up spec
brianchristopherbrady Mar 20, 2023
5558b93
formatting
brianchristopherbrady Mar 20, 2023
3c045c3
updates component name to text input
brianchristopherbrady Mar 20, 2023
2370967
updates component name in spec
brianchristopherbrady Mar 20, 2023
9c4eb6b
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Mar 27, 2023
056b82e
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Apr 24, 2023
196ed30
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady May 9, 2023
2a9ae23
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady May 22, 2023
677a59c
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Jun 6, 2023
17819f9
Merge branch 'microsoft:web-components-v3' into web-components-v3
brianchristopherbrady Jun 28, 2023
dfe1311
high contrast mode color fixes
brianchristopherbrady Aug 3, 2023
dd472a4
removes file
brianchristopherbrady Aug 3, 2023
d1b6af5
yarn change
brianchristopherbrady Aug 3, 2023
658f7f8
Merge branch 'web-components-v3' into user/brianbrady/a11yHighContras…
brianchristopherbrady Aug 3, 2023
4af2957
high contrast visual fixes
brianchristopherbrady Aug 3, 2023
3d50372
high contrast a11y fixes: optimizes high contrast styles using forced…
brianchristopherbrady Aug 7, 2023
d6ffb3a
Merge branch 'user/brianbrady/a11yHighContrastFixes' of https://githu…
brianchristopherbrady Aug 7, 2023
7bc3824
hc a11y: addresses feedback
brianchristopherbrady Aug 7, 2023
27a2c1e
hc a11y: removes dead code
brianchristopherbrady Aug 7, 2023
d9cf80e
hc a11y: fixes radio colors
brianchristopherbrady Aug 7, 2023
48220af
hc a11y: fixes switch, togglebutton styles
brianchristopherbrady Aug 7, 2023
26f8be1
hc a11y: combines css selectors
brianchristopherbrady Aug 7, 2023
44082c1
Merge branch 'web-components-v3' into user/brianbrady/a11yHighContras…
chrisdholt Aug 7, 2023
b9d268d
hc a11y: updates button styles
brianchristopherbrady Aug 7, 2023
2fb2cfa
hc a11y: updates toggle button styles
brianchristopherbrady Aug 7, 2023
22323ce
hc a11y: fixes button styles
brianchristopherbrady Aug 7, 2023
1533572
Merge branch 'user/brianbrady/a11yHighContrastFixes' of https://githu…
brianchristopherbrady Aug 7, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
Copy link
Collaborator

@fabricteam fabricteam Aug 7, 2023

Choose a reason for hiding this comment

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

🕵 fluentui-web-components-v3 Open the Visual Regressions report to inspect the affected screenshots

Accordion 9 screenshots
Image Name Diff(in Pixels) Image Type
Accordion.Expand Icon Position End - Dark Mode.normal.chromium.png 33 Changed
Accordion.Expand Icon Position End.normal.chromium.png 5 Changed
Accordion.Disabled - RTL.normal.chromium.png 3 Changed
Accordion.Expand Icon Position End - RTL.normal.chromium.png 5 Changed
Accordion.Disabled - Dark Mode.normal.chromium.png 19 Changed
Accordion.Disabled.normal.chromium.png 3 Changed
Accordion.Size - RTL.normal.chromium.png 11 Changed
Accordion.Size.normal.chromium.png 11 Changed
Accordion.Size - Dark Mode.normal.chromium.png 66 Changed

"type": "prerelease",
"comment": "(accessibility): high contrast fixes",
"packageName": "@fluentui/web-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const chevronRight20Filled = html.partial(`<svg
>
<path
d="M7.73271 4.20694C8.03263 3.92125 8.50737 3.93279 8.79306 4.23271L13.7944 9.48318C14.0703 9.77285 14.0703 10.2281 13.7944 10.5178L8.79306 15.7682C8.50737 16.0681 8.03263 16.0797 7.73271 15.794C7.43279 15.5083 7.42125 15.0336 7.70694 14.7336L12.2155 10.0005L7.70694 5.26729C7.42125 4.96737 7.43279 4.49264 7.73271 4.20694Z"
fill="#212121"
fill="currentColor"
/>
</svg>`);

Expand All @@ -26,7 +26,7 @@ const chevronDown20Filled = html.partial(`<svg
>
<path
d="M15.794 7.73271C16.0797 8.03263 16.0681 8.50737 15.7682 8.79306L10.5178 13.7944C10.2281 14.0703 9.77285 14.0703 9.48318 13.7944L4.23271 8.79306C3.93279 8.50737 3.92125 8.03263 4.20694 7.73271C4.49264 7.43279 4.96737 7.42125 5.26729 7.70694L10.0005 12.2155L14.7336 7.70694C15.0336 7.42125 15.5083 7.43279 15.794 7.73271Z"
fill="#212121"
fill="currentColor"
/>
</svg>`);

Expand Down
8 changes: 4 additions & 4 deletions packages/web-components/src/accordion/accordion.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type AccordionStoryMeta = Meta<AccordionStoryArgs>;
const add20Filled = html`<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M10.5 2.75C10.5 2.33579 10.1642 2 9.75 2C9.33579 2 9 2.33579 9 2.75V9H2.75C2.33579 9 2 9.33579 2 9.75C2 10.1642 2.33579 10.5 2.75 10.5H9V16.75C9 17.1642 9.33579 17.5 9.75 17.5C10.1642 17.5 10.5 17.1642 10.5 16.75V10.5H16.75C17.1642 10.5 17.5 10.1642 17.5 9.75C17.5 9.33579 17.1642 9 16.75 9H10.5V2.75Z"
fill="#212121"
fill="currentColor"
/>
</svg>`;
const subtract20Filled = html`<svg
Expand All @@ -22,7 +22,7 @@ const subtract20Filled = html`<svg
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<rect x="3" y="9.25" width="14" height="1.5" rx="0.75" fill="#212121" />
<rect x="3" y="9.25" width="14" height="1.5" rx="0.75" fill="currentColor" />
</svg>`;

const eye20Regular = html`<svg
Expand All @@ -34,7 +34,7 @@ const eye20Regular = html`<svg
>
<path
d="M3.25909 11.6021C3.94254 8.32689 6.79437 6 10 6C13.2057 6 16.0574 8.32688 16.7409 11.6021C16.7974 11.8725 17.0622 12.0459 17.3325 11.9895C17.6029 11.933 17.7763 11.6682 17.7199 11.3979C16.9425 7.67312 13.6934 5 10 5C6.3066 5 3.05742 7.67311 2.28017 11.3979C2.22377 11.6682 2.39718 11.933 2.6675 11.9895C2.93782 12.0459 3.20268 11.8725 3.25909 11.6021ZM10 8C8.067 8 6.5 9.567 6.5 11.5C6.5 13.433 8.067 15 10 15C11.933 15 13.5 13.433 13.5 11.5C13.5 9.567 11.933 8 10 8ZM7.5 11.5C7.5 10.1193 8.61929 9 10 9C11.3807 9 12.5 10.1193 12.5 11.5C12.5 12.8807 11.3807 14 10 14C8.61929 14 7.5 12.8807 7.5 11.5Z"
fill="#212121"
fill="currentColor"
/>
</svg>`;
const eyeOff20Regular = html`<svg
Expand All @@ -46,7 +46,7 @@ const eyeOff20Regular = html`<svg
>
<path
d="M2.85355 2.14645C2.65829 1.95118 2.34171 1.95118 2.14645 2.14645C1.95118 2.34171 1.95118 2.65829 2.14645 2.85355L5.6453 6.35239C3.97044 7.49179 2.7234 9.27384 2.28017 11.3979C2.22377 11.6682 2.39718 11.9331 2.6675 11.9895C2.93782 12.0459 3.20268 11.8725 3.25909 11.6021C3.6629 9.66699 4.82367 8.06291 6.36714 7.07422L7.95336 8.66045C7.07297 9.29611 6.5 10.3311 6.5 11.5C6.5 13.433 8.067 15 10 15C11.1689 15 12.2039 14.427 12.8396 13.5466L17.1464 17.8536C17.3417 18.0488 17.6583 18.0488 17.8536 17.8536C18.0488 17.6583 18.0488 17.3417 17.8536 17.1464L2.85355 2.14645ZM12.1194 12.8265C11.6773 13.5314 10.8934 14 10 14C8.61929 14 7.5 12.8807 7.5 11.5C7.5 10.6066 7.96863 9.82265 8.67348 9.38057L12.1194 12.8265ZM10.1235 8.00214L13.4979 11.3765C13.4342 9.54169 11.9583 8.06576 10.1235 8.00214ZM10 6C9.43016 6 8.87149 6.07353 8.33419 6.21285L7.53113 5.40979C8.31349 5.14331 9.14485 5 10 5C13.6934 5 16.9425 7.67312 17.7199 11.3979C17.7763 11.6682 17.6029 11.933 17.3325 11.9895C17.0622 12.0459 16.7974 11.8725 16.7409 11.6021C16.0574 8.32688 13.2057 6 10 6Z"
fill="#212121"
fill="currentColor"
/>
</svg>`;

Expand Down
10 changes: 8 additions & 2 deletions packages/web-components/src/button/button.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { display, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import {
borderRadiusCircular,
borderRadiusLarge,
Expand Down Expand Up @@ -308,4 +308,10 @@ export const styles = css`
color: ${colorNeutralForegroundDisabled};
cursor: not-allowed;
}
`;
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
:host([appearance='transparent']:hover) .control {
Copy link
Member

Choose a reason for hiding this comment

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

@brianchristopherbrady what is the reason we need both of these? :host(:hover) .control also applies to transparent, does it not?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:host(:hover) .control this was not applying the style to transparent. But after a 2nd look it seems it wasn't applying styles to any of the variations and isn't needed. But the :host([appearance='transparent']:hover) .control selector is still necessary for the transparent variation.

border-color: Highlight;
}
`),
);
18 changes: 16 additions & 2 deletions packages/web-components/src/divider/divider.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { display, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import {
colorBrandForeground1,
colorBrandStroke1,
Expand Down Expand Up @@ -125,4 +125,18 @@ export const styles = css`
:host([appearance='subtle']) ::slotted(*) {
color: ${colorNeutralForeground3};
}
`;
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
:host([appearance='strong'])::before,
:host([appearance='strong'])::after,
:host([appearance='brand'])::before,
:host([appearance='brand'])::after,
:host([appearance='subtle'])::before,
:host([appearance='subtle'])::after,
:host::after,
:host::before {
background: WindowText;
color: WindowText;
}
`),
);
22 changes: 20 additions & 2 deletions packages/web-components/src/progress-bar/progress-bar.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { display, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import {
borderRadiusMedium,
colorBrandBackground2,
Expand Down Expand Up @@ -165,4 +165,22 @@ export const styles = css`
opacity: 1;
}
}
`;
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
.progress {
background-color: HighlightText;
}
.determinate,
:host([validation-state='success']) .determinate,
:host([validation-state='warning']) .determinate,
:host([validation-state='error']) .determinate,
:host([validation-state='success']) ..indeterminate-indicator-1,
:host([validation-state='success']) ..indeterminate-indicator-2,
:host([validation-state='warning']) .indeterminate-indicator-1,
:host([validation-state='warning']) .indeterminate-indicator-2,
:host([validation-state='error']) .indeterminate-indicator-1,
:host([validation-state='error']) .indeterminate-indicator-2 {
background-color: Highlight;
}
`),
);
16 changes: 14 additions & 2 deletions packages/web-components/src/radio/radio.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { display, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import {
borderRadiusCircular,
borderRadiusSmall,
Expand Down Expand Up @@ -127,4 +127,16 @@ export const styles = css`
:host([disabled]) .checked-indicator {
background: ${colorNeutralForegroundDisabled};
}
`;
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
:host .control {
border-color: InactiveBorder;
}
:host([aria-checked='true']) .checked-indicator,
:host([aria-checked='true']:active) .checked-indicator,
:host([aria-checked='true']:hover) .checked-indicator {
background-color: Highlight;
border-color: ActiveBorder;
}
Copy link
Member

Choose a reason for hiding this comment

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

Another instance where it's odd for active border to be on the non checked.

`),
);
23 changes: 21 additions & 2 deletions packages/web-components/src/slider/slider.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { display, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import {
borderRadiusCircular,
borderRadiusMedium,
Expand Down Expand Up @@ -199,4 +199,23 @@ export const styles = css`
width: 100%;
bottom: 0;
}
`;
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
.track:hover,
.track:active,
.track {
background: WindowText;
}
.thumb-cursor:hover,
.thumb-cursor:active,
.thumb-cursor {
background: ButtonText;
}

:host(:hover) .track-start,
.track-start:active,
.track-start {
background: Highlight;
}
`),
);
36 changes: 34 additions & 2 deletions packages/web-components/src/switch/switch.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { display, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import {
borderRadiusCircular,
colorCompoundBrandBackground,
Expand All @@ -18,18 +18,22 @@ import {
colorNeutralStrokeAccessibleHover,
colorNeutralStrokeAccessiblePressed,
colorNeutralStrokeDisabled,
colorStrokeFocus2,
colorTransparentBackground,
colorTransparentStroke,
curveEasyEase,
durationNormal,
fontFamilyBase,
fontSizeBase300,
fontWeightRegular,
lineHeightBase300,
shadow4,
spacingHorizontalS,
spacingHorizontalXS,
spacingHorizontalXXS,
spacingVerticalS,
spacingVerticalXS,
strokeWidthThick,
} from '../theme/design-tokens.js';

export const styles = css`
Expand Down Expand Up @@ -142,4 +146,32 @@ export const styles = css`
:host([aria-checked='true'][disabled]) .checked-indicator {
background: ${colorNeutralForegroundDisabled};
}
`;

:host(:focus-visible) {
border-color: ${colorTransparentStroke};
outline: ${strokeWidthThick} solid ${colorTransparentStroke};
box-shadow: ${shadow4}, 0 0 0 2px ${colorStrokeFocus2};
}
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
.switch {
border-color: InactiveBorder;
}
:host([aria-checked='true']) .switch,
:host([aria-checked='true']:active) .switch,
:host([aria-checked='true']:hover) .switch {
background: Highlight;
border-color: Highlight;
}
.checked-indicator,
:host(:hover) .checked-indicator,
:host(:active) .checked-indicator {
background-color: ActiveCaption;
}
Copy link
Member

Choose a reason for hiding this comment

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

Likewise can these also be a single selector? Let's look for duplication like this elsewhere and fix as well please :)

:host([aria-checked='true']) .checked-indicator,
:host([aria-checked='true']:hover) .checked-indicator,
:host([aria-checked='true']:active) .checked-indicator {
background-color: ButtonFace;
}
`),
);
10 changes: 8 additions & 2 deletions packages/web-components/src/tab/tab.styles.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { css } from '@microsoft/fast-element';
import { display } from '@microsoft/fast-foundation';
import { display, forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import {
borderRadiusCircular,
borderRadiusMedium,
Expand Down Expand Up @@ -108,4 +108,10 @@ export const styles = css`
box-shadow: 0 0 0 3px ${colorStrokeFocus2};
outline: 1px solid ${colorStrokeFocus1};
}
`;
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
:host([aria-selected='true'])::after {
background-color: Highlight;
}
`),
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { css } from '@microsoft/fast-element';
import { forcedColorsStylesheetBehavior } from '@microsoft/fast-foundation';
import { styles as ButtonStyles } from '../button/button.styles.js';
import {
colorBrandBackgroundHover,
Expand Down Expand Up @@ -105,4 +106,16 @@ export const styles = css`
:host([aria-pressed='true'][appearance='transparent']:active) .control {
color: ${colorNeutralForeground2BrandPressed};
}
`;
`.withBehaviors(
forcedColorsStylesheetBehavior(css`
:host([aria-pressed='true']) .control,
:host([aria-pressed='true'][appearance='primary']) .control,
:host([aria-pressed='true'][appearance='subtle']) .control,
:host([aria-pressed='true'][appearance='outline']) .control,
:host([aria-pressed='true'][appearance='transparent']) .control,
:host([aria-pressed='true'][appearance='transparent']) .control {
background: SelectedItem;
color: SelectedItemText;
}
Copy link
Member

Choose a reason for hiding this comment

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

Combine with the first block which shares the same styles

`),
);