components/Stat
import { … } from 'zidane-ui'ui/src/components/Stat.tsx
Components#
DeltaComponent#
Renders a signed change with an arrow, toned by whether the change is good. Its accessible name says the direction in words (Up 12%, Down 5%, No change).
function Delta(props: DeltaProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | DeltaProps |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| format? | (abs: number) => string | Formats the size of the change (no sign). Default: up to one decimal, in the labels' | |
| good? | 'up' | 'down' | 'none' | 'up' | Which way is good. |
| style? | CSSProperties | Inline styles on the root element. | |
| tone? | DeltaTone | Sets the tone, whatever the sign. | |
| unit? | string | Text after the number, for example | |
| value | number | The signed change, for example |
StatComponent#
Renders one number: its label, the value large, then the optional line. The label comes first, so a screen reader says what the number is before it.
function Stat(props: StatProps): ElementReturns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| delta? | ReactNode | A change beside the value, usually a | |
| label | ReactNode | What the number is, for example "Cost". | |
| size? | StatSize | 'stat' |
|
| style? | CSSProperties | Inline styles on the root element. | |
| sub? | ReactNode | A line under the value, for example "40.6k to 19.7k tokens". | |
| title? | string | A native tooltip on the value. | |
| tone? | StatTone | 'neutral' | Colors the value with a status tone. |
| value | ReactNode | The number, formatted. |
StatRowComponent#
Renders stats side by side as a list, each one an item.
function StatRow(props: StatRowProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | StatRowProps |
Returns
ElementProps
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The stats, usually |
| className? | string | Extra classes on the root element. |
| columns? | 2 | 1 | 3 | 4 | 5 | 6 | A fixed number of columns. Default: as many as fit, each at least 8rem wide, so a few stats stay in one row and wrap only when narrow. |
| framed? | boolean | Set the row in a tray. Off inside a surface that is already a tray. |
| label? | string | Accessible name of the list. |
| style? | CSSProperties | Inline styles on the root element. |
| tiles? | boolean | Set each stat in its own tile ( |
Functions#
deltaToneFunction#
The tone a change reads in: a rise is positive when up is good, a drop when down is good.
Constants#
STAT_ROW_COLUMNSConstant#
The default columns: as many as fit, each at least 8rem wide (or the whole row when narrower).
const STAT_ROW_COLUMNS = 'repeat(auto-fit, minmax(min(100%, 8rem), 1fr))'Interfaces#
DeltaPropsInterface#
Props for Delta.
interface DeltaPropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| format? | (abs: number) => string | Formats the size of the change (no sign). Default: up to one decimal, in the labels' | |
| good? | 'up' | 'down' | 'none' | 'up' | Which way is good. |
| style? | CSSProperties | Inline styles on the root element. | |
| tone? | DeltaTone | Sets the tone, whatever the sign. | |
| unit? | string | Text after the number, for example | |
| value | number | The signed change, for example |
StatPropsInterface#
Props for Stat.
interface StatPropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| className? | string | Extra classes on the root element. | |
| delta? | ReactNode | A change beside the value, usually a | |
| label | ReactNode | What the number is, for example "Cost". | |
| size? | StatSize | 'stat' |
|
| style? | CSSProperties | Inline styles on the root element. | |
| sub? | ReactNode | A line under the value, for example "40.6k to 19.7k tokens". | |
| title? | string | A native tooltip on the value. | |
| tone? | StatTone | 'neutral' | Colors the value with a status tone. |
| value | ReactNode | The number, formatted. |
StatRowPropsInterface#
Props for StatRow.
interface StatRowPropsProperties
| Name | Type | Description |
|---|---|---|
| children | ReactNode | The stats, usually |
| className? | string | Extra classes on the root element. |
| columns? | 2 | 1 | 3 | 4 | 5 | 6 | A fixed number of columns. Default: as many as fit, each at least 8rem wide, so a few stats stay in one row and wrap only when narrow. |
| framed? | boolean | Set the row in a tray. Off inside a surface that is already a tray. |
| label? | string | Accessible name of the list. |
| style? | CSSProperties | Inline styles on the root element. |
| tiles? | boolean | Set each stat in its own tile ( |
Types#
DeltaToneType#
How a Delta reads: good news, bad news, or neither.
type DeltaTone = 'positive' | 'negative' | 'neutral'StatSizeType#
How large a Stat's value draws.
type StatSize = 'stat' | 'headline'StatToneType#
The status tone of a Stat's value.
type StatTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger'