$spacer:     1rem;
$spacer-x:   $spacer;
$spacer-y:   $spacer;
$spacers: (
  0: (
    x:   0,
    y:   0
  ),
  h: (
    x:   ($spacer-x * 0.5),
    y:   ($spacer-y * 0.5)
  ),
  1: (
    x:   $spacer-x,
    y:   $spacer-y
  ),
  2: (
    x:   ($spacer-x * 1.5),
    y:   ($spacer-y * 1.5)
  ),
  3: (
    x:   ($spacer-x * 3),
    y:   ($spacer-y * 3)
  ),
  4: (
    x:   ($spacer-x * 4),
    y:   ($spacer-y * 4)
  ),
);

@mixin spacing() {
    .mx-auto { margin: 0 auto; }
    @each $prop, $abbrev in (margin: m, padding: p) {
      @each $size, $lengths in $spacers {
        $length-x:   map-get($lengths, x);
        $length-y:   map-get($lengths, y);

        .#{$abbrev}-#{$size} { #{$prop}:         $length-y $length-x !important; }
        .#{$abbrev}t-#{$size} { #{$prop}-top:    $length-y !important; }
        .#{$abbrev}r-#{$size} { #{$prop}-right:  $length-x !important; }
        .#{$abbrev}b-#{$size} { #{$prop}-bottom: $length-y !important; }
        .#{$abbrev}l-#{$size} { #{$prop}-left:   $length-x !important; }
        .#{$abbrev}y-#{$size} { #{$prop}-top:    $length-y !important; #{$prop}-bottom: $length-y !important; }
        .#{$abbrev}x-#{$size} { #{$prop}-left:   $length-x !important; #{$prop}-right:  $length-x !important; }

        @include mobile {
            .#{$abbrev}-#{$size}-mobile { #{$prop}:         $length-y $length-x !important; }
            .#{$abbrev}t-#{$size}-mobile { #{$prop}-top:    $length-y !important; }
            .#{$abbrev}r-#{$size}-mobile { #{$prop}-right:  $length-x !important; }
            .#{$abbrev}b-#{$size}-mobile { #{$prop}-bottom: $length-y !important; }
            .#{$abbrev}l-#{$size}-mobile { #{$prop}-left:   $length-x !important; }
            .#{$abbrev}y-#{$size}-mobile { #{$prop}-top:    $length-y !important; #{$prop}-bottom: $length-y !important; }
            .#{$abbrev}x-#{$size}-mobile { #{$prop}-left:   $length-x !important; #{$prop}-right:  $length-x !important; }
        }
        @include tablet {
            .#{$abbrev}-#{$size}-tablet { #{$prop}:         $length-y $length-x !important; }
            .#{$abbrev}t-#{$size}-tablet { #{$prop}-top:    $length-y !important; }
            .#{$abbrev}r-#{$size}-tablet { #{$prop}-right:  $length-x !important; }
            .#{$abbrev}b-#{$size}-tablet { #{$prop}-bottom: $length-y !important; }
            .#{$abbrev}l-#{$size}-tablet { #{$prop}-left:   $length-x !important; }
            .#{$abbrev}y-#{$size}-tablet { #{$prop}-top:    $length-y !important; #{$prop}-bottom: $length-y !important; }
            .#{$abbrev}x-#{$size}-tablet { #{$prop}-left:   $length-x !important; #{$prop}-right:  $length-x !important; }
        }
        @include desktop {
            .#{$abbrev}-#{$size}-desktop { #{$prop}:         $length-y $length-x !important; }
            .#{$abbrev}t-#{$size}-desktop { #{$prop}-top:    $length-y !important; }
            .#{$abbrev}r-#{$size}-desktop { #{$prop}-right:  $length-x !important; }
            .#{$abbrev}b-#{$size}-desktop { #{$prop}-bottom: $length-y !important; }
            .#{$abbrev}l-#{$size}-desktop { #{$prop}-left:   $length-x !important; }
            .#{$abbrev}y-#{$size}-desktop { #{$prop}-top:    $length-y !important; #{$prop}-bottom: $length-y !important; }
            .#{$abbrev}x-#{$size}-desktop { #{$prop}-left:   $length-x !important; #{$prop}-right:  $length-x !important; }
        }

      }
    }
}

@include spacing;