-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(client): Styled Dialog Component (#852)
* feat(client): added dialog for when user wants to log out * feat(client): creating component for dialogs * style(client): removing unused imports
- Loading branch information
Showing
5 changed files
with
170 additions
and
91 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 |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React from 'react'; | ||
import { Dialog, DialogTitle, DialogContent, DialogActions, Button, IconButton } from '@mui/material'; | ||
import { Close as CloseIcon } from '@mui/icons-material'; | ||
import { styled } from '@mui/system'; | ||
|
||
const ContentContainer = styled('div')` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
height: 100%; | ||
width: 100%; | ||
padding-top: 10px; | ||
`; | ||
|
||
const StyledDialogTitleFont = styled('div')` | ||
font-size: 18px; | ||
font-weight: 500; | ||
`; | ||
|
||
const StyledDialogContent = styled(DialogContent)` | ||
padding-bottom: 20px; | ||
`; | ||
|
||
const StyledDialogButtons = styled(DialogActions)` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: flex-end; | ||
align-items: flex-end; | ||
gap: 12px; | ||
padding-bottom: 20px; | ||
padding-right: 24px; | ||
`; | ||
|
||
export const StyledDialogTitle = styled(DialogTitle)` | ||
display: flex; | ||
flex-direction: row; | ||
padding: 8px 12px 8px 24px; | ||
justify-content: space-between; | ||
align-items: center; | ||
`; | ||
|
||
const CustomCloseIconButton = styled(IconButton)` | ||
width: 40px; | ||
height: 40px; | ||
border-radius: 8px; | ||
`; | ||
|
||
// Props definition | ||
interface StyledDialogProps { | ||
open: boolean; | ||
onClose: () => void; | ||
onConfirm: () => void; | ||
title: string; | ||
content: string; | ||
confirmButtonText: string; | ||
cancelButtonText?: string; | ||
disableConfirm?: boolean; | ||
confirmButtonId?: string; | ||
} | ||
|
||
const StyledDialog: React.FC<StyledDialogProps> = ({ | ||
open, | ||
onClose, | ||
onConfirm, | ||
title, | ||
content, | ||
confirmButtonText, | ||
cancelButtonText = 'Cancel', | ||
disableConfirm = false, | ||
confirmButtonId, | ||
}) => ( | ||
<Dialog maxWidth="xs" onClose={onClose} open={open}> | ||
<ContentContainer> | ||
<StyledDialogTitle> | ||
<StyledDialogTitleFont>{title}</StyledDialogTitleFont> | ||
<CustomCloseIconButton onClick={onClose}> | ||
<CloseIcon /> | ||
</CustomCloseIconButton> | ||
</StyledDialogTitle> | ||
<StyledDialogContent>{content}</StyledDialogContent> | ||
</ContentContainer> | ||
<StyledDialogButtons> | ||
<Button onClick={onClose} variant="outlined"> | ||
{cancelButtonText} | ||
</Button> | ||
<Button id={confirmButtonId} onClick={onConfirm} variant="contained" disabled={disableConfirm}> | ||
{confirmButtonText} | ||
</Button> | ||
</StyledDialogButtons> | ||
</Dialog> | ||
); | ||
|
||
export default StyledDialog; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.