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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | 1x 1x 56x 1x 505x 168x 168x 168x 1x 337x 168x 168x 58x 168x | import { Box, Paper, styled, Typography } from "@mui/material";
import React from "react";
interface StatusOption<T> {
value: T;
title: string;
description: string;
icon: React.ReactNode;
}
interface StatusCardGroupProps<T> {
title: string;
options: StatusOption<T>[];
selectedValue: T;
onSelect: (value: T) => void;
}
const StatusCardContainer = styled(Box)(({ theme }) => ({
display: "grid",
gridTemplateColumns: "repeat(auto-fit, minmax(200px, 1fr))",
gap: theme.spacing(2),
marginTop: theme.spacing(2),
[theme.breakpoints.up("md")]: {
gridAutoRows: "1fr",
},
}));
const StatusCard = styled(Paper, {
shouldForwardProp: (prop) => prop !== "selected",
})<{ selected?: boolean }>(({ theme, selected }) => ({
padding: theme.spacing(2),
cursor: "pointer",
border: selected ? `2px solid var(--mui-palette-primary-main)` : `1px solid var(--mui-palette-grey-200)`,
backgroundColor: selected ? `var(--mui-palette-primary-main)15` : "var(--mui-palette-background-paper)",
transition: "all 0.2s ease-in-out",
height: "100%",
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
minHeight: "100px",
"&:hover": {
borderColor: "var(--mui-palette-primary-main)",
backgroundColor: selected ? "var(--mui-palette-primary-main)20" : "var(--mui-palette-grey-50)",
transform: "translateY(-2px)",
boxShadow: "0 8px 25px rgba(0, 0, 0, 0.15)",
},
[theme.breakpoints.down("md")]: {
padding: theme.spacing(1.5),
height: "auto",
minHeight: "75px",
},
}));
const StatusCardContent = styled(Box)(({ theme }) => ({
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
textAlign: "center",
gap: theme.spacing(1),
color: "var(--mui-palette-text-primary)",
"& svg": {
fill: "var(--mui-palette-text-primary)",
},
[theme.breakpoints.down("md")]: {
display: "grid",
gridTemplateColumns: "auto 1fr",
gap: theme.spacing(1.5),
flex: "none",
},
}));
const StatusTextContainer = styled(Box)(({ theme }) => ({
display: "grid",
gridTemplateColumns: "40% 60%",
gap: theme.spacing(1),
alignItems: "center",
[theme.breakpoints.up("md")]: {
display: "flex",
flexDirection: "column",
alignItems: "center",
},
[theme.breakpoints.down("md")]: {
gridTemplateColumns: "40% 60%",
gap: theme.spacing(1),
},
}));
const StatusTitle = styled(Typography, {
shouldForwardProp: (prop) => prop !== "selected",
})<{ selected?: boolean }>(({ theme, selected }) => ({
fontSize: "1rem",
fontWeight: 600,
color: selected ? "var(--mui-palette-primary-main)" : "var(--mui-palette-text-primary)",
marginBottom: 0,
textAlign: "left",
[theme.breakpoints.down("md")]: {
fontSize: "0.875rem",
},
}));
const StatusDescription = styled(Typography)(({ theme }) => ({
textAlign: "center",
fontSize: "0.75rem",
lineHeight: 1.4,
color: "var(--mui-palette-text-secondary)",
[theme.breakpoints.down("md")]: {
fontSize: "0.75rem",
textAlign: "left",
},
}));
export default function StatusCardGroup<T extends string | number>({
title,
options,
selectedValue,
onSelect,
}: StatusCardGroupProps<T>) {
return (
<Box>
<Typography variant="h3" gutterBottom>
{title}
</Typography>
<StatusCardContainer>
{options.map((option) => (
<StatusCard
key={option.value}
selected={selectedValue === option.value}
onClick={() => onSelect(option.value)}
>
<StatusCardContent>
{option.icon}
<StatusTextContainer>
<StatusTitle selected={selectedValue === option.value}>{option.title}</StatusTitle>
<StatusDescription>{option.description}</StatusDescription>
</StatusTextContainer>
</StatusCardContent>
</StatusCard>
))}
</StatusCardContainer>
</Box>
);
}
|