import { Box, Flex, Text, chakra } from '@chakra-ui/react'; import React from 'react'; import type { Route } from 'nextjs-routes'; import { route } from 'nextjs-routes'; import { Link } from 'toolkit/chakra/link'; import { Skeleton } from 'toolkit/chakra/skeleton'; import { Hint } from 'toolkit/components/Hint/Hint'; import { TruncatedText } from 'toolkit/components/truncation/TruncatedText'; import IconSvg, { type IconName } from 'ui/shared/IconSvg'; export type Props = { className?: string; label: string; value: string | React.ReactNode; valuePrefix?: string; valuePostfix?: string; hint?: string | React.ReactNode; isLoading?: boolean; diff?: string | number; diffFormatted?: string; diffPeriod?: '24h'; period?: '1h' | '24h' | '30min'; href?: Route; icon?: IconName; isFallback?: boolean; }; const Container = ({ href, children, className }: { href?: Route; children: React.JSX.Element; className?: string }) => { if (href) { return ( { children } ); } return children; }; const StatsWidget = ({ className, icon, label, value, valuePrefix, valuePostfix, isLoading, hint, diff, diffPeriod = '24h', diffFormatted, period, href, isFallback, }: Props) => { return ( { icon && ( ) }

{ label }

{ valuePrefix && { valuePrefix } } { typeof value === 'string' ? ( ) : ( value ) } { valuePostfix && { valuePostfix } } { diff && Number(diff) > 0 && ( <> +{ diffFormatted || Number(diff).toLocaleString() } ({ diffPeriod }) ) } { period && ({ period }) }
{ typeof hint === 'string' ? ( ) : hint }
); }; export default chakra(StatsWidget);