Back to Woocommerce

README

packages/js/components/src/summary/README.md

10.8.0-dev3.1 KB
Original Source

SummaryList

A container element for a list of SummaryNumbers. This component handles detecting & switching to the mobile format on smaller screens.

Usage

jsx
<SummaryList>
	{ () => {
		return [
			<SummaryNumber
				key="revenue"
				value={ '$829.40' }
				label="Total sales"
				delta={ 29 }
				href="/analytics/report"
			>
				<span>27 orders</span>
			</SummaryNumber>,
			<SummaryNumber
				key="refunds"
				value={ '$24.00' }
				label="Refunds"
				delta={ -10 }
				href="/analytics/report"
				selected
			/>,
		];
	} }
</SummaryList>

Props

NameTypeDefaultDescription
childrenFunctionnull(required) A function returning a list of <SummaryNumber />s
labelString__( 'Performance Indicators', 'woocommerce' )An optional label of this group, read to screen reader users

SummaryNumber

A component to show a value, label, and optionally a change percentage and children node. Can also act as a link to a specific report focus.

Usage

See above

Props

NameTypeDefaultDescription
deltaNumbernullA number to represent the percentage change since the last comparison period - positive numbers will show a green up arrow, negative numbers will show a red down arrow, and zero will show a flat right arrow. If omitted, no change value will display
hrefString''An internal link to the report focused on this number
isOpenBooleanfalseBoolean describing whether the menu list is open. Only applies in mobile view, and only applies to the toggle-able item (first in the list)
labelStringnull(required) A string description of this value, ex "Revenue", or "New Customers"
onToggleFunctionnullA function used to switch the given SummaryNumber to a button, and called on click
prevLabelString__( 'Previous period:', 'woocommerce' )A string description of the previous value's timeframe, ex "Previous year:"
prevValueOne of type: number, stringnullA string or number value to display - a string is allowed so we can accept currency formatting. If omitted, this section won't display
reverseTrendBooleanfalseA boolean used to indicate that a negative delta is "good", and should be styled like a positive (and vice-versa)
selectedBooleanfalseA boolean used to show a highlight style on this number
valueOne of type: number, stringnullA string or number value to display - a string is allowed so we can accept currency formatting
onLinkClickCallbackFunctionnoopA function to be called after a SummaryNumber, rendered as a link, is clicked

SummaryListPlaceholder

SummaryListPlaceholder behaves like SummaryList but displays placeholder summary items instead of data. This can be used while loading data.

Usage

jsx
<SummaryListPlaceholder numberOfItems={ 2 } />

Props

NameTypeDefaultDescription
numberOfItemsNumbernull(required) An integer with the number of summary items to display
numberOfRows5