Skip to content

Instantly share code, notes, and snippets.

@scheibome
Last active October 22, 2021 08:57
Show Gist options
  • Save scheibome/9bb2e4ca750452944401d38f41f351f1 to your computer and use it in GitHub Desktop.
Save scheibome/9bb2e4ca750452944401d38f41f351f1 to your computer and use it in GitHub Desktop.
Spacing before and after in scss with scss-maps
$spacing-orientation-map: (
'frame-space-before': 'top',
'frame-space-after': 'bottom'
);
$spacing-map: (
'extra-small': '1',
'small': '2'
);
@each $o-key, $o-value in $spacing-orientation-map {
.#{$o-key} {
@each $key, $value in $spacing-map {
&-#{$key} {
@if $o-value == top {
margin-top: #{$value}rem;
} @else if $o-value == bottom {
margin-bottom: #{$value}rem;
}
}
}
}
}
.frame-space-before-extra-small {
margin-top: 1rem;
}
.frame-space-before-small {
margin-top: 2rem;
}
.frame-space-after-extra-small {
margin-bottom: 1rem;
}
.frame-space-after-small {
margin-bottom: 2rem;
}
{
"sass": {
"compiler": "dart-sass/1.26.11",
"extensions": {},
"syntax": "SCSS",
"outputStyle": "expanded"
},
"autoprefixer": false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment