weddingsite/components/Modal.js

95 lines
2 KiB
JavaScript
Raw Normal View History

2022-11-10 21:26:09 +00:00
import {
Root,
Trigger,
Portal,
Overlay,
Content,
Title,
Description,
Close,
} from '@radix-ui/react-dialog';
2021-06-04 00:58:40 +00:00
import styled from 'styled-components';
2022-11-10 21:26:09 +00:00
const OverlayStyles = styled.div`
background: rgba(0 0 0 / 0.5);
position: fixed;
top: 0%;
left: 0%;
right: 0%;
bottom: 0%;
display: grid;
place-items: center;
overflow-y: auto;
`;
const ContentStyles = styled.div`
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
min-width: 300px;
background: var(--modalBackground);
box-shadow: var(--level-4);
padding: 15px;
border-radius: var(--borderRadius);
width: 50vw;
@media (max-width: 1000px) {
2022-11-10 21:26:09 +00:00
width: 65vw;
}
@media (max-width: 800px) {
2022-11-10 21:26:09 +00:00
width: 68vw;
}
@media (max-width: 650px) {
2022-11-10 21:26:09 +00:00
width: 70vw;
}
@media (max-width: 600px) {
2022-11-10 21:26:09 +00:00
width: 80vw;
}
@media (max-width: 550px) {
2022-11-10 21:26:09 +00:00
width: 90vw;
}
@media (max-width: 500px) {
2022-11-10 21:26:09 +00:00
width: 95vw;
}
2021-06-04 00:58:40 +00:00
`;
export default function Modal({
isOpen,
onHide,
contentLabel,
headerCaption,
children,
}) {
return (
2022-11-10 21:26:09 +00:00
<Root open={isOpen} onOpenChange={onHide}>
<Portal>
<OverlayStyles>
<Overlay>
<ContentStyles>
<Content aria-describedby={contentLabel}>
{/* <div style={{ display: 'grid', margin: '2rem', borderRadius: '4px'}}> */}
<div
style={{
display: 'flex',
flexWrap: 'nowrap',
alignItems: 'center',
justifyContent: headerCaption
? 'space-between'
: 'flex-end',
marginBottom: '1rem',
}}
>
{headerCaption && <Title>{headerCaption}</Title>}
<Close aria-label="Close">x</Close>
</div>
{children}
{/* </div> */}
</Content>
</ContentStyles>
</Overlay>
</OverlayStyles>
</Portal>
</Root>
);
}