* Now can update the list of files without pausing/unpausing * Shrink a few functions * Reopen write when updating files * Todos * opened_file abstraction * iter_pieces_within iterator * Simplify iter_pieces_within * Simplify iter_pieces_within * Add "iter_file_details" * temporarily broken: readonly by default * Live torrent - reopen files * Reopen files after changing the list * Now reopening files read only when they are completed * Fix a bug in opened_file.rs * update todos * update help * Reconnect all peers that are idling * Add a couple fields to OpenedFile * Add a couple fields to OpenedFile * Small cleanups - use the new iterator where possible * size_of_piece_in_file function * Updating have * Include file progress * Almost nothing * ugly progress bars * bad UI, saving * its not so bad * Works now * update progress bar a bit * Reopen read-only on pause * Zero bytes isnt too bad! Doesnt break anything * fix per file progress bars * progress bar not as ugly anymore? * ui tweaks * fix a react bug * TODO.md update * Fix js + TODOs * Compute per-file progress on init * Fix stats updating live * Nothing * Nothing * cleanup ui a bit * Nothing * Final fixes * Trying to fix rust 1.73 * Sorting filenames * remove unnecessary indentation * Remove unnecessary comment
33 lines
931 B
TypeScript
33 lines
931 B
TypeScript
const variantClassNames = {
|
|
warn: "bg-amber-500 text-white",
|
|
info: "bg-blue-500 text-white",
|
|
success: "bg-green-700 text-white",
|
|
error: "bg-red-500 text-white",
|
|
};
|
|
|
|
export const ProgressBar: React.FC<{
|
|
now: number;
|
|
label?: string | null;
|
|
variant?: "warn" | "info" | "success" | "error";
|
|
classNames?: string;
|
|
}> = ({ now, variant, label, classNames }) => {
|
|
const progressLabel = label ?? `${now.toFixed(2)}%`;
|
|
|
|
const variantClassName =
|
|
variantClassNames[variant ?? "info"] ?? variantClassNames["info"];
|
|
|
|
return (
|
|
<div
|
|
className={`w-full bg-gray-200 rounded-full mb-1 dark:bg-gray-500 ${classNames}`}
|
|
>
|
|
<div
|
|
className={`text-xs font-medium transition-all text-center leading-none py-0.5 px-2 rounded-full ${variantClassName} ${
|
|
now < 1 && "bg-transparent"
|
|
}`}
|
|
style={{ width: `${now}%` }}
|
|
>
|
|
{progressLabel}
|
|
</div>
|
|
</div>
|
|
);
|
|
};
|