@import '../src/mixins/_all'

$bal-spacing-values: ("auto": $bal-space-auto, "none": $bal-space-none, "xx-small": $bal-space-xx-small, "x-small": $bal-space-x-small, "small": $bal-space-small, "normal": $bal-space-normal, "medium": $bal-space-medium, "large": $bal-space-large, "x-large": $bal-space-x-large, "xx-large": $bal-space-xx-large, "xxx-large": $bal-space-xxx-large, "xxxx-large": $bal-space-xxxx-large) !default
$bal-spacing-values-tablet: ("auto": $bal-space-tablet-auto, "none": $bal-space-tablet-none, "xx-small": $bal-space-tablet-xx-small, "x-small": $bal-space-tablet-x-small, "small": $bal-space-tablet-small, "normal": $bal-space-tablet-normal, "medium": $bal-space-tablet-medium, "large": $bal-space-tablet-large, "x-large": $bal-space-tablet-x-large, "xx-large": $bal-space-tablet-xx-large, "xxx-large": $bal-space-tablet-xxx-large, "xxxx-large": $bal-space-tablet-xxxx-large) !default
$bal-spacing-values-desktop: ("auto": $bal-space-desktop-auto, "none": $bal-space-desktop-none, "xx-small": $bal-space-desktop-xx-small, "x-small": $bal-space-desktop-x-small, "small": $bal-space-desktop-small, "normal": $bal-space-desktop-normal, "medium": $bal-space-desktop-medium, "large": $bal-space-desktop-large, "x-large": $bal-space-desktop-x-large, "xx-large": $bal-space-desktop-xx-large, "xxx-large": $bal-space-desktop-xxx-large, "xxxx-large": $bal-space-desktop-xxxx-large) !default

$bal-legacy-spacing-values: ("auto": $bal-space-auto, "0": $bal-space-none, "1": $bal-space-xx-small, "2": $bal-space-x-small, "3": $bal-space-small, "4": $bal-space-normal, "5": $bal-space-medium, "6": $bal-space-large, "7": $bal-space-x-large, "8": $bal-space-xx-large, "9": $bal-space-xxx-large, "10": $bal-space-xxxx-large) !default
$bal-legacy-spacing-values-tablet: ("auto": $bal-space-tablet-auto, "0": $bal-space-tablet-none, "1": $bal-space-tablet-xx-small, "2": $bal-space-tablet-x-small, "3": $bal-space-tablet-small, "4": $bal-space-tablet-normal, "5": $bal-space-tablet-medium, "6": $bal-space-tablet-large, "7": $bal-space-tablet-x-large, "8": $bal-space-tablet-xx-large, "9": $bal-space-tablet-xxx-large, "10": $bal-space-tablet-xxxx-large) !default
$bal-legacy-spacing-values-desktop: ("auto": $bal-space-desktop-auto, "0": $bal-space-desktop-none, "1": $bal-space-desktop-xx-small, "2": $bal-space-desktop-x-small, "3": $bal-space-desktop-small, "4": $bal-space-desktop-normal, "5": $bal-space-desktop-medium, "6": $bal-space-desktop-large, "7": $bal-space-desktop-x-large, "8": $bal-space-desktop-xx-large, "9": $bal-space-desktop-xxx-large, "10": $bal-space-desktop-xxxx-large) !default


.is-marginless
  margin: 0 !important

.is-paddingless
  padding: 0 !important

$spacing-shortcuts: ("margin": "m", "padding": "p") !default
$spacing-directions: ("top": "t", "right": "r", "bottom": "b", "left": "l") !default
$spacing-horizontal: "x" !default
$spacing-vertical: "y" !default

