From 3b23604438b850557e7e3d0a0594a8cca119859b Mon Sep 17 00:00:00 2001 From: Siddharth Kshetrapal Date: Thu, 17 Mar 2022 16:55:39 +0100 Subject: [PATCH 1/9] ActionMenu: Fix styles for windows high contrast mode (#1970) * add forced-colors styles for Overlay & focused Button * respect comment style * add changeset * update snapshots * Revert "update snapshots" This reverts commit 63743cd452f6a4bb70fee64a52b03e797eab555e. * only update relevant snapshots --- .../actionmenu-fix-high-contrast-mode.md | 5 ++++ src/ActionList/Item.tsx | 3 +- src/Button/styles.ts | 6 ++++ src/Overlay.tsx | 6 ++++ .../__snapshots__/ActionMenu.test.tsx.snap | 6 ++++ .../AnchoredOverlay.test.tsx.snap | 6 ++++ .../__snapshots__/Button.test.tsx.snap | 30 +++++++++++++++++++ 7 files changed, 60 insertions(+), 2 deletions(-) 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 diff --git a/src/ActionList/Item.tsx b/src/ActionList/Item.tsx index 31a74a1ac52..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': { - // 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..a38b80b0b61 100644 --- a/src/Button/styles.ts +++ b/src/Button/styles.ts @@ -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' + } } }) diff --git a/src/Overlay.tsx b/src/Overlay.tsx index 6962a1f6112..cc9c721213c 100644 --- a/src/Overlay.tsx +++ b/src/Overlay.tsx @@ -78,6 +78,12 @@ 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 = { 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; + } +} + + + +

No visual

+ + + + + + + + + + +

Leading visual

+ + + + + + + + + + +

Trailing visual

+ + + + + + + + + + +

Both visuals

+ + + + + + + + + + + ) +} + +WithLoadingIndicator.parameters = {controls: {exclude: ['loading']}} + export const ContrastTextInput = (args: TextInputProps) => { const [value, setValue] = useState('') diff --git a/src/stories/TextInputWithTokens.stories.tsx b/src/stories/TextInputWithTokens.stories.tsx index b02db775a99..084d3179f90 100644 --- a/src/stories/TextInputWithTokens.stories.tsx +++ b/src/stories/TextInputWithTokens.stories.tsx @@ -2,7 +2,7 @@ import React, {useCallback, useState} from 'react' import {Meta} from '@storybook/react' import {CheckIcon, NumberIcon} from '@primer/octicons-react' -import {BaseStyles, Box, ThemeProvider} from '..' +import {BaseStyles, Box, FormControl, ThemeProvider} from '..' import TextInputWithTokens, {TextInputWithTokensProps} from '../TextInputWithTokens' import IssueLabelToken from '../Token/IssueLabelToken' @@ -47,6 +47,21 @@ export default { type: 'boolean' } }, + loading: { + name: 'loading', + defaultValue: false, + control: { + type: 'boolean' + } + }, + loaderPosition: { + name: 'loaderPosition', + defaultValue: 'auto', + options: ['auto', 'leading', 'trailing'], + control: { + type: 'radio' + } + }, size: { name: 'size (token size)', defaultValue: 'extralarge', @@ -121,6 +136,59 @@ export const WithTrailingVisual = (args: TextInputWithTokensProps) => { WithTrailingVisual.parameters = {controls: {exclude: [excludedControls, 'maxHeight']}} +export const WithLoadingIndicator = (args: TextInputWithTokensProps) => { + const [tokens, setTokens] = useState([...mockTokens].slice(0, 3)) + const [loading, setLoading] = useState(true) + const onTokenRemove: (tokenId: string | number) => void = tokenId => { + setTokens(tokens.filter(token => token.id !== tokenId)) + } + const toggleLoadingState = () => { + setLoading(!loading) + } + + return ( +
+ + + + + + + No visual + + + + + Leading visual + + + + + Both visuals + + + +
+ ) +} + +WithLoadingIndicator.parameters = {controls: {exclude: [excludedControls, 'maxHeight', 'loading']}} + export const UsingIssueLabelTokens = (args: TextInputWithTokensProps) => { const [tokens, setTokens] = useState([ {text: 'enhancement', id: 1, fillColor: '#a2eeef'}, From a377a510a041c95ec9e002c07acd3431fe7b1dad Mon Sep 17 00:00:00 2001 From: GitHub Design Systems Bot <30705008+primer-css@users.noreply.github.com> Date: Tue, 22 Mar 2022 06:17:15 -0700 Subject: [PATCH 9/9] Version Packages (#1966) Co-authored-by: github-actions[bot] --- .../actionmenu-fix-high-contrast-mode.md | 5 ---- .changeset/healthy-cooks-draw.md | 5 ---- .changeset/large-owls-dance.md | 5 ---- .changeset/loud-schools-own.md | 5 ---- .changeset/seven-hornets-jam.md | 5 ---- .changeset/smooth-lemons-brake.md | 5 ---- .changeset/spotty-eagles-help.md | 5 ---- .changeset/stupid-terms-hang.md | 5 ---- .changeset/ten-apes-smell.md | 5 ---- .changeset/yellow-planes-decide.md | 5 ---- CHANGELOG.md | 26 +++++++++++++++++++ package.json | 2 +- 12 files changed, 27 insertions(+), 51 deletions(-) delete mode 100644 .changeset/actionmenu-fix-high-contrast-mode.md delete mode 100644 .changeset/healthy-cooks-draw.md delete mode 100644 .changeset/large-owls-dance.md delete mode 100644 .changeset/loud-schools-own.md delete mode 100644 .changeset/seven-hornets-jam.md delete mode 100644 .changeset/smooth-lemons-brake.md delete mode 100644 .changeset/spotty-eagles-help.md delete mode 100644 .changeset/stupid-terms-hang.md delete mode 100644 .changeset/ten-apes-smell.md delete mode 100644 .changeset/yellow-planes-decide.md diff --git a/.changeset/actionmenu-fix-high-contrast-mode.md b/.changeset/actionmenu-fix-high-contrast-mode.md deleted file mode 100644 index c4d3c5ef3b2..00000000000 --- a/.changeset/actionmenu-fix-high-contrast-mode.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/react': patch ---- - -ActionMenu: Fix styles for windows high contrast mode diff --git a/.changeset/healthy-cooks-draw.md b/.changeset/healthy-cooks-draw.md deleted file mode 100644 index 3680cb91a6f..00000000000 --- a/.changeset/healthy-cooks-draw.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/react': patch ---- - -Ensures select option text has acceptable contrast in Firefox when in dark mode diff --git a/.changeset/large-owls-dance.md b/.changeset/large-owls-dance.md deleted file mode 100644 index 0c218546dc7..00000000000 --- a/.changeset/large-owls-dance.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@primer/react": patch ---- - -Icon button fixes: Removes iconLabel and adds aria-label to the type diff --git a/.changeset/loud-schools-own.md b/.changeset/loud-schools-own.md deleted file mode 100644 index 068d42c986a..00000000000 --- a/.changeset/loud-schools-own.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@primer/react": patch ---- - -Fix `TextInput` types diff --git a/.changeset/seven-hornets-jam.md b/.changeset/seven-hornets-jam.md deleted file mode 100644 index 2699e13c8dd..00000000000 --- a/.changeset/seven-hornets-jam.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/react': minor ---- - -Adds button element selector to FilteredSearch button styles diff --git a/.changeset/smooth-lemons-brake.md b/.changeset/smooth-lemons-brake.md deleted file mode 100644 index 4a68284bebf..00000000000 --- a/.changeset/smooth-lemons-brake.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/react': minor ---- - -Adds a loadings state to our text input components diff --git a/.changeset/spotty-eagles-help.md b/.changeset/spotty-eagles-help.md deleted file mode 100644 index 2593685d9e9..00000000000 --- a/.changeset/spotty-eagles-help.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@primer/react': patch ---- - -Instead of rendering unexpected FormControl children before the rest of the content, we render them in the same spot we'd normally render a Primer input component diff --git a/.changeset/stupid-terms-hang.md b/.changeset/stupid-terms-hang.md deleted file mode 100644 index bee78b92e04..00000000000 --- a/.changeset/stupid-terms-hang.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@primer/react": minor ---- - -Bump primer/primitives to `7.5.1` diff --git a/.changeset/ten-apes-smell.md b/.changeset/ten-apes-smell.md deleted file mode 100644 index 0485e9a3be5..00000000000 --- a/.changeset/ten-apes-smell.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@primer/react": patch ---- - -Add overlay props to Autocomplete.Overlay diff --git a/.changeset/yellow-planes-decide.md b/.changeset/yellow-planes-decide.md deleted file mode 100644 index d0923ffb3ea..00000000000 --- a/.changeset/yellow-planes-decide.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@primer/react": patch ---- - -Add disabled color and backgroundColor to Button.Counter diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d23bad7bf2..3ba19a02fcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,31 @@ # @primer/components +## 35.1.0 + +### Minor Changes + +- [#1942](https://github.com/primer/react/pull/1942) [`3f50ef54`](https://github.com/primer/react/commit/3f50ef543b8cea0306aba44bb44611f22dae657d) Thanks [@mperrotti](https://github.com/mperrotti)! - Adds button element selector to FilteredSearch button styles + +* [#1920](https://github.com/primer/react/pull/1920) [`40ed423e`](https://github.com/primer/react/commit/40ed423ed546ed91b69bc7bcc8361fd1e41faa8c) Thanks [@mperrotti](https://github.com/mperrotti)! - Adds a loadings state to our text input components + +- [#1961](https://github.com/primer/react/pull/1961) [`767d4166`](https://github.com/primer/react/commit/767d4166ef3e76e8ea12b6eec2d1d22f45f8609c) Thanks [@simurai](https://github.com/simurai)! - Bump primer/primitives to `7.5.1` + +### Patch Changes + +- [#1970](https://github.com/primer/react/pull/1970) [`3b236044`](https://github.com/primer/react/commit/3b23604438b850557e7e3d0a0594a8cca119859b) Thanks [@siddharthkp](https://github.com/siddharthkp)! - ActionMenu: Fix styles for windows high contrast mode + +* [#1981](https://github.com/primer/react/pull/1981) [`e9bb5956`](https://github.com/primer/react/commit/e9bb595680ff51a563260c020d1475102eba2535) Thanks [@mperrotti](https://github.com/mperrotti)! - Ensures select option text has acceptable contrast in Firefox when in dark mode + +- [#1945](https://github.com/primer/react/pull/1945) [`ef3b58a1`](https://github.com/primer/react/commit/ef3b58a1fdffc8d3f709c9f63e0ee70ee0f397ba) Thanks [@pksjce](https://github.com/pksjce)! - Icon button fixes: Removes iconLabel and adds aria-label to the type + +* [#1959](https://github.com/primer/react/pull/1959) [`2025036e`](https://github.com/primer/react/commit/2025036e552d8c8d02ed3139e5c8da4cb1546bb7) Thanks [@colebemis](https://github.com/colebemis)! - Fix `TextInput` types + +- [#1968](https://github.com/primer/react/pull/1968) [`1b01485a`](https://github.com/primer/react/commit/1b01485a282dc882aa7c8cc3a55fe736afdac029) Thanks [@mperrotti](https://github.com/mperrotti)! - Instead of rendering unexpected FormControl children before the rest of the content, we render them in the same spot we'd normally render a Primer input component + +* [#1967](https://github.com/primer/react/pull/1967) [`c83a06f0`](https://github.com/primer/react/commit/c83a06f00280ee2f8139d0cc3489242f1af46982) Thanks [@pksjce](https://github.com/pksjce)! - Add overlay props to Autocomplete.Overlay + +- [#1955](https://github.com/primer/react/pull/1955) [`77e123f4`](https://github.com/primer/react/commit/77e123f403df0669f492ac636de651506709bd9a) Thanks [@pksjce](https://github.com/pksjce)! - Add disabled color and backgroundColor to Button.Counter + ## 35.0.1 ### Patch Changes diff --git a/package.json b/package.json index 1570c01b181..f80909698e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@primer/react", - "version": "35.0.1", + "version": "35.1.0", "description": "An implementation of GitHub's Primer Design System using React", "main": "lib/index.js", "module": "lib-esm/index.js",