Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 | 26x 26x | import { alpha } from "@mui/material/styles";
import { Box, Card, CardContent, Skeleton, Tooltip, Typography } from "@mui/material";
import InfoOutlinedIcon from "@mui/icons-material/InfoOutlined";
export default function StatCard({ icon, value, label, color, loading, tooltip }) {
return (
<Card
elevation={0}
sx={{
border: (t) => `1px solid ${t.palette.divider}`,
borderRadius: 3,
overflow: "hidden",
position: "relative",
"&::before": {
content: '""',
position: "absolute",
top: 0,
left: 0,
right: 0,
height: 4,
bgcolor: color,
borderRadius: "12px 12px 0 0",
},
}}
>
<CardContent sx={{ pt: 3 }}>
<Box sx={{ display: "flex", alignItems: "flex-start", justifyContent: "space-between" }}>
<Box>
{loading ? (
<>
<Skeleton width={60} height={44} />
<Skeleton width={100} height={20} />
</>
) : (
<>
<Typography
variant="h3"
fontWeight={800}
sx={{ lineHeight: 1, color, letterSpacing: "-0.02em" }}
>
{value}
</Typography>
<Typography
variant="body2"
sx={{
mt: 0.75,
fontWeight: 500,
color: "text.secondary",
display: "flex",
alignItems: "center",
gap: 0.5,
}}
>
{label}
{tooltip && (
<Tooltip title={tooltip} placement="top" arrow>
<InfoOutlinedIcon sx={{ fontSize: 14, cursor: "help" }} />
</Tooltip>
)}
</Typography>
</>
)}
</Box>
<Box
sx={{
width: 44,
height: 44,
borderRadius: 2.5,
bgcolor: alpha(color, 0.1),
display: "flex",
alignItems: "center",
justifyContent: "center",
color,
flexShrink: 0,
}}
>
{icon}
</Box>
</Box>
</CardContent>
</Card>
);
}
|