@if $spacing-legacy-numbering
  @each $property, $shortcut in $spacing-shortcuts
    @each $name, $value in $bal-legacy-spacing-values
      // All directions
      .#{$shortcut}-#{$name}
        #{$property}: $value !important

      // Cardinal directions
      @each $direction, $suffix in $spacing-directions
        .#{$shortcut}#{$suffix}-#{$name}
          #{$property}-#{$direction}: $value !important

      // Horizontal axis
      @if $spacing-horizontal != null
        .#{$shortcut}#{$spacing-horizontal}-#{$name}
          #{$property}-left: $value !important
          #{$property}-right: $value !important

      // Vertical axis
      @if $spacing-vertical != null
        .#{$shortcut}#{$spacing-vertical}-#{$name}
          #{$property}-top: $value !important
          #{$property}-bottom: $value !important

  @include tablet()
    @each $property, $shortcut in $spacing-shortcuts
      @each $name, $value in $bal-legacy-spacing-values-tablet
        // All directions
        .#{$shortcut}-#{$name}
          #{$property}: $value !important

        // Cardinal directions
        @each $direction, $suffix in $spacing-directions
          .#{$shortcut}#{$suffix}-#{$name}
            #{$property}-#{$direction}: $value !important

        // Horizontal axis
        @if $spacing-horizontal != null
          .#{$shortcut}#{$spacing-horizontal}-#{$name}
            #{$property}-left: $value !important
            #{$property}-right: $value !important

        // Vertical axis
        @if $spacing-vertical != null
          .#{$shortcut}#{$spacing-vertical}-#{$name}
            #{$property}-top: $value !important
            #{$property}-bottom: $value !important

  @include desktop()
    @each $property, $shortcut in $spacing-shortcuts
      @each $name, $value in $bal-legacy-spacing-values-desktop
        // All directions
        .#{$shortcut}-#{$name}
          #{$property}: $value !important

        // Cardinal directions
        @each $direction, $suffix in $spacing-directions
          .#{$shortcut}#{$suffix}-#{$name}
            #{$property}-#{$direction}: $value !important

        // Horizontal axis
        @if $spacing-horizontal != null
          .#{$shortcut}#{$spacing-horizontal}-#{$name}
            #{$property}-left: $value !important
            #{$property}-right: $value !important

        // Vertical axis
        @if $spacing-vertical != null
          .#{$shortcut}#{$spacing-vertical}-#{$name}
            #{$property}-top: $value !important
            #{$property}-bottom: $value !important

@each $property, $shortcut in $spacing-shortcuts
  @each $name, $value in $bal-spacing-values
    // All directions
    .#{$shortcut}-#{$name}
      #{$property}: $value !important

    // Cardinal directions
    @each $direction, $suffix in $spacing-directions
      .#{$shortcut}#{$suffix}-#{$name}
        #{$property}-#{$direction}: $value !important

    // Horizontal axis
    @if $spacing-horizontal != null
      .#{$shortcut}#{$spacing-horizontal}-#{$name}
        #{$property}-left: $value !important
        #{$property}-right: $value !important

    // Vertical axis
    @if $spacing-vertical != null
      .#{$shortcut}#{$spacing-vertical}-#{$name}
        #{$property}-top: $value !important
        #{$property}-bottom: $value !important

@include tablet()
  @each $property, $shortcut in $spacing-shortcuts
    @each $name, $value in $bal-spacing-values-tablet
      // All directions
      .#{$shortcut}-#{$name}
        #{$property}: $value !important

      // Cardinal directions
      @each $direction, $suffix in $spacing-directions
        .#{$shortcut}#{$suffix}-#{$name}
          #{$property}-#{$direction}: $value !important

      // Horizontal axis
      @if $spacing-horizontal != null
        .#{$shortcut}#{$spacing-horizontal}-#{$name}
          #{$property}-left: $value !important
          #{$property}-right: $value !important

      // Vertical axis
      @if $spacing-vertical != null
        .#{$shortcut}#{$spacing-vertical}-#{$name}
          #{$property}-top: $value !important
          #{$property}-bottom: $value !important

@include desktop()
  @each $property, $shortcut in $spacing-shortcuts
    @each $name, $value in $bal-spacing-values-desktop
      // All directions
      .#{$shortcut}-#{$name}
        #{$property}: $value !important

      // Cardinal directions
      @each $direction, $suffix in $spacing-directions
        .#{$shortcut}#{$suffix}-#{$name}
          #{$property}-#{$direction}: $value !important

      // Horizontal axis
      @if $spacing-horizontal != null
        .#{$shortcut}#{$spacing-horizontal}-#{$name}
          #{$property}-left: $value !important
          #{$property}-right: $value !important

      // Vertical axis
      @if $spacing-vertical != null
        .#{$shortcut}#{$spacing-vertical}-#{$name}
          #{$property}-top: $value !important
          #{$property}-bottom: $value !important


