From 48010d41b9d14a5e06be40e15f56dbe18745c388 Mon Sep 17 00:00:00 2001 From: Siddharth Kshetrapal Date: Wed, 16 Mar 2022 17:52:51 +0100 Subject: [PATCH 1/6] add forced-colors styles for Overlay & focused Button --- src/ActionList/Item.tsx | 4 ++-- src/Button/styles.ts | 7 +++++++ src/Overlay.tsx | 7 +++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/ActionList/Item.tsx b/src/ActionList/Item.tsx index 31a74a1ac52..827125a7a57 100644 --- a/src/ActionList/Item.tsx +++ b/src/ActionList/Item.tsx @@ -161,8 +161,8 @@ export const Item = React.forwardRef( '@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' } }, diff --git a/src/Button/styles.ts b/src/Button/styles.ts index a17f6910347..1511d9fcd2c 100644 --- a/src/Button/styles.ts +++ b/src/Button/styles.ts @@ -250,6 +250,13 @@ 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' + } } }) diff --git a/src/Overlay.tsx b/src/Overlay.tsx index 6962a1f6112..c519f8fe98e 100644 --- a/src/Overlay.tsx +++ b/src/Overlay.tsx @@ -78,6 +78,13 @@ const StyledOverlay = styled.div` :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 = { From a769c7c0081407b7ddd663f8ae189593981fbdbd Mon Sep 17 00:00:00 2001 From: Siddharth Kshetrapal Date: Wed, 16 Mar 2022 17:56:13 +0100 Subject: [PATCH 2/6] respect comment style --- src/ActionList/Item.tsx | 3 +-- src/Button/styles.ts | 3 +-- src/Overlay.tsx | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/ActionList/Item.tsx b/src/ActionList/Item.tsx index 827125a7a57..c57eba32b85 100644 --- a/src/ActionList/Item.tsx +++ b/src/ActionList/Item.tsx @@ -161,8 +161,7 @@ export const Item = React.forwardRef( '@media (forced-colors: active)': { ':focus': { - // Support for Windows high contrast - // https://sarahmhigley.com/writing/whcm-quick-tips + // Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips outline: 'solid 1px transparent !important' } }, diff --git a/src/Button/styles.ts b/src/Button/styles.ts index 1511d9fcd2c..a38b80b0b61 100644 --- a/src/Button/styles.ts +++ b/src/Button/styles.ts @@ -253,8 +253,7 @@ export const getBaseStyles = (theme?: Theme) => ({ }, '@media (forced-colors: active)': { '&:focus': { - // Support for Windows high contrast - // https://sarahmhigley.com/writing/whcm-quick-tips + // Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips outline: 'solid 1px transparent' } } diff --git a/src/Overlay.tsx b/src/Overlay.tsx index c519f8fe98e..cc9c721213c 100644 --- a/src/Overlay.tsx +++ b/src/Overlay.tsx @@ -80,8 +80,7 @@ const StyledOverlay = styled.div` } @media (forced-colors: active) { - // Support for Windows high contrast - // https://sarahmhigley.com/writing/whcm-quick-tips + /* Support for Windows high contrast https://sarahmhigley.com/writing/whcm-quick-tips */ outline: solid 1px transparent; } From bb9dfb5d11a3423171d71f3dafdea77060a4701a Mon Sep 17 00:00:00 2001 From: Siddharth Kshetrapal Date: Wed, 16 Mar 2022 17:57:27 +0100 Subject: [PATCH 3/6] add changeset --- .changeset/actionmenu-fix-high-contrast-mode.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/actionmenu-fix-high-contrast-mode.md diff --git a/.changeset/actionmenu-fix-high-contrast-mode.md b/.changeset/actionmenu-fix-high-contrast-mode.md new file mode 100644 index 00000000000..c4d3c5ef3b2 --- /dev/null +++ b/.changeset/actionmenu-fix-high-contrast-mode.md @@ -0,0 +1,5 @@ +--- +'@primer/react': patch +--- + +ActionMenu: Fix styles for windows high contrast mode From 63743cd452f6a4bb70fee64a52b03e797eab555e Mon Sep 17 00:00:00 2001 From: Siddharth Kshetrapal Date: Thu, 17 Mar 2022 14:39:44 +0100 Subject: [PATCH 4/6] update snapshots --- .../__snapshots__/ActionMenu.test.tsx.snap | 6 + .../AnchoredOverlay.test.tsx.snap | 6 + .../__snapshots__/Button.test.tsx.snap | 30 + .../__snapshots__/themePreval.test.ts.snap | 579 +++++++----------- 4 files changed, 265 insertions(+), 356 deletions(-) diff --git a/src/__tests__/__snapshots__/ActionMenu.test.tsx.snap b/src/__tests__/__snapshots__/ActionMenu.test.tsx.snap index b7e6b825d1c..6a1ffc5e47e 100644 --- a/src/__tests__/__snapshots__/ActionMenu.test.tsx.snap +++ b/src/__tests__/__snapshots__/ActionMenu.test.tsx.snap @@ -104,6 +104,12 @@ exports[`ActionMenu renders consistently 1`] = ` margin-right: -4px; } +@media (forced-colors:active) { + .c1:focus { + outline: solid 1px transparent; + } +} +
@@ -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; + } +} +