Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating Modal component + Adding X Icon to icons folder #62

Merged
merged 4 commits into from
Jan 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions apps/builddao/widget/components/Modal.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const { Button } = VM.require("buildhub.near/widget/components.Button");

const toggle = props.toggle ?? <Button variant="primary">Open Modal</Button>;

const Overlay = styled.div`
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: grid;
place-items: center;
overflow-y: auto;
z-index: 1000;
width: 100vw;
height: 100vh;
background: rgba(11, 12, 20, 0.5);
`;

const Content = styled.div`
min-width: 500px;
max-width: 1000px;
padding: 24px;
outline: none !important;
background: #23242B;
border-radius: 16px;
color: white;
`;

const NoButton = styled.button`
background: transparent;
border: none;
padding: 0;
margin: 0;
box-shadow: none;
`;

const CloseContainer = styled.div`
display: flex;
justify-content: flex-end;
width: 100%;
padding-bottom: 24px;
`;

const Icon = styled.i`
font-size: 24px;
`;

function Modal({ children, open, onOpenChange, toggle, toggleContainerProps }) {
return (
<Dialog.Root open={open} onOpenChange={onOpenChange}>
<Dialog.Trigger asChild>
<NoButton {...toggleContainerProps}>{toggle}</NoButton>
</Dialog.Trigger>
<Dialog.Overlay asChild>
<Overlay>
<Dialog.Content asChild>
<Content>
<Dialog.Trigger asChild>
<CloseContainer>
<Button variant="outline" type="icon">
<Icon className="bi bi-x" />
</Button>
</CloseContainer>
</Dialog.Trigger>
{children}
</Content>
</Dialog.Content>
</Overlay>
</Dialog.Overlay>
</Dialog.Root>
);
}

return { Modal };