-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathStats.tsx
41 lines (32 loc) · 1.01 KB
/
Stats.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from "react";
import styled from "styled-components";
import Skeleton from "react-loading-skeleton";
import { isUndefined } from "utils/index";
const FieldWrapper = styled.div`
display: inline-flex;
gap: 8px;
`;
const StyledLabel = styled.label`
color: ${({ theme }) => theme.primaryText};
`;
const ValueAndExtraLabel = styled.div`
display: flex;
gap: 4px;
`;
const Field: React.FC<{ label: string; value?: number; extraLabel?: string }> = ({ label, value, extraLabel }) => (
<FieldWrapper>
<StyledLabel>{label}</StyledLabel>
<ValueAndExtraLabel>
<small>{!isUndefined(value) ? value : <Skeleton width={16} />}</small>
{extraLabel ? <small>{extraLabel}</small> : null}
</ValueAndExtraLabel>
</FieldWrapper>
);
export interface IStats {
totalJurors?: number;
}
const Stats: React.FC<IStats> = ({ totalJurors }) => {
const value = !isUndefined(totalJurors) ? totalJurors : undefined;
return <Field label="Total" value={value} extraLabel="Jurors" />;
};
export default Stats;