2019-06-19 14:40:52 +00:00
|
|
|
import Card from "@material-ui/core/Card";
|
|
|
|
import CardContent from "@material-ui/core/CardContent";
|
|
|
|
import { IconProps } from "@material-ui/core/Icon";
|
2019-10-30 14:34:24 +00:00
|
|
|
import { makeStyles } from "@material-ui/core/styles";
|
2019-06-19 14:40:52 +00:00
|
|
|
import Typography from "@material-ui/core/Typography";
|
2019-08-09 10:26:22 +00:00
|
|
|
import React from "react";
|
2019-08-26 14:19:19 +00:00
|
|
|
import { FormattedMessage } from "react-intl";
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-12-03 15:28:40 +00:00
|
|
|
const useStyles = makeStyles(
|
|
|
|
theme => ({
|
|
|
|
cardContent: {
|
|
|
|
"&:last-child": {
|
|
|
|
padding: theme.spacing(2, 3)
|
|
|
|
},
|
|
|
|
display: "grid",
|
|
|
|
gridColumnGap: theme.spacing(3),
|
|
|
|
gridTemplateColumns: "1fr 64px"
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
2019-12-03 15:28:40 +00:00
|
|
|
cardSpacing: {
|
|
|
|
[theme.breakpoints.down("sm")]: {
|
|
|
|
marginBottom: theme.spacing(1)
|
|
|
|
},
|
|
|
|
marginBottom: theme.spacing(3)
|
2019-06-19 14:40:52 +00:00
|
|
|
},
|
2019-12-03 15:28:40 +00:00
|
|
|
cardSubtitle: {
|
|
|
|
fontSize: 12,
|
|
|
|
height: "20px",
|
|
|
|
lineHeight: 0.9
|
|
|
|
},
|
|
|
|
cardTitle: {
|
|
|
|
fontSize: 20,
|
|
|
|
fontWeight: 500 as 500
|
|
|
|
},
|
|
|
|
icon: {
|
|
|
|
color: theme.palette.primary.contrastText,
|
|
|
|
fontSize: 54,
|
|
|
|
margin: ".5rem .3rem"
|
|
|
|
},
|
|
|
|
iconBackground: {
|
|
|
|
backgroundColor: theme.palette.background.default,
|
|
|
|
borderRadius: "8px",
|
|
|
|
color: "white",
|
|
|
|
fontSize: "54px",
|
|
|
|
height: "100%",
|
|
|
|
padding: "10px 5px 0px 5px",
|
|
|
|
width: "100%"
|
|
|
|
},
|
|
|
|
value: {
|
|
|
|
textAlign: "right"
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
{ name: "HomeAnalyticsCard" }
|
|
|
|
);
|
2019-06-19 14:40:52 +00:00
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
interface HomeAnalyticsCardProps {
|
2019-06-19 14:40:52 +00:00
|
|
|
icon: React.ReactElement<IconProps>;
|
|
|
|
title: string;
|
|
|
|
children?: React.ReactNode;
|
|
|
|
}
|
|
|
|
|
2019-10-30 14:34:24 +00:00
|
|
|
const HomeAnalyticsCard: React.FC<HomeAnalyticsCardProps> = props => {
|
|
|
|
const { children, title, icon } = props;
|
|
|
|
|
|
|
|
const classes = useStyles(props);
|
|
|
|
|
|
|
|
return (
|
2019-06-19 14:40:52 +00:00
|
|
|
<Card className={classes.cardSpacing}>
|
|
|
|
<CardContent className={classes.cardContent}>
|
|
|
|
<div>
|
|
|
|
<Typography className={classes.cardTitle} variant="subtitle1">
|
|
|
|
{title}
|
|
|
|
</Typography>
|
|
|
|
<Typography
|
|
|
|
className={classes.cardSubtitle}
|
|
|
|
variant="caption"
|
|
|
|
color="textSecondary"
|
|
|
|
>
|
2019-08-26 14:19:19 +00:00
|
|
|
<FormattedMessage
|
|
|
|
defaultMessage="Today"
|
|
|
|
id="homeAnalyticsCardHeader"
|
|
|
|
/>
|
2019-06-19 14:40:52 +00:00
|
|
|
</Typography>
|
|
|
|
<Typography
|
|
|
|
className={classes.value}
|
|
|
|
color="textPrimary"
|
|
|
|
variant="h4"
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</Typography>
|
|
|
|
</div>
|
|
|
|
<div className={classes.iconBackground}>{icon}</div>
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
2019-10-30 14:34:24 +00:00
|
|
|
);
|
|
|
|
};
|
2019-06-19 14:40:52 +00:00
|
|
|
HomeAnalyticsCard.displayName = "HomeAnalyticsCard";
|
|
|
|
export default HomeAnalyticsCard;
|