|
1 |
| -import { Button, Stack, Typography, type ButtonProps } from "@mui/material" |
2 |
| -import { type FC } from "react" |
| 1 | +import { Stack, Typography } from "@mui/material" |
3 | 2 |
|
| 3 | +import { LinkButton, type LinkButtonProps } from "../router" |
4 | 4 | import { primary, secondary, tertiary } from "../../theme/colors"
|
5 | 5 | import palette from "../../theme/palette"
|
6 | 6 | import Image, { type ImageProps } from "../Image"
|
7 | 7 | import Section from "./Section"
|
8 | 8 |
|
9 |
| -export interface BannerProps { |
| 9 | +export interface BannerProps< |
| 10 | + Button1State extends Record<string, any> = Record<string, any>, |
| 11 | + Button2State extends Record<string, any> = Record<string, any>, |
| 12 | +> { |
10 | 13 | header: string
|
11 | 14 | subheader?: string
|
12 | 15 | textAlign?: "start" | "center"
|
13 | 16 | imageProps?: ImageProps
|
14 |
| - buttonProps?: ButtonProps |
| 17 | + button1Props?: LinkButtonProps<"to", Button1State> |
| 18 | + button2Props?: LinkButtonProps<"to", Button2State> |
15 | 19 | bgcolor?: "primary" | "secondary" | "tertiary"
|
16 | 20 | }
|
17 | 21 |
|
18 |
| -const Banner: FC<BannerProps> = ({ |
| 22 | +const Banner = < |
| 23 | + Button1State extends Record<string, any> = Record<string, any>, |
| 24 | + Button2State extends Record<string, any> = Record<string, any>, |
| 25 | +>({ |
19 | 26 | header,
|
20 | 27 | subheader,
|
21 | 28 | textAlign = "start",
|
22 | 29 | imageProps,
|
23 |
| - buttonProps, |
| 30 | + button1Props, |
| 31 | + button2Props, |
24 | 32 | bgcolor = "primary",
|
25 |
| -}) => { |
| 33 | +}: BannerProps<Button1State, Button2State>) => { |
26 | 34 | // @ts-expect-error guaranteed to be in palette
|
27 | 35 | const contrastText = palette[bgcolor].contrastText
|
28 | 36 |
|
@@ -61,12 +69,15 @@ const Banner: FC<BannerProps> = ({
|
61 | 69 | <Typography
|
62 | 70 | color={contrastText}
|
63 | 71 | variant="h4"
|
64 |
| - mb={buttonProps !== undefined ? undefined : 0} |
| 72 | + mb={button1Props !== undefined ? undefined : 0} |
65 | 73 | >
|
66 | 74 | {subheader}
|
67 | 75 | </Typography>
|
68 | 76 | )}
|
69 |
| - {buttonProps !== undefined && <Button {...buttonProps} />} |
| 77 | + <Stack direction="row" gap={2}> |
| 78 | + {button1Props !== undefined && <LinkButton {...button1Props} />} |
| 79 | + {button2Props !== undefined && <LinkButton {...button2Props} />} |
| 80 | + </Stack> |
70 | 81 | </Stack>
|
71 | 82 | {imageProps !== undefined && (
|
72 | 83 | <Image
|
|
0 commit comments