Some checks failed
CI / lint-typecheck (pull_request) Failing after 10s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { LucideIcon } from 'lucide-react';
|
|
import { Box } from './Box';
|
|
import { Icon } from './Icon';
|
|
import { Surface } from './Surface';
|
|
import { Text } from './Text';
|
|
|
|
export interface StatBoxProps {
|
|
label: string;
|
|
value: string | number;
|
|
icon: LucideIcon;
|
|
intent?: 'primary' | 'success' | 'warning' | 'critical' | 'telemetry' | 'low';
|
|
color?: string;
|
|
}
|
|
|
|
export const StatBox = ({
|
|
label,
|
|
value,
|
|
icon,
|
|
intent = 'primary',
|
|
color
|
|
}: StatBoxProps) => {
|
|
return (
|
|
<Surface variant="muted" rounded="xl" padding={4} style={{ border: '1px solid var(--ui-color-border-default)' }}>
|
|
<Box display="flex" alignItems="center" gap={4}>
|
|
<Box padding={2} rounded="lg" bg="var(--ui-color-bg-surface-muted)" style={color ? { color } : undefined}>
|
|
<Icon icon={icon} size={5} intent={color ? undefined : intent} />
|
|
</Box>
|
|
<Box>
|
|
<Text data-testid={`stat-label-${label.toLowerCase().replace(/\s+/g, '-')}`} size="xs" weight="bold" variant="low" uppercase>
|
|
{label}
|
|
</Text>
|
|
<Text data-testid={`stat-value-${label.toLowerCase().replace(/\s+/g, '-')}`} size="xl" weight="bold" variant="high" block marginTop={0.5}>
|
|
{value}
|
|
</Text>
|
|
</Box>
|
|
</Box>
|
|
</Surface>
|
|
);
|
|
};
|