From c30aeb51e103684a49d8873b7098efd2a32d5e1f Mon Sep 17 00:00:00 2001 From: sarayourfriend <24264157+sarayourfriend@users.noreply.github.com> Date: Mon, 17 May 2021 10:00:34 -0700 Subject: [PATCH 1/8] Revert "Revert "components: Promote VisuallyHidden from ui into full components (#31244)" (#31882)" This reverts commit 269f31aca6d4561b61bb872e6adf0a0ab2b68489. --- .../test/__snapshots__/index.js.snap | 3 + .../src/alignment-matrix-control/cell.js | 2 +- packages/components/src/base-control/index.js | 2 +- packages/components/src/button/index.js | 2 +- packages/components/src/button/test/index.js | 2 +- packages/components/src/color-picker/hue.js | 2 +- .../components/src/color-picker/inputs.js | 2 +- .../components/src/color-picker/saturation.js | 2 +- .../test/__snapshots__/index.js.snap | 70 ++++++++++++++----- .../src/custom-gradient-bar/control-points.js | 2 +- .../components/src/external-link/index.js | 2 +- .../components/src/font-size-picker/index.js | 2 +- .../components/src/form-token-field/token.js | 2 +- packages/components/src/index.js | 2 +- .../components/src/input-control/label.js | 2 +- .../src/navigation/menu/menu-title-search.js | 2 +- packages/components/src/style.scss | 1 - .../src/ui/form-group/form-group-label.js | 4 +- packages/components/src/ui/index.js | 1 - .../src/ui/visually-hidden/index.js | 2 - .../src/ui/visually-hidden/stories/index.js | 42 ----------- .../components/src/visually-hidden/README.md | 14 +++- .../src/{ui => }/visually-hidden/component.js | 6 +- .../components/src/visually-hidden/hook.js | 26 +++++++ .../components/src/visually-hidden/index.js | 47 +------------ .../src/visually-hidden/stories/index.js | 2 +- .../components/src/visually-hidden/style.scss | 30 -------- .../src/{ui => }/visually-hidden/styles.js | 2 +- .../test/__snapshots__/index.js.snap | 0 .../{ui => }/visually-hidden/test/index.js | 0 .../test/__snapshots__/index.js.snap | 8 +-- 31 files changed, 119 insertions(+), 167 deletions(-) create mode 100644 packages/block-editor/src/components/link-control/test/__snapshots__/index.js.snap delete mode 100644 packages/components/src/ui/visually-hidden/index.js delete mode 100644 packages/components/src/ui/visually-hidden/stories/index.js rename packages/components/src/{ui => }/visually-hidden/component.js (76%) create mode 100644 packages/components/src/visually-hidden/hook.js delete mode 100644 packages/components/src/visually-hidden/style.scss rename packages/components/src/{ui => }/visually-hidden/styles.js (92%) rename packages/components/src/{ui => }/visually-hidden/test/__snapshots__/index.js.snap (100%) rename packages/components/src/{ui => }/visually-hidden/test/index.js (100%) diff --git a/packages/block-editor/src/components/link-control/test/__snapshots__/index.js.snap b/packages/block-editor/src/components/link-control/test/__snapshots__/index.js.snap new file mode 100644 index 00000000000000..43a6e4b0476981 --- /dev/null +++ b/packages/block-editor/src/components/link-control/test/__snapshots__/index.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Basic rendering should render 1`] = `""`; diff --git a/packages/components/src/alignment-matrix-control/cell.js b/packages/components/src/alignment-matrix-control/cell.js index 48dd339ebfc5a0..2aeb839831c0c0 100644 --- a/packages/components/src/alignment-matrix-control/cell.js +++ b/packages/components/src/alignment-matrix-control/cell.js @@ -3,7 +3,7 @@ */ import { CompositeItem } from '../composite'; import Tooltip from '../tooltip'; -import VisuallyHidden from '../visually-hidden'; +import { VisuallyHidden } from '../visually-hidden'; /** * Internal dependencies diff --git a/packages/components/src/base-control/index.js b/packages/components/src/base-control/index.js index aaae49a9a95da9..bbeb0a7b77bb4d 100644 --- a/packages/components/src/base-control/index.js +++ b/packages/components/src/base-control/index.js @@ -6,7 +6,7 @@ import classnames from 'classnames'; /** * Internal dependencies */ -import VisuallyHidden from '../visually-hidden'; +import { VisuallyHidden } from '../visually-hidden'; import { Wrapper, StyledField, diff --git a/packages/components/src/button/index.js b/packages/components/src/button/index.js index 34b30a4338beac..d610436edd39e3 100644 --- a/packages/components/src/button/index.js +++ b/packages/components/src/button/index.js @@ -15,7 +15,7 @@ import { forwardRef } from '@wordpress/element'; */ import Tooltip from '../tooltip'; import Icon from '../icon'; -import VisuallyHidden from '../visually-hidden'; +import { VisuallyHidden } from '../visually-hidden'; const disabledEventsOnDisabledButton = [ 'onMouseDown', 'onClick' ]; diff --git a/packages/components/src/button/test/index.js b/packages/components/src/button/test/index.js index ea0a3257071c35..b4dc89eaaf092b 100644 --- a/packages/components/src/button/test/index.js +++ b/packages/components/src/button/test/index.js @@ -13,7 +13,7 @@ import { plusCircle } from '@wordpress/icons'; * Internal dependencies */ import ButtonWithForwardedRef, { Button } from '../'; -import VisuallyHidden from '../../visually-hidden'; +import { VisuallyHidden } from '../../visually-hidden'; describe( 'Button', () => { describe( 'basic rendering', () => { diff --git a/packages/components/src/color-picker/hue.js b/packages/components/src/color-picker/hue.js index 7261b729a29477..b454712555b5c0 100644 --- a/packages/components/src/color-picker/hue.js +++ b/packages/components/src/color-picker/hue.js @@ -43,7 +43,7 @@ import { TAB } from '@wordpress/keycodes'; */ import { calculateHueChange } from './utils'; import KeyboardShortcuts from '../keyboard-shortcuts'; -import VisuallyHidden from '../visually-hidden'; +import { VisuallyHidden } from '../visually-hidden'; export class Hue extends Component { constructor() { diff --git a/packages/components/src/color-picker/inputs.js b/packages/components/src/color-picker/inputs.js index aa8d9ff7900367..eb649795047da3 100644 --- a/packages/components/src/color-picker/inputs.js +++ b/packages/components/src/color-picker/inputs.js @@ -18,7 +18,7 @@ import { chevronDown } from '@wordpress/icons'; */ import Button from '../button'; import TextControl from '../text-control'; -import VisuallyHidden from '../visually-hidden'; +import { VisuallyHidden } from '../visually-hidden'; import { isValidHex } from './utils'; /* Wrapper for TextControl, only used to handle intermediate state while typing. */ diff --git a/packages/components/src/color-picker/saturation.js b/packages/components/src/color-picker/saturation.js index 3b9666d734588f..fa0604bb11379b 100644 --- a/packages/components/src/color-picker/saturation.js +++ b/packages/components/src/color-picker/saturation.js @@ -44,7 +44,7 @@ import { compose, pure, withInstanceId } from '@wordpress/compose'; import { calculateSaturationChange } from './utils'; import Button from '../button'; import KeyboardShortcuts from '../keyboard-shortcuts'; -import VisuallyHidden from '../visually-hidden'; +import { VisuallyHidden } from '../visually-hidden'; export class Saturation extends Component { constructor( props ) { diff --git a/packages/components/src/color-picker/test/__snapshots__/index.js.snap b/packages/components/src/color-picker/test/__snapshots__/index.js.snap index 9adc7729df2928..580469f14b5e4d 100644 --- a/packages/components/src/color-picker/test/__snapshots__/index.js.snap +++ b/packages/components/src/color-picker/test/__snapshots__/index.js.snap @@ -39,7 +39,7 @@ Snapshot Diff: type="button" />
@@ -86,7 +86,7 @@ Snapshot Diff: tabIndex="0" />

@@ -161,7 +161,7 @@ Snapshot Diff: type="button" />

@@ -208,7 +208,7 @@ Snapshot Diff: tabIndex="0" />

@@ -283,7 +283,7 @@ Snapshot Diff: type="button" />

@@ -330,7 +330,7 @@ Snapshot Diff: tabIndex="0" />

@@ -405,7 +405,7 @@ Snapshot Diff: type="button" />

@@ -452,7 +452,7 @@ Snapshot Diff: tabIndex="0" />

@@ -511,7 +511,7 @@ Snapshot Diff: type="button" />

@@ -537,7 +537,7 @@ Snapshot Diff: tabIndex="0" />

@@ -575,19 +575,53 @@ Snapshot Diff: exports[`ColorPicker should render color picker 1`] = ` .emotion-0 { + border: 0; + clip: rect( 1px, 1px, 1px, 1px ); + -webkit-clip-path: inset( 50% ); + -webkit-clip-path: inset( 50% ); + clip-path: inset( 50% ); + height: 1px; + margin: -1px; + overflow: hidden; + padding: 0; + position: absolute; + width: 1px; + word-wrap: normal!important; +} + +.emotion-0:focus { + background-color: #edeff0; + clip: auto!important; + -webkit-clip-path: none; + clip-path: none; + color: #444; + display: block; + font-size: 1em; + height: auto; + left: 5px; + line-height: normal; + padding: 15px 23px 14px; + -webkit-text-decoration: none; + text-decoration: none; + top: 5px; + width: auto; + z-index: 100000; +} + +.emotion-6 { font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif; font-size: 13px; } -.emotion-2 { +.emotion-8 { margin-bottom: calc(4px * 2); } -.components-panel__row .emotion-2 { +.components-panel__row .emotion-8 { margin-bottom: inherit; } -.emotion-4 { +.emotion-10 { display: inline-block; margin-bottom: calc(4px * 2); } @@ -631,7 +665,7 @@ exports[`ColorPicker should render color picker 1`] = ` type="button" />

Use your arrow keys to change the base color. Move up to lighten the color, down to darken, left to decrease saturation, and right to increase saturation. @@ -691,7 +725,7 @@ exports[`ColorPicker should render color picker 1`] = ` tabIndex="0" />

Move the arrow left or right to change hue. @@ -708,13 +742,13 @@ exports[`ColorPicker should render color picker 1`] = ` className="components-color-picker__inputs-fields" >

-@@ -56,11 +56,11 @@ +@@ -58,11 +58,11 @@ >

@@ -94,7 +98,7 @@ Snapshot Diff:

-@@ -119,22 +119,22 @@ +@@ -123,22 +123,22 @@
@@ -127,7 +131,7 @@ Snapshot Diff: - First value + Second value -@@ -11,36 +11,36 @@ +@@ -11,38 +11,38 @@ onTouchMove={[Function bound handleChange]} onTouchStart={[Function bound handleChange]} role="application" @@ -161,7 +165,9 @@ Snapshot Diff: type="button" />
@@ -169,7 +175,7 @@ Snapshot Diff:
-@@ -56,11 +56,11 @@ +@@ -58,11 +58,11 @@ >

@@ -216,7 +224,7 @@ Snapshot Diff:

-@@ -119,22 +119,22 @@ +@@ -123,22 +123,22 @@
@@ -249,7 +257,7 @@ Snapshot Diff: - First value + Second value -@@ -11,36 +11,36 @@ +@@ -11,38 +11,38 @@ onTouchMove={[Function bound handleChange]} onTouchStart={[Function bound handleChange]} role="application" @@ -283,7 +291,9 @@ Snapshot Diff: type="button" />
@@ -291,7 +301,7 @@ Snapshot Diff:
-@@ -56,11 +56,11 @@ +@@ -58,11 +58,11 @@ >

@@ -338,7 +350,7 @@ Snapshot Diff:

-@@ -119,22 +119,22 @@ +@@ -123,22 +123,22 @@
@@ -371,7 +383,7 @@ Snapshot Diff: - First value + Second value -@@ -11,36 +11,36 @@ +@@ -11,38 +11,38 @@ onTouchMove={[Function bound handleChange]} onTouchStart={[Function bound handleChange]} role="application" @@ -405,7 +417,9 @@ Snapshot Diff: type="button" />
@@ -413,7 +427,7 @@ Snapshot Diff:
-@@ -56,11 +56,11 @@ +@@ -58,11 +58,11 @@ >

@@ -460,7 +476,7 @@ Snapshot Diff:

-@@ -119,22 +119,22 @@ +@@ -123,22 +123,22 @@
@@ -506,12 +522,12 @@ Snapshot Diff: onKeyDown={[Function preventKeyEvents]} style={ Object { -@@ -36,11 +36,11 @@ - } - type="button" +@@ -38,11 +38,11 @@ />
@@ -519,7 +535,7 @@ Snapshot Diff:
-@@ -78,11 +78,11 @@ +@@ -80,11 +80,11 @@ onMouseDown={[Function bound handleMouseDown]} onTouchMove={[Function bound handleChange]} onTouchStart={[Function bound handleChange]} @@ -532,12 +548,12 @@ Snapshot Diff: aria-valuemax="1" aria-valuemin="359" aria-valuenow={0} -@@ -96,11 +96,11 @@ - } - tabIndex="0" +@@ -100,11 +100,11 @@ />

@@ -545,7 +561,7 @@ Snapshot Diff:

-@@ -119,22 +119,22 @@ +@@ -123,22 +123,22 @@
@@ -608,20 +624,20 @@ exports[`ColorPicker should render color picker 1`] = ` z-index: 100000; } -.emotion-6 { +.emotion-4 { font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif; font-size: 13px; } -.emotion-8 { +.emotion-6 { margin-bottom: calc(4px * 2); } -.components-panel__row .emotion-8 { +.components-panel__row .emotion-6 { margin-bottom: inherit; } -.emotion-10 { +.emotion-8 { display: inline-block; margin-bottom: calc(4px * 2); } @@ -665,7 +681,9 @@ exports[`ColorPicker should render color picker 1`] = ` type="button" />
Use your arrow keys to change the base color. Move up to lighten the color, down to darken, left to decrease saturation, and right to increase saturation. @@ -725,7 +743,9 @@ exports[`ColorPicker should render color picker 1`] = ` tabIndex="0" />

Move the arrow left or right to change hue. @@ -742,13 +762,13 @@ exports[`ColorPicker should render color picker 1`] = ` className="components-color-picker__inputs-fields" >

-@@ -58,11 +58,11 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -73,11 +73,11 @@ >
-

- Move the arrow left or right to change hue. -

-
-
-@@ -123,22 +123,22 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -154,22 +154,22 @@
@@ -165,17 +166,17 @@ Snapshot Diff: type="button" />
- Use your arrow keys to change the base color. Move up to lighten the color, down to darken, left to decrease saturation, and right to increase saturation. -
-
-
-@@ -58,11 +58,11 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -73,11 +73,11 @@ >
-

- Move the arrow left or right to change hue. -

-
-
-@@ -123,22 +123,22 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -154,22 +154,22 @@
@@ -291,17 +293,17 @@ Snapshot Diff: type="button" />
- Use your arrow keys to change the base color. Move up to lighten the color, down to darken, left to decrease saturation, and right to increase saturation. -
-
- -@@ -58,11 +58,11 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -73,11 +73,11 @@ >
-

- Move the arrow left or right to change hue. -

-
- -@@ -123,22 +123,22 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -154,22 +154,22 @@
@@ -417,17 +420,17 @@ Snapshot Diff: type="button" />
- Use your arrow keys to change the base color. Move up to lighten the color, down to darken, left to decrease saturation, and right to increase saturation. -
-
- -@@ -58,11 +58,11 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -73,11 +73,11 @@ >
-

- Move the arrow left or right to change hue. -

-
- -@@ -123,22 +123,22 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -154,22 +154,22 @@
@@ -525,17 +529,17 @@ Snapshot Diff: @@ -38,11 +38,11 @@ />
- Use your arrow keys to change the base color. Move up to lighten the color, down to darken, left to decrease saturation, and right to increase saturation. -
-
- -@@ -80,11 +80,11 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -95,11 +95,11 @@ onMouseDown={[Function bound handleMouseDown]} onTouchMove={[Function bound handleChange]} onTouchStart={[Function bound handleChange]} @@ -548,20 +552,20 @@ Snapshot Diff: aria-valuemax="1" aria-valuemin="359" aria-valuenow={0} -@@ -100,11 +100,11 @@ - /> -

- Move the arrow left or right to change hue. -

- - -@@ -123,22 +123,22 @@ + style={ + Object { + "WebkitClipPath": "inset( 50% )", + "border": 0, + "clip": "rect(1px, 1px, 1px, 1px)", +@@ -154,22 +154,22 @@
@@ -591,53 +595,19 @@ Snapshot Diff: exports[`ColorPicker should render color picker 1`] = ` .emotion-0 { - border: 0; - clip: rect( 1px, 1px, 1px, 1px ); - -webkit-clip-path: inset( 50% ); - -webkit-clip-path: inset( 50% ); - clip-path: inset( 50% ); - height: 1px; - margin: -1px; - overflow: hidden; - padding: 0; - position: absolute; - width: 1px; - word-wrap: normal!important; -} - -.emotion-0:focus { - background-color: #edeff0; - clip: auto!important; - -webkit-clip-path: none; - clip-path: none; - color: #444; - display: block; - font-size: 1em; - height: auto; - left: 5px; - line-height: normal; - padding: 15px 23px 14px; - -webkit-text-decoration: none; - text-decoration: none; - top: 5px; - width: auto; - z-index: 100000; -} - -.emotion-4 { font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif; font-size: 13px; } -.emotion-6 { +.emotion-2 { margin-bottom: calc(4px * 2); } -.components-panel__row .emotion-6 { +.components-panel__row .emotion-2 { margin-bottom: inherit; } -.emotion-8 { +.emotion-4 { display: inline-block; margin-bottom: calc(4px * 2); } @@ -681,10 +651,25 @@ exports[`ColorPicker should render color picker 1`] = ` type="button" />
Use your arrow keys to change the base color. Move up to lighten the color, down to darken, left to decrease saturation, and right to increase saturation.
@@ -742,14 +727,30 @@ exports[`ColorPicker should render color picker 1`] = ` } tabIndex="0" /> -

Move the arrow left or right to change hue. -

+
@@ -762,13 +763,13 @@ exports[`ColorPicker should render color picker 1`] = ` className="components-color-picker__inputs-fields" >