woocommerce/plugins/woocommerce-blocks/assets/js/blocks/cart-checkout/cart/full-cart/cart-line-items-title.js

36 lines
847 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* External dependencies
*/
import { __, sprintf, _n } from '@wordpress/i18n';
import PropTypes from 'prop-types';
import Title from '@woocommerce/base-components/title';
const CartLineItemsTitle = ( {
title = __( 'Shopping cart', 'woo-gutenberg-products-block' ),
itemCount = 1,
} ) => {
const itemCountHeading = sprintf(
_n( '%d item', '%d items', itemCount, 'woo-gutenberg-products-block' ),
itemCount
);
const readableHeading = `${ title } ${ itemCountHeading }`;
return (
<Title headingLevel="2" aria-label={ readableHeading }>
<span>{ title } </span>
{ !! itemCount && (
<span className="wc-block-cart__item-count">
{ itemCountHeading }
</span>
) }
</Title>
);
};
CartLineItemsTitle.propTypes = {
title: PropTypes.string,
itemCount: PropTypes.number,
};
export default CartLineItemsTitle;