Files
codexbar-mobile/components/ProgressBar.tsx
T

24 lines
609 B
TypeScript

import { View } from "react-native";
interface ProgressBarProps {
percent: number;
}
function getBarColor(percent: number): string {
if (percent >= 85) return "bg-red-500";
if (percent >= 60) return "bg-yellow-400";
return "bg-green-500";
}
export function ProgressBar({ percent }: ProgressBarProps) {
const clamped = Math.max(0, Math.min(100, percent));
return (
<View className="h-2.5 w-full rounded-full bg-neutral-200 dark:bg-neutral-700">
<View
className={`h-2.5 rounded-full ${getBarColor(clamped)}`}
style={{ width: `${clamped}%` }}
/>
</View>
);
}