Skip to content

Instantly share code, notes, and snippets.

@EdwardIrby
Last active August 29, 2015 14:27
Show Gist options
  • Save EdwardIrby/771d083985f5cf887bec to your computer and use it in GitHub Desktop.
Save EdwardIrby/771d083985f5cf887bec to your computer and use it in GitHub Desktop.
Media Query Mixins with maps
@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