-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: carson comments, remove makeStyles favoring MUI
- Loading branch information
1 parent
7d302d3
commit 25583a8
Showing
6 changed files
with
153 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,63 @@ | ||
import { Edit } from '@mui/icons-material'; | ||
import { Box, Skeleton, Tooltip, Typography } from '@mui/material'; | ||
import { | ||
Box, | ||
Divider, | ||
Skeleton, | ||
Stack, | ||
Tooltip, | ||
Typography, | ||
} from '@mui/material'; | ||
import { ReactNode } from 'react'; | ||
import { StyleProps } from '~/common'; | ||
import { IconButton } from '../IconButton'; | ||
|
||
interface EditableSectionProps { | ||
interface EditableSectionProps extends StyleProps { | ||
children?: ReactNode; | ||
title?: string; | ||
tooltipTitle?: string; | ||
partner?: boolean; | ||
loading?: boolean; | ||
canEdit?: boolean; | ||
onEdit?: () => void; | ||
} | ||
|
||
export const EditableSection = ({ | ||
partner, | ||
loading, | ||
canEdit, | ||
onEdit, | ||
title, | ||
tooltipTitle, | ||
children, | ||
...rest | ||
}: EditableSectionProps) => { | ||
return ( | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
padding: '8px', | ||
borderBottom: '1px solid #e0e0e0', | ||
}} | ||
> | ||
<Typography variant="h3"> | ||
{partner ? title : <Skeleton width="120px" />} | ||
</Typography> | ||
{partner && ( | ||
<Box {...rest} component="section"> | ||
<Box | ||
sx={{ | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
p: 1, | ||
}} | ||
> | ||
<Typography variant="h3"> | ||
{!loading ? title : <Skeleton width="120px" />} | ||
</Typography> | ||
<Tooltip title={tooltipTitle}> | ||
<IconButton disabled={!canEdit} onClick={onEdit}> | ||
<Edit /> | ||
</IconButton> | ||
<span> | ||
<IconButton disabled={!canEdit} onClick={onEdit} loading={loading}> | ||
<Edit /> | ||
</IconButton> | ||
</span> | ||
</Tooltip> | ||
)} | ||
</Box> | ||
<Divider /> | ||
<Stack | ||
sx={{ | ||
p: 2, | ||
}} | ||
> | ||
{children} | ||
</Stack> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.