Skip to content

Commit 6cf57f1

Browse files
authored
Merge branch 'main' into docs-remove-linkbutton
2 parents 9ab7280 + e9bb595 commit 6cf57f1

File tree

9 files changed

+69
-7
lines changed

9 files changed

+69
-7
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
ActionMenu: Fix styles for windows high contrast mode

.changeset/healthy-cooks-draw.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react': patch
3+
---
4+
5+
Ensures select option text has acceptable contrast in Firefox when in dark mode

src/ActionList/Item.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(
161161

162162
'@media (forced-colors: active)': {
163163
':focus': {
164-
// we set color to be transparent and let the high contrast rules
165-
// decide what color with contrast should that be corrected to
164+
// Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips
166165
outline: 'solid 1px transparent !important'
167166
}
168167
},

src/Button/styles.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,12 @@ export const getBaseStyles = (theme?: Theme) => ({
250250
},
251251
'&:disabled svg': {
252252
opacity: '0.6'
253+
},
254+
'@media (forced-colors: active)': {
255+
'&:focus': {
256+
// Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips
257+
outline: 'solid 1px transparent'
258+
}
253259
}
254260
})
255261

src/Overlay.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ const StyledOverlay = styled.div<StyledOverlayProps>`
7878
:focus {
7979
outline: none;
8080
}
81+
82+
@media (forced-colors: active) {
83+
/* Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips */
84+
outline: solid 1px transparent;
85+
}
86+
8187
${sx};
8288
`
8389
type BaseOverlayProps = {

src/Select.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ const StyledSelect = styled.select`
1616
outline: none;
1717
width: 100%;
1818
19+
option {
20+
color: initial;
21+
}
22+
1923
/* colors the select input's placeholder text */
2024
&:invalid {
2125
color: ${get('colors.fg.subtle')};
2226
}
23-
24-
/* For Firefox: reverts color of non-placeholder options in the dropdown */
25-
&:invalid option:not(:first-child) {
26-
color: ${get('colors.fg.default')};
27-
}
2827
`
2928

3029
const ArrowIndicatorSVG: React.FC<{className?: string}> = ({className}) => (

src/__tests__/__snapshots__/ActionMenu.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,12 @@ exports[`ActionMenu renders consistently 1`] = `
104104
margin-right: -4px;
105105
}
106106
107+
@media (forced-colors:active) {
108+
.c1:focus {
109+
outline: solid 1px transparent;
110+
}
111+
}
112+
107113
<div
108114
className="c0"
109115
color="fg.default"

src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ exports[`AnchoredOverlay should render consistently when open 1`] = `
185185
outline: none;
186186
}
187187
188+
@media (forced-colors:active) {
189+
.c2 {
190+
outline: solid 1px transparent;
191+
}
192+
}
193+
188194
<div>
189195
<div
190196
class="c0"

src/__tests__/__snapshots__/Button.test.tsx.snap

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ exports[`Button renders consistently 1`] = `
8888
border-color: rgba(27,31,36,0.15);
8989
}
9090
91+
@media (forced-colors:active) {
92+
.c0:focus {
93+
outline: solid 1px transparent;
94+
}
95+
}
96+
9197
<button
9298
className="c0"
9399
/>
@@ -198,6 +204,12 @@ exports[`Button styles danger button appropriately 1`] = `
198204
border-color: btn.danger.selectedBorder;
199205
}
200206
207+
@media (forced-colors:active) {
208+
.c0:focus {
209+
outline: solid 1px transparent;
210+
}
211+
}
212+
201213
<button
202214
class="c0"
203215
>
@@ -294,6 +306,12 @@ exports[`Button styles invisible button appropriately 1`] = `
294306
background-color: btn.selectedBg;
295307
}
296308
309+
@media (forced-colors:active) {
310+
.c0:focus {
311+
outline: solid 1px transparent;
312+
}
313+
}
314+
297315
<button
298316
class="c0"
299317
>
@@ -411,6 +429,12 @@ exports[`Button styles outline button appropriately 1`] = `
411429
border-color: btn.outline.selectedBorder;
412430
}
413431
432+
@media (forced-colors:active) {
433+
.c0:focus {
434+
outline: solid 1px transparent;
435+
}
436+
}
437+
414438
<button
415439
class="c0"
416440
>
@@ -514,6 +538,12 @@ exports[`Button styles primary button appropriately 1`] = `
514538
box-shadow: undefined;
515539
}
516540
541+
@media (forced-colors:active) {
542+
.c0:focus {
543+
outline: solid 1px transparent;
544+
}
545+
}
546+
517547
<button
518548
class="c0"
519549
>

0 commit comments

Comments
 (0)