feat: Add custom dialog component
This commit is contained in:
parent
eb30a3c077
commit
b13fc5bd16
18
src/components/CloseButton/index.jsx
Normal file
18
src/components/CloseButton/index.jsx
Normal 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;
|
14
src/components/CustomDialog/Transition.jsx
Normal file
14
src/components/CustomDialog/Transition.jsx
Normal 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;
|
46
src/components/CustomDialog/index.jsx
Normal file
46
src/components/CustomDialog/index.jsx
Normal 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;
|
20
src/styles/CloseButton.styles.js
Normal file
20
src/styles/CloseButton.styles.js
Normal 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};
|
||||
}
|
||||
`;
|
17
src/styles/CustomDialog.styles.js
Normal file
17
src/styles/CustomDialog.styles.js
Normal 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};
|
||||
`;
|
Loading…
Reference in New Issue
Block a user