Skip to content

Instantly share code, notes, and snippets.

@israelias
Created November 18, 2020 05:45
Show Gist options
  • Save israelias/e099e09b9660076d13f619f180ac06a1 to your computer and use it in GitHub Desktop.
Save israelias/e099e09b9660076d13f619f180ac06a1 to your computer and use it in GitHub Desktop.
Boolean State Indicator
/* Declare default state and action indicators for '.toggle-container' scope. */
.toggle-container {
--current-mode: "interactive/";
--current-state: "collapsible";
--current-action: "expand";
--current-scope: "all";
}
/* Select '.toggle-container' via ':checked' to set values in toggled state. */
#toggle-all:checked + label .toggle-container {
--current-mode: "static/";
--current-state: "expanded";
--current-action: "collapse";
--current-scope: "back";
}
/* Select '.toggle-container' directly and via ':checked' to set values
* for landscape mode. The query is itself the boolean selector that
* overrides previous states.
*/
@media (max-width: 991.98px) and (orientation: landscape) {
.toggle-container,
#toggle-all:checked + label .toggle-container {
--current-mode: "dashboard/";
--current-state: "expanded";
--current-action: "landscape";
--current-scope: "auto";
}
}
/* The state indicator ruleset (snippet) */
#toggle-all + label .toggle-container:after {
content: var(--current-mode) "\a" var(--current-state);
}
/* The action indicator ruleset (snippet) */
#toggle-all + label .toggle-container:before {
content: var(--current-action) "\a" var(--current-scope);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment