Last active
August 29, 2015 14:27
-
-
Save EdwardIrby/771d083985f5cf887bec to your computer and use it in GitHub Desktop.
Media Query Mixins with maps
This file contains hidden or 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
@import "StyleVars.json"; | |
@mixin max-media($breakpoint) { | |
@if map-has-key($breakpoints, $breakpoint){ | |
@media(max-width:(map-get($breakpoints, $breakpoint) - 1) + px){ | |
@content | |
} | |
} | |
@else if round($breakpoint) == $breakpoint{ | |
@media(max-width:$breakpoint - 1px){ | |
@content | |
} | |
} | |
@else { | |
@warn "Unfortunately, no value could be retrieved from `#{$breakpoint}`. " | |
+ "Please make sure it is defined in `$breakpoints` map. or a valid interger"; | |
} | |
} | |
@mixin min-media($breakpoint) { | |
@if map-has-key($breakpoints, $breakpoint){ | |
@media(min-width:(map-get($breakpoints, $breakpoint)) + px){ | |
@content | |
} | |
} | |
@else if round($breakpoint) == $breakpoint{ | |
@media(min-width:$breakpoint){ | |
@content | |
} | |
} | |
@else { | |
@warn "Unfortunately, no value could be retrieved from `#{$breakpoint}`. " | |
+ "Please make sure it is defined in `$breakpoints` map. or a valid interger"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment