Skip to content

Instantly share code, notes, and snippets.

@SvenBudak
Created February 10, 2022 00:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SvenBudak/339a33db0c1d2cadc5ed32d33bb0c8e6 to your computer and use it in GitHub Desktop.
Save SvenBudak/339a33db0c1d2cadc5ed32d33bb0c8e6 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
$breakpoints: ('xs': 0, 'sm': 600px) !default;
@mixin media-min($var) {@media only screen and (min-width: $var) {@content;}}
@mixin media-max($var) {@media only screen and (max-width: $var - 1px) {@content;}}
@mixin media-from-to($var1, $var2) {@media only screen and (min-width: $var1) and (max-width: $var2 - 1px) {@content;}}
$spacings: (
'margin': (
'shorten-class-names': false,
'directions': ('top', 'right', 'bottom', 'left'),
'spacings': ('4px', '8px'),
'no-classes': true,
'no-min-classes': false,
'no-max-classes': false,
'no-from-to-classes': true,
'base-classes': false,
'base-min-classes': false,
'base-max-classes': false,
'base-from-to-classes': false,
)
);
@each $variants, $variantObject in $spacings {
@each $type in $variants {
// No Classes
@if map-get($variantObject, 'no-classes') {
.no-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($type, 0, 1), $type)} {
#{$type}: 0 !important;
}
@if map-get($variantObject, 'directions') {
@each $direction in map-get($variantObject, 'directions') {
.no-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($type, 0, 1), $type)}-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($direction, 0, 1), $direction)} {
#{$type}-#{$direction}: 0 !important;
}
}
}
}
// No Min Classes
@if map-get($variantObject, 'no-min-classes') {
@each $breakpoint, $res in $breakpoints {
@include media-min($res) {
.no-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($type, 0, 1), $type)}-min-#{$breakpoint} {
#{$type}: 0 !important;
}
@if map-get($variantObject, 'directions') {
@each $direction in map-get($variantObject, 'directions') {
.no-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($type, 0, 1), $type)}-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($direction, 0, 1), $direction)}-min-#{$breakpoint} {
#{$type}-#{$direction}: 0 !important;
}
}
}
}
}
}
// No Max Classes
@if map-get($variantObject, 'no-max-classes') {
@each $breakpoint, $res in $breakpoints {
@include media-max($res) {
.no-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($type, 0, 1), $type)}-max-#{$breakpoint} {
#{$type}: 0 !important;
}
@if map-get($variantObject, 'directions') {
@each $direction in map-get($variantObject, 'directions') {
.no-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($type, 0, 1), $type)}-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($direction, 0, 1), $direction)}-max-#{$breakpoint} {
#{$type}-#{$direction}: 0 !important;
}
}
}
}
}
}
// No From > To Classes
@if map-get($variantObject, 'no-max-classes') {
@each $breakpoint, $res in $breakpoints {
@include media-from-to($res) {
.no-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($type, 0, 1), $type)}-from-to-#{$breakpoint} {
#{$type}: 0 !important;
}
@if map-get($variantObject, 'directions') {
@each $direction in map-get($variantObject, 'directions') {
.no-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($type, 0, 1), $type)}-#{if(map-get($variantObject, 'shorten-class-names'), str-slice($direction, 0, 1), $direction)}-from-to-#{$breakpoint} {
#{$type}-#{$direction}: 0 !important;
}
}
}
}
}
}
}
}
.no-margin {
margin: 0 !important;
}
.no-margin-top {
margin-top: 0 !important;
}
.no-margin-right {
margin-right: 0 !important;
}
.no-margin-bottom {
margin-bottom: 0 !important;
}
.no-margin-left {
margin-left: 0 !important;
}
{
"sass": {
"compiler": "dart-sass/1.32.12",
"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