Skip to content

Instantly share code, notes, and snippets.

@jleiva
Created September 26, 2014 01:55
Show Gist options
  • Save jleiva/26f3b3bf62b02a1e6cfe to your computer and use it in GitHub Desktop.
Save jleiva/26f3b3bf62b02a1e6cfe to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.4)
// Compass (v1.0.1)
// ----
@function map-getter($listmap, $value) {
@each $item in $listmap {
$index: index($item, $value);
@if $index {
$return: if($index == 1, 2, $index);
@return nth($item, $return);
}
}
@return false;
}
$breakpoints: (
'small': '22.5em', //360px
'small portrait': ('22.5em', 'portrait'),
'medium': '45em', //720px
'medium portrait': ('45em', 'portrait'),
'large': '67.5em', //1080px
'large portrait': ('67.5em', 'portrait')
);
@mixin query($breakpoint, $orientation: 'none') {
$val: map-getter($breakpoints, $breakpoint);
@if $val == false {
@if type-of($breakpoint) == number {
@if $orientation != 'none' {
@media only screen and ("min-width": $breakpoint) and ("orientation": $orientation) {
@content;
}
}
@else {
@media only screen and ("min-width": $breakpoint) {
@content;
}
}
}
@else {
@error 'QUERY MIXINS ERROR: INVALID ARGUMENT'
}
}
@else {
@if type-of($val) == list {
@media only screen and ("min-width": nth($val, 1)) and ("orientation": nth($val, 2)) {
@content;
}
}
@else {
@if $orientation != 'none' {
@media only screen and ("min-width": $val) and ("orientation": $orientation) {
@content;
}
}
@else {
@media only screen and ("min-width": $val) {
@content;
}
}
}
}
};
body {
@include query('small', 'landscape') {text-transform: none;};
@include query('small portrait') {background: red;};
@include query('medium') { border: none;};
@include query('large') { font-weight: bold;};
@include query('large portrait') {padding: none;};
@include query(80, landscape) {margin: 80;};
}
@media only screen and (min-width: 22.5em) and (orientation: landscape) {
body {
text-transform: none;
}
}
@media only screen and (min-width: 22.5em) and (orientation: portrait) {
body {
background: red;
}
}
@media only screen and (min-width: 45em) {
body {
border: none;
}
}
@media only screen and (min-width: 67.5em) {
body {
font-weight: bold;
}
}
@media only screen and (min-width: 67.5em) and (orientation: portrait) {
body {
padding: none;
}
}
@media only screen and (min-width: 80) and (orientation: landscape) {
body {
margin: 80;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment