Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "components: Promote VisuallyHidden from ui into full components (#31244)" #31882

Merged
merged 1 commit into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Basic rendering should render 1`] = `"<div tabindex=\\"-1\\" class=\\"block-editor-link-control\\"><div class=\\"block-editor-link-control__search-input-wrapper\\"><form><div class=\\"components-base-control block-editor-url-input block-editor-link-control__search-input css-wdf2ti-Wrapper e1puf3u0\\"><div class=\\"components-base-control__field css-11vcxb9-StyledField e1puf3u1\\"><input required=\\"\\" class=\\"block-editor-url-input__input\\" type=\\"text\\" placeholder=\\"Search or type url\\" role=\\"combobox\\" aria-label=\\"URL\\" aria-expanded=\\"false\\" aria-autocomplete=\\"list\\" aria-owns=\\"block-editor-url-input-suggestions-0\\" value=\\"\\"></div></div><div class=\\"block-editor-link-control__search-actions\\"><button type=\\"submit\\" class=\\"components-button block-editor-link-control__search-submit has-icon\\" aria-label=\\"Submit\\"><svg width=\\"24\\" height=\\"24\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"-2 -2 24 24\\" role=\\"img\\" aria-hidden=\\"true\\" focusable=\\"false\\"><path d=\\"M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z\\"></path></svg></button></div></form></div><fieldset class=\\"block-editor-link-control__settings\\"><legend class=\\"components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0\\">Currently selected link settings</legend><div class=\\"components-base-control components-toggle-control block-editor-link-control__setting css-wdf2ti-Wrapper e1puf3u0\\"><div class=\\"components-base-control__field css-11vcxb9-StyledField e1puf3u1\\"><span class=\\"components-form-toggle\\"><input class=\\"components-form-toggle__input\\" id=\\"inspector-toggle-control-0\\" type=\\"checkbox\\"><span class=\\"components-form-toggle__track\\"></span><span class=\\"components-form-toggle__thumb\\"></span></span><label for=\\"inspector-toggle-control-0\\" class=\\"components-toggle-control__label\\">Open in new tab</label></div></div></fieldset></div>"`;
exports[`Basic rendering should render 1`] = `"<div tabindex=\\"-1\\" class=\\"block-editor-link-control\\"><div class=\\"block-editor-link-control__search-input-wrapper\\"><form><div class=\\"components-base-control block-editor-url-input block-editor-link-control__search-input css-wdf2ti-Wrapper e1puf3u0\\"><div class=\\"components-base-control__field css-11vcxb9-StyledField e1puf3u1\\"><input required=\\"\\" class=\\"block-editor-url-input__input\\" type=\\"text\\" placeholder=\\"Search or type url\\" role=\\"combobox\\" aria-label=\\"URL\\" aria-expanded=\\"false\\" aria-autocomplete=\\"list\\" aria-owns=\\"block-editor-url-input-suggestions-0\\" value=\\"\\"></div></div><div class=\\"block-editor-link-control__search-actions\\"><button type=\\"submit\\" class=\\"components-button block-editor-link-control__search-submit has-icon\\" aria-label=\\"Submit\\"><svg width=\\"24\\" height=\\"24\\" xmlns=\\"http://www.w3.org/2000/svg\\" viewBox=\\"-2 -2 24 24\\" role=\\"img\\" aria-hidden=\\"true\\" focusable=\\"false\\"><path d=\\"M6.734 16.106l2.176-2.38-1.093-1.028-3.846 4.158 3.846 4.157 1.093-1.027-2.176-2.38h2.811c1.125 0 2.25.03 3.374 0 1.428-.001 3.362-.25 4.963-1.277 1.66-1.065 2.868-2.906 2.868-5.859 0-2.479-1.327-4.896-3.65-5.93-1.82-.813-3.044-.8-4.806-.788l-.567.002v1.5c.184 0 .368 0 .553-.002 1.82-.007 2.704-.014 4.21.657 1.854.827 2.76 2.657 2.76 4.561 0 2.472-.973 3.824-2.178 4.596-1.258.807-2.864 1.04-4.163 1.04h-.02c-1.115.03-2.229 0-3.344 0H6.734z\\"></path></svg></button></div></form></div><fieldset class=\\"block-editor-link-control__settings\\"><legend class=\\"components-visually-hidden\\">Currently selected link settings</legend><div class=\\"components-base-control components-toggle-control block-editor-link-control__setting css-wdf2ti-Wrapper e1puf3u0\\"><div class=\\"components-base-control__field css-11vcxb9-StyledField e1puf3u1\\"><span class=\\"components-form-toggle\\"><input class=\\"components-form-toggle__input\\" id=\\"inspector-toggle-control-0\\" type=\\"checkbox\\"><span class=\\"components-form-toggle__track\\"></span><span class=\\"components-form-toggle__thumb\\"></span></span><label for=\\"inspector-toggle-control-0\\" class=\\"components-toggle-control__label\\">Open in new tab</label></div></div></fieldset></div>"`;
2 changes: 1 addition & 1 deletion packages/components/src/alignment-matrix-control/cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { CompositeItem } from '../composite';
import Tooltip from '../tooltip';
import { VisuallyHidden } from '../visually-hidden';
import VisuallyHidden from '../visually-hidden';

