/* components/form-ruler/form-ruler.wxss */

// 定义一个混合，用于生成三角形
@mixin triangle($size, $color, $direction) {
  height: 0;
  width: 0;

  border-color: transparent;
  border-style: solid;
  border-width: $size * 0.5;

  @if $direction=='up' {
    border-bottom-color: $color;
  }

  @else if $direction=='right' {
    border-left-color: $color;
  }

  @else if $direction=='down' {
    border-top-color: $color;
  }

  @else if $direction=='left' {
    border-right-color: $color;
  }

  @else {
    @error "Unknown direction #{$direction}.";
  }
}
.show-data {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: flex-end;
  margin: 12px 0;
  font-size: 12px;
  .value {
    margin: 0 4px;
    font-size: 18px;
  }
}
.form-ruler {
  --height: 56px;
  --width: 100%;
  --active-color: #34A76B;
  --tick-width: 5px;
  position: relative;
  width: calc(var(--width) + 2px);
  height: calc(var(--height) + 2px);
  border: 1px solid #D3D4D5;
  border-radius: var(--height);
  box-sizing: border-box;
  overflow: hidden;

  &::before,
  &::after {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }

  &::before {
    top: 0;
    @include triangle(14px, var(--active-color), 'down');
  }

  &::after {
    bottom: 0;
    @include triangle(14px, var(--active-color), 'up');
  }

  &__inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    height: 100%;
  }

  &__axis {
    position: relative;
    height: 32px;
    transform: translateY(calc(var(--height) * 0.25));
    font-size: 12px;
    width: 5px;
    box-sizing: border-box;

    text {
      position: absolute;
      left: 2px;
      bottom: -10px;
    }

    .tick {
      height: calc(var(--height) * 0.2);
      border-left: 1px solid #D3D4D5;
    }

    .median {
      height: calc(var(--height) * 0.32);
      border-left: 1px solid #D3D4D5;
    }

    .integer {
      height: calc(var(--height) * 0.5);
      border-left: 1px solid #D3D4D5;
    }
  }
}