Skip to content

Instantly share code, notes, and snippets.

@czajkovsky
Last active August 29, 2015 13:58
Show Gist options
  • Save czajkovsky/10103251 to your computer and use it in GitHub Desktop.
Save czajkovsky/10103251 to your computer and use it in GitHub Desktop.
// variables.scss
$screen-phone: 767px;
$screen-rest: $screen-phone + 1px;
// mixins.scss
$is_phone: 0;
@mixin responsive {
$is_phone: 0;
@media screen and (min-width: $screen-rest) {
@content;
}
$is_phone: 1;
@content;
}
@mixin r($rule, $phone, $rest) {
@if $is_phone == 1 {
#{$rule}: $phone;
}
@else {
#{$rule}: $rest;
}
}
// view or component
.foo {
margin: 10px;
@include responsive {
@include r(padding, 10px, 20px);
@include r(content, "phone", "the rest");
}
}
.foo {
margin: 10px;
padding: 10px;
content: "phone";
}
@media screen and (min-width: 768px) {
.foo {
padding: 20px;
content: "the rest";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment