UNPKG

rabbit-design

Version:

A lightweight UI plugin library written in TypeScript and based on JavaScript

203 lines (172 loc) 4.36 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; border-radius: 22px; vertical-align: middle; border: @border-width-base @border-style-base transparent; background-color: rgba(0, 0, 0, 0.25); position: relative; cursor: pointer; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; transition: all @transition-time @ease-in-out; &[loading='true'] { opacity: 0.4; } &[loading='true']:before { display: block; } &:after { content: ''; .square(18px); border-radius: 18px; background-color: @white; position: absolute; left: 1px; top: 1px; cursor: pointer; box-shadow: 0 2px 4px 0 rgba(0, 35, 11, 0.2); transition: left @transition-time @ease-in-out, width @transition-time @ease-in-out; } &:active:after { width: 26px; } &:before { content: ''; display: none; .square(14px); border-radius: 50%; background-color: transparent; position: absolute; left: 3px; top: 3px; z-index: 1; border: @border-width-base @border-style-base @primary-color; border-color: transparent transparent transparent @primary-color; -webkit-animation: rab-switch-loading 1s linear; animation: rab-switch-loading 1s linear; -webkit-animation-iteration-count: infinite; animation-iteration-count: infinite; } &:focus { box-shadow: 0 0 0 2px fade(@primary-color, 20%); outline: 0; } &:focus:hover { box-shadow: none; } &[checked='true'] { border-color: @primary-color; background-color: @primary-color; .@{switch-prefix-cls}-inner { left: 7px; } &:after { left: 23px; } &:before { left: 25px; } &:active:after { left: 15px; } } &[size='large'] { width: 56px; &:active:after { width: 30px; } } &[size='large'][checked='true']:after { left: 35px; } &[size='large'][checked='true']:before { left: 37px; } &[size='large']:active[checked='true']:after { left: 23px; } &[size='small'] { .size(28px,16px); line-height: 14px; &:after { .square(12px); } &:active:after { width: 14px; } &:before { .square(10px); left: 2px; top: 2px; } } &[size='small'][checked='true']:after { left: 13px; } &[size='small'][checked='true']:before { left: 14px; } &[size='small']:active[checked='true']:after { left: 11px; } &[disabled] { cursor: @cursor-disabled; opacity: 0.4; box-shadow: none; &:after { background: @white; cursor: not-allowed; } .@{switch-prefix-cls}-inner { color: @white; } } &[disabled][checked='true'] { border-color: @primary-color; background-color: @primary-color; opacity: 0.4; &:after { background: @white; } .@{switch-prefix-cls}-inner { color: @white; } } } .@{switch-prefix-cls} { &-inner { color: @white; font-size: @font-size-small; position: absolute; left: 23px; i { .square(12px); text-align: center; position: relative; } } } @-webkit-keyframes rab-switch-loading { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } } @keyframes rab-switch-loading { 0% { transform: rotate(0); } 100% { transform: rotate(360deg); } }