components/Compare
import { … } from 'zidane-ui'ui/src/components/Compare.tsx
Components#
CompareComponent#
Renders before and after values with their change, and a summary on top.
function Compare(props: CompareProps): ElementParameters
| Name | Type | Description |
|---|---|---|
| props | CompareProps |
Returns
ElementProps
| Name | Type | Default | Description |
|---|---|---|---|
| after? | string | The name of the second column. Default: the | |
| before? | string | The name of the first column. Default: the | |
| className? | string | Extra classes on the root element. | |
| format? | (value: number) => string | Formats a value. Default: the number in full, up to two decimals. | |
| goodWhen? | 'up' | 'down' | 'down' | Which way is good, for the color of a change. |
| mode? | 'bars' | 'table' | 'bars' |
|
| rows | readonly CompareRow[] | The rows, in order. | |
| style? | CSSProperties | Inline styles on the root element. | |
| title? | ReactNode | A title above the summary. | |
| unit? | string | The values' unit, for example |
Interfaces#
ComparePropsInterface#
Props for Compare.
interface ComparePropsProperties
| Name | Type | Default | Description |
|---|---|---|---|
| after? | string | The name of the second column. Default: the | |
| before? | string | The name of the first column. Default: the | |
| className? | string | Extra classes on the root element. | |
| format? | (value: number) => string | Formats a value. Default: the number in full, up to two decimals. | |
| goodWhen? | 'up' | 'down' | 'down' | Which way is good, for the color of a change. |
| mode? | 'bars' | 'table' | 'bars' |
|
| rows | readonly CompareRow[] | The rows, in order. | |
| style? | CSSProperties | Inline styles on the root element. | |
| title? | ReactNode | A title above the summary. | |
| unit? | string | The values' unit, for example |
CompareRowInterface#
One row: its label, the values before and after, and what the change came to.
interface CompareRowProperties
| Name | Type | Description |
|---|---|---|
| after | number | The value after. |
| before | number | The value before. |
| change | number | null | The relative change (0.1 is 10% more), or |
| label | string | What the row measures. |
| verdict | CompareVerdict | Whether the change is better, worse, or the same. |
Types#
CompareVerdictType#
What a row's change came to.
type CompareVerdict = 'better' | 'worse' | 'same'