Skip to content

Commit

Permalink
Use VisuallyHidden component to render hidden text (#6570)
Browse files Browse the repository at this point in the history
Co-authored-by: Pierre Gordon <pierregordon@protonmail.com>
Co-authored-by: Piotr Delawski <piotr.delawski@gmail.com>
  • Loading branch information
3 people committed Aug 27, 2021
1 parent 2a43bda commit d4d2a7b
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 21 deletions.
6 changes: 3 additions & 3 deletions assets/src/block-editor/components/amp-preview-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import PropTypes from 'prop-types';
/**
* WordPress dependencies
*/
import { Button, Icon } from '@wordpress/components';
import { Button, Icon, VisuallyHidden } from '@wordpress/components';
import { compose } from '@wordpress/compose';
import { withDispatch, withSelect } from '@wordpress/data';
import { Component, createRef, renderToString } from '@wordpress/element';
Expand Down Expand Up @@ -226,12 +226,12 @@ class AmpPreviewButton extends Component {
ref={ this.buttonRef }
>
{ ampFilledIcon( { viewBox: '0 0 62 62', width: 18, height: 18 } ) }
<span className="screen-reader-text">
<VisuallyHidden as="span">
{
/* translators: accessibility text */
__( '(opens in a new tab)', 'amp' )
}
</span>
</VisuallyHidden>
</Button>
);
}
Expand Down
6 changes: 3 additions & 3 deletions assets/src/components/amp-drawer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { PanelBody } from '@wordpress/components';
import { PanelBody, VisuallyHidden } from '@wordpress/components';
import { useEffect, useState } from '@wordpress/element';

/**
Expand Down Expand Up @@ -101,9 +101,9 @@ export function AMPDrawer( { children = null, className, heading, handleType = H
{ 'resetting' !== resetStatus && (
<PanelBody
title={ handleType === HANDLE_TYPE_RIGHT ? (
<span className="components-visually-hidden">
<VisuallyHidden as="span">
{ hiddenTitle }
</span>
</VisuallyHidden>
) : (
<div className="amp-drawer__heading">
{ heading }
Expand Down
4 changes: 4 additions & 0 deletions assets/src/components/amp-drawer/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@
border-bottom-width: 0;
}

.amp .amp-drawer__panel-body .components-panel__body-toggle {
padding: 0;
}

.amp-drawer__panel-body-inner {
border-top: 1px solid var(--amp-settings-color-border);
}
Expand Down
18 changes: 9 additions & 9 deletions assets/src/components/carousel/carousel-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import classnames from 'classnames';
/**
* WordPress dependencies
*/
import { Button } from '@wordpress/components';
import { Button, VisuallyHidden } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
Expand All @@ -33,13 +33,13 @@ function Dot( { id, isHighlighted, label, namespace, onClick } ) {
onClick={ onClick }
aria-label={ label }
>
<span className="components-visually-hidden">
<VisuallyHidden as="span">
{ label }
</span>
</VisuallyHidden>
{ isHighlighted && (
<span className="components-visually-hidden">
<VisuallyHidden as="span">
{ __( '(Selected item)', 'amp' ) }
</span>
</VisuallyHidden>
) }
<span className={ `${ namespace }__nav-dot` } />
</Button>
Expand Down Expand Up @@ -88,9 +88,9 @@ export function CarouselNav( {
className={ `${ namespace }__prev` }
aria-label={ __( 'Previous', 'amp' ) }
>
<span className="components-visually-hidden">
<VisuallyHidden as="span">
{ __( 'Previous', 'amp' ) }
</span>
</VisuallyHidden>
<svg width="12" height="11" viewBox="0 0 12 11" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.47729 1.19531L1.18289 5.48906L5.47729 9.78347" stroke="#FAFAFC" strokeWidth="2" strokeLinejoin="round" />
<path d="M1.15854 5.48828L10.281 5.48828" stroke="#FAFAFC" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
Expand Down Expand Up @@ -132,9 +132,9 @@ export function CarouselNav( {
className={ `${ namespace }__next` }
aria-label={ __( 'Next', 'amp' ) }
>
<span className="components-visually-hidden">
<VisuallyHidden as="span">
{ __( 'Next', 'amp' ) }
</span>
</VisuallyHidden>
<svg width="12" height="11" viewBox="0 0 12 11" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.95255 1.19531L10.247 5.48906L5.95255 9.78347" stroke="#FAFAFC" strokeWidth="2" strokeLinejoin="round" />
<path d="M10.2712 5.48828L1.14868 5.48828" stroke="#FAFAFC" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions assets/src/settings-page/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { v4 as uuidv4 } from 'uuid';
import { __, sprintf } from '@wordpress/i18n';
import { useContext, useEffect, useRef } from '@wordpress/element';
import { Icon, plus, trash } from '@wordpress/icons';
import { Button, TextControl, PanelRow, BaseControl } from '@wordpress/components';
import { Button, TextControl, PanelRow, BaseControl, VisuallyHidden } from '@wordpress/components';

/**
* Internal dependencies
Expand Down Expand Up @@ -264,9 +264,9 @@ export function Analytics() {
} );
} }
>
<span className="screen-reader-text">
<VisuallyHidden as="span">
{ __( 'Add entry', 'amp' ) }
</span>
</VisuallyHidden>
<Icon icon={ plus } />
</Button>
</div>
Expand Down

0 comments on commit d4d2a7b

Please sign in to comment.