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(css): Add example of :modal #2316

Merged
merged 3 commits into from
Jul 22, 2023
Merged
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
11 changes: 11 additions & 0 deletions live-examples/css-examples/pseudo-class/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,17 @@
"defaultTab": "css",
"height": "tabbed-shorter"
},
"modal": {
"exampleCode": "./live-examples/css-examples/pseudo-class/modal.html",
"cssExampleSrc": "./live-examples/css-examples/pseudo-class/modal.css",
"jsExampleSrc": "./live-examples/css-examples/pseudo-class/modal.js",
"fileName": "pseudo-class-modal.html",
"title": "HTML Demo: :modal",
"type": "tabbed",
"defaultTab": "css",
"tabs": "html,css,js",
"height": "tabbed-shorter"
},
"not": {
"cssExampleSrc": "./live-examples/css-examples/pseudo-class/not.css",
"exampleCode": "./live-examples/css-examples/pseudo-class/not.html",
Expand Down
12 changes: 12 additions & 0 deletions live-examples/css-examples/pseudo-class/modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
button {
display: block;
margin: auto;
width: 10rem;
height: 2rem;
}

:modal {
background-color: beige;
border: 2px solid burlywood;
border-radius: 5px;
}
9 changes: 9 additions & 0 deletions live-examples/css-examples/pseudo-class/modal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<p>Would you like to see a new random number?</p>
<button id="showNumber">Show me</button>

<dialog id="favDialog">
<form method="dialog">
<p>Lucky number is: <strong id="number"></strong></p>
<button>Close dialog</button>
</form>
</dialog>
8 changes: 8 additions & 0 deletions live-examples/css-examples/pseudo-class/modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const showNumber = document.getElementById('showNumber');
const favDialog = document.getElementById('favDialog');
const number = document.getElementById('number');

showNumber.addEventListener('click', () => {
number.innerText = Math.floor(Math.random() * 1000);
favDialog.showModal();
});
Loading