Skip to content

Commit 8dc3fc9

Browse files
authored
Improvements to various components in Windows High Contrast Mode (#1111)
* high contrast mode improvements to various components * add changeset * highlight active ActionMenu item * update changeset * update changeset * tweaked VideoPlayer focus styles
1 parent 69398e7 commit 8dc3fc9

File tree

10 files changed

+158
-4
lines changed

10 files changed

+158
-4
lines changed

.changeset/chilly-yaks-unite.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@primer/react-brand': patch
3+
---
4+
5+
Improvements to the styling of various components when viewed in Windows High Contrast Mode.
6+
7+
- `FAQGroup`: Improved appearance for the selected tab
8+
- `Pagination`: Improved appearance for the current page item
9+
- `VideoPlayer`: Improved legibility for all text and controls
10+
- `Checkbox`: Improved focus and checked appearance
11+
- `Radio`: Improved focus and checked appearance
12+
- `TextInput`: Improved focus appearance
13+
- `Textarea`: Improved focus appearance
14+
- `ActionMenu`: Improved focus appearance

packages/react/src/ActionMenu/ActionMenu.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,13 @@
276276
fill: var(--base-color-scale-gray-3);
277277
}
278278

279+
@media (forced-colors: active) {
280+
.ActionMenu__item:focus-visible {
281+
outline: var(--brand-borderWidth-thick) solid Highlight;
282+
outline-offset: var(--base-size-2);
283+
}
284+
}
285+
279286
/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
280287
@media (prefers-reduced-motion: reduce) {
281288
.ActionMenu,

packages/react/src/FAQ/FAQGroup.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,11 @@
5050
font-size: var(--brand-text-size-200);
5151
line-height: var(--brand-text-lineHeight-200);
5252
}
53+
54+
@media (forced-colors: active) {
55+
.FAQGroup__tablist-button[aria-selected='true'] {
56+
border-color: Highlight;
57+
border-width: var(--brand-borderWidth-thicker);
58+
color: HighlightText;
59+
}
60+
}

packages/react/src/Pagination/Pagination.module.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,14 @@
115115
}
116116
}
117117

118+
@media (forced-colors: active) {
119+
.Pagination__item[aria-current],
120+
.Pagination__item[aria-current]:hover {
121+
border-color: Highlight;
122+
border-width: var(--brand-borderWidth-thicker);
123+
}
124+
}
125+
118126
/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
119127
@media (prefers-reduced-motion: reduce) {
120128
.Pagination,

packages/react/src/VideoPlayer/VideoPlayer.module.css

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
height: 100%;
3232
}
3333

34+
@media (forced-colors: active) {
35+
.VideoPlayer__container {
36+
border: var(--brand-borderWidth-thin) solid ButtonBorder;
37+
}
38+
}
39+
3440
/* ---------------------------------------------------------- */
3541
/* 2. Player */
3642
/* ---------------------------------------------------------- */
@@ -87,6 +93,13 @@
8793
color: var(--brand-videoPlayer-playButton-fgColor-rest);
8894
}
8995

96+
@media (forced-colors: active) {
97+
.VideoPlayer__playButton {
98+
color: Highlight;
99+
opacity: 1;
100+
}
101+
}
102+
90103
/* ---------------------------------------------------------- */
91104
/* 4. Title */
92105
/* ---------------------------------------------------------- */
@@ -114,6 +127,13 @@
114127
visibility: hidden;
115128
}
116129

130+
@media (forced-colors: active) {
131+
.VideoPlayer__title {
132+
background: Canvas;
133+
color: CanvasText;
134+
}
135+
}
136+
117137
/* ---------------------------------------------------------- */
118138
/* 5. Controls */
119139
/* ---------------------------------------------------------- */
@@ -173,12 +193,15 @@
173193
}
174194

175195
.VideoPlayer__iconControl:focus-visible {
176-
border-color: var(--brand-color-focus);
177-
outline: none;
178-
box-shadow: 0 0 0 0.125rem var(--brand-color-focus);
196+
outline: var(--brand-borderWidth-thick) solid var(--brand-color-focus);
197+
outline-offset: var(--base-size-6);
179198
opacity: 1;
180199
}
181200

201+
.VideoPlayer__iconControl:not(.VideoPlayer__closedCaption):focus-visible {
202+
border-radius: var(--brand-borderRadius-small);
203+
}
204+
182205
.VideoPlayer__iconControl svg {
183206
color: var(--brand-videoPlayer-controls-fgColor);
184207
}
@@ -224,6 +247,30 @@
224247
color: var(--brand-videoPlayer-closedCaption-fgColor-disabled);
225248
}
226249

