StatisticsCard.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { makeStyles, Theme, Typography } from '@material-ui/core';
  2. import { FC } from 'react';
  3. import { StatisticsCardProps } from './Types';
  4. const useStyles = makeStyles((theme: Theme) => ({
  5. wrapper: {
  6. display: `grid`,
  7. gridTemplateColumns: 'repeat(auto-fill, minmax(200px, 1fr))',
  8. columnGap: '20px',
  9. padding: theme.spacing(3),
  10. },
  11. itemWrapper: {
  12. paddingLeft: theme.spacing(1),
  13. borderLeft: '3px solid #f0f4f9',
  14. },
  15. label: {
  16. fontSize: '12px',
  17. lineHeight: '16px',
  18. color: theme.palette.milvusDark.main,
  19. },
  20. value: {
  21. fontSize: '24px',
  22. lineHeight: '28px',
  23. fontWeight: 'bold',
  24. },
  25. }));
  26. const StatisticsCard: FC<StatisticsCardProps> = ({
  27. data = [],
  28. wrapperClass = '',
  29. }) => {
  30. const classes = useStyles();
  31. return (
  32. <div className={`card-wrapper ${classes.wrapper} ${wrapperClass}`}>
  33. {data.map(item => (
  34. <div key={item.label} className={classes.itemWrapper}>
  35. <Typography className={classes.label}>{item.label}</Typography>
  36. <Typography
  37. className={classes.value}
  38. style={{ color: item.valueColor }}
  39. >
  40. {item.value}
  41. </Typography>
  42. </div>
  43. ))}
  44. </div>
  45. );
  46. };
  47. export default StatisticsCard;