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

feat: ✨ add styles for dialog element & its backdrop #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,22 @@ <h2>What can you build with MVP.css?</h2>
<button id="close">Close</button>
</dialog>
</section>

<!-- Dialog HTML Element Example -->
<section>
<button style="margin-top: 6rem;" popovertarget="dialog-modal" id="openDialog">
Open Dialog
</button>

<dialog popover id="dialog-modal">
<h3>Hello, I am a header of the modal</h3>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Quos ullam at assumenda cum placeat aperiam
ab error, doloribus eligendi sit. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quos
ullam.
</p>
</dialog>
</section>
</main>
<footer>
<hr>
Expand Down
56 changes: 47 additions & 9 deletions mvp.css
Original file line number Diff line number Diff line change
Expand Up @@ -442,15 +442,53 @@ label {

/* Popups */
dialog {
max-width: 90%;
max-height: 85dvh;
margin: auto;
padding: 0;
border: 1px solid var(--color-bg-secondary);
border-radius: var(--border-radius);
box-shadow: var(--box-shadow) var(--color-shadow);
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 50%;
z-index: 999;
border-radius: 0.5rem;
overscroll-behavior: contain;
scroll-behavior: smooth;
scrollbar-width: none; /* Hide scrollbar for Firefox */
-ms-overflow-style: none; /* Hide scrollbar for IE and Edge */
scrollbar-color: transparent transparent;
animation: bottom-to-top 0.25s ease-in-out forwards;
}

dialog::-webkit-scrollbar {
width: 0;
display: none;
}

dialog::-webkit-scrollbar-track {
background: transparent;
}

dialog::-webkit-scrollbar-thumb {
background-color: transparent;
}

@media (min-width: 650px) {
dialog {
max-width: 39rem;
}
}

dialog::backdrop {
background-color: rgba(0, 0, 0, 0.5);
}

@keyframes bottom-to-top {
0% {
opacity: 0;
transform: translateY(10%);
}

100% {
opacity: 1;
transform: translateY(0);
}
}

/* Tables */
Expand Down Expand Up @@ -535,4 +573,4 @@ blockquote footer {
*::-webkit-scrollbar-thumb {
background-color: var(--color-scrollbar);
border-radius: 10px;
}
}