feat(cava): display smallest bar if value is 0

This commit is contained in:
2024-05-30 20:29:37 +02:00
parent 073214174c
commit 53b315186a

View File

@@ -46,12 +46,17 @@ const FrequencyBar = (props: {
const emptyBlocksCount =
props.height - fullBlocksCount - (remainderIndex > 0 ? 1 : 0);
if (remainderIndex === 0 && fullBlocksCount === 0) {
bar += `${" ".repeat(WIDTH)}\n`.repeat(Math.max(emptyBlocksCount - 1, 0));
bar += GRADIENT[0].repeat(WIDTH);
} else {
bar += `${" ".repeat(WIDTH)}\n`.repeat(Math.max(emptyBlocksCount, 0));
if (remainderIndex > 0) {
bar += `${GRADIENT[remainderIndex]!.repeat(WIDTH)}\n`;
}
bar += `${FULL_BLOCK.repeat(WIDTH)}\n`.repeat(fullBlocksCount);
}
return <span>{bar}</span>;
};