How to use @wordpress/a11y - 10 common examples

To help you get started, we’ve selected a few @wordpress/a11y examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yoast / wordpress-seo / js / src / structured-data-blocks / how-to / components / HowTo.js View on Github external
id: HowTo.generateId( "how-to-step" ),
			name,
			text,
			jsonName: "",
			jsonText: "",
		} );

		this.props.setAttributes( { steps } );

		if ( focus ) {
			setTimeout( this.setFocus.bind( this, `${ index + 1 }:name` ) );
			// When moving focus to a newly created step, return and don't use the speak() messaage.
			return;
		}

		speak( __( "New step added", "wordpress-seo" ) );
	}
github php4dev / heroku-wordpress / wp-content / plugins / woocommerce / packages / woocommerce-blocks / assets / js / base / components / product-list / index.js View on Github external
const announceLoadingCompletion = ( totalProducts ) => {
	if ( ! Number.isFinite( totalProducts ) ) {
		return;
	}

	if ( totalProducts === 0 ) {
		speak( __( 'No products found', 'woocommerce' ) );
	} else {
		speak(
			sprintf(
				// translators: %s is an integer higher than 0 (1, 2, 3...)
				_n(
					'%d product found',
					'%d products found',
					totalProducts,
					'woocommerce'
				),
				totalProducts
			)
		);
	}
};
github Automattic / vip-go-mu-plugins-built / jetpack / extensions / blocks / podcast-player / components / podcast-player.js View on Github external
// Record that user has interacted.
		this.recordUserInteraction();

		const trackData = this.getTrack( track );
		if ( ! trackData ) {
			return;
		}

		this.setState( { currentTrack: track } );
		this.setAudioSource( trackData.src );

		/*
		 * Read that we're loading the track and its description. This is
		 * dismissible via ctrl on VoiceOver.
		 */
		speak(
			/* translators: %s is the track title. It describes the current state of
			the track as "Loading: [track title]". */
			`${ sprintf( __( 'Loading: %s', 'jetpack' ), trackData.title ) } ${ trackData.description }`,
			'assertive'
		);

		this.play();
	};
github Automattic / wp-calypso / client / gutenberg / editor / edit-post / store / effects.js View on Github external
SWITCH_MODE( action ) {
		// Unselect blocks when we switch to the code editor.
		if ( action.mode !== 'visual' ) {
			dispatch( 'core/editor' ).clearSelectedBlock();
		}

		const message =
			action.mode === 'visual' ? __( 'Visual editor selected' ) : __( 'Code editor selected' );
		speak( message, 'assertive' );
	},
	INIT( _, store ) {
github php4dev / heroku-wordpress / wp-content / plugins / woocommerce / packages / woocommerce-blocks / assets / js / blocks / attribute-filter / block.js View on Github external
filterRemovedName
						)
					);
				} else if ( filterAddedName ) {
					speak(
						sprintf(
							// translators: %s attribute term (for example: 'red', 'blue', 'large'...)
							__(
								'%s filter added.',
								'woocommerce'
							),
							filterAddedName
						)
					);
				} else if ( filterRemovedName ) {
					speak(
						sprintf(
							// translators: %s attribute term (for example: 'red', 'blue', 'large'...)
							__(
								'%s filter removed.',
								'woocommerce'
							),
							filterRemovedName
						)
					);
				}
			};
github php4dev / heroku-wordpress / wp-content / plugins / woocommerce / packages / woocommerce-blocks / assets / js / base / components / product-list / index.js View on Github external
const announceLoadingCompletion = ( totalProducts ) => {
	if ( ! Number.isFinite( totalProducts ) ) {
		return;
	}

	if ( totalProducts === 0 ) {
		speak( __( 'No products found', 'woocommerce' ) );
	} else {
		speak(
			sprintf(
				// translators: %s is an integer higher than 0 (1, 2, 3...)
				_n(
					'%d product found',
					'%d products found',
					totalProducts,
					'woocommerce'
				),
				totalProducts
			)
		);
	}
};
github php4dev / heroku-wordpress / wp-content / plugins / woo-gutenberg-products-block / assets / js / blocks / attribute-filter / block.js View on Github external
const announceFilterChange = ( { filterAdded, filterRemoved } ) => {
				const filterAddedName = filterAdded
					? getFilterNameFromValue( filterAdded )
					: null;
				const filterRemovedName = filterRemoved
					? getFilterNameFromValue( filterRemoved )
					: null;
				if ( filterAddedName && filterRemovedName ) {
					speak(
						sprintf(
							__(
								// translators: %s attribute terms (for example: 'red', 'blue', 'large'...)
								'%s filter replaced with %s.',
								'woo-gutenberg-products-block'
							),
							filterAddedName,
							filterRemovedName
						)
					);
				} else if ( filterAddedName ) {
					speak(
						sprintf(
							// translators: %s attribute term (for example: 'red', 'blue', 'large'...)
							__(
								'%s filter added.',
github getblocklab / block-lab / js / migration / components / steps / install-activate-gcb.js View on Github external
} ).catch( ( result ) => {
			speak( __( 'The installation and activation failed with the following error:', 'block-lab' ) );
			if ( result.hasOwnProperty( 'message' ) ) {
				speak( result.message );
				setErrorMessage( result.message );
			}
			setIsSuccess( false );
			setIsError( true );
		} );
github php4dev / heroku-wordpress / wp-content / plugins / woocommerce / packages / woocommerce-blocks / assets / js / blocks / reviews / frontend-container-block.js View on Github external
onReviewsAppended( { newReviews } ) {
		speak(
			sprintf(
				_n(
					'%d review loaded.',
					'%d reviews loaded.',
					newReviews.length,
					'woocommerce'
				),
				newReviews.length
			)
		);
	}
github getblocklab / block-lab / js / migration / components / steps / install-activate-gcb.js View on Github external
} ).catch( ( result ) => {
			speak( __( 'The installation and activation failed with the following error:', 'block-lab' ) );
			if ( result.hasOwnProperty( 'message' ) ) {
				speak( result.message );
				setErrorMessage( result.message );
			}
			setIsSuccess( false );
			setIsError( true );
		} );

@wordpress/a11y

Accessibility (a11y) utilities for WordPress.

GPL-2.0-or-later
Latest version published 17 days ago

Package Health Score

95 / 100
Full package analysis

Popular @wordpress/a11y functions