Skip to content

Commit

Permalink
Use human readable numbers in Cardinal
Browse files Browse the repository at this point in the history
  • Loading branch information
ghengeveld committed Mar 21, 2023
1 parent 001ebba commit 52ddae7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/components/Cardinal.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,3 +185,11 @@ export const WithIcon = () => (
);

WithIcon.storyName = 'with icon';

export const Thousands = () => <Cardinal count={12345} text="Story" />;

Thousands.storyName = 'thousands';

export const Decimals = () => <Cardinal count={123.45} text="Story" />;

Decimals.storyName = 'decimals';
4 changes: 2 additions & 2 deletions src/components/Cardinal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,11 @@ export const Cardinal: FunctionComponent<CardinalProps> = ({
alignment,
...props
}) => {
let countValue = count;
let countValue = typeof count === 'number' ? count.toLocaleString('en-US') : count;
if (countLink) {
countValue = (
<Link href={countLink} inverse={status === 'inverse'}>
{count}
{countValue}
</Link>
);
}
Expand Down

0 comments on commit 52ddae7

Please sign in to comment.