Skip to content

Commit ed48726

Browse files
fix: recover Stats component
1 parent b780e39 commit ed48726

File tree

1 file changed

+38
-0
lines changed
  • packages/components/src/components/Stats

1 file changed

+38
-0
lines changed

packages/components/src/components/Stats/index.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import React from 'react';
2+
import { Text } from '../Text';
3+
import { Stack } from '../Stack';
4+
import { Icon } from '../Icon';
25

36
export const HeartIcon = props => (
47
<svg width={16} height={16} fill="none" viewBox="0 0 16 16" {...props}>
@@ -37,3 +40,38 @@ export const formatNumber = (count: number): string | number => {
3740

3841
return count;
3942
};
43+
44+
export const Stats = ({ sandbox, ...props }) => (
45+
<Stack gap={4} {...props}>
46+
{typeof sandbox.likeCount !== 'undefined' && (
47+
<Stack gap={2} align="center">
48+
<Text variant="muted" style={{ display: 'flex', alignItems: 'center' }}>
49+
<Icon name="heart" size={13} />
50+
</Text>
51+
<Text size={3} variant="muted">
52+
{formatNumber(sandbox.likeCount)}
53+
</Text>
54+
</Stack>
55+
)}
56+
{typeof sandbox.viewCount !== 'undefined' && (
57+
<Stack gap={2} align="center">
58+
<Text variant="muted" style={{ display: 'flex', alignItems: 'center' }}>
59+
<Icon name="eye" size={16} />
60+
</Text>
61+
<Text size={3} variant="muted">
62+
{formatNumber(sandbox.viewCount)}
63+
</Text>
64+
</Stack>
65+
)}
66+
{typeof sandbox.forkCount !== 'undefined' && (
67+
<Stack gap={2} align="center">
68+
<Text variant="muted" style={{ display: 'flex', alignItems: 'center' }}>
69+
<Icon name="forkFilled" size={14} />
70+
</Text>
71+
<Text size={3} variant="muted">
72+
{formatNumber(sandbox.forkCount)}
73+
</Text>
74+
</Stack>
75+
)}
76+
</Stack>
77+
);

0 commit comments

Comments
 (0)