Skip to content

Instantly share code, notes, and snippets.

@JoeCianflone
Created May 30, 2021 17:52
Show Gist options
  • Select an option

  • Save JoeCianflone/14c77448bc3caf6abf2356a01d9c9d64 to your computer and use it in GitHub Desktop.

Select an option

Save JoeCianflone/14c77448bc3caf6abf2356a01d9c9d64 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
@mixin when($parent-selector, $child: &) {
@at-root {
#{$parent-selector} #{$child} {
@extend #{$child};
@content;
}
}
}
.foo {
color: red;
@include when('.bar') {
@media(min-width: 500px) {
color: green;
}
}
}
.media {
display: flex;
&--visual {
background: #ccc;
height: 200px;
width: 200px;
@media (min-width: 500px) {
border: 2px solid green;
}
@include when('.media--flip') {
order: 2;
@media(min-width: 500px) {
border: 2px solid blue;
}
}
}
&--content {
padding: 0 0 0 10px;
@include when('.media--flip') {
padding: 0 10px 0 0;
}
}
&--headline {
color: green;
}
}
<div class="media media--flip">
<div class="media--visual"></div>
<div class="media--content">
<div class="media--headline">
<h2>Hello There</h2>
</div>
<div class="media--body">
<p>This is a test</p>
</div>
</div>
</div>
.foo, .bar .foo {
color: red;
}
@media (min-width: 500px) {
.bar .foo {
color: green;
}
}
.media {
display: flex;
}
.media--visual, .media--flip .media--visual {
background: #ccc;
height: 200px;
width: 200px;
}
@media (min-width: 500px) {
.media--visual, .media--flip .media--visual {
border: 2px solid green;
}
}
.media--flip .media--visual {
order: 2;
}
@media (min-width: 500px) {
.media--flip .media--visual {
border: 2px solid blue;
}
}
.media--content, .media--flip .media--content {
padding: 0 0 0 10px;
}
.media--flip .media--content {
padding: 0 10px 0 0;
}
.media--headline {
color: green;
}
{
"sass": {
"compiler": "dart-sass/1.32.12",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment