mirror of
https://github.com/kognise/water.css.git
synced 2025-08-13 08:34:45 +02:00
feat: Add <dialog> support
This commit is contained in:
@@ -278,6 +278,21 @@
|
||||
<p>Lorem ipsum dolor sit blah blah.</p>
|
||||
</details>
|
||||
|
||||
<p>The dialog (form, and menu) tag</p>
|
||||
<button type='button' id='dialog-trigger'>Show me the dialog!</button>
|
||||
<span id='dialog-result'></span>
|
||||
<dialog id='dialog'>
|
||||
<header>This is a sample dialog</header>
|
||||
<form method="dialog">
|
||||
<p>What is your favorite pet animal?</p>
|
||||
<menu>
|
||||
<button value="feline">Cats</button>
|
||||
<button value="canine">Dogs</button>
|
||||
<button value="other">Others</button>
|
||||
</menu>
|
||||
</form>
|
||||
</dialog>
|
||||
|
||||
<h3 id="typography">Typography</h3>
|
||||
<p>
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque dictum hendrerit velit, quis
|
||||
|
@@ -77,3 +77,11 @@ copyButton.addEventListener('click', () => {
|
||||
.catch(() => { copyButtonFeedback.textContent = '❌' })
|
||||
.then(() => setTimeout(() => { copyButtonFeedback.textContent = '' }, 1000))
|
||||
})
|
||||
|
||||
document.getElementById('dialog-trigger').addEventListener('click', function (event) {
|
||||
document.getElementById('dialog-result').innerText = '';
|
||||
document.getElementById('dialog').showModal();
|
||||
});
|
||||
document.getElementById('dialog').addEventListener('close', function (event) {
|
||||
document.getElementById('dialog-result').innerText = `Your answer: ${event.target.returnValue}`;
|
||||
});
|
||||
|
@@ -109,6 +109,35 @@ summary::-webkit-details-marker {
|
||||
color: var(--text-main);
|
||||
}
|
||||
|
||||
dialog {
|
||||
background-color: var(--background-alt);
|
||||
color: var(--text-main);
|
||||
|
||||
border: none;
|
||||
border-radius: 6px;
|
||||
border-color: var(--border);
|
||||
|
||||
box-shadow: 0 10px 30px color-mod(var(--border) alpha(0.1)), 0 1px 8px color-mod(var(--border) alpha(0.2));
|
||||
|
||||
padding: 10px 30px;
|
||||
}
|
||||
|
||||
dialog > header {
|
||||
background-color: var(--background);
|
||||
|
||||
border-radius: 6px 6px 0 0;
|
||||
|
||||
margin: -10px -30px 10px;
|
||||
padding: 10px;
|
||||
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
dialog::backdrop {
|
||||
background: color-mod(var(--background-body) alpha(0.15));
|
||||
backdrop-filter: blur(4px);
|
||||
}
|
||||
|
||||
footer {
|
||||
border-top: 1px solid var(--border);
|
||||
padding-top: 10px;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
--text-muted: #70777f;
|
||||
--links: #0076d1;
|
||||
--focus: #0096bfab;
|
||||
--border: #dbdbdb;
|
||||
--border: #363636;
|
||||
--code: #000;
|
||||
--animation-duration: 0.1s;
|
||||
--button-hover: #ddd;
|
||||
|
Reference in New Issue
Block a user