khamba
Version:
A cli tool for sharing files through local network.
18 lines (17 loc) • 674 B
JavaScript
import React, { useMemo } from 'react';
import { Text } from 'ink';
const emptyCharacter = '⠀';
const fillCharacter = '█';
const remainCharacter = '░';
const ProgressBar = ({ left = 0, percent, title }) => {
const unitSize = 5;
const fill = useMemo(() => Math.floor(percent / unitSize), [percent]);
const remain = useMemo(() => Math.ceil((100 - percent) / unitSize), [percent]);
return (React.createElement(Text, null,
[...Array(left)]?.map(() => emptyCharacter),
[...Array(fill)]?.map(() => fillCharacter),
[...Array(remain)]?.map(() => remainCharacter),
emptyCharacter,
title));
};
export default ProgressBar;