feat: Add custom dialog component

This commit is contained in:
jhynsoo 2023-11-09 15:44:30 +09:00
parent eb30a3c077
commit b13fc5bd16
5 changed files with 115 additions and 0 deletions

View File

@ -0,0 +1,18 @@
import * as S from '../../styles/CloseButton.styles';
function CloseButton({ onClick }) {
return (
<S.CloseButton onClick={onClick}>
<svg
xmlns="http://www.w3.org/2000/svg"
height="24"
viewBox="0 -960 960 960"
width="24"
>
<path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z" />
</svg>
</S.CloseButton>
);
}
export default CloseButton;

View File

@ -0,0 +1,14 @@
import { Slide } from '@mui/material';
import React from 'react';
const Transition = React.forwardRef(function Transition(props, ref) {
return (
<Slide
direction="up"
ref={ref}
{...props}
/>
);
});
export default Transition;

View File

@ -0,0 +1,46 @@
import * as S from '../../styles/CustomDialog.styles';
import { Dialog } from '@mui/material';
import Transition from './transition';
import CloseButton from '../CloseButton';
function CustomDialog({
children,
open,
onClose,
hasCloseButton = true,
title,
}) {
return (
<Dialog
open={open}
onClose={onClose}
TransitionComponent={Transition}
PaperProps={{
style: {
display: 'flex',
flexDirection: 'column',
gap: '24px',
padding: '24px',
borderRadius: '20px',
},
}}
slotProps={{
backdrop: {
style: {
backdropFilter: 'blur(5px)',
},
},
}}
>
{hasCloseButton && (
<S.DialogHeader>
<S.DialogTitle>{title}</S.DialogTitle>
<CloseButton onClick={onClose} />
</S.DialogHeader>
)}
{children}
</Dialog>
);
}
export default CustomDialog;

View File

@ -0,0 +1,20 @@
import styled from 'styled-components';
export const CloseButton = styled.button`
display: flex;
justify-content: center;
align-items: center;
width: 24px;
height: 24px;
border: none;
background-color: transparent;
cursor: pointer;
outline: none;
padding: 0;
& > svg {
width: 24px;
height: 24px;
fill: ${({ theme }) => theme.colors.gray700};
}
`;

View File

@ -0,0 +1,17 @@
import styled from 'styled-components';
export const DialogHeader = styled.header`
display: flex;
justify-content: space-between;
align-items: center;
`;
export const DialogTitle = styled.h2`
font-size: 18px;
font-weight: 700;
padding: 0 8px;
margin: 0;
user-select: none;
box-sizing: border-box;
color: ${({ theme }) => theme.colors.gray900};
`;