/** * ProgressBar 进度条组件 * 用于审核进度展示 */ import React from 'react'; export interface ProgressBarProps { value: number; // 0-100 max?: number; showLabel?: boolean; size?: 'sm' | 'md' | 'lg'; variant?: 'default' | 'success' | 'warning' | 'error'; className?: string; } const sizeStyles = { sm: 'h-1', md: 'h-2', lg: 'h-3', }; const variantStyles = { default: 'bg-accent-indigo', success: 'bg-accent-green', warning: 'bg-accent-amber', error: 'bg-accent-coral', }; export const ProgressBar: React.FC = ({ value, max = 100, showLabel = false, size = 'md', variant = 'default', className = '', }) => { const percentage = Math.min(100, Math.max(0, (value / max) * 100)); return (
{showLabel && (
进度 {Math.round(percentage)}%
)}
); }; // 环形进度条 (用于审核中状态) export interface CircularProgressProps { value: number; // 0-100 size?: number; strokeWidth?: number; variant?: 'default' | 'success' | 'warning' | 'error'; showLabel?: boolean; label?: string; className?: string; } const circularVariantColors = { default: '#6366F1', success: '#32D583', warning: '#F59E0B', error: '#E85A4F', }; export const CircularProgress: React.FC = ({ value, size = 120, strokeWidth = 8, variant = 'default', showLabel = true, label, className = '', }) => { const percentage = Math.min(100, Math.max(0, value)); const radius = (size - strokeWidth) / 2; const circumference = radius * 2 * Math.PI; const offset = circumference - (percentage / 100) * circumference; return (
{/* Background circle */} {/* Progress circle */} {showLabel && (
{Math.round(percentage)}% {label && ( {label} )}
)}
); }; export default ProgressBar;