woocommerce/plugins/woocommerce-admin/client/components/count/index.js

45 lines
771 B
JavaScript
Raw Normal View History

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