Skip to content

Commit bff356f

Browse files
author
Ives van Hoorne
committed
DRY up the statistics
1 parent 70d5e64 commit bff356f

File tree

3 files changed

+50
-47
lines changed

3 files changed

+50
-47
lines changed

src/app/pages/Sandbox/Editor/Workspace/Project/Statistics.js

Lines changed: 0 additions & 47 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
4+
const Count = styled.span`
5+
color: white;
6+
font-weight: 500;
7+
`;
8+
9+
const CountDescription = styled.span`
10+
color: rgba(255, 255, 255, 0.6);
11+
`;
12+
13+
type Props = {
14+
className: string,
15+
count: number,
16+
singular: string,
17+
plural: string,
18+
};
19+
20+
export default ({ className, count, singular, plural }: Props) =>
21+
<div className={className}>
22+
<Count>{`${count} `}</Count>
23+
<CountDescription>
24+
{` ${count === 1 ? singular : plural}`}
25+
</CountDescription>
26+
</div>;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import WorkspaceSubtitle from '../../WorkspaceSubtitle';
4+
5+
import StatCount from './StatCount';
6+
7+
type Props = {
8+
likeCount: number,
9+
forkCount: number,
10+
viewCount: number,
11+
};
12+
13+
const StyledStatCount = styled(StatCount)`
14+
margin: .5rem 1rem;
15+
font-size: .875rem;
16+
`;
17+
18+
export default ({ likeCount, forkCount, viewCount }: Props) =>
19+
<div>
20+
<WorkspaceSubtitle>Statistics</WorkspaceSubtitle>
21+
<StyledStatCount count={likeCount} singular="like" plural="likes" />
22+
<StyledStatCount count={forkCount} singular="fork" plural="forks" />
23+
<StyledStatCount count={viewCount} singular="view" plural="views" />
24+
</div>;

0 commit comments

Comments
 (0)