/**
* Internal dependencies
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/base-control/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import classnames from 'classnames';
/**
* Internal dependencies
*/
import { VisuallyHidden } from '../visually-hidden';
import VisuallyHidden from '../visually-hidden';
import {
Wrapper,
StyledField,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/button/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ];

Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/button/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/color-picker/hue.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/color-picker/inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/color-picker/saturation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Snapshot Diff:
type="button"
/>
<div
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="color-picker-saturation-4"
+ id="color-picker-saturation-3"
>
Expand Down Expand Up @@ -86,7 +86,7 @@ Snapshot Diff:
tabIndex="0"
/>
<p
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="components-color-picker__hue-description-4"
+ id="components-color-picker__hue-description-3"
>
Expand Down Expand Up @@ -161,7 +161,7 @@ Snapshot Diff:
type="button"
/>
<div
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="color-picker-saturation-8"
+ id="color-picker-saturation-7"
>
Expand Down Expand Up @@ -208,7 +208,7 @@ Snapshot Diff:
tabIndex="0"
/>
<p
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="components-color-picker__hue-description-8"
+ id="components-color-picker__hue-description-7"
>
Expand Down Expand Up @@ -283,7 +283,7 @@ Snapshot Diff:
type="button"
/>
<div
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="color-picker-saturation-10"
+ id="color-picker-saturation-9"
>
Expand Down Expand Up @@ -330,7 +330,7 @@ Snapshot Diff:
tabIndex="0"
/>
<p
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="components-color-picker__hue-description-10"
+ id="components-color-picker__hue-description-9"
>
Expand Down Expand Up @@ -405,7 +405,7 @@ Snapshot Diff:
type="button"
/>
<div
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="color-picker-saturation-6"
+ id="color-picker-saturation-5"
>
Expand Down Expand Up @@ -452,7 +452,7 @@ Snapshot Diff:
tabIndex="0"
/>
<p
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="components-color-picker__hue-description-6"
+ id="components-color-picker__hue-description-5"
>
Expand Down Expand Up @@ -511,7 +511,7 @@ Snapshot Diff:
type="button"
/>
<div
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="color-picker-saturation-2"
+ id="color-picker-saturation-1"
>
Expand All @@ -537,7 +537,7 @@ Snapshot Diff:
tabIndex="0"
/>
<p
className="components-visually-hidden css-1r162ic-VisuallyHidden css-1mm2cvy-View em57xhy0"
className="components-visually-hidden"
- id="components-color-picker__hue-description-2"
+ id="components-color-picker__hue-description-1"
>
Expand Down Expand Up @@ -574,56 +574,20 @@ Snapshot Diff:
`;

exports[`ColorPicker should render color picker 1`] = `
.emotion-0 {
border: 0;
-webkit-clip: rect( 1px,1px,1px,1px );
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;
-webkit-clip: auto !important;
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-10 {
.emotion-4 {
font-family: -apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,Oxygen-Sans,Ubuntu,Cantarell,'Helvetica Neue',sans-serif;
font-size: 13px;
}

.emotion-8 {
.emotion-2 {
margin-bottom: 8px;
}

.components-panel__row .emotion-8 {
.components-panel__row .emotion-2 {
margin-bottom: inherit;
}

.emotion-6 {
.emotion-0 {
display: inline-block;
margin-bottom: 8px;
}
Expand Down Expand Up @@ -667,7 +631,7 @@ exports[`ColorPicker should render color picker 1`] = `
type="button"
/>
<div
className="components-visually-hidden emotion-0 emotion-1 emotion-2"
className="components-visually-hidden"
id="color-picker-saturation-0"
>
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.
Expand Down Expand Up @@ -727,7 +691,7 @@ exports[`ColorPicker should render color picker 1`] = `
tabIndex="0"
/>
<p
className="components-visually-hidden emotion-0 emotion-1 emotion-2"
className="components-visually-hidden"
id="components-color-picker__hue-description-0"
>
Move the arrow left or right to change hue.
Expand All @@ -744,13 +708,13 @@ exports[`ColorPicker should render color picker 1`] = `
className="components-color-picker__inputs-fields"
>
<div
className="components-base-control components-color-picker__inputs-field emotion-10 emotion-11"
className="components-base-control components-color-picker__inputs-field emotion-4 emotion-5"
>
<div
className="components-base-control__field emotion-8 emotion-9"
className="components-base-control__field emotion-2 emotion-3"
>
<label
className="components-base-control__label emotion-6 emotion-7"
className="components-base-control__label emotion-0 emotion-1"
htmlFor="inspector-text-control-0"
>
Color value in hexadecimal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import Button from '../button';
import ColorPicker from '../color-picker';
import Dropdown from '../dropdown';
import KeyboardShortcuts from '../keyboard-shortcuts';
import { VisuallyHidden } from '../visually-hidden';
import VisuallyHidden from '../visually-hidden';

import {
addControlPoint,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/external-link/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { external } from '@wordpress/icons';
/**
* Internal dependencies
*/
import { VisuallyHidden } from '../visually-hidden';
import VisuallyHidden from '../visually-hidden';
import { StyledIcon } from './styles/external-link-styles';

export function ExternalLink(
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/font-size-picker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Button from '../button';
import RangeControl from '../range-control';
import UnitControl from '../unit-control';
import CustomSelectControl from '../custom-select-control';
import { VisuallyHidden } from '../visually-hidden';
import VisuallyHidden from '../visually-hidden';

const DEFAULT_FONT_SIZE = 'default';
const CUSTOM_FONT_SIZE = 'custom';
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/form-token-field/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { closeSmall } from '@wordpress/icons';
* Internal dependencies
*/
import Button from '../button';
import { VisuallyHidden } from '../visually-hidden';
import VisuallyHidden from '../visually-hidden';

export default function Token( {
value,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export {
export { default as TreeSelect } from './tree-select';
export { Truncate as __experimentalTruncate } from './truncate';
export { default as __experimentalUnitControl } from './unit-control';
export { VisuallyHidden } from './visually-hidden';
export { default as VisuallyHidden } from './visually-hidden';
export { VStack as __experimentalVStack } from './v-stack';
export { default as IsolatedEventContainer } from './isolated-event-container';
export {
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/input-control/label.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { VisuallyHidden } from '../visually-hidden';
import VisuallyHidden from '../visually-hidden';
import { Label as BaseLabel } from './styles/input-control-styles';

export default function Label( {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ESCAPE } from '@wordpress/keycodes';
* Internal dependencies
*/
import Button from '../../button';
import { VisuallyHidden } from '../../visually-hidden';
import VisuallyHidden from '../../visually-hidden';
import withSpokenMessages from '../../higher-order/with-spoken-messages';
import { useNavigationMenuContext } from './context';
import { useNavigationContext } from '../context';
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,4 @@
@import "./toolbar-button/style.scss";
@import "./toolbar-group/style.scss";
@import "./tooltip/style.scss";
@import "./visually-hidden/style.scss";
4 changes: 2 additions & 2 deletions packages/components/src/ui/form-group/form-group-label.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { memo } from '@wordpress/element';
* Internal dependencies
*/
import { ControlLabel } from '../control-label';
import { VisuallyHidden } from '../../visually-hidden';
import VisuallyHidden from '../../visually-hidden';

/**
* @param {import('../context').ViewOwnProps<import('./types').FormGroupLabelProps, 'label'>} props
Expand All @@ -18,7 +18,7 @@ function FormGroupLabel( { children, id, labelHidden = false, ...props } ) {

if ( labelHidden ) {
return (
<VisuallyHidden as="label" htmlFor={ id?.toString() }>
<VisuallyHidden as="label" htmlFor={ id }>
{ children }
</VisuallyHidden>
);
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './elevation';
export * from './form-group';
export * from './shortcut';
export * from './spinner';
export * from './visually-hidden';
17 changes: 17 additions & 0 deletions packages/components/src/ui/visually-hidden/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# VisuallyHidden

`VisuallyHidden` is a component used to render text intended to be visually hidden, but will show for alternate devices, for example a screen reader.

## Usage

```jsx
import { View, VisuallyHidden } from '@wordpress/components/ui';

function Example() {
return (
<VisuallyHidden>
<View as="label">Code is Poetry</View>
</VisuallyHidden>
);
}
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Internal dependencies
*/
import { createComponent } from '../ui/utils';
import { createComponent } from '../utils';
import { useVisuallyHidden } from './hook';

/**
Expand All @@ -10,12 +10,12 @@ import { useVisuallyHidden } from './hook';
*
* @example
* ```jsx
* import { VisuallyHidden } from `@wordpress/components`;
* import { View, VisuallyHidden } from `@wordpress/components/ui`;
*
* function Example() {
* return (
* <VisuallyHidden>
* <label>Code is Poetry</label>
* <View as="label">Code is Poetry</View>
* </VisuallyHidden>
* );
* }
Expand Down
Loading