Last active
March 12, 2019 14:49
-
-
Save vctrtvfrrr/e0576b755a49ef3682354091c6911dcb to your computer and use it in GitHub Desktop.
Sass spacing helper
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
$sizeUnit: rem | |
$marginKey: "m" | |
$paddingKey: "p" | |
$separator: "-" | |
$sizes: ("none", 0), ("auto", auto), ("xxs", 0.125), ("xs", 0.25), ("sm", 0.5), ("md", 1), ("lg", 2), ("xl", 4), ("xxl", 8) | |
$positions: ("t", "top"), ("r", "right"), ("b", "bottom"), ("l", "left") | |
@function sizeValue($key, $value) | |
@return if($key == "none" or $key == "auto", $value, $value + $sizeUnit) | |
@each $size in $sizes | |
$sizeKey: nth($size, 1) | |
$sizeValue: nth($size, 2) | |
.#{$marginKey}#{$separator}#{$sizeKey} | |
margin: sizeValue($sizeKey, $sizeValue) !important | |
@if ($sizeKey != "auto") | |
.#{$paddingKey}#{$separator}#{$sizeKey} | |
padding: sizeValue($sizeKey, $sizeValue) !important | |
@each $position in $positions | |
$posKey: nth($position, 1) | |
$posValue: nth($position, 2) | |
.#{$marginKey}#{$posKey}#{$separator}#{$sizeKey} | |
margin-#{$posValue}: sizeValue($sizeKey, $sizeValue) !important | |
@if ($sizeKey != "auto") | |
.#{$paddingKey}#{$posKey}#{$separator}#{$sizeKey} | |
padding-#{$posValue}: sizeValue($sizeKey, $sizeValue) !important | |
// Alias for margin auto horizontaly and verticaly | |
.mh-auto | |
@extend .ml-auto | |
@extend .mr-auto | |
.mv-auto | |
@extend .mt-auto | |
@extend .mb-auto |
@VictorOtavio @hellokvn how to use bulma's breakpoints?
Awesome. Thanks guys
Great, thanks!
WARNING
This code introduces the issue to Bulma, because it overrides $sizes
variable.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@VictorOtavio @hellokvn we should use
!important
?