From 77b940d669217fc917d246df44dd087cf6345b08 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Tue, 13 Sep 2022 02:01:18 +0900 Subject: [PATCH] Flex: Remove flex `gap` polyfill (#43995) * Flex: Use native flex gap * Fix style hacks in InputControl - Fixes regression in CustomSelectControl - Fixes styles for labelPosition='bottom' * InputControl: Remove redundant styles * Update snapshots * Add changelog --- .../test/__snapshots__/control.js.snap | 15 +- packages/components/CHANGELOG.md | 2 + .../test/__snapshots__/index.js.snap | 8 +- .../card/test/__snapshots__/index.tsx.snap | 52 +++--- .../test/__snapshots__/index.js.snap | 154 ++++++++---------- .../test/__snapshots__/index.test.js.snap | 64 +------- packages/components/src/flex/flex/hook.ts | 59 +------ .../flex/test/__snapshots__/index.tsx.snap | 16 +- .../h-stack/test/__snapshots__/index.tsx.snap | 15 +- .../src/input-control/input-base.tsx | 20 +-- .../components/src/input-control/label.tsx | 13 +- .../styles/input-control-styles.tsx | 43 ----- .../test/__snapshots__/index.js.snap | 5 +- .../test/__snapshots__/index.tsx.snap | 10 +- .../v-stack/test/__snapshots__/index.tsx.snap | 15 +- .../enable-custom-fields.js.snap | 20 +-- .../test/__snapshots__/index.js.snap | 10 +- .../__snapshots__/meta-boxes-section.js.snap | 15 +- 18 files changed, 144 insertions(+), 392 deletions(-) diff --git a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap index 172121132b2436..7db5f3ee20eb63 100644 --- a/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap +++ b/packages/block-editor/src/components/color-palette/test/__snapshots__/control.js.snap @@ -29,15 +29,12 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; + gap: calc(4px * 1); -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; } -.emotion-4>*+*:not( marquee ) { - margin-top: calc(4px * 1); -} - .emotion-4>* { min-height: 0; } @@ -64,15 +61,12 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` -webkit-flex-direction: column; -ms-flex-direction: column; flex-direction: column; + gap: calc(4px * 3); -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; } -.emotion-8>*+*:not( marquee ) { - margin-top: calc(4px * 3); -} - .emotion-8>* { min-height: 0; } @@ -89,16 +83,13 @@ exports[`ColorPaletteControl matches the snapshot 1`] = ` -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; + gap: calc(4px * 2); -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; width: 100%; } -.emotion-10>*+*:not( marquee ) { - margin-left: calc(4px * 2); -} - .emotion-10>* { min-width: 0; } diff --git a/packages/components/CHANGELOG.md b/packages/components/CHANGELOG.md index 8a92bbc4534395..6de5d62cc3507e 100644 --- a/packages/components/CHANGELOG.md +++ b/packages/components/CHANGELOG.md @@ -10,6 +10,7 @@ ### Bug Fix - `Button`, `Icon`: Fix `iconSize` prop doesn't work with some icons ([#43821](https://github.com/WordPress/gutenberg/pull/43821)). +- `InputControl`, `NumberControl`, `UnitControl`: Fix margin when `labelPosition` is `bottom` ([#43995](https://github.com/WordPress/gutenberg/pull/43995)). - `Popover`: enable auto-updating every animation frame ([#43617](https://github.com/WordPress/gutenberg/pull/43617)). - `Popover`: improve the component's performance and reactivity to prop changes by reworking its internals ([#43335](https://github.com/WordPress/gutenberg/pull/43335)). - `NavigatorScreen`: updated to satisfy `react/exhaustive-deps` eslint rule ([#43876](https://github.com/WordPress/gutenberg/pull/43876)) @@ -20,6 +21,7 @@ - `ToggleControl`: Add `__nextHasNoMargin` prop for opting into the new margin-free styles ([#43717](https://github.com/WordPress/gutenberg/pull/43717)). - `CheckboxControl`: Add `__nextHasNoMargin` prop for opting into the new margin-free styles ([#43720](https://github.com/WordPress/gutenberg/pull/43720)). - `TextControl`, `TextareaControl`: Add `__nextHasNoMargin` prop for opting into the new margin-free styles ([#43782](https://github.com/WordPress/gutenberg/pull/43782)). +- `Flex`: Remove margin-based polyfill implementation of flex `gap` ([#43995](https://github.com/WordPress/gutenberg/pull/43995)). - `RangeControl`: Tweak dark gray marking color to be consistent with the grays in `@wordpress/base-styles` ([#43773](https://github.com/WordPress/gutenberg/pull/43773)). - `UnitControl`: Tweak unit dropdown color to be consistent with the grays in `@wordpress/base-styles` ([#43773](https://github.com/WordPress/gutenberg/pull/43773)). - `SearchControl`: Add `__nextHasNoMargin` prop for opting into the new margin-free styles ([#43871](https://github.com/WordPress/gutenberg/pull/43871)). diff --git a/packages/components/src/base-field/test/__snapshots__/index.js.snap b/packages/components/src/base-field/test/__snapshots__/index.js.snap index bf844bf643de68..f35321afdb0555 100644 --- a/packages/components/src/base-field/test/__snapshots__/index.js.snap +++ b/packages/components/src/base-field/test/__snapshots__/index.js.snap @@ -25,7 +25,7 @@ Snapshot Diff: - Received styles + Base styles -@@ -14,18 +14,17 @@ +@@ -14,19 +14,18 @@ "background": "#fff", "border": "1px solid", "border-color": "#757575", @@ -36,6 +36,7 @@ Snapshot Diff: "flex": "1", "flex-direction": "row", "font-size": "13px", + "gap": "calc(4px * 2)", "justify-content": "space-between", "outline": "none", "padding": "0 8px", @@ -80,6 +81,7 @@ exports[`base field should render correctly 1`] = ` -webkit-flex-direction: row; -ms-flex-direction: row; flex-direction: row; + gap: calc(4px * 2); -webkit-box-pack: justify; -webkit-justify-content: space-between; justify-content: space-between; @@ -105,10 +107,6 @@ exports[`base field should render correctly 1`] = ` width: 100%; } -.emotion-0>*+*:not( marquee ) { - margin-left: calc(4px * 2); -} - .emotion-0>* { min-width: 0; } diff --git a/packages/components/src/card/test/__snapshots__/index.tsx.snap b/packages/components/src/card/test/__snapshots__/index.tsx.snap index c7329fb8c111df..2325e13746aa95 100644 --- a/packages/components/src/card/test/__snapshots__/index.tsx.snap +++ b/packages/components/src/card/test/__snapshots__/index.tsx.snap @@ -42,8 +42,8 @@ Snapshot Diff: @@ -1,8 +1,8 @@