Skip to content

Commit

Permalink
feat(css): Add example of :indeterminate and :defined (#2199)
Browse files Browse the repository at this point in the history
* indeterminate, defined

* lin & size

* Update live-examples/css-examples/pseudo-class/defined.html

Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>

* Update live-examples/css-examples/pseudo-class/indeterminate.html

Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>

---------

Co-authored-by: Estelle Weyl <estelle@openwebdocs.org>
  • Loading branch information
NiedziolkaMichal and estelle authored Jul 28, 2023
1 parent 8d776bb commit 80a67b5
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 0 deletions.
9 changes: 9 additions & 0 deletions live-examples/css-examples/pseudo-class/defined.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.all-elements > * {
display: block;
margin: 20px 0;
}

.all-elements > *:defined {
outline: 2px solid deeppink;
outline-offset: 2px;
}
9 changes: 9 additions & 0 deletions live-examples/css-examples/pseudo-class/defined.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div class="all-elements">
<p>This is an ordinary <b>&;lt;p&gt;</b> element.</p>

<invalid>This <b>&;lt;invalid&gt;</b> element is not defined, but has no hyphen.</invalid>

<not-registered>This <b>&;lt;not-registered&gt;</b> element is neither defined nor registered.</not-registered>

<registered-custom>This <b>&;lt;registered-custom&gt;</b> element is registered.</registered-custom>
</div>
3 changes: 3 additions & 0 deletions live-examples/css-examples/pseudo-class/defined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class RegisteredCustom extends HTMLElement {}

customElements.define('registered-custom', RegisteredCustom);
9 changes: 9 additions & 0 deletions live-examples/css-examples/pseudo-class/indeterminate.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
label {
display: block;
margin-top: 0.3em;
}

*:indeterminate {
outline: 2px solid deeppink;
outline-offset: 2px;
}
12 changes: 12 additions & 0 deletions live-examples/css-examples/pseudo-class/indeterminate.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<form>
<p>How did you find out about us?</p>
<label><input name="origin" type="radio" value="duck"> Duck-duck-go</label>
<label><input name="origin" type="radio" value="mastodon"> Mastodon</label>

<p>Choose your subscriptions:</p>
<label><input id="newsletter" name="newsletter" type="checkbox"> Newsletter</label>
<label><input id="premium" disabled name="premium" type="checkbox"> Premium Card</label>

<p>Please wait for rest of the form:</p>
<progress id="loading"></progress>
</form>
15 changes: 15 additions & 0 deletions live-examples/css-examples/pseudo-class/indeterminate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var newsletter = document.getElementById('newsletter');
var premium = document.getElementById('premium');

premium.indeterminate = true;

newsletter.addEventListener('change', function() {
if (this.checked) {
premium.disabled = false;
premium.indeterminate = false;
} else {
premium.checked = false;
premium.disabled = true;
premium.indeterminate = true;
}
});
22 changes: 22 additions & 0 deletions live-examples/css-examples/pseudo-class/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@
"defaultTab": "css",
"height": "tabbed-shorter"
},
"defined": {
"cssExampleSrc": "./live-examples/css-examples/pseudo-class/defined.css",
"exampleCode": "./live-examples/css-examples/pseudo-class/defined.html",
"jsExampleSrc": "./live-examples/css-examples/pseudo-class/defined.js",
"fileName": "pseudo-class-defined.html",
"title": "CSS Demo: :defined",
"type": "tabbed",
"defaultTab": "css",
"tabs": "html,css,js",
"height": "tabbed-shorter"
},
"disabled": {
"cssExampleSrc": "./live-examples/css-examples/pseudo-class/disabled.css",
"exampleCode": "./live-examples/css-examples/pseudo-class/disabled.html",
Expand Down Expand Up @@ -90,6 +101,17 @@
"defaultTab": "css",
"height": "tabbed-shorter"
},
"indeterminate": {
"cssExampleSrc": "./live-examples/css-examples/pseudo-class/indeterminate.css",
"exampleCode": "./live-examples/css-examples/pseudo-class/indeterminate.html",
"jsExampleSrc": "./live-examples/css-examples/pseudo-class/indeterminate.js",
"fileName": "pseudo-class-indeterminate.html",
"title": "CSS Demo: :indeterminate",
"type": "tabbed",
"defaultTab": "css",
"tabs": "html,css,js",
"height": "tabbed-standard"
},
"focus": {
"cssExampleSrc": "./live-examples/css-examples/pseudo-class/focus.css",
"exampleCode": "./live-examples/css-examples/pseudo-class/focus.html",
Expand Down

0 comments on commit 80a67b5

Please sign in to comment.