turash/bugulma/frontend/components/ui/Progress.tsx
Damir Mukimov 673e8d4361
Some checks failed
CI/CD Pipeline / backend-lint (push) Failing after 31s
CI/CD Pipeline / backend-build (push) Has been skipped
CI/CD Pipeline / frontend-lint (push) Failing after 1m37s
CI/CD Pipeline / frontend-build (push) Has been skipped
CI/CD Pipeline / e2e-test (push) Has been skipped
fix: resolve all frontend lint errors (85 issues fixed)
- Replace all 'any' types with proper TypeScript interfaces
- Fix React hooks setState in useEffect issues with lazy initialization
- Remove unused variables and imports across all files
- Fix React Compiler memoization dependency issues
- Add comprehensive i18n translation keys for admin interfaces
- Apply consistent prettier formatting throughout codebase
- Clean up unused bulk editing functionality
- Improve type safety and code quality across frontend

Files changed: 39
- ImpactMetrics.tsx: Fixed any types and interfaces
- AdminVerificationQueuePage.tsx: Added i18n keys, removed unused vars
- LocalizationUIPage.tsx: Fixed memoization, added translations
- LocalizationDataPage.tsx: Added type safety and translations
- And 35+ other files with various lint fixes
2025-12-25 14:14:58 +01:00

80 lines
2.0 KiB
TypeScript

import React from 'react';
import { clsx } from 'clsx';
import { useTranslation } from '@/hooks/useI18n';
export interface ProgressProps extends React.HTMLAttributes<HTMLDivElement> {
value: number;
max?: number;
showLabel?: boolean;
size?: 'sm' | 'md' | 'lg';
variant?: 'default' | 'success' | 'warning' | 'error';
animated?: boolean;
}
/**
* Progress bar component
*/
export const Progress = React.forwardRef<HTMLDivElement, ProgressProps>(
(
{
value,
max = 100,
showLabel = false,
size = 'md',
variant = 'default',
animated = false,
className,
...props
},
ref
) => {
const { t } = useTranslation();
const percentage = Math.min(Math.max((value / max) * 100, 0), 100);
const sizeClasses = {
sm: 'h-1',
md: 'h-2',
lg: 'h-3',
};
const variantClasses = {
default: 'bg-primary',
success: 'bg-success',
warning: 'bg-warning',
error: 'bg-destructive',
};
return (
<div
ref={ref}
className={clsx('w-full', className)}
role="progressbar"
aria-valuenow={value}
aria-valuemin={0}
aria-valuemax={max}
{...props}
>
{showLabel && (
<div className="flex justify-between items-center mb-1">
<span className="text-sm text-muted-foreground">{t('progress.label')}</span>
<span className="text-sm font-medium text-foreground">{Math.round(percentage)}%</span>
</div>
)}
<div className={clsx('w-full bg-muted rounded-full overflow-hidden', sizeClasses[size])}>
<div
className={clsx(
'h-full rounded-full transition-all duration-300',
variantClasses[variant],
{
'animate-pulse': animated,
}
)}
style={{ width: `${percentage}%` }}
/>
</div>
</div>
);
}
);
Progress.displayName = 'Progress';