@import '../../settings.less';

@weuiSwitchWidth: 52px;
@weuiSwitchHeight: 32px;

// ref: https://github.com/Tencent/weui/blob/master/src/style/widget/weui-cell/weui-switch.less
.weui--switch {
  position: relative;
  display: inline-block;
  width: @weuiSwitchWidth;
  height: @weuiSwitchHeight;
  border: 2px solid @weuiLineColorLight;
  outline: 0;
  border-radius: @weuiSwitchHeight / 2;
  box-sizing: border-box;
  transition: background-color 0.1s, border 0.1s;

  &::before {
    content: ' ';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    border-radius: @weuiSwitchHeight / 2 - 1;
    background-color: var(--weui-BG-3);
    transition: transform 0.35s cubic-bezier(0.45, 1, 0.4, 1);
  }

  &::after {
    content: ' ';
    position: absolute;
    top: 0;
    left: 0;
    width: @weuiSwitchHeight - 4;
    height: @weuiSwitchHeight - 4;
    border-radius: @weuiSwitchHeight / 2 - 1;
    background-color: #fff; // 固定色值
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    transition: transform 0.35s cubic-bezier(0.4, 0.4, 0.25, 1.35);
  }

  &_on {
    border-color: @weuiColorPrimary;
    background-color: @weuiColorPrimary;

    &::before {
      transform: scale(0);
    }

    &::after {
      transform: translateX(@weuiSwitchWidth - @weuiSwitchHeight);
    }
  }

  &_disabled {
    opacity: 0.6;
  }
}