250+
@media (forced-colors: active) {
251+
.VideoPlayer__iconControl svg {
252+
color: ButtonText;
253+
}
254+
255+
.VideoPlayer__iconControl:focus-visible {
256+
outline-color: Highlight;
257+
}
258+
259+
.VideoPlayer__closedCaption:focus-visible {
260+
outline: none;
261+
}
262+
263+
.VideoPlayer__closedCaption:not(.VideoPlayer__ccOff) {
264+
background: Highlight;
265+
border-color: Highlight;
266+
}
267+
268+
.VideoPlayer__closedCaption:not(.VideoPlayer__ccOff) .VideoPlayer__ccText {
269+
background-color: Highlight;
270+
color: HighlightText;
271+
}
272+
}
273+
227274
/* ---------------------------------------------------------- */
228275
/* 6. Range Element */
229276
/* ---------------------------------------------------------- */
@@ -254,7 +301,8 @@
254301

255302
.VideoPlayer__rangeInput:focus-visible {
256303
outline: var(--brand-borderWidth-thick) solid var(--brand-color-focus);
257-
outline-offset: var(--base-size-4);
304+
outline-offset: var(--base-size-8);
305+
border-radius: var(--brand-borderRadius-small);
258306
opacity: 1;
259307
}
260308

@@ -303,6 +351,28 @@
303351
border: none;
304352
}
305353

354+
@media (forced-colors: active) {
355+
.VideoPlayer__rangeProgress::-webkit-progress-bar {
356+
background-color: FieldText;
357+
}
358+
359+
.VideoPlayer__rangeProgress::-webkit-progress-value {
360+
background-color: Highlight;
361+
}
362+
363+
.VideoPlayer__rangeProgress::-moz-progress-bar {
364+
background: Highlight;
365+
}
366+
367+
.VideoPlayer__rangeProgress::-ms-fill-lower {
368+
background-color: Highlight;
369+
}
370+
371+
.VideoPlayer__rangeProgress::-ms-fill-upper {
372+
background-color: FieldText;
373+
}
374+
}
375+
306376
/* ---------------------------------------------------------- */
307377
/* 7. Tooltip */
308378
/* ---------------------------------------------------------- */

packages/react/src/forms/Checkbox/Checkbox.module.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@
8787
opacity: 1;
8888
}
8989

90+
@media (forced-colors: active) {
91+
.Checkbox-input:focus + .Checkbox {
92+
outline: var(--brand-borderWidth-thick) solid Highlight;
93+
outline-offset: var(--base-size-2);
94+
}
95+
96+
.Checkbox-input:checked + .Checkbox .Checkbox-checkmark-path {
97+
stroke: Highlight;
98+
}
99+
100+
.Checkbox {
101+
transition: none;
102+
}
103+
}
104+
90105
/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
91106
@media (prefers-reduced-motion: reduce) {
92107
.Checkbox,

packages/react/src/forms/Radio/Radio.module.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,17 @@ Fixes safari bug where outline doesn't respect border-radius
111111
opacity: 1;
112112
}
113113

114+
@media (forced-colors: active) {
115+
.Radio-input:focus + .Radio {
116+
outline: var(--brand-borderWidth-thick) solid Highlight;
117+
outline-offset: var(--base-size-4);
118+
}
119+
120+
.Radio-input:checked + .Radio .Radio-dot {
121+
background-color: Highlight;
122+
}
123+
}
124+
114125
/* Remove all animations, transitions and smooth scroll for people that prefer not to see them */
115126
@media (prefers-reduced-motion: reduce) {
116127
.Radio,

packages/react/src/forms/Select/Select.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
box-shadow: 0 0 0 2px var(--brand-color-focus);
3535
}
3636

37+
@media (forced-colors: active) {
38+
.Select:focus-visible {
39+
outline: var(--brand-borderWidth-thick) solid Highlight;
40+
outline-offset: var(--base-size-2);
41+
}
42+
}
43+
3744
.Select[disabled] {
3845
-webkit-text-fill-color: var(--brand-control-color-fg-disabled);
3946
color: var(--brand-control-color-fg-disabled);

packages/react/src/forms/TextInput/TextInput.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@
101101
outline: none;
102102
}
103103

104+
@media (forced-colors: active) {
105+
.TextInput-wrapper:focus-within {
106+
outline: var(--brand-borderWidth-thick) solid Highlight;
107+
outline-offset: var(--base-size-2);
108+
}
109+
}
110+
104111
/*
105112
* Validation
106113
*/

packages/react/src/forms/Textarea/Textarea.module.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@
108108
outline: none;
109109
}
110110

111+
@media (forced-colors: active) {
112+
.Textarea-wrapper:focus-within {
113+
outline: var(--brand-borderWidth-thick) solid Highlight;
114+
outline-offset: var(--base-size-2);
115+
}
116+
}
117+
111118
/*
112119
* Validation
113120
*/

0 commit comments

Comments
 (0)