generated from layer5io/layer5-repo-template
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #527 from sudhanshutech/genric/modal
Genric or Custom Modal
- Loading branch information
Showing
10 changed files
with
169 additions
and
54 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
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 |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Backdrop, type DialogProps } from '@mui/material'; | ||
import { Dialog } from '../../base/Dialog'; | ||
import { DialogTitle } from '../../base/DialogTitle'; | ||
import StyledDialogActions from './StyledDialogActions'; | ||
import StyledDialogContent from './StyledDialogContent'; | ||
import { ButtonContainer, ContentContainer, HeaderModal, ModalWrapper } from './style'; | ||
|
||
export interface CustomDialogProps { | ||
open: boolean; | ||
fullScreen?: boolean; | ||
title?: string; | ||
leftHeaderIcon?: React.ReactNode; | ||
helpText?: string; | ||
helpArea?: React.ReactNode; | ||
actions?: React.ReactNode; | ||
hideActions?: boolean; | ||
styleContent?: React.CSSProperties; | ||
content: React.ReactNode; | ||
maxWidth?: DialogProps['maxWidth']; | ||
onClose: () => void; | ||
} | ||
|
||
function CustomDialog({ | ||
open, | ||
onClose, | ||
title, | ||
leftHeaderIcon, | ||
helpText, | ||
helpArea, | ||
actions, | ||
hideActions = false, | ||
content, | ||
maxWidth = 'xs', | ||
...props | ||
}: CustomDialogProps): JSX.Element { | ||
return ( | ||
<Dialog | ||
sx={{ | ||
'& .MuiDialog-paper': { | ||
borderRadius: '10px' | ||
} | ||
}} | ||
open={open} | ||
maxWidth={maxWidth} | ||
onClose={onClose} | ||
slots={{ backdrop: Backdrop }} | ||
slotProps={{ | ||
backdrop: { | ||
timeout: 500 | ||
} | ||
}} | ||
{...props} | ||
> | ||
<ModalWrapper> | ||
<HeaderModal> | ||
{leftHeaderIcon && ( | ||
<div style={{ display: 'flex', alignItems: 'center' }}>{leftHeaderIcon}</div> | ||
)} | ||
{title && ( | ||
<> | ||
<div style={{ display: 'flex', alignItems: 'center' }}> | ||
<DialogTitle>{title}</DialogTitle> | ||
</div> | ||
</> | ||
)} | ||
|
||
<div style={{ display: 'flex', alignItems: 'center' }}> | ||
{helpText && <div>{helpArea}</div>} | ||
</div> | ||
</HeaderModal> | ||
<StyledDialogContent> | ||
<ContentContainer>{content}</ContentContainer> | ||
</StyledDialogContent> | ||
{!hideActions && ( | ||
<StyledDialogActions> | ||
<ButtonContainer>{actions}</ButtonContainer> | ||
</StyledDialogActions> | ||
)} | ||
</ModalWrapper> | ||
</Dialog> | ||
); | ||
} | ||
|
||
export default CustomDialog; |
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
export { default as StyledDialog } from './StyledDialog'; | ||
export { default as CustomDialog } from './CustomDialog'; | ||
export { default as StyledDialogActions } from './StyledDialogActions'; | ||
export { default as StyledDialogContent } from './StyledDialogContent'; | ||
export { default as StyledDialogTitle } from './StyledDialogTitle'; |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { styled } from '@mui/material'; | ||
import { | ||
BLACK, | ||
BUTTON_MODAL, | ||
BUTTON_MODAL_DARK, | ||
NOT_FOUND, | ||
SLIGHT_BLACK_2, | ||
SLIGHT_BLUE, | ||
WHITE | ||
} from '../../theme/colors/colors'; | ||
|
||
export const HeaderModal = styled('div')(({ theme }) => { | ||
const startColor = theme.palette.mode === 'light' ? BUTTON_MODAL : BLACK; | ||
const endColor = theme.palette.mode === 'light' ? SLIGHT_BLUE : SLIGHT_BLACK_2; | ||
|
||
return { | ||
display: 'flex', | ||
justifyContent: 'space-between', | ||
padding: '1rem', | ||
boxShadow: 'inset 0px -1px 3px 0px rgba(0,0,0,0.2)', | ||
background: `linear-gradient(90deg, ${startColor}, ${endColor})`, | ||
filter: | ||
theme.palette.mode === 'light' | ||
? `progid:DXImageTransform.Microsoft.gradient(startColorstr='${BUTTON_MODAL}',endColorstr='${SLIGHT_BLUE}',GradientType=1)` | ||
: `progid:DXImageTransform.Microsoft.gradient(startColorstr='${BUTTON_MODAL_DARK}',GradientType=1)` | ||
}; | ||
}); | ||
|
||
export const ModalWrapper = styled('div')(() => ({ | ||
zIndex: '100', | ||
borderRadius: '5px' | ||
})); | ||
|
||
export const ButtonContainer = styled('div')(({ theme }) => ({ | ||
padding: '1rem 1.5rem', | ||
display: 'flex', | ||
justifyContent: 'flex-end', | ||
backgroundColor: theme.palette.mode === 'light' ? BUTTON_MODAL : BUTTON_MODAL_DARK, | ||
boxShadow: 'inset 0px 3px 5px 0px rgba(0,0,0,0.25)' | ||
})); | ||
|
||
export const ContentContainer = styled('div')(({ theme }) => ({ | ||
padding: '2rem 1rem', | ||
backgroundColor: theme.palette.mode === 'light' ? WHITE : NOT_FOUND | ||
})); |
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