2018-05-21 00:12:40 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
2018-06-01 14:39:48 +00:00
|
|
|
import { __, sprintf } from '@wordpress/i18n';
|
2018-05-21 00:12:40 +00:00
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import './style.scss';
|
|
|
|
|
2018-08-31 17:27:21 +00:00
|
|
|
/**
|
|
|
|
* Display a number with a styled border.
|
|
|
|
*
|
|
|
|
* @return { object } -
|
|
|
|
*/
|
2018-06-01 14:39:48 +00:00
|
|
|
const Count = ( { count, label } ) => {
|
|
|
|
if ( ! label ) {
|
2018-07-10 12:48:06 +00:00
|
|
|
label = sprintf( __( 'Total %d', 'wc-admin' ), count );
|
2018-06-01 14:39:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<span className="woocommerce-count" aria-label={ label }>
|
|
|
|
{ count }
|
|
|
|
</span>
|
|
|
|
);
|
2018-05-21 00:12:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Count.propTypes = {
|
2018-08-31 17:27:21 +00:00
|
|
|
/**
|
|
|
|
* Value of the number to be displayed.
|
|
|
|
*/
|
2018-05-21 00:12:40 +00:00
|
|
|
count: PropTypes.number.isRequired,
|
2018-08-31 17:27:21 +00:00
|
|
|
/**
|
|
|
|
* A translated label with the number in context, used for screen readers.
|
|
|
|
*/
|
2018-06-01 14:39:48 +00:00
|
|
|
label: PropTypes.string,
|
|
|
|
};
|
|
|
|
|
|
|
|
Count.defaultProps = {
|
|
|
|
label: '',
|
2018-05-21 00:12:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Count;
|