Modal
Components
Work in progress...
Demo
<button onclick="document.querySelector('x-modal').active = true">Show Modal</button>
<x-modal>
<x-modal-content>
<div>A Modal</div>
<x-modal-dismiss>X</x-modal-dismiss>
</x-modal-content>
</x-modal>
x-modal {
position: fixed;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
opacity: 0;
visibility: hidden;
transform: scale(1.1);
transition: visibility 0s linear 0.25s, opacity 0.25s 0s, transform 0.25s;
&[active] {
opacity: 1;
visibility: visible;
transform: scale(1.0);
transition: visibility 0s linear 0s, opacity 0.25s 0s, transform 0.25s;
}
x-modal-content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: white;
padding: 1rem 1.5rem;
width: 24rem;
border-radius: 0.5rem;
display: flex;
justify-content: space-between;
}
x-modal-dismiss {
cursor: pointer;
border: 1px solid black;
padding: 4px;
}
}
A Modal
X