Skip to content

Instantly share code, notes, and snippets.

@larrybotha
Last active December 27, 2015 08:59
Show Gist options
  • Save larrybotha/7300528 to your computer and use it in GitHub Desktop.
Save larrybotha/7300528 to your computer and use it in GitHub Desktop.
Easily manage styles for pseudo classes, especially [disabled]. Quickly create helper classes for KSS-style pseudo modifiers.

Pseudos Helper Function

Quickly manage disabled styles for an element, multiple pseudo classes, and also create helpers for KSS-style pseudo modifiers (excellent for styleguides).

Full credit goes to @fr4nktic for this technique.

Usage

a
 color: red
 +pseudos(hover focus)
    color: blue

// or even
a
 color: red
  +pseudos(hover focus)
    color: blue
  +pseudos(disabled)
    opacity: 0.4

TODO

Rewrite for scss.

=pseudos($pseudos)
@each $pseudo in $pseudos
@if $pseudo == disabled
&:#{$pseudo},
&[#{$pseudo}],
&[#{$pseudo}]:hover,
&[#{$pseudo}]:active,
&.pseudo-class-#{$pseudo},
&.pseudo-class-#{$pseudo}:hover,
&.pseudo-class-#{$pseudo}:active
@content
@else
&:#{$pseudo},
&.is-#{$pseudo},
&.pseudo-class-#{$pseudo}
@content
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment