Last active
March 21, 2019 13:08
-
-
Save scheibome/62798e0c656995acdec3fe7c9078dc84 to your computer and use it in GitHub Desktop.
SASS font-size and color via sass-map in breakpoints
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
// ---- | |
// Sass (v3.4.25) | |
// Compass (v1.0.3) | |
// ---- | |
$h1-fontsize: ( | |
null: ( | |
size: 26px | |
), | |
'768px': ( | |
size: 50px | |
) | |
); | |
$h2-fontsize: ( | |
null: ( | |
size: 22px, | |
color: null | |
), | |
'768px': ( | |
size: 27px, | |
color: red | |
) | |
); | |
@mixin fontcolor($color) { | |
@if $color { | |
color: $color; | |
} | |
} | |
@mixin fontsize($fs-map) { | |
@each $breakpoints, $settings in $fs-map { | |
$size: map-get($settings, 'size'); | |
$color: map-get($settings, 'color'); | |
@if $breakpoints == null { | |
@include fontcolor($color); | |
font-size: $size; | |
} @else { | |
@media screen and (min-width: $breakpoints) { | |
@include fontcolor($color); | |
font-size: $size; | |
} | |
} | |
} | |
} | |
h1 { | |
@include fontsize($h1-fontsize); | |
} | |
h2 { | |
@include fontsize($h2-fontsize); | |
} |
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
h1 { | |
font-size: 26px; | |
} | |
@media screen and (min-width: 768px) { | |
h1 { | |
font-size: 50px; | |
} | |
} | |
h2 { | |
font-size: 22px; | |
} | |
@media screen and (min-width: 768px) { | |
h2 { | |
color: red; | |
font-size: 27px; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment