@import '../../styles/index.less';

@interval-prefix-cls: ~'@{open-prefix}-scale-bar';
@border-radius: 6px;
@current-color: #177ddc;
@default-background-color: #dcdfe6;
@interval-width: 1px;
@stroke-height: 12px;

.@{interval-prefix-cls} {
  color: @current-color;
  padding: 5px 0px;
  width: 350px;
  justify-content: space-between;

  &-title {
    color: rgba(0, 0, 0, 0.65);
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-all;
    font-size: 18px;
    padding-bottom: 5px;
  }

  &-item {
    position: relative;
    width: 100%;
    margin-left: @interval-width;
    margin-right: @interval-width;
    overflow: hidden;
    padding-top: 10px;

    &-arrow {
      left: calc(50% - 4px);
      display: inline-block;
      position: absolute;
      border: 8px solid transparent;
      top: -1px;
      width: 0px;
      height: 0px;
      border-top-color: gray;
    }

    .@{interval-prefix-cls}-item-span {
      position: relative;
      width: inherit;
      height: @stroke-height;
      display: inline-block;
      background-color: @default-background-color;
    }

    .@{interval-prefix-cls}-item-span-active::before {
      width: 100%;
      height: inherit;
      content: '';
      border-radius: inherit;
      position: absolute;
      top: 0px;
      bottom: 0px;
      right: 0px;
      left: 0px;
      opacity: 0;
      background: white;
      -webkit-animation: ~'@{interval-prefix-cls}-stroke-active' 2s infinite;
      animation: ~'@{interval-prefix-cls}-stroke-active' 2s infinite;
    }

    .@{interval-prefix-cls}-item-span-background {
      background-color: @current-color;
    }

    .@{interval-prefix-cls}-item-span-first {
      border-top-left-radius: @border-radius;
      border-bottom-left-radius: @border-radius;
    }

    .@{interval-prefix-cls}-item-span-last {
      border-top-right-radius: @border-radius;
      border-bottom-right-radius: @border-radius;
    }

    &-text {
      color: rgba(0, 0, 0, 0.65);
      font-size: 14px;
      text-align: center;
      // padding-bottom: 10px;
    }

    &-text-color {
      color: inherit;
    }
  }

  &-degree {
    width: 100%;
    height: @stroke-height;
    position: relative;
    border-radius: @border-radius;
    overflow: hidden;

    &-placeholder {
      width: 100%;
      height: inherit;
      position: absolute;
      top: 0;
      bottom: 0;
      display: flex;
      justify-content: space-between;
      z-index: 2;

      span {
        display: inline-block;
        height: inherit;
        width: @interval-width+0.5;
        background-color: white;

        &:first-child {
          visibility: hidden;
        }

        &:last-child {
          visibility: hidden;
        }
      }
    }

    &-background {
      width: 100%;
      height: inherit;
      background-color: @default-background-color;
      position: absolute;
      top: 0;
      bottom: 0;
    }

    &-stroke {
      width: 100%;
      height: inherit;
      border-radius: inherit;
      z-index: 1;
      position: absolute;
      top: 0;
      bottom: 0;
      background-image: linear-gradient(
        to right,
        rgb(16, 142, 233) 0%,
        rgb(135, 208, 104) 100%
      );
    }

    &-stroke-active {
      &::before {
        content: '';
        border-radius: inherit;
        position: absolute;
        top: 0px;
        bottom: 0px;
        right: 0px;
        left: 0px;
        opacity: 0;
        background: white;
        -webkit-animation: ~'@{interval-prefix-cls}-stroke-active' 2.4s infinite;
        animation: ~'@{interval-prefix-cls}-stroke-active' 2.4s infinite;
      }
    }

    &-text {
      color: rgba(0, 0, 0, 0.65);
    }
  }

  &-content {
    font-size: 14px;
    margin: 8px -10px;
    display: flex;
    justify-content: space-between;
  }
}

.@{interval-prefix-cls}-flex {
  display: inline-flex;
  width: 100%;
}

/**动画**/
@keyframes ~ "@{interval-prefix-cls}-stroke-active" {
  //类名继承

  0% {
    transform: translateX(-100%) scaleX(0);
    opacity: 0.2;
  }

  30% {
    transform: translateX(-100%) scaleX(0);
    opacity: 0.6;
  }

  100% {
    transform: translateX(0) scaleX(1);
    opacity: 0;
  }
}
