/** @format */ /** * External dependencies */ import { __, sprintf } from '@wordpress/i18n'; import { Button } from '@wordpress/components'; import classnames from 'classnames'; import Gridicon from 'gridicons'; import { isUndefined } from 'lodash'; import PropTypes from 'prop-types'; /** * External dependencies */ import Link from 'components/link'; const SummaryNumber = ( { delta, href, label, onToggle, prevLabel, prevValue, reverseTrend, selected, value, } ) => { const liClasses = classnames( 'woocommerce-summary__item-container', { 'is-dropdown-button': onToggle, } ); const classes = classnames( 'woocommerce-summary__item', { 'is-selected': selected, 'is-good-trend': reverseTrend ? delta < 0 : delta > 0, 'is-bad-trend': reverseTrend ? delta > 0 : delta < 0, } ); let icon = delta > 0 ? 'arrow-up' : 'arrow-down'; let screenReaderLabel = delta > 0 ? sprintf( __( 'Up %d%% from %s', 'wc-admin' ), delta, prevLabel ) : sprintf( __( 'Down %d%% from %s', 'wc-admin' ), Math.abs( delta ), prevLabel ); if ( ! delta ) { // delta is zero or falsey icon = 'arrow-right'; screenReaderLabel = sprintf( __( 'No change from %s', 'wc-admin' ), prevLabel ); } const Container = onToggle ? Button : Link; const containerProps = { className: classes, 'aria-current': selected ? 'page' : null, }; if ( ! onToggle ) { containerProps.href = href; containerProps.role = 'menuitem'; } else { containerProps.onClick = onToggle; } return (