@import "mixins/mixins";
@import "common/var";

@mixin setTheme($bgColorPercent,$borderColorPercent,$fontColorPercent,$hoverColorPercent) {
  background-color: mix($tag-primary-color, $color-white, $bgColorPercent);
  border-color: mix($tag-primary-color, $color-white, $borderColorPercent);
  color: mix($tag-primary-color, $color-white, $fontColorPercent);

  @include pf(hit) {
    border-color: $tag-primary-color;
  }
  .#{$namespace}-tag_close {
    color: mix($tag-primary-color, $color-white, $fontColorPercent);

    &:hover {
      color: $color-white;
      background-color: mix($tag-primary-color, $color-white, $hoverColorPercent);
    }
  }

  &.#{$namespace}-tag-info {
    background-color: mix($tag-info-color, $color-white, $bgColorPercent);
    border-color: mix($tag-info-color, $color-white, $borderColorPercent);
    color: mix($tag-info-color, $color-white, $fontColorPercent);

    @include pf(hit) {
      border-color: $tag-info-color;
    }

    .#{$namespace}-tag_close {
      color: mix($tag-info-color, $color-white, $fontColorPercent);

      &:hover {
        color: $color-white;
        background-color: mix($tag-info-color, $color-white, $hoverColorPercent);
      }
    }
  }

  &.#{$namespace}-tag-success {
    background-color: mix($tag-success-color, $color-white, $bgColorPercent);
    border-color: mix($tag-success-color, $color-white, $borderColorPercent);
    color: mix($tag-success-color, $color-white, $fontColorPercent);

    @include pf(hit) {
      border-color: $tag-success-color;
    }

    .#{$namespace}-tag_close {
      color: mix($tag-success-color, $color-white, $fontColorPercent);

      &:hover {
        color: $color-white;
        background-color: mix($tag-success-color, $color-white, $hoverColorPercent);
      }
    }
  }

  &.#{$namespace}-tag-warning {
    background-color: mix($tag-warning-color, $color-white, $bgColorPercent);
    border-color: mix($tag-warning-color, $color-white, $borderColorPercent);
    color: mix($tag-warning-color, $color-white, $fontColorPercent);

    @include pf(hit) {
      border-color: $tag-warning-color;
    }

    .#{$namespace}-tag_close {
      color: mix($tag-warning-color, $color-white, $fontColorPercent);

      &:hover {
        color: $color-white;
        background-color: mix($tag-warning-color, $color-white, $hoverColorPercent);
      }
    }
  }

  &.#{$namespace}-tag-danger {
    background-color: mix($tag-danger-color, $color-white, $bgColorPercent);
    border-color: mix($tag-danger-color, $color-white, $borderColorPercent);
    color: mix($tag-danger-color, $color-white, $fontColorPercent);

    @include pf(hit) {
      border-color: $tag-danger-color;
    }

    .#{$namespace}-tag_close {
      color: mix($tag-danger-color, $color-white, $fontColorPercent);

      &:hover {
        color: $color-white;
        background-color: mix($tag-danger-color, $color-white, $hoverColorPercent);
      }
    }
  }


}


@include b(tag) {
  @include setTheme(10%, 20%, 100%, 100%);
  height: 32px;
  padding: $tag-padding;
  line-height: 30px;
  display: inline-block;
  box-sizing: border-box;
  color: $tag-primary-color;
  border-width: 1px;
  border-style: solid;
  border-radius: $tag-border-radius;
  white-space: nowrap;
  font-size: $tag-font-size;

  .#{$namespace}-icon-close {
    border-radius: 50%;
    text-align: center;
    cursor: pointer;
    width: 16px;
    height: 16px;
    line-height: 16px;
    font-size: 12px;
    vertical-align: middle;
    position: relative;
    right: -5px;
    top: -1px;

    &::before {
      display: block;
    }
  }

  @include mf(dark) {
    @include setTheme(100%, 100%, 0, 80%)
  }

  @include mf(simple) {
    @include setTheme(0, 40%, 100%, 100%);
  }

  @include mf(medium) {
    height: 28px;
    line-height: 26px;
    .#{$namespace}-icon-close {
      transform: scale(.8);
    }
  }
  @include mf(small) {
    height: 24px;
    line-height: 22px;
    padding: 0 8px;
    .#{$namespace}-icon-close {
      transform: scale(.8);
    }
  }
  @include mf(mini) {
    height: 20px;
    line-height: 19px;
    padding: 0 5px;
    .#{$namespace}-icon-close {
      margin-left: -3px;
      transform: scale(.7);
    }
  }
}
