diff --git a/src/components/layout/ProgressBar.tsx b/src/components/layout/ProgressBar.tsx new file mode 100644 index 0000000..766a0e7 --- /dev/null +++ b/src/components/layout/ProgressBar.tsx @@ -0,0 +1,38 @@ +import { Progress } from "@kobalte/core"; +import { SmallHeader } from "."; + +export default function formatNumber(num: number) { + const map = [ + { suffix: 'T', threshold: 1e12 }, + { suffix: 'B', threshold: 1e9 }, + { suffix: 'M', threshold: 1e6 }, + { suffix: 'K', threshold: 1e3 }, + { suffix: '', threshold: 1 }, + ]; + + const found = map.find((x) => Math.abs(num) >= x.threshold); + if (found) { + const formatted = (num / found.threshold).toLocaleString() + found.suffix; + return formatted; + } + + return num.toLocaleString(); +} + +export function ProgressBar(props: { value: number, max: number }) { + return ( `${formatNumber(value)} of ${formatNumber(max)} sats sent`} + class="w-full flex flex-col gap-2" + > +
+ Sending... + +
+ + + +
) +} \ No newline at end of file