From 867ba9a2b3079eda784df7292c8e84fc3f5e3f80 Mon Sep 17 00:00:00 2001 From: Valentyna Date: Wed, 17 Apr 2024 10:48:00 +0200 Subject: [PATCH 1/5] fix(react-swatch-picker): fixes after bug bash --- .../SwatchPicker/SwatchPicker.stories.tsx | 6 +-- .../useColorSwatchStyles.styles.ts | 8 ++-- .../EmptySwatch/EmptySwatch.test.tsx | 1 + .../components/EmptySwatch/useEmptySwatch.ts | 2 + .../useEmptySwatchStyles.styles.ts | 2 +- .../useImageSwatchStyles.styles.ts | 8 ++-- .../SwatchPicker/SwatchPicker.test.tsx | 2 +- .../SwatchPicker/SwatchPicker.types.ts | 2 +- .../SwatchPicker/useSwatchPicker.ts | 12 ------ .../useSwatchPickerStyles.styles.ts | 24 +++++++---- .../SwatchPickerRow/SwatchPickerRow.test.tsx | 1 - .../SwatchPickerRow/SwatchPickerRow.types.ts | 3 +- .../SwatchPickerRow/useSwatchPickerRow.ts | 9 +--- .../useSwatchPickerRowStyles.styles.ts | 25 ++++++----- .../src/contexts/swatchPicker.ts | 1 + .../react-swatch-picker-preview/src/index.ts | 1 - .../__snapshots__/renderUtils.test.tsx.snap | 11 ----- .../SwatchPicker/EmptySwatch.stories.tsx | 43 ++++++++++++++----- .../SwatchPicker/SwatchPickerBestPractices.md | 5 --- .../SwatchPickerDefault.stories.tsx | 3 ++ .../SwatchPickerLayout.stories.tsx | 3 ++ .../SwatchPickerPopup.stories.tsx | 3 ++ .../SwatchPicker/SwatchPickerSize.stories.tsx | 2 +- .../SwatchPickerWithTooltip.stories.tsx | 3 ++ .../stories/SwatchPicker/index.stories.tsx | 3 +- 25 files changed, 98 insertions(+), 85 deletions(-) delete mode 100644 packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerBestPractices.md diff --git a/apps/vr-tests-react-components/src/stories/SwatchPicker/SwatchPicker.stories.tsx b/apps/vr-tests-react-components/src/stories/SwatchPicker/SwatchPicker.stories.tsx index 5fb6f3bf26bbb5..4bd6cc1d08ec93 100644 --- a/apps/vr-tests-react-components/src/stories/SwatchPicker/SwatchPicker.stories.tsx +++ b/apps/vr-tests-react-components/src/stories/SwatchPicker/SwatchPicker.stories.tsx @@ -29,17 +29,17 @@ export const DefaultRTL = getStoryVariant(Default, RTL); export const Size = () => ( <>

Colors

- +

Images

- +

Grid layout

- + diff --git a/packages/react-components/react-swatch-picker-preview/src/components/ColorSwatch/useColorSwatchStyles.styles.ts b/packages/react-components/react-swatch-picker-preview/src/components/ColorSwatch/useColorSwatchStyles.styles.ts index 6865de83d5d48c..13aadd65a01c09 100644 --- a/packages/react-components/react-swatch-picker-preview/src/components/ColorSwatch/useColorSwatchStyles.styles.ts +++ b/packages/react-components/react-swatch-picker-preview/src/components/ColorSwatch/useColorSwatchStyles.styles.ts @@ -89,7 +89,7 @@ const useStyles = makeStyles({ }); const useSizeStyles = makeStyles({ - extraSmall: { + 'extra-small': { width: '20px', height: '20px', }, @@ -136,7 +136,7 @@ const useIconStyles = makeStyles({ display: 'flex', alignSelf: 'center', }, - extraSmall: { + 'extra-small': { fontSize: '16px', }, small: { @@ -160,13 +160,13 @@ export const useColorSwatchStyles_unstable = (state: ColorSwatchState): ColorSwa const shapeStyles = useShapeStyles(); const iconStyles = useIconStyles(); - const size = state.size ?? 'medium'; + const { size = 'medium', shape = 'square' } = state; state.root.className = mergeClasses( colorSwatchClassNames.root, resetStyles, sizeStyles[size], - shapeStyles[state.shape ?? 'square'], + shapeStyles[shape], state.selected && styles.selected, state.disabled && styles.disabled, state.root.className, diff --git a/packages/react-components/react-swatch-picker-preview/src/components/EmptySwatch/EmptySwatch.test.tsx b/packages/react-components/react-swatch-picker-preview/src/components/EmptySwatch/EmptySwatch.test.tsx index 18eca475904cab..d60a3fc49bfd53 100644 --- a/packages/react-components/react-swatch-picker-preview/src/components/EmptySwatch/EmptySwatch.test.tsx +++ b/packages/react-components/react-swatch-picker-preview/src/components/EmptySwatch/EmptySwatch.test.tsx @@ -14,6 +14,7 @@ describe('EmptySwatch', () => { expect(result.container).toMatchInlineSnapshot(`
+ + ); }; diff --git a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerBestPractices.md b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerBestPractices.md deleted file mode 100644 index 08ff8ddeeb5f86..00000000000000 --- a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerBestPractices.md +++ /dev/null @@ -1,5 +0,0 @@ -## Best practices - -### Do - -### Don't diff --git a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerDefault.stories.tsx b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerDefault.stories.tsx index e5c803b837d57b..0e9821d5b357aa 100644 --- a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerDefault.stories.tsx +++ b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerDefault.stories.tsx @@ -8,6 +8,9 @@ const useStyles = makeStyles({ height: '100px', ...shorthands.border('1px', 'solid', '#ccc'), ...shorthands.margin('20px', '0'), + '@media (forced-colors: active)': { + forcedColorAdjust: 'none', + }, }, }); diff --git a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerLayout.stories.tsx b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerLayout.stories.tsx index 2715475e35fcad..4f7c3ee88b4ac5 100644 --- a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerLayout.stories.tsx +++ b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerLayout.stories.tsx @@ -14,6 +14,9 @@ const useStyles = makeStyles({ height: '100px', ...shorthands.border('1px', 'solid', '#ccc'), ...shorthands.margin('20px', '0'), + '@media (forced-colors: active)': { + forcedColorAdjust: 'none', + }, }, }); diff --git a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerPopup.stories.tsx b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerPopup.stories.tsx index d4680243bceb94..124716c25dda00 100644 --- a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerPopup.stories.tsx +++ b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerPopup.stories.tsx @@ -8,6 +8,9 @@ const useStyles = makeStyles({ height: '100px', ...shorthands.border('1px', 'solid', '#ccc'), ...shorthands.margin('20px', '0'), + '@media (forced-colors: active)': { + forcedColorAdjust: 'none', + }, }, }); diff --git a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerSize.stories.tsx b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerSize.stories.tsx index b6e0d73d1b9b85..c72924c17352c0 100644 --- a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerSize.stories.tsx +++ b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerSize.stories.tsx @@ -44,7 +44,7 @@ export const SwatchPickerSize = () => { })}

Extra small

- + {colors.map(color => { return ; })} diff --git a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerWithTooltip.stories.tsx b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerWithTooltip.stories.tsx index 19bb7bded6add5..bdad1826398113 100644 --- a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerWithTooltip.stories.tsx +++ b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/SwatchPickerWithTooltip.stories.tsx @@ -13,6 +13,9 @@ const useStyles = makeStyles({ height: '100px', ...shorthands.border('1px', 'solid', '#ccc'), ...shorthands.margin('20px', '0'), + '@media (forced-colors: active)': { + forcedColorAdjust: 'none', + }, }, }); diff --git a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/index.stories.tsx b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/index.stories.tsx index e5b34e7d23f102..19297aaf1ce439 100644 --- a/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/index.stories.tsx +++ b/packages/react-components/react-swatch-picker-preview/stories/SwatchPicker/index.stories.tsx @@ -8,7 +8,6 @@ import { } from '@fluentui/react-swatch-picker-preview'; import descriptionMd from './SwatchPickerDescription.md'; -import bestPracticesMd from './SwatchPickerBestPractices.md'; export { Default } from './SwatchPickerDefault.stories'; export { SwatchPickerImage } from './SwatchPickerImage.stories'; @@ -33,7 +32,7 @@ const metadata: ComponentMeta = { parameters: { docs: { description: { - component: [descriptionMd, bestPracticesMd].join('\n'), + component: [descriptionMd].join('\n'), }, }, }, From 42f499361edd3465e9138c8092854b9af3332e91 Mon Sep 17 00:00:00 2001 From: Valentyna Date: Thu, 18 Apr 2024 17:51:05 +0200 Subject: [PATCH 2/5] updated api --- .../etc/react-swatch-picker-preview.api.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/react-components/react-swatch-picker-preview/etc/react-swatch-picker-preview.api.md b/packages/react-components/react-swatch-picker-preview/etc/react-swatch-picker-preview.api.md index b470ddd7514464..eb11c8742a68e7 100644 --- a/packages/react-components/react-swatch-picker-preview/etc/react-swatch-picker-preview.api.md +++ b/packages/react-components/react-swatch-picker-preview/etc/react-swatch-picker-preview.api.md @@ -108,11 +108,6 @@ export const SwatchPicker: ForwardRefComponent; // @public (undocumented) export const swatchPickerClassNames: SlotClassNames; -// @public (undocumented) -export const swatchPickerCSSVars: { - gridGap: string; -}; - // @public (undocumented) export type SwatchPickerGridProps = { items: SwatchProps[]; @@ -139,7 +134,7 @@ export type SwatchPickerProps = ComponentProps & { layout?: 'row' | 'grid'; onSelectionChange?: EventHandler; selectedValue?: string; - size?: 'extraSmall' | 'small' | 'medium' | 'large'; + size?: 'extra-small' | 'small' | 'medium' | 'large'; shape?: 'rounded' | 'square' | 'circular'; spacing?: 'small' | 'medium'; }; @@ -159,7 +154,7 @@ export type SwatchPickerRowSlots = { }; // @public -export type SwatchPickerRowState = ComponentState; +export type SwatchPickerRowState = ComponentState & Pick; // @public (undocumented) export type SwatchPickerSlots = { From 012879e93cfbda39b52536d7bff84af973645e0d Mon Sep 17 00:00:00 2001 From: Valentyna Date: Thu, 18 Apr 2024 17:52:26 +0200 Subject: [PATCH 3/5] change files --- ...icker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json diff --git a/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json b/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json new file mode 100644 index 00000000000000..031bd8b8fd47db --- /dev/null +++ b/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json @@ -0,0 +1,7 @@ +{ + "type": "minor", + "comment": "fix(react-swatch-picker): api changes and fixes", + "packageName": "@fluentui/react-swatch-picker-preview", + "email": "vkozlova@microsoft.com", + "dependentChangeType": "patch" +} From 5b86eadf1cd7d8da96827cb86116f047788505d2 Mon Sep 17 00:00:00 2001 From: Valentina Date: Fri, 19 Apr 2024 11:56:19 +0200 Subject: [PATCH 4/5] Update change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json Co-authored-by: Martin Hochel --- ...tch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json b/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json index 031bd8b8fd47db..ffbabf5b3ee5b2 100644 --- a/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json +++ b/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json @@ -1,6 +1,6 @@ { "type": "minor", - "comment": "fix(react-swatch-picker): api changes and fixes", + "comment": "fix: api changes and fixes", "packageName": "@fluentui/react-swatch-picker-preview", "email": "vkozlova@microsoft.com", "dependentChangeType": "patch" From 72e6c1c9697958c14aeceda9fc44ad7b85915cc2 Mon Sep 17 00:00:00 2001 From: Valentina Date: Fri, 19 Apr 2024 14:53:47 +0200 Subject: [PATCH 5/5] Update change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json Co-authored-by: Martin Hochel --- ...tch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json b/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json index ffbabf5b3ee5b2..0df655e161f2eb 100644 --- a/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json +++ b/change/@fluentui-react-swatch-picker-preview-6246310c-e802-4b75-a4dd-6aa211c022b9.json @@ -1,6 +1,6 @@ { "type": "minor", - "comment": "fix: api changes and fixes", + "comment": "fix: BREAKING CHANGE - api changes and fixes", "packageName": "@fluentui/react-swatch-picker-preview", "email": "vkozlova@microsoft.com", "dependentChangeType": "patch"