Skip to content

Commit 58ed5dc

Browse files
committed
Add complex card mui component
1 parent 977352b commit 58ed5dc

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

test/integration/next/pages/mui.tsx

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,21 @@ import { DataGrid, GridColDef, GridValueGetterParams } from '@mui/x-data-grid';
4747

4848
import Link from '@mui/material/Link';
4949

50+
import { styled } from '@mui/material/styles';
51+
import Card from '@mui/material/Card';
52+
import CardHeader from '@mui/material/CardHeader';
53+
import CardMedia from '@mui/material/CardMedia';
54+
import CardContent from '@mui/material/CardContent';
55+
import CardActions from '@mui/material/CardActions';
56+
import Collapse from '@mui/material/Collapse';
57+
import Avatar from '@mui/material/Avatar';
58+
import IconButton, { IconButtonProps } from '@mui/material/IconButton';
59+
import { red } from '@mui/material/colors';
60+
import FavoriteIcon from '@mui/icons-material/Favorite';
61+
import ShareIcon from '@mui/icons-material/Share';
62+
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
63+
import MoreVertIcon from '@mui/icons-material/MoreVert';
64+
5065

5166

5267
const { MuiDsfrThemeProvider } = createMuiDsfrThemeProvider({
@@ -97,6 +112,7 @@ export default function Mui() {
97112
<HorizontalLinearStepper />
98113
<DataGridDemo />
99114
<Links />
115+
<RecipeReviewCard />
100116
</>
101117
);
102118

@@ -674,3 +690,111 @@ const { Links } = (() => {
674690
return { Links };
675691

676692
})();
693+
694+
const { RecipeReviewCard } = (() => {
695+
696+
697+
interface ExpandMoreProps extends IconButtonProps {
698+
expand: boolean;
699+
}
700+
701+
const ExpandMore = styled((props: ExpandMoreProps) => {
702+
const { expand, ...other } = props;
703+
return <IconButton {...other} />;
704+
})(({ theme, expand }) => ({
705+
transform: !expand ? 'rotate(0deg)' : 'rotate(180deg)',
706+
marginLeft: 'auto',
707+
transition: theme.transitions.create('transform', {
708+
duration: theme.transitions.duration.shortest,
709+
}),
710+
}));
711+
712+
function RecipeReviewCard() {
713+
const [expanded, setExpanded] = React.useState(false);
714+
715+
const handleExpandClick = () => {
716+
setExpanded(!expanded);
717+
};
718+
719+
return (
720+
<Card sx={{ maxWidth: 345, mt: 7 }}>
721+
<CardHeader
722+
avatar={
723+
<Avatar sx={{ bgcolor: red[500] }} aria-label="recipe">
724+
R
725+
</Avatar>
726+
}
727+
action={
728+
<IconButton aria-label="settings">
729+
<MoreVertIcon />
730+
</IconButton>
731+
}
732+
title="Shrimp and Chorizo Paella"
733+
subheader="September 14, 2016"
734+
/>
735+
<CardMedia
736+
component="img"
737+
height="194"
738+
image="https://mui.com/static/images/cards/paella.jpg"
739+
alt="Paella dish"
740+
/>
741+
<CardContent>
742+
<Typography variant="body2" color="text.secondary">
743+
This impressive paella is a perfect party dish and a fun meal to cook
744+
together with your guests. Add 1 cup of frozen peas along with the mussels,
745+
if you like.
746+
</Typography>
747+
</CardContent>
748+
<CardActions disableSpacing>
749+
<IconButton aria-label="add to favorites">
750+
<FavoriteIcon />
751+
</IconButton>
752+
<IconButton aria-label="share">
753+
<ShareIcon />
754+
</IconButton>
755+
<ExpandMore
756+
expand={expanded}
757+
onClick={handleExpandClick}
758+
aria-expanded={expanded}
759+
aria-label="show more"
760+
>
761+
<ExpandMoreIcon />
762+
</ExpandMore>
763+
</CardActions>
764+
<Collapse in={expanded} timeout="auto" unmountOnExit>
765+
<CardContent>
766+
<Typography paragraph>Method:</Typography>
767+
<Typography paragraph>
768+
Heat 1/2 cup of the broth in a pot until simmering, add saffron and set
769+
aside for 10 minutes.
770+
</Typography>
771+
<Typography paragraph>
772+
Heat oil in a (14- to 16-inch) paella pan or a large, deep skillet over
773+
medium-high heat. Add chicken, shrimp and chorizo, and cook, stirring
774+
occasionally until lightly browned, 6 to 8 minutes. Transfer shrimp to a
775+
large plate and set aside, leaving chicken and chorizo in the pan. Add
776+
pimentón, bay leaves, garlic, tomatoes, onion, salt and pepper, and cook,
777+
stirring often until thickened and fragrant, about 10 minutes. Add
778+
saffron broth and remaining 4 1/2 cups chicken broth; bring to a boil.
779+
</Typography>
780+
<Typography paragraph>
781+
Add rice and stir very gently to distribute. Top with artichokes and
782+
peppers, and cook without stirring, until most of the liquid is absorbed,
783+
15 to 18 minutes. Reduce heat to medium-low, add reserved shrimp and
784+
mussels, tucking them down into the rice, and cook again without
785+
stirring, until mussels have opened and rice is just tender, 5 to 7
786+
minutes more. (Discard any mussels that don&apos;t open.)
787+
</Typography>
788+
<Typography>
789+
Set aside off of the heat to let rest for 10 minutes, and then serve.
790+
</Typography>
791+
</CardContent>
792+
</Collapse>
793+
</Card>
794+
);
795+
}
796+
797+
return { RecipeReviewCard };
798+
799+
800+
})();

0 commit comments

Comments
 (0)