Skip to content

Instantly share code, notes, and snippets.

@davision
Forked from kieranmv95/_spacing-helper.scss
Last active August 8, 2020 10:53
Show Gist options
  • Save davision/6e36e327c792b00f44dbf4d476369143 to your computer and use it in GitHub Desktop.
Save davision/6e36e327c792b00f44dbf4d476369143 to your computer and use it in GitHub Desktop.
Generates a array of spacing helper classes for margin and padding
// Customisable spacing units. these can be changed and new ones added
$spacing-units: (
1: 1rem,
2: 2rem,
3: 3rem,
4: 4rem,
5: 5rem,
6: 6rem,
);
// These will not change this is just to help generate the classes with the correct naming
$spacing-naming: (
top: t,
right: r,
bottom: b,
left: l
);
@each $key, $value in $spacing-units {
@each $keyq, $valueq in $spacing-naming {
.m#{$valueq}-#{$key} {
margin-#{$keyq}: $value;
}
}
@each $keyq, $valueq in $spacing-naming {
.p#{$valueq}-#{$key} {
padding-#{$keyq}: $value;
}
}
.pa-#{$key} {
padding: $value;
}
.ma-#{$key} {
margin: $value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment