/*
  Label
*/
////
/// @group label
////

// Label
/// @type Number
$label-fontsize: 0.8rem !default;
/// @type Number | List
$label-padding: ($global-padding / 3) ($global-padding / 2) !default;
/// @type Number | List
$label-margin: 0 0 ($global-spacing / 2) 0 !default;
/// @type Number
$label-radius: 0 !default;
/// @type Color
$label-background: $primary-color !default;
/// @type Color
$label-color: isitlight($primary-color) !default;

/// @type Number | List
$badge-margin: 0 0 ($global-spacing / 2) 0 !default;
/// @type Number
$badge-fontsize: 0.8em !default;
/// @type Number
$badge-diameter: 1.5rem !default;
/// @type Color
$badge-background: $primary-color !default;
/// @type Color
$badge-color: #fff !default;
///

%label {
  line-height: 1;
  white-space: nowrap;
  display: inline-block;
  cursor: default;
}

@mixin label-layout(
  $fontsize: $label-fontsize,
  $padding: $label-padding,
  $margin: $label-margin
) {
  font-size: $fontsize;
  padding: $padding;
  margin: $margin;
}

@mixin label-style(
  $background: $label-background,
  $color: $label-color,
  $radius: $label-radius
) {
  background: $background;
  border-radius: $radius;

  @if $color == auto {
    color: isitlight($background);
  }
  @else {
    color: $color;
  }
}

@mixin label(
  $background: $label-background,
  $color: $label-color,
  $radius: $label-radius,
  $fontsize: $label-fontsize,
  $padding: $label-padding,
  $margin: $label-margin
) {
  @extend %label;
  @include label-layout($fontsize, $padding, $margin);
  @include label-style($background, $color, $radius);
}

@include exports(label) {
  .label {
    @include label;

    @each $color in map-keys($base-apps-colors) {
      &.#{$color} {
        $color-value: map-get($base-apps-colors, $color);
        @include label-style($color-value, auto);
      }
    }
  }
}

/*
  Badge
*/

%badge {
  align-items: center;
  justify-content: center;
  display: inline-flex;
  border-radius: 1000px;
}

@mixin badge-layout(
  $fontsize: $badge-fontsize,
  $diameter: $badge-diameter,
  $margin: $badge-margin
) {
  font-size: $fontsize;
  width: $diameter;
  height: $diameter;
  margin: $margin;
}

@mixin badge-style(
  $background: $badge-background,
  $color: $badge-font-color
) {
  background: $background;

  @if $color == auto {
    color: isitlight($background);
  }
  @else {
    color: $color;
  }
}

@mixin badge(
  $background: $badge-background,
  $color: $badge-color,
  $diameter: $badge-diameter,
  $fontsize: $badge-fontsize,
  $margin: $badge-margin
) {
  @extend %badge;
  @include badge-layout($fontsize, $diameter, $margin);
  @include badge-style($background, $color);
}

@include exports(badge) {
  .badge {
    @include badge;

    &.secondary {
      @include badge-style($secondary-color, auto);
    }
    @each $color in map-keys($base-apps-colors) {
      &.#{$color} {
        $color-value: map-get($base-apps-colors, $color);
        @include badge-style($color-value, auto);
      }
    }
  }
}
