-
-
Notifications
You must be signed in to change notification settings - Fork 16
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 #1798 from AletheiaFact/Migrating-all-modal-for-MUI
Migrating all modals to MUI
- Loading branch information
Showing
11 changed files
with
282 additions
and
164 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
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,80 +1,126 @@ | ||
import { Button, Modal } from "antd"; | ||
import { Dialog, DialogTitle, DialogContent, IconButton, Button } from "@mui/material"; | ||
import CloseOutlined from "@mui/icons-material/CloseOutlined"; | ||
import styled from "styled-components"; | ||
import colors from "../../styles/colors"; | ||
import { NameSpaceEnum } from "../../types/Namespace"; | ||
|
||
const AletheiaModal = styled(Modal)` | ||
background: none; | ||
box-shadow: none; | ||
padding: 0; | ||
const DefaultModal = styled(Dialog)` | ||
display: flex; | ||
justify-content: center; | ||
align-self: center; | ||
.ant-modal-content { | ||
width: ${(props) => (props.width ? props.width : "300px")}; | ||
margin: 0 auto; | ||
border-radius: 8px; | ||
background-color: ${(props) => | ||
props.theme === "dark" ? colors.black : colors.lightNeutral}; | ||
box-shadow: 0px 0px 15px ${colors.shadow}; | ||
padding: 26px 26px; | ||
max-width: 90vw; | ||
} | ||
.MuiDialog-paper { | ||
width: ${(props) => (props.width ? props.width : "300px")}; | ||
margin: 0 auto; | ||
border-radius: 8px; | ||
background-color: ${(props) => | ||
props.theme === "dark" ? colors.black : colors.lightNeutral}; | ||
box-shadow: 0px 0px 15px ${colors.shadow}; | ||
padding: 24px; | ||
max-width: 90vw; | ||
} | ||
.ant-modal-body { | ||
padding: 0; | ||
} | ||
.MuiDialogTitle-root { | ||
color: ${(props) => props.theme === "dark" ? colors.white : colors.black}; | ||
font-size: 14px; | ||
line-height: 20px; | ||
margin-bottom: 12; | ||
padding: 0; | ||
} | ||
.ant-modal-header { | ||
background: none; | ||
border-bottom: 0px; | ||
padding: 0 0 10px 0; | ||
} | ||
.MuiDialogActions-root { | ||
display: flex; | ||
justify-content: center; | ||
font-size: 24px; | ||
line-height: 24px; | ||
padding: 20px 0; | ||
} | ||
.ant-modal-title { | ||
color: ${(props) => | ||
props.theme === "dark" ? colors.white : colors.black}; | ||
font-weight: 700; | ||
font-size: 14px; | ||
text-align: center; | ||
text-transform: uppercase; | ||
padding: 0 32px; | ||
} | ||
.MuiIconButton-root { | ||
top: 10px; | ||
right: 10px; | ||
position: absolute; | ||
color: ${(props) => | ||
props.theme === "dark" ? colors.white : colors.primary}; | ||
} | ||
svg[data-icon="close"] { | ||
margin-top: 26px; | ||
width: 14px; | ||
height: 14px; | ||
color: ${(props) => | ||
props.theme === "dark" ? colors.white : colors.primary}; | ||
margin-right: 20px; | ||
} | ||
.MuiDialogContent-root { | ||
font-size: 14px; | ||
padding: 0; | ||
} | ||
.ant-modal-body .modal-title { | ||
display: flex; | ||
gap: 10px; | ||
width: calc(100% - 20px); | ||
font-size: 24px; | ||
line-height: 24px; | ||
} | ||
.MuiButtonBase-root { | ||
color: ${({ namespace }) => | ||
namespace === NameSpaceEnum.Main ? colors.primary : colors.secondary}; | ||
font-size: 14px; | ||
} | ||
.hide-modal { | ||
color: ${colors.warning}; | ||
} | ||
.hide-modal { | ||
color: ${colors.warning}; | ||
} | ||
.delete-modal { | ||
color: #ca1105; | ||
} | ||
.delete-modal { | ||
color: #ca1105; | ||
} | ||
`; | ||
|
||
const ModalCancelButton = styled(Button)` | ||
height: 40px; | ||
width: 120px; | ||
color: ${({ namespace }) => | ||
namespace === NameSpaceEnum.Main | ||
? colors.primary | ||
: colors.secondary}; | ||
namespace === NameSpaceEnum.Main | ||
? colors.primary | ||
: colors.secondary}; | ||
text-align: "center"; | ||
font-weight: 700; | ||
font-size: 14; | ||
`; | ||
|
||
interface AletheiaModalProps { | ||
open: boolean; | ||
closeIcon?: React.ReactNode; | ||
width?: string; | ||
theme?: string; | ||
namespace?: NameSpaceEnum; | ||
onCancel?: () => void; | ||
style?: React.CSSProperties; | ||
title?: React.ReactNode; | ||
children: React.ReactNode; | ||
} | ||
|
||
const AletheiaModal: React.FC<AletheiaModalProps> = ({ | ||
open, | ||
closeIcon = true, | ||
onCancel, | ||
style = {}, | ||
title, | ||
children, | ||
width, | ||
theme, | ||
namespace | ||
}) => ( | ||
<DefaultModal | ||
open={open} | ||
onClose={onCancel} | ||
width={width} | ||
theme={theme} | ||
namespace={namespace} | ||
style={{ ...style }} | ||
> | ||
<DialogTitle> | ||
{title} | ||
{typeof closeIcon === 'boolean' ? ( | ||
<IconButton size="small" onClick={onCancel}> | ||
<CloseOutlined /> | ||
</IconButton> | ||
) : ( | ||
<IconButton size="small" onClick={onCancel}> | ||
{closeIcon} | ||
</IconButton> | ||
)} | ||
</DialogTitle> | ||
<DialogContent>{children}</DialogContent> | ||
</DefaultModal> | ||
); | ||
|
||
export { AletheiaModal, ModalCancelButton }; |
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.