Repository navigation
Expand file tree
/
Copy pathFieldset.tsx
More file actions
83 lines (80 loc) · 1.96 KB
/
Copy pathFieldset.tsx
File metadata and controls
83 lines (80 loc) · 1.96 KB
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
import type { FC, ReactNode, FormEventHandler } from "react";
import Button from "@mui/material/Button";
import { type CSSObject, useTheme } from "@emotion/react";
interface FieldsetProps {
children: ReactNode;
title: string | JSX.Element;
subtitle?: string | JSX.Element;
validation?: string | JSX.Element | false;
button?: JSX.Element | false;
onSubmit: FormEventHandler<HTMLFormElement>;
isSubmitting?: boolean;
}
export const Fieldset: FC<FieldsetProps> = (props) => {
const {
title,
subtitle,
children,
validation,
button,
onSubmit,
isSubmitting,
} = props;
const theme = useTheme();
return (
<form
css={{
borderRadius: 8,
border: `1px solid ${theme.palette.divider}`,
background: theme.palette.background.paper,
marginTop: 32,
}}
onSubmit={onSubmit}
>
<header css={{ padding: 24 }}>
<div
css={{
fontSize: 20,
margin: 0,
fontWeight: 600,
}}
>
{title}
</div>
{subtitle && (
<div
css={{
color: theme.palette.text.secondary,
fontSize: 14,
marginTop: 8,
}}
>
{subtitle}
</div>
)}
<div css={[theme.typography.body2 as CSSObject, { paddingTop: 16 }]}>
{children}
</div>
</header>
<footer
css={[
theme.typography.body2 as CSSObject,
{
background: theme.palette.background.paperLight,
padding: "16px 24px",
display: "flex",
alignItems: "center",
justifyContent: "space-between",
},
]}
>
<div css={{ color: theme.palette.text.secondary }}>{validation}</div>
{button || (
<Button type="submit" disabled={isSubmitting}>
Submit
</Button>
)}
</footer>
</form>
);
};