import React from 'react'; import { QaheraTone, QaheraSize } from './types'; export interface ProgressProps extends React.HTMLAttributes { value?: number; // 0 to 100 max?: number; tone?: QaheraTone | 'primary' | 'luxury' | 'secondary' | 'purple'; size?: QaheraSize | 'xxs' | 'xl'; striped?: boolean; animated?: boolean; indeterminate?: boolean; vertical?: boolean; orientation?: 'horizontal' | 'vertical'; label?: string; showValue?: boolean; } export const Progress: React.FC = ({ value = 0, max = 100, tone = 'primary', size = 'md', striped = false, animated = false, indeterminate = false, vertical = false, orientation = 'horizontal', label, showValue = false, className = '', ...props }) => { const isVertical = vertical || orientation === 'vertical'; const percentage = indeterminate ? 0 : Math.min(Math.max(0, (value / max) * 100), 100); const classes = [ 'qhr-progress', `qhr-progress--${size}`, isVertical ? 'qhr-progress--vertical' : '', tone !== 'primary' ? `qhr-progress--${tone}` : '', striped ? 'qhr-progress--striped' : '', animated ? 'qhr-progress--animated' : '', indeterminate ? 'qhr-progress--indeterminate' : '', className, ].filter(Boolean).join(' '); const barStyle = indeterminate ? undefined : isVertical ? { height: `${percentage}%` } : { width: `${percentage}%` }; const bar = (
{!isVertical && size === 'xl' && showValue && `${Math.round(percentage)}%`}
); if (label || (showValue && size !== 'xl' && !isVertical)) { return (
{label && {label}} {showValue && !indeterminate && ( {Math.round(percentage)}% )}
{bar}
); } return bar; };