Last active
February 5, 2020 15:18
-
-
Save KittyGiraudel/2f733e56552243ac9881 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ---- | |
| // Sass (v3.4.7) | |
| // Compass (v1.0.1) | |
| // ---- | |
| /// Bind all events, including self state if `$self` is true. | |
| /// @author Harry Roberts | |
| /// @link https://github.com/csswizardry/csswizardry.github.com/blob/master/css/_tools.mixins.scss#L13 CSSWizardry | |
| /// @param {Bool} $self - Include self state | |
| /// @output `:hover`, `:active` and `:focus` | |
| @mixin on-event($self: false) { | |
| // If $self is truthy, include self state | |
| @if $self { | |
| &, &:hover, &:active, &:focus { @content } | |
| } | |
| @else { | |
| &:hover, &:active, &:focus { @content } | |
| } | |
| } | |
| /// Define a context for the current selector | |
| /// @author Hugo Giraudel | |
| /// @param {String} $context - Context | |
| /// @output `#{$context} & { ... }` | |
| @mixin when-inside($context) { | |
| #{$context} & { | |
| @content; | |
| } | |
| } | |
| // `on-event` test | |
| element { | |
| opacity: 1; | |
| @include on-event { | |
| opacity: .5; | |
| } | |
| } | |
| // `context` test | |
| element { | |
| opacity: 0; | |
| @include when-inside('.no-opacity') { | |
| visibility: hidden; | |
| } | |
| } | |
| // You can also mix and match | |
| // Although I would not recommend this | |
| // since it can hurt readability. | |
| element { | |
| @include when-inside('.no-opacity') { | |
| visibility: hidden; | |
| @include on-event { | |
| visibility: visible; | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| element { | |
| opacity: 1; | |
| } | |
| element:hover, element:active, element:focus { | |
| opacity: .5; | |
| } | |
| element { | |
| opacity: 0; | |
| } | |
| .no-opacity element { | |
| visibility: hidden; | |
| } | |
| .no-opacity element { | |
| visibility: hidden; | |
| } | |
| .no-opacity element:hover, .no-opacity element:active, .no-opacity element:focus { | |
| visibility: visible; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment