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

ActionMenu: Fix styles for windows high contrast mode #1970

Merged
merged 7 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 5 additions & 0 deletions .changeset/actionmenu-fix-high-contrast-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/react': patch
---

ActionMenu: Fix styles for windows high contrast mode
3 changes: 1 addition & 2 deletions src/ActionList/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,7 @@ export const Item = React.forwardRef<HTMLLIElement, ActionListItemProps>(

'@media (forced-colors: active)': {
':focus': {
// we set color to be transparent and let the high contrast rules
// decide what color with contrast should that be corrected to
// Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips
outline: 'solid 1px transparent !important'
}
},
Expand Down
6 changes: 6 additions & 0 deletions src/Button/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ export const getBaseStyles = (theme?: Theme) => ({
},
'&:disabled svg': {
opacity: '0.6'
},
'@media (forced-colors: active)': {
'&:focus': {
// Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips
outline: 'solid 1px transparent'
}
}
})

Expand Down
6 changes: 6 additions & 0 deletions src/Overlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ const StyledOverlay = styled.div<StyledOverlayProps>`
:focus {
outline: none;
}

@media (forced-colors: active) {
/* Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips */
outline: solid 1px transparent;
}

${sx};
`
type BaseOverlayProps = {
Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/__snapshots__/ActionMenu.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ exports[`ActionMenu renders consistently 1`] = `
margin-right: -4px;
}

@media (forced-colors:active) {
.c1:focus {
outline: solid 1px transparent;
}
}

<div
className="c0"
color="fg.default"
Expand Down
6 changes: 6 additions & 0 deletions src/__tests__/__snapshots__/AnchoredOverlay.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,12 @@ exports[`AnchoredOverlay should render consistently when open 1`] = `
outline: none;
}

@media (forced-colors:active) {
.c2 {
outline: solid 1px transparent;
}
}

<div>
<div
class="c0"
Expand Down
30 changes: 30 additions & 0 deletions src/__tests__/__snapshots__/Button.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ exports[`Button renders consistently 1`] = `
border-color: rgba(27,31,36,0.15);
}

@media (forced-colors:active) {
.c0:focus {
outline: solid 1px transparent;
}
}

<button
className="c0"
/>
Expand Down Expand Up @@ -198,6 +204,12 @@ exports[`Button styles danger button appropriately 1`] = `
border-color: btn.danger.selectedBorder;
}

@media (forced-colors:active) {
.c0:focus {
outline: solid 1px transparent;
}
}

<button
class="c0"
>
Expand Down Expand Up @@ -294,6 +306,12 @@ exports[`Button styles invisible button appropriately 1`] = `
background-color: btn.selectedBg;
}

@media (forced-colors:active) {
.c0:focus {
outline: solid 1px transparent;
}
}

<button
class="c0"
>
Expand Down Expand Up @@ -411,6 +429,12 @@ exports[`Button styles outline button appropriately 1`] = `
border-color: btn.outline.selectedBorder;
}

@media (forced-colors:active) {
.c0:focus {
outline: solid 1px transparent;
}
}

<button
class="c0"
>
Expand Down Expand Up @@ -514,6 +538,12 @@ exports[`Button styles primary button appropriately 1`] = `
box-shadow: undefined;
}

@media (forced-colors:active) {
.c0:focus {
outline: solid 1px transparent;
}
}

<button
class="c0"
>
Expand Down