import type { HTMLAttributes } from 'react'; import { cx } from '../utils/cx'; import type { Size, Tone } from '../utils/types'; export { Spinner, type SpinnerProps } from './Spinner'; export interface SkeletonProps extends HTMLAttributes { variant?: 'text' | 'rect' | 'circle'; width?: number | string; height?: number | string; lines?: number; } export function Skeleton({ variant = 'text', width, height, lines = 1, className, style, ...rest }: SkeletonProps) { if (variant === 'text' && lines > 1) { return ( {Array.from({ length: lines }, (_, index) => ( ))} ); } return ( ); } export interface ProgressProps extends Omit, 'children'> { /** Omit for an indeterminate bar. */ value?: number; max?: number; size?: Exclude; tone?: Extract; label?: string; showValue?: boolean; } export function Progress({ value, max = 100, size = 'md', tone = 'accent', label, showValue = false, className, ...rest }: ProgressProps) { const indeterminate = value === undefined; const percent = indeterminate ? 0 : Math.min(100, Math.max(0, (value / max) * 100)); return ( {(label || showValue) && ( {label && {label}} {showValue && !indeterminate && ( {Math.round(percent)}% )} )} ); }