From c8f297a700626db63570b3674353ec751f78bf3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albert=20Juh=C3=A9=20Lluveras?= Date: Thu, 30 Jan 2020 11:04:39 +0100 Subject: [PATCH] All Products & filters accessibility improvements (https://github.com/woocommerce/woocommerce-blocks/pull/1656) * Add aria-label to All Products ratings * Add specific screen reader text to some buttons * Increase All Products regular price color constrast * Remove invalid CSS declaration * Make styleint-disable comment more specific * Attributes Filter: make input non-focusable if we display the 'change filter' button * Improve translator documentation * Hide price slider from screen readers if price inputs are enabled * Linting fixes * Price slider: make it non-focusable if input fields are displayed * All Products: announce how many products were found * All Products: announce when a filter is removed * Revert "All Products: announce when a filter is removed" This reverts commit 2c861bf1b988155313ad44bafbcaf3f4f1549296. * Pagination component: improve screen reader texts * Filter submit button: improve screen reader texts * Remove unnecessary text * Improve comment * Use %d for numeric values * Add label and screenReaderLabel props to FilterSubmitButton component --- .../atomic/components/product/rating/index.js | 16 +++++----- .../components/product/sale-badge/index.js | 9 +++++- .../components/dropdown-selector/index.js | 7 +++++ .../components/dropdown-selector/input.js | 2 ++ .../dropdown-selector/selected-value.js | 2 ++ .../components/filter-submit-button/index.js | 15 ++++++++-- .../js/base/components/pagination/index.js | 29 +++++++++++++++--- .../js/base/components/price-slider/index.js | 14 ++++++--- .../js/base/components/product-list/index.js | 30 +++++++++++++++++++ .../base/components/product-list/style.scss | 6 ++-- .../assets/js/blocks/active-filters/block.js | 20 +++++++++---- .../assets/js/blocks/active-filters/utils.js | 6 +++- 12 files changed, 126 insertions(+), 30 deletions(-) diff --git a/plugins/woocommerce-blocks/assets/js/atomic/components/product/rating/index.js b/plugins/woocommerce-blocks/assets/js/atomic/components/product/rating/index.js index b4681b09305..eee84a1b039 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/components/product/rating/index.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/components/product/rating/index.js @@ -18,6 +18,11 @@ const ProductRating = ( { className, product } ) => { width: ( rating / 5 ) * 100 + '%', }; + const ratingText = sprintf( + __( 'Rated %d out of 5', 'woo-gutenberg-products-block' ), + rating + ); + return (
{
- - { sprintf( - __( - 'Rated %d out of 5', - 'woo-gutenberg-products-block' - ), - rating - ) } - + { ratingText }
); diff --git a/plugins/woocommerce-blocks/assets/js/atomic/components/product/sale-badge/index.js b/plugins/woocommerce-blocks/assets/js/atomic/components/product/sale-badge/index.js index 9e64f7ccf98..3ee4bca4401 100644 --- a/plugins/woocommerce-blocks/assets/js/atomic/components/product/sale-badge/index.js +++ b/plugins/woocommerce-blocks/assets/js/atomic/components/product/sale-badge/index.js @@ -4,6 +4,7 @@ import { __ } from '@wordpress/i18n'; import classnames from 'classnames'; import { useProductLayoutContext } from '@woocommerce/base-context/product-layout-context'; +import Label from '@woocommerce/base-components/label'; const ProductSaleBadge = ( { className, product, align } ) => { const { layoutStyleClassPrefix } = useProductLayoutContext(); @@ -21,7 +22,13 @@ const ProductSaleBadge = ( { className, product, align } ) => { `${ layoutStyleClassPrefix }__product-onsale` ) } > - { __( 'Sale', 'woo-gutenberg-products-block' ) } +