Skip to content

Commit

Permalink
feat(css): Add example of :modal (#2316)
Browse files Browse the repository at this point in the history
  • Loading branch information
NiedziolkaMichal committed Jul 22, 2023
1 parent 1d69481 commit 173563a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
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 @@ -222,6 +222,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();
});

0 comments on commit 173563a

Please sign in to comment.