From 8753d77debd3c3cf492889e9d2d22927798af287 Mon Sep 17 00:00:00 2001 From: Carlos Matallin Date: Wed, 22 Nov 2023 15:40:25 -0500 Subject: [PATCH 1/3] [Select, Text] Add magic tone --- .../src/components/Select/Select.scss | 41 ++++++++++++++ .../src/components/Select/Select.stories.tsx | 55 +++++++++++++++++++ .../src/components/Select/Select.tsx | 33 +++++++++-- polaris-react/src/components/Text/Text.scss | 8 +++ .../src/components/Text/Text.stories.tsx | 6 ++ polaris-react/src/components/Text/Text.tsx | 9 ++- 6 files changed, 146 insertions(+), 6 deletions(-) diff --git a/polaris-react/src/components/Select/Select.scss b/polaris-react/src/components/Select/Select.scss index 1f978c56f90..21b5f39eb07 100644 --- a/polaris-react/src/components/Select/Select.scss +++ b/polaris-react/src/components/Select/Select.scss @@ -175,6 +175,47 @@ } } +.toneMagic { + .Content { + color: var(--p-color-text-magic); + } + + .InlineLabel { + color: inherit; + } + + .Backdrop { + border-color: var(--p-color-border-magic-secondary); + background-color: var(--p-color-bg-surface-magic); + } + + // stylelint-disable-next-line selector-max-combinators -- set Icon fill + .Icon svg { + fill: var(--p-color-icon-magic); + } + + // stylelint-disable selector-max-specificity, selector-max-class, selector-max-combinators, selector-max-compound-selectors, max-nesting-depth -- apply hover and active styles + &:not(.disabled):not(.error) { + &:not(:focus-within) { + &:hover .Backdrop { + border-color: var(--p-color-border-magic-secondary-hover); + background-color: var(--p-color-bg-surface-magic-hover); + } + } + + .Input:focus-visible { + ~ .Content { + color: var(--p-color-text); + + .Icon svg { + fill: var(--p-color-icon-secondary); + } + } + } + } + // stylelint-enable selector-max-specificity, selector-max-class, selector-max-combinators +} + @media (-ms-high-contrast: active) { .Content { color: windowText; diff --git a/polaris-react/src/components/Select/Select.stories.tsx b/polaris-react/src/components/Select/Select.stories.tsx index fad8a589bb4..5453fb3abb0 100644 --- a/polaris-react/src/components/Select/Select.stories.tsx +++ b/polaris-react/src/components/Select/Select.stories.tsx @@ -77,6 +77,46 @@ export function Disabled() { ); } +export function Magic() { + return ( + + ); +} + export function WithPrefix() { const [selected, setSelected] = useState('enabled'); @@ -205,6 +245,13 @@ export function All() { onChange={() => {}} error="Province is required" /> + {}} labelInline /> + { + toggleFocused(); + }, [toggleFocused]); + const handleChange = onChange ? (event: React.ChangeEvent) => onChange(event.currentTarget.value, id) @@ -136,7 +147,13 @@ export function Select({ const inlineLabelMarkup = labelInline && ( - + {label} @@ -179,8 +196,14 @@ export function Select({ value={value} className={styles.Input} disabled={disabled} - onFocus={onFocus} - onBlur={onBlur} + onFocus={() => { + handleFocus(); + onFocus?.(); + }} + onBlur={() => { + toggleFocused(); + onBlur?.(); + }} onChange={handleChange} aria-invalid={Boolean(error)} aria-describedby={ diff --git a/polaris-react/src/components/Text/Text.scss b/polaris-react/src/components/Text/Text.scss index 216846ff54d..91aa0d832b6 100644 --- a/polaris-react/src/components/Text/Text.scss +++ b/polaris-react/src/components/Text/Text.scss @@ -52,6 +52,14 @@ color: var(--p-color-text-secondary); } +.magic { + color: var(--p-color-text-magic); +} + +.magic-subdued { + color: var(--p-color-text-magic-secondary); +} + .text-inverse { color: var(--p-color-text-inverse); } diff --git a/polaris-react/src/components/Text/Text.stories.tsx b/polaris-react/src/components/Text/Text.stories.tsx index a9651b404ca..97b17da7b32 100644 --- a/polaris-react/src/components/Text/Text.stories.tsx +++ b/polaris-react/src/components/Text/Text.stories.tsx @@ -102,6 +102,12 @@ export const WithTone = () => ( Use in combination with a symbol showing a decreasing value to indicate a downward trend. + + Recommended for text generated by magic AI. + + + Recommended for secondary-level prominence of text suggested by magic AI. + ); diff --git a/polaris-react/src/components/Text/Text.tsx b/polaris-react/src/components/Text/Text.tsx index cde97c8b899..ab2ea82a3a8 100644 --- a/polaris-react/src/components/Text/Text.tsx +++ b/polaris-react/src/components/Text/Text.tsx @@ -35,7 +35,14 @@ type Alignment = 'start' | 'center' | 'end' | 'justify'; type FontWeight = 'regular' | 'medium' | 'semibold' | 'bold'; -type Tone = 'success' | 'critical' | 'caution' | 'subdued' | 'text-inverse'; +type Tone = + | 'success' + | 'critical' + | 'caution' + | 'subdued' + | 'text-inverse' + | 'magic' + | 'magic-subdued'; type TextDecorationLine = 'line-through'; From e6e7cf68d0f8846e57ab591ad2062ce27f507f80 Mon Sep 17 00:00:00 2001 From: Carlos Matallin Date: Thu, 23 Nov 2023 12:05:19 -0500 Subject: [PATCH 2/3] [Sidekick] Bump `color-text-magic-secondary` to purple 13 --- polaris-tokens/src/themes/base/color.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/polaris-tokens/src/themes/base/color.ts b/polaris-tokens/src/themes/base/color.ts index f1cfa271281..2330bcb8ac6 100644 --- a/polaris-tokens/src/themes/base/color.ts +++ b/polaris-tokens/src/themes/base/color.ts @@ -854,7 +854,7 @@ export const color: { description: 'Use for text suggested by magic AI.', }, 'color-text-magic-secondary': { - value: colors.purple[12], + value: colors.purple[13], description: 'Use for text suggested by magic AI with a secondary level of prominence.', }, From c82ceae96167c2837aadf25ec1e1a4aacb85cd23 Mon Sep 17 00:00:00 2001 From: Carlos Matallin Date: Wed, 22 Nov 2023 15:46:58 -0500 Subject: [PATCH 3/3] Changeset --- .changeset/odd-seahorses-compare.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .changeset/odd-seahorses-compare.md diff --git a/.changeset/odd-seahorses-compare.md b/.changeset/odd-seahorses-compare.md new file mode 100644 index 00000000000..a449e0d3d64 --- /dev/null +++ b/.changeset/odd-seahorses-compare.md @@ -0,0 +1,9 @@ +--- +'@shopify/polaris': minor +'@shopify/polaris-tokens': minor +--- + +- Bumped `color-text-magic-secondary` to purple 13 +- Added `tone` prop with `magic` value to `Select` +- Added `magic` value to `tone` prop of `Text` +- Added `magic-subdued` value to `tone` prop of `Text`