Skip to content

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.

TypeScript
function Compare(props: CompareProps): Element
Parameters
NameTypeDescription
propsCompareProps

CompareProps.

Element
Compare props
NameTypeDefaultDescription
after?string

The name of the second column. Default: the compareAfter label.

before?string

The name of the first column. Default: the compareBefore label.

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. down: a drop is better (time, cost). up: a rise is better.

mode?'bars' | 'table''bars'

bars: a bar per row for its change, either side of a zero line. table: numbers only.

rowsreadonly 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 ms (see withUnit).

ui/src/components/Compare.tsx:161

Interfaces#

ComparePropsInterface#

Props for Compare.

TypeScript
interface CompareProps
CompareProps properties
NameTypeDefaultDescription
after?string

The name of the second column. Default: the compareAfter label.

before?string

The name of the first column. Default: the compareBefore label.

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. down: a drop is better (time, cost). up: a rise is better.

mode?'bars' | 'table''bars'

bars: a bar per row for its change, either side of a zero line. table: numbers only.

rowsreadonly 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 ms (see withUnit).

ui/src/components/Compare.tsx:42

CompareRowInterface#

One row: its label, the values before and after, and what the change came to.

TypeScript
interface CompareRow
CompareRow properties
NameTypeDescription
afternumber

The value after.

beforenumber

The value before.

changenumber | null

The relative change (0.1 is 10% more), or null when only the plain difference reads (from 0).

labelstring

What the row measures.

verdictCompareVerdict

Whether the change is better, worse, or the same.

ui/src/components/Compare.tsx:28

Types#

CompareVerdictType#

What a row's change came to.

TypeScript
type CompareVerdict = 'better' | 'worse' | 'same'

ui/src/components/Compare.tsx:25