UNPKG

rabbit-simple-ui

Version:

A simple UI component library based on JavaScript

191 lines (161 loc) 3.84 kB
@import '../custom.less'; @import '../mixins/size.less'; @switch-tag-name: r-switch; @switch-prefix-cls: ~'@{css-prefix}switch'; @{switch-tag-name} { display: inline-block; .size(44px,22px); line-height: 20px; vertical-align: middle; border: 1px solid transparent; border-radius: 100px; background-color: fade(#000, 25%); position: relative; cursor: pointer; user-select: none; transition: all @transition-time @ease-in-out; &:before { content: ''; display: none; .square(14px); border-radius: 50%; background-color: transparent; position: absolute; left: 3px; top: 3px; z-index: 1; border: 1px solid @primary-color; border-color: transparent transparent transparent @primary-color; animation: rab-switch-loading 1s linear; animation-iteration-count: infinite; } &::after { content: ''; .square(18px); border-radius: 18px; background-color: @white; position: absolute; left: 1px; top: 1px; cursor: pointer; transition: left @transition-time @ease-in-out, width @transition-time @ease-in-out; box-shadow: 0 2px 4px 0 rgb(0 35 11 / 20%); } &:active:after { width: 26px; } &:focus { box-shadow: 0 0 0 2px fade(@primary-color, 20%); outline: 0; } &:focus:hover { box-shadow: none; } } .@{switch-prefix-cls} { &-loading { opacity: 0.4; &:before { display: block; } } &-inner { color: @white; font-size: @font-size-small; position: absolute; left: 23px; i { .square(12px); text-align: center; position: relative; } } &-small { .size(28px,16px); line-height: 14px; &:after { .square(12px); } &:active:after { width: 14px; } &:before { .square(10px); left: 2px; top: 2px; } } &-small&-checked:after { left: 13px; } &-small&-checked:before { left: 14px; } &-small:active&-checked:after { left: 11px; } &-large { width: 56px; &:active:after { width: 26px; } } &-large:active:after { width: 30px; } &-large&-checked:after { left: 35px; } &-large&-checked:before { left: 37px; } &-large:active&-checked:after { left: 23px; } &-checked { border-color: @primary-color; background-color: @primary-color; .@{switch-prefix-cls}-inner { left: 7px; } &:after { left: 23px; } &:before { left: 25px; } &:active:after { left: 15px; } } &-disabled { cursor: @cursor-disabled; opacity: 0.4; &:after { background: @white; cursor: not-allowed; } .@{switch-prefix-cls}-inner { color: @white; } } &-disabled&-checked { border-color: @primary-color; background-color: @primary-color; opacity: 0.4; &:after { background: @white; } .@{switch-prefix-cls}-inner { color: @white; } } } @keyframes rab-switch-loading { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } }