Add loading indicators, error state, and EmptyContent to the revenue report. (#347, woocommerce/woocommerce-admin#348)
* Add loading indiciators for the revenue report.
* Improve accessibility, and fix up some documentation comments.
* Fix top border on mobile
* Add EmptyContent Component and revenue error/empty states. (https://github.com/woocommerce/woocommerce-admin/pull/348)
* Add EmptyContent Component and revenue error/empty states.
* Move relative image handling to ImageAsset, combine secondary and primary action rendering, add some missing isRequired proptypes, add empty error handling.
* Handle PR Feedback: Clean up button css, set a default for illustration, fix deprecation typo, some code cleanup.
2018-09-05 16:45:49 +00:00
|
|
|
/** @format */
|
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { Component } from '@wordpress/element';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
import { range } from 'lodash';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-11-02 19:20:11 +00:00
|
|
|
import { withViewportMatch } from '@wordpress/viewport';
|
Add loading indicators, error state, and EmptyContent to the revenue report. (#347, woocommerce/woocommerce-admin#348)
* Add loading indiciators for the revenue report.
* Improve accessibility, and fix up some documentation comments.
* Fix top border on mobile
* Add EmptyContent Component and revenue error/empty states. (https://github.com/woocommerce/woocommerce-admin/pull/348)
* Add EmptyContent Component and revenue error/empty states.
* Move relative image handling to ImageAsset, combine secondary and primary action rendering, add some missing isRequired proptypes, add empty error handling.
* Handle PR Feedback: Clean up button css, set a default for illustration, fix deprecation typo, some code cleanup.
2018-09-05 16:45:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* `SummaryListPlaceholder` behaves like `SummaryList` but displays placeholder summary items instead of data.
|
|
|
|
* This can be used while loading data.
|
|
|
|
*/
|
|
|
|
class SummaryListPlaceholder extends Component {
|
|
|
|
render() {
|
2018-11-02 19:20:11 +00:00
|
|
|
const { isDropdownBreakpoint } = this.props;
|
Add loading indicators, error state, and EmptyContent to the revenue report. (#347, woocommerce/woocommerce-admin#348)
* Add loading indiciators for the revenue report.
* Improve accessibility, and fix up some documentation comments.
* Fix top border on mobile
* Add EmptyContent Component and revenue error/empty states. (https://github.com/woocommerce/woocommerce-admin/pull/348)
* Add EmptyContent Component and revenue error/empty states.
* Move relative image handling to ImageAsset, combine secondary and primary action rendering, add some missing isRequired proptypes, add empty error handling.
* Handle PR Feedback: Clean up button css, set a default for illustration, fix deprecation typo, some code cleanup.
2018-09-05 16:45:49 +00:00
|
|
|
const numberOfItems = isDropdownBreakpoint ? 1 : this.props.numberOfItems;
|
|
|
|
|
|
|
|
const hasItemsClass = numberOfItems < 10 ? `has-${ numberOfItems }-items` : 'has-10-items';
|
|
|
|
const classes = classnames( 'woocommerce-summary', {
|
|
|
|
[ hasItemsClass ]: ! isDropdownBreakpoint,
|
|
|
|
'is-placeholder': true,
|
|
|
|
} );
|
|
|
|
|
|
|
|
const rows = range( numberOfItems ).map( i => {
|
|
|
|
return (
|
|
|
|
<li className="woocommerce-summary__item-container is-placeholder" key={ i }>
|
|
|
|
<span className="woocommerce-summary__item">
|
|
|
|
<span className="woocommerce-summary__item-label" />
|
|
|
|
<span className="woocommerce-summary__item-data">
|
|
|
|
<span className="woocommerce-summary__item-value" />
|
|
|
|
<div className="woocommerce-summary__item-delta">
|
|
|
|
<span className="woocommerce-summary__item-delta-value" />
|
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
<span className="woocommerce-summary__item-prev-label" />
|
|
|
|
<span className="woocommerce-summary__item-prev-value" />
|
|
|
|
</span>
|
|
|
|
</li>
|
|
|
|
);
|
|
|
|
} );
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ul className={ classes } aria-hidden="true">
|
|
|
|
{ rows }
|
|
|
|
</ul>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SummaryListPlaceholder.propTypes = {
|
|
|
|
/**
|
|
|
|
* An integer with the number of summary items to display.
|
|
|
|
*/
|
|
|
|
numberOfItems: PropTypes.number.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
SummaryListPlaceholder.defaultProps = {
|
|
|
|
numberOfRows: 5,
|
|
|
|
};
|
|
|
|
|
2018-11-02 19:20:11 +00:00
|
|
|
export default withViewportMatch( {
|
|
|
|
isDropdownBreakpoint: '< large',
|
|
|
|
} )( SummaryListPlaceholder );
|