Skip to content
This repository was archived by the owner on May 15, 2025. It is now read-only.

Commit 9f730ca

Browse files
committed
fix: percentage
1 parent c163531 commit 9f730ca

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/components/primitives/Value.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ export default function Value({
3737
fallback,
3838
...props
3939
}: ValueProps) {
40-
const formatDecimals = (_format.match(/#/g) || []).length + (_format.includes("%") ? 2 : 0);
4140
const formatIsCurrency = _format.includes("$");
41+
const formatIsPercentage = _format.includes("%");
42+
const formatDecimals = (_format.match(/#/g) || []).length + (formatIsPercentage ? 2 : 0);
4243
const formatOrShow = (v: typeof children) => {
4344
if (Number(v) < 1 / 10 ** formatDecimals && !(Number(v) <= 0) && formatDecimals > 0)
44-
return `<${`${formatIsCurrency ? "$" : ""}0.${"0".repeat(Math.max(formatDecimals - 1))}1`}`;
45+
return `<${`${formatIsCurrency ? "$" : ""}0.${"0".repeat(Math.max(formatDecimals - 1))}1`}${formatIsPercentage ? "%" : ""}`;
4546
return format(v, _format, { currency: "USD" });
4647
};
4748

0 commit comments

Comments
 (0)