CardCounter.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. import React from "react";
  2. import { Avatar, Card, CardHeader, Typography } from "@material-ui/core";
  3. import Skeleton from "@material-ui/lab/Skeleton";
  4. import { makeStyles } from "@material-ui/core/styles";
  5. import { grey } from '@material-ui/core/colors';
  6. const useStyles = makeStyles(theme => ({
  7. cardAvatar: {
  8. fontSize: '55px',
  9. color: grey[500],
  10. backgroundColor: '#ffffff',
  11. width: theme.spacing(7),
  12. height: theme.spacing(7)
  13. },
  14. cardTitle: {
  15. fontSize: '18px',
  16. color: theme.palette.text.primary
  17. },
  18. cardSubtitle: {
  19. color: grey[600],
  20. fontSize: '14px'
  21. }
  22. }));
  23. export default function CardCounter(props) {
  24. const { icon, title, value, loading } = props
  25. const classes = useStyles();
  26. return ( !loading ?
  27. <Card>
  28. <CardHeader
  29. avatar={
  30. <Avatar className={classes.cardAvatar}>
  31. {icon}
  32. </Avatar>
  33. }
  34. title={
  35. <Typography variant="h6" component="h2" className={classes.cardTitle}>
  36. { title }
  37. </Typography>
  38. }
  39. subheader={
  40. <Typography variant="subtitle1" component="p" className={classes.cardSubtitle}>
  41. { value }
  42. </Typography>
  43. }
  44. />
  45. </Card>
  46. : <Skeleton variant="rect" height={80} />
  47. )
  48. }