-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContentBox.tsx
More file actions
57 lines (55 loc) · 1.47 KB
/
ContentBox.tsx
File metadata and controls
57 lines (55 loc) · 1.47 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
import * as React from 'react';
import { Box, Typography, type SxProps } from '@mui/material';
export interface ContentBoxProps {
title: string;
subtile?: React.ReactNode;
width?: Record<string, string>;
outlineColor: string;
padding?: Partial<SxProps>;
margin?: string | number;
sx?: SxProps;
action?: React.ReactNode;
}
export const ContentBox = (
props: React.PropsWithChildren<ContentBoxProps>,
): React.ReactElement => {
return (
<Box
width={props.width ?? { xs: '100%', sm: '100%', md: '100%' }}
sx={{
backgroundColor: 'background.default',
color: 'text.primary',
borderRadius: '6px',
border: `2px solid ${props.outlineColor}`,
p: props.padding ?? 5,
m: props.margin ?? 0,
fontSize: '18px',
fontWeight: 700,
mr: 0,
...props.sx,
}}
>
{(props.title.trim() !== '' || props.action != null) && (
<Typography
variant='h5'
sx={{
flexShrink: 0,
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
mb: 1,
}}
>
{props.title.trim() !== '' && <span>{props.title}</span>}
{props.action != null && props.action}
</Typography>
)}
{props.subtile != null && (
<Typography variant='subtitle1' sx={{ mb: 2 }}>
{props.subtile}
</Typography>
)}
{props.children}
</Box>
);
};