Created
April 11, 2019 17:29
-
-
Save jhned/a0ed837cd7d5ffe5971f75286bee479a to your computer and use it in GitHub Desktop.
Fluid Property
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 fluid_property($properties, $sizes, $include-default: true) { | |
$counter: 1; | |
$has-default: false; | |
$breakpoints-keys: map-keys($breakpoints); | |
@each $current-size in $sizes { | |
$continue: false; | |
$next-size: n; | |
@if (length($sizes) == $counter + 1) { | |
$continue: true; | |
} | |
@if (length($sizes) != $counter) { | |
$next-size: nth($sizes, $counter + 1); | |
} | |
$current-breakpoint: map-get($breakpoints, nth($breakpoints-keys, $counter)); | |
@if (1 == $counter) { | |
$current-breakpoint: 375px; | |
} | |
@if (n != $current-size and n != $next-size) { | |
$next-breakpoint: map_get($breakpoints, nth($breakpoints-keys, $counter + 1)); | |
@if (false == $has-default and true == $include-default) { | |
@each $property in $properties { | |
#{$property}: scut-em($current-size); | |
} | |
$has-default: true; | |
} | |
@include between_with_media_queries($properties, $current-size * 1px, $next-size * 1px, $current-breakpoint, $next-breakpoint, $continue); | |
} | |
$counter: $counter + 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage is like this: