import React, { ReactNode } from 'react'; import cx from 'classnames'; import { FlexStack } from '../../layout/flex-stack'; import { Stack } from '../../layout/stack'; import { HoverCard } from '../../ui/hover-card'; import { Table } from '../../ui/table'; import css from './metric-change-legend.module.css'; import { Separator } from '../../layout'; type ChangeKind = 'improvement' | 'regression' | 'neutral' | 'no-change'; type ChangeKindVariant = 'low' | 'medium' | 'high'; type BarProps = { className?: string; kind: ChangeKind; variants: ChangeKindVariant[]; size?: 'medium' | 'large'; }; const Variants = (props: BarProps) => { const { className, kind, variants, size = 'medium' } = props; return ( {variants.map((variant) => ( ))} ); }; type ChangeMagnitudeInfoProps = { kind: 'improvement' | 'regression'; impact: string; }; const ChangeMagnitudeInfo = (props: ChangeMagnitudeInfoProps) => { const { kind, impact } = props; return (

Changes flagged as {kind}s have a {impact} impact on user performance.

The report shows different intensity colors depending on the magnitude of the percentage change.

Change is smaller or equal than 5% Change is smaller or equal than 50% Change is larger than 50%
); }; const ImprovementInfo = () => ; const RegressionInfo = () => ; const NeutralInfo = () => (

Neutral changes do not have a clear positive or negative impact on user performance.

); const NoChangeInfo = () => (

The metric value is unchanged between the compared builds.

); type ChangeConfig = { id: ChangeKind; label: string; variants: ChangeKindVariant[]; info: ReactNode; }; const ITEMS: ChangeConfig[] = [ { id: 'improvement', label: 'Improvement', variants: ['low', 'medium', 'high'], info: , }, { id: 'regression', label: 'Regression', variants: ['low', 'medium', 'high'], info: , }, { id: 'neutral', label: 'Neutral', variants: ['medium'], info: , }, { id: 'no-change', label: 'No change', variants: ['medium'], info: , }, ]; export interface MetricChangeLegendProps extends React.ComponentProps<'div'> {} export const MetricChangeLegend = (props: MetricChangeLegendProps) => { const { className, ...restProps } = props; return ( {ITEMS.map(({ id, variants, label, info }) => ( {label} } > {info} ))} ); };