-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathCard.tsx
62 lines (59 loc) · 1.49 KB
/
Card.tsx
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
import {
CardActions,
CardContent,
CardMedia,
type CardMediaProps,
Card as MuiCard,
type CardProps as MuiCardProps,
Typography,
} from "@mui/material"
import { LinkButton, type LinkButtonProps } from "codeforlife/components/router"
export type CardProps<
Override extends "delta" | "to",
State extends Record<string, unknown> = Record<string, unknown>,
> = MuiCardProps & {
title: string
description: string
mediaProps: {
image: NonNullable<CardMediaProps["image"]>
title: NonNullable<CardMediaProps["title"]>
}
linkButtonProps: LinkButtonProps<Override, State>
}
const Card: {
(props: CardProps<"delta">): JSX.Element
<State extends Record<string, unknown> = Record<string, unknown>>(
props: CardProps<"to", State>,
): JSX.Element
} = ({
title,
description,
mediaProps,
linkButtonProps,
style,
...otherCardProps
}: CardProps<"delta"> | CardProps<"to">) => {
return (
<MuiCard
style={{
display: "flex",
flexDirection: "column",
minHeight: "100%",
maxWidth: "400px",
...style,
}}
{...otherCardProps}
>
<CardMedia component="img" height={242} {...mediaProps} />
<CardContent sx={{ flexGrow: 1 }}>
<Typography variant="h5">{title}</Typography>
<Typography mb={0}>{description}</Typography>
</CardContent>
<CardActions>
{/* @ts-expect-error props */}
<LinkButton {...linkButtonProps} />
</CardActions>
</MuiCard>
)
}
export default Card