// @import "../node_modules/carbon-components/scss/globals/scss/vars";
@import "~carbon-components/scss/globals/scss/vars";

$space-options: (
  "0",
  "01",
  "02",
  "03",
  "04",
  "05",
  "06",
  "07",
  "08",
  "09",
  "10",
  "11",
  "12"
);
$space-amounts: (
  0,
  $spacing-01,
  $spacing-02,
  $spacing-03,
  $spacing-04,
  $spacing-05,
  $spacing-06,
  $spacing-07,
  $spacing-08,
  $spacing-09,
  $spacing-10,
  $spacing-11,
  $spacing-12
);
$positions: "", block, inline, top, bottom, left, right;

/* Carbon padding based on spacing-0x  */
/* block = top and bottom, inline = left and right */
@for $i from 1 through length($space-options) {
  @each $pos in $positions {
    @if $pos == "" {
      .p-#{nth($space-options, $i)} {
        padding: nth($space-amounts, $i);
      }
    } @else if $pos == block or $pos == inline {
      .p-#{$pos}-#{nth($space-options, $i)} {
        padding-#{$pos}: nth($space-amounts, $i);
      }
    } @else {
      .p-#{str-slice($pos,0,1)}-#{nth($space-options, $i)} {
        padding-#{$pos}: nth($space-amounts, $i);
      }
    }
  }
}

/* Carbon margin based on spacing-0x */
/* block = top and bottom, inline = left and right */
@for $i from 1 through length($space-options) {
  @each $pos in $positions {
    @if $pos == "" {
      .m-#{nth($space-options, $i)} {
        margin: nth($space-amounts, $i);
      }
    } @else if $pos == block or $pos == inline {
      .m-#{$pos}-#{nth($space-options, $i)} {
        margin-#{$pos}: nth($space-amounts, $i);
      }
    } @else {
      .m-#{str-slice($pos,0,1)}-#{nth($space-options, $i)} {
        margin-#{$pos}: nth($space-amounts, $i);
      }
    }
  }
}