Skip to content

Commit

Permalink
handle types
Browse files Browse the repository at this point in the history
  • Loading branch information
0xKurt committed Oct 24, 2024
1 parent 5ba717a commit c85c644
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/primitives/Indicators/CircleStat/CircleStat.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const meta: Meta<typeof CircleStat> = {
},
text: {
control: "number",
table: {
type: {
summary: "number | string",
},
},
},
showPercentageSymbol: {
control: "boolean",
Expand Down
8 changes: 5 additions & 3 deletions src/primitives/Indicators/CircleStat/CircleStat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ export const CircleStat: React.FC<CircleStatProps> = ({

const getColor = (text: number | string) => {
if (color) return color;
if (typeof text === "string") {
const value = typeof text === "string" ? parseFloat(text) : text;

if (isNaN(value)) {
return defaultColors.low;
}
if (text <= 30) {
if (value <= 30) {
return defaultColors.low;
} else if (text < 60) {
} else if (value < 60) {
return defaultColors.mid;
} else {
return defaultColors.high;
Expand Down

0 comments on commit c85c644

Please sign in to comment.