parent
0e720527bd
commit
f4d256323a
5 changed files with 69 additions and 92 deletions
@ -1,25 +1,28 @@ |
||||
import { ReactNode } from 'react'; |
||||
import { Box } from '@mui/material'; |
||||
import { styled } from '@mui/material/styles'; |
||||
import { FC } from 'react'; |
||||
import { Box as MUIBox, BoxProps as MUIBoxProps } from '@mui/material'; |
||||
|
||||
import { BORDER_RADIUS, DIVIDER } from '../../lib/consts/DEFAULT_THEME'; |
||||
|
||||
const StyledBox = styled(Box)({ |
||||
borderWidth: '1px', |
||||
borderRadius: BORDER_RADIUS, |
||||
borderStyle: 'solid', |
||||
borderColor: DIVIDER, |
||||
marginTop: '1.4em', |
||||
marginBottom: '1.4em', |
||||
paddingBottom: 0, |
||||
position: 'relative', |
||||
}); |
||||
type InnerPanelProps = MUIBoxProps; |
||||
|
||||
type Props = { |
||||
children: ReactNode; |
||||
}; |
||||
const InnerPanel: FC<InnerPanelProps> = ({ sx, ...muiBoxRestProps }) => ( |
||||
<MUIBox |
||||
{...{ |
||||
sx: { |
||||
borderWidth: '1px', |
||||
borderRadius: BORDER_RADIUS, |
||||
borderStyle: 'solid', |
||||
borderColor: DIVIDER, |
||||
marginTop: '1.4em', |
||||
marginBottom: '1.4em', |
||||
paddingBottom: 0, |
||||
position: 'relative', |
||||
|
||||
const InnerPanel = ({ children }: Props): JSX.Element => ( |
||||
<StyledBox>{children}</StyledBox> |
||||
...sx, |
||||
}, |
||||
...muiBoxRestProps, |
||||
}} |
||||
/> |
||||
); |
||||
|
||||
export default InnerPanel; |
||||
|
@ -1,42 +1,38 @@ |
||||
import { ReactNode } from 'react'; |
||||
import { Box, styled } from '@mui/material'; |
||||
import { FC } from 'react'; |
||||
import { Box } from '@mui/material'; |
||||
|
||||
import { BORDER_RADIUS, DIVIDER } from '../../lib/consts/DEFAULT_THEME'; |
||||
|
||||
const PREFIX = 'InnerPanelHeader'; |
||||
|
||||
const classes = { |
||||
header: `${PREFIX}-header`, |
||||
}; |
||||
|
||||
const StyledBox = styled(Box)(() => ({ |
||||
position: 'relative', |
||||
padding: '0 .7em', |
||||
whiteSpace: 'pre-wrap', |
||||
|
||||
[`& .${classes.header}`]: { |
||||
top: '-.3em', |
||||
left: '-.3em', |
||||
padding: '1.4em 0', |
||||
position: 'absolute', |
||||
content: '""', |
||||
borderColor: DIVIDER, |
||||
borderWidth: '1px', |
||||
borderRadius: BORDER_RADIUS, |
||||
borderStyle: 'solid', |
||||
width: '100%', |
||||
}, |
||||
})); |
||||
|
||||
type Props = { |
||||
children: ReactNode; |
||||
}; |
||||
|
||||
const InnerPanelHeader = ({ children }: Props): JSX.Element => ( |
||||
<StyledBox> |
||||
<div className={classes.header} /> |
||||
{children} |
||||
</StyledBox> |
||||
const InnerPanelHeader: FC = ({ children }) => ( |
||||
<Box sx={{ position: 'relative', whiteSpace: 'pre-wrap' }}> |
||||
<Box |
||||
sx={{ |
||||
borderColor: DIVIDER, |
||||
borderRadius: BORDER_RADIUS, |
||||
borderStyle: 'solid', |
||||
borderWidth: '1px', |
||||
display: 'flex', |
||||
left: '-.3em', |
||||
paddingBottom: '.2em', |
||||
paddingLeft: '1em', |
||||
paddingRight: '.7em', |
||||
paddingTop: '.4em', |
||||
position: 'absolute', |
||||
top: '-.3em', |
||||
width: '100%', |
||||
zIndex: '10', |
||||
|
||||
'& > :first-child': { |
||||
flexGrow: 1, |
||||
}, |
||||
}} |
||||
> |
||||
{children} |
||||
</Box> |
||||
<Box sx={{ paddingBottom: '.4em', width: '100%', visibility: 'hidden' }}> |
||||
{children instanceof Array ? children[0] : children} |
||||
</Box> |
||||
</Box> |
||||
); |
||||
|
||||
export default InnerPanelHeader; |
||||
|
Loading…
Reference in new issue