Skip to content

Instantly share code, notes, and snippets.

@daphotron
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save daphotron/91ca013d8e46aacd0f43 to your computer and use it in GitHub Desktop.

Select an option

Save daphotron/91ca013d8e46aacd0f43 to your computer and use it in GitHub Desktop.
Sass Maps for spacing
// padding and margin
$space_orientation: (
v,
h
);
$space_direction: (
top,
right,
bottom,
left
);
$space_sizes:
(xs, 0.25em),
(s, 0.5em),
('', 1em),
(m, 1.5em),
(l, 2em)
;
@each $space_direction, $direction in $space_direction {
@each $space_sizes, $size in $space_sizes {
$hyphen: '';
@if $space_sizes != ''{
$hyphen: '-';
}
.pad-#{$space_direction}#{$hyphen}#{$space_sizes} {
padding-#{$space_direction}: $size;
}
.gap-#{$space_direction}#{$hyphen}#{$space_sizes} {
margin-#{$space_direction}: $size;
}
}
}
@each $space_orientation, $orientation in $space_orientation {
@each $space_sizes, $size in $space_sizes {
$hyphen: '';
@if $space_sizes != ''{
$hyphen: '-';
}
@if $space_orientation == "v" {
.pad-#{$space_orientation}#{$hyphen}#{$space_sizes} {
padding-bottom: $size;
padding-top: $size;
}
.gap-#{$space_orientation}#{$hyphen}#{$space_sizes} {
margin-bottom: $size;
margin-top: $size;
}
}
@else {
.pad-#{$space_orientation}#{$hyphen}#{$space_sizes} {
padding-left: $size;
padding-right: $size;
}
.gap-#{$space_orientation}#{$hyphen}#{$space_sizes} {
margin-left: $size;
margin-right: $size;
}
}
}
}
// border
$border_direction: (
top,
right,
bottom,
left
);
$border_sizes:
(m, 5px),
('', 2px),
(s, 1px)
;
@each $border_direction, $direction in $border_direction {
@each $border_sizes, $width in $border_sizes {
@if $border_sizes != "" {
.border-#{$border_direction}-#{$border_sizes} {
border-#{$border_direction}: $width solid $color-border-soft;
}
}
@else {
.border-#{$border_direction} {
border-#{$border_direction}: $width solid $color-border-soft;
}
}
}
}
// spaces
.pad-top-xs {
padding-top: 0.25em
}
.gap-top-xs {
margin-top: 0.25em
}
.pad-top-s {
padding-top: 0.5em
}
.gap-top-s {
margin-top: 0.5em
}
.pad-top {
padding-top: 1em
}
.gap-top {
margin-top: 1em
}
.pad-top-m {
padding-top: 1.5em
}
.gap-top-m {
margin-top: 1.5em
}
.pad-top-l {
padding-top: 2em
}
.gap-top-l {
margin-top: 2em
}
.pad-right-xs {
padding-right: 0.25em
}
.gap-right-xs {
margin-right: 0.25em
}
.pad-right-s {
padding-right: 0.5em
}
.gap-right-s {
margin-right: 0.5em
}
.pad-right {
padding-right: 1em
}
.gap-right {
margin-right: 1em
}
.pad-right-m {
padding-right: 1.5em
}
.gap-right-m {
margin-right: 1.5em
}
.pad-right-l {
padding-right: 2em
}
.gap-right-l {
margin-right: 2em
}
.pad-bottom-xs {
padding-bottom: 0.25em
}
.gap-bottom-xs {
margin-bottom: 0.25em
}
.pad-bottom-s {
padding-bottom: 0.5em
}
.gap-bottom-s {
margin-bottom: 0.5em
}
.pad-bottom {
padding-bottom: 1em
}
.gap-bottom {
margin-bottom: 1em
}
.pad-bottom-m {
padding-bottom: 1.5em
}
.gap-bottom-m {
margin-bottom: 1.5em
}
.pad-bottom-l {
padding-bottom: 2em
}
.gap-bottom-l {
margin-bottom: 2em
}
.pad-left-xs {
padding-left: 0.25em
}
.gap-left-xs {
margin-left: 0.25em
}
.pad-left-s {
padding-left: 0.5em
}
.gap-left-s {
margin-left: 0.5em
}
.pad-left {
padding-left: 1em
}
.gap-left {
margin-left: 1em
}
.pad-left-m {
padding-left: 1.5em
}
.gap-left-m {
margin-left: 1.5em
}
.pad-left-l {
padding-left: 2em
}
.gap-left-l {
margin-left: 2em
}
.pad-v-xs {
padding-bottom: 0.25em;
padding-top: 0.25em
}
.gap-v-xs {
margin-bottom: 0.25em;
margin-top: 0.25em
}
.pad-v-s {
padding-bottom: 0.5em;
padding-top: 0.5em
}
.gap-v-s {
margin-bottom: 0.5em;
margin-top: 0.5em
}
.pad-v {
padding-bottom: 1em;
padding-top: 1em
}
.gap-v {
margin-bottom: 1em;
margin-top: 1em
}
.pad-v-m {
padding-bottom: 1.5em;
padding-top: 1.5em
}
.gap-v-m {
margin-bottom: 1.5em;
margin-top: 1.5em
}
.pad-v-l {
padding-bottom: 2em;
padding-top: 2em
}
.gap-v-l {
margin-bottom: 2em;
margin-top: 2em
}
// borders
.border-top-m {
border-top: 5px solid #e0d8d8
}
.border-top {
border-top: 2px solid #e0d8d8
}
.border-top-s {
border-top: 1px solid #e0d8d8
}
.border-right-m {
border-right: 5px solid #e0d8d8
}
.border-right {
border-right: 2px solid #e0d8d8
}
.border-right-s {
border-right: 1px solid #e0d8d8
}
.border-bottom-m {
border-bottom: 5px solid #e0d8d8
}
.border-bottom {
border-bottom: 2px solid #e0d8d8
}
.border-bottom-s {
border-bottom: 1px solid #e0d8d8
}
.border-left-m {
border-left: 5px solid #e0d8d8
}
.border-left {
border-left: 2px solid #e0d8d8
}
.border-left-s {
border-left: 1px solid #e0d8d8
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment