Created
January 8, 2014 11:41
-
-
Save Rehtrew/8315626 to your computer and use it in GitHub Desktop.
Mixin for inserting list properties at breakpoints in scss.
This file contains 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
h1 { | |
@include breakpoint-property-array($h1--sizes, font-size); | |
} | |
h2 { | |
@include breakpoint-property-array($h2--sizes, font-size); | |
} |
This file contains 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
@function find-value($key, $list) { | |
@each $item in $list { | |
@if ($key == nth($item, 1)) { | |
@return nth($item, 2); | |
} | |
} | |
@return false; | |
} |
This file contains 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
$breakpoints: ( | |
'palm' (max-width 480px), | |
'lap' (481px 1024px), | |
'portable' (max-width 1024px), | |
'desk' 1025px, | |
'cinema' 1919px | |
); | |
$h1--sizes: ( | |
'palm' 40px, | |
'lap' 50px, | |
'portable' 60px, | |
'desk' 70px, | |
'cinema' | |
); | |
$h2--sizes: ( | |
'palm' 22px, | |
'portable' 30px | |
); |
This file contains 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
@mixin breakpoint-property-array($list, $property) { | |
@each $item in $list { | |
$key: nth($item, 1); | |
$declaration: nth($item, 2); | |
@include breakpoint(find-value($key, $breakpoints)) { | |
#{$property} : $declaration; | |
} | |
//@debug 'name (breakpoint): ' + $key + ' declaration: ' + $declaration; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment