SysCard.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import { Theme, Typography, Box } from '@mui/material';
  2. import { Link } from 'react-router-dom';
  3. const SysCard = (data: {
  4. title: string;
  5. count: number | string;
  6. des?: string;
  7. link?: string;
  8. }) => {
  9. return (
  10. <Box
  11. sx={(theme: Theme) => ({
  12. minWidth: 'auto',
  13. gap: theme.spacing(1),
  14. backgroundColor: theme.palette.background.paper,
  15. padding: theme.spacing(2),
  16. border: `1px solid ${theme.palette.divider}`,
  17. cursor: 'pointer',
  18. borderRadius: 2,
  19. display: 'flex',
  20. flexDirection: 'column',
  21. alignItems: 'flex-start',
  22. transition: 'box-shadow 0.2s',
  23. '& a': {
  24. textDecoration: 'none',
  25. color: theme.palette.text.primary,
  26. },
  27. })}
  28. >
  29. {data.link ? (
  30. <Link to={data.link} style={{ textDecoration: 'none' }}>
  31. <Typography component="p" sx={{ fontSize: 24, m: 0 }}>
  32. {data.count}
  33. </Typography>
  34. <Typography
  35. component="h3"
  36. sx={theme => ({
  37. m: 0,
  38. fontSize: 14,
  39. lineHeight: 1.5,
  40. color: theme.palette.text.secondary,
  41. })}
  42. >
  43. {data.title}
  44. </Typography>
  45. {data.des ? (
  46. <Typography component="p" sx={{ fontSize: 14, m: 0 }}>
  47. {data.des}
  48. </Typography>
  49. ) : null}
  50. </Link>
  51. ) : (
  52. <>
  53. <Typography component="p" sx={{ fontSize: 24, m: 0 }}>
  54. {data.count}
  55. </Typography>
  56. <Typography
  57. component="h3"
  58. sx={theme => ({
  59. m: 0,
  60. fontSize: 14,
  61. lineHeight: 1.5,
  62. color: theme.palette.text.secondary,
  63. })}
  64. >
  65. {data.title}
  66. </Typography>
  67. {data.des ? (
  68. <Typography component="p" sx={{ fontSize: 14, m: 0 }}>
  69. {data.des}
  70. </Typography>
  71. ) : null}
  72. </>
  73. )}
  74. </Box>
  75. );
  76. };
  77. export default SysCard;