Skip to content

Instantly share code, notes, and snippets.

@Snugug
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save Snugug/37424f7b9a02ce5d97f4 to your computer and use it in GitHub Desktop.

Select an option

Save Snugug/37424f7b9a02ce5d97f4 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
<div class="foo" data-eq-state="small medium large">
hello world
</div>
<div class="bar" data-eq-state="small medium large">
hello world
</div>
<div class="foo" data-eq-state="small">
hello world
</div>
// ----
// libsass (v3.1.0)
// ----
@mixin eq($state) {
&[data-eq-state$=#{$state}] {
@content;
}
}
@mixin eq-contains($state) {
&[data-eq-state~=#{$state}] {
@content;
}
}
.foo {
@include eq('large') {
background: blue;
}
}
.foo {
@include eq('small') {
background: red;
}
}
.bar {
@include eq-contains('medium') {
background: green;
}
}
// .bar {
// @include eq-contains('small') {
// background: yellow;
// }
// }
.foo[data-eq-state$=large] {
background: blue; }
.foo[data-eq-state$=small] {
background: red; }
.bar[data-eq-state~=medium] {
background: green; }
<div class="foo" data-eq-state="small medium large">
hello world
</div>
<div class="bar" data-eq-state="small medium large">
hello world
</div>
<div class="foo" data-eq-state="small">
hello world
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment