UNPKG

heyui

Version:

A UI components Library.

91 lines (88 loc) 1.83 kB
@switch-prefix: ~"@{prefix}switch"; @switch-hight: 26px; @min-switch-height: 18px; .switchset(@height) { width: @height*1.8+2px; height: @height+2px; &:after { width: @height - 2px; height: @height - 2px; } &:before { width: @height*1.8; height: @height; } &:checked,&[checked] { &:after { transform: translateX(@height*0.8); } } } input[type=checkbox].@{switch-prefix},.@{switch-prefix} .@{switch-prefix}-span { display: inline-block; margin: 0px; cursor: pointer; position: relative; font-family: inherit; outline: none; border: 1px solid @gray1-color; border-radius: 16px; box-sizing: border-box; background: @gray1-color; vertical-align: -38%; margin-right: 5px; transition: all .3s; .switchset(@switch-hight); &.@{switch-prefix}-small { .switchset(@min-switch-height); vertical-align: -25%; } &:after { background-color: @white-color; box-shadow: 0 1px 3px rgba(0, 0, 0, .4); border: 2px solid #ffffff; border: none; top: 1px; left: 1px; } &:before { background-color: @gray1-color; top: 0; left: 0; } &:after, &:before { content: " "; position: absolute; border-radius: 15px; transition: transform .3s; } &:checked,&[checked] { border-color: @primary-color; background: @primary-color; &:before { transform: scale(0); } &[disabled]{ background-color: @gray2-color; } } &[disabled]{ border-color: @gray2-color; background-color: @gray2-color; pointer-events: painted; cursor: @disabled-cursor; &:after{ border-color: @white-color; } &:before { background-color: @gray2-color; } } } .@{switch-prefix}{ display: inline-block; >.h-switch-text{ display: inline-block; } }