.violetSwitch {
  margin: 0;
  padding: 0;
  color: rgba(0, 0, 0, 0.85);
  font-size: 14px;
  font-variant: tabular-nums;
  line-height: 1.5715;
  list-style: none;
  font-feature-settings: 'tnum';
  position: relative;
  display: inline-block;
  box-sizing: border-box;
  min-width: 44px;
  height: 22px;
  line-height: 22px;
  vertical-align: middle;
  background-color: rgba(0, 0, 0, 0.25);
  border: 0;
  border-radius: 100px;
  cursor: pointer;
  transition: all 0.2s;
  &:focus {
    outline: 0;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
    &:hover {
      box-shadow: none;
    }
  }
  &:not(.violetSwitch--disabled):active {
    .violetSwitch__handle {
      &::before {
        right: -30%;
        left: 0;
      }
    }
    &.violetSwitch--checked {
      .violetSwitch__handle {
        &::before {
          right: 0;
          left: -30%;
        }
      }
    }
  }
}

@each $key, $val in $theme-colors {
  .violetSwitch--checked.violetSwitch--#{$key} {
    background-color: $val;
    &:focus {
      box-shadow: 0 0 0 2px #e6f7ff;
    }
    .violetSwitch__inner {
      margin: 0 25px 0 7px;
    }
    .violetSwitch__handle {
      left: calc(100% - 18px - 2px);
    }
    .violetSwitch__loadingIcon {
      color: #1890ff;
    }
  }
}

.violetSwitch--loading,
.violetSwitch--disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.violetSwitch--loading *,
.violetSwitch--disabled * {
  box-shadow: none;
  cursor: not-allowed;
  pointer-events: none;
}

.violetSwitch__inner {
  display: block;
  margin: 0 7px 0 25px;
  color: #fff;
  font-size: 12px;
  transition: margin 0.2s;
}

.violetSwitch__handle {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  transition: all 0.2s ease-in-out;
  &::before {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background-color: #fff;
    border-radius: 9px;
    box-shadow: 0 2px 4px 0 rgba(0, 35, 11, 0.2);
    transition: all 0.2s ease-in-out;
    content: '';
  }
}
.violetSwitch__loadingIcon {
  &.anticon {
    position: relative;
    top: 2px;
    color: rgba(0, 0, 0, 0.65);
    vertical-align: top;
  }
}
.violetSwitch--small {
  min-width: 28px;
  height: 16px;
  line-height: 16px;
  .violetSwitch__inner {
    margin: 0 5px 0 18px;
    font-size: 12px;
  }
  .violetSwitch__handle {
    width: 12px;
    height: 12px;
  }
  .violetSwitch__loadingIcon {
    top: 1.5px;
    font-size: 9px;
  }
  &.violetSwitch--checked {
    .violetSwitch__inner {
      margin: 0 18px 0 5px;
    }
    .violetSwitch__handle {
      left: calc(100% - 12px - 2px);
    }
  }
}
