refactor: refactored createProgressNode logic (#486)

This commit is contained in:
Anurag Hazra
2020-09-24 13:20:12 +05:30
committed by GitHub
parent 9c0e130a90
commit 278d6a1739
3 changed files with 46 additions and 41 deletions
+28
View File
@@ -0,0 +1,28 @@
const { clampValue } = require("../common/utils");
const createProgressNode = ({
x,
y,
width,
color,
progress,
progressBarBackgroundColor,
}) => {
const progressPercentage = clampValue(progress, 2, 100);
return `
<svg width="${width}" x="${x}" y="${y}">
<rect rx="5" ry="5" x="0" y="0" width="${width}" height="8" fill="${progressBarBackgroundColor}"></rect>
<rect
height="8"
fill="${color}"
rx="5" ry="5" x="0" y="0"
data-testid="lang-progress"
width="${progressPercentage}%"
>
</rect>
</svg>
`;
};
exports.createProgressNode = createProgressNode;