yqcloud-ui
Version:
An enterprise-class UI design language and React-based implementation
204 lines (184 loc) • 4.85 kB
text/less
@import "../../style/mixins/index";
.antCheckboxFn(@checkbox-prefix-cls: ~"@{ant-prefix}-checkbox") {
@checkbox-inner-prefix-cls: ~"@{checkbox-prefix-cls}-inner";
// 一般状态
.@{checkbox-prefix-cls} {
.reset-component;
white-space: nowrap;
cursor: pointer;
outline: none;
display: inline-block;
line-height: 1;
position: relative;
vertical-align: middle;
top: -0.09em;
&-checked:after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: @border-radius-sm;
content: '';
}
&:hover:after,
.@{checkbox-prefix-cls}-wrapper:hover &:after {
visibility: visible;
}
&-inner {
position: relative;
top: 0;
left: 0;
display: block;
width: @checkbox-size;
height: @checkbox-size;
border: @checkbox-border-width @border-style-base #ACB3BF;
border-radius: @border-radius-sm;
background-color: #fff;
transition: border-color 90ms cubic-bezier(0, 0, 0.2, 0.1), background-color 90ms cubic-bezier(0, 0, 0.2, 0.1);
&:after {
@check-width: (@checkbox-size / 14) * 5px;
@check-height: (@checkbox-size / 14) * 10px;
transform: rotate(45deg) scale(0);
position: absolute;
left: (@checkbox-size - @check-width) / 2 - 1.5px * (@checkbox-size / 14);
top: (@checkbox-size - @check-height) / 2 - 3px * (@checkbox-size / 14);
display: table;
width: @check-width;
height: @check-height;
border: 2px solid #fff;
border-top: 0;
border-left: 0;
content: ' ';
transition: all .1s @ease-in-back;
}
}
&-input {
position: absolute;
left: 0;
z-index: 1;
cursor: pointer;
opacity: 0;
top: 0;
bottom: 0;
right: 0;
width: 100%;
height: 100%;
}
}
// 半选状态
.@{checkbox-prefix-cls}-indeterminate .@{checkbox-inner-prefix-cls}:after {
@indeterminate-width: (@checkbox-size / 14) * 8px;
@indeterminate-height: (@checkbox-size / 14) * 1px;
content: ' ';
transform: scale(1);
position: absolute;
left: (@checkbox-size - 3 - @indeterminate-width) / 2;
top: (@checkbox-size - 4 - @indeterminate-height) / 2;
width: @indeterminate-width;
height: @indeterminate-height;
}
.@{checkbox-prefix-cls}-indeterminate.@{checkbox-prefix-cls}-disabled .@{checkbox-inner-prefix-cls}:after {
border-color: @disabled-color;
}
// 选中状态
.@{checkbox-prefix-cls}-checked .@{checkbox-inner-prefix-cls}:after {
transform: rotate(45deg) scale(1);
position: absolute;
display: table;
border: 2px solid #fff;
border-top: 0;
border-left: 0;
content: ' ';
transition: all .2s @ease-out-back .1s;
}
.@{checkbox-prefix-cls}-checked,
.@{checkbox-prefix-cls}-indeterminate {
.@{checkbox-inner-prefix-cls} {
background-color: @checkbox-color;
border-color: @checkbox-color;
}
}
.@{checkbox-prefix-cls}-disabled {
cursor: not-allowed;
&.@{checkbox-prefix-cls}-checked {
.@{checkbox-inner-prefix-cls}:after {
animation-name: none;
border-color: @disabled-color;
}
}
.@{checkbox-prefix-cls}-input {
cursor: not-allowed;
}
.@{checkbox-inner-prefix-cls} {
border-color: @border-color-base ;
background-color: @input-disabled-bg;
&:after {
animation-name: none;
border-color: @input-disabled-bg;
}
}
& + span {
color: @input-disabled-color;
cursor: not-allowed;
}
}
.@{checkbox-prefix-cls}-wrapper {
.reset-component;
line-height: unset;
cursor: pointer;
display: inline-block;
& + & {
margin-left: 8px;
}
}
.@{checkbox-prefix-cls}-wrapper + span,
.@{checkbox-prefix-cls} + span {
padding-left: 8px;
padding-right: 8px;
}
.@{checkbox-prefix-cls}-group {
display: inline-block;
&-item {
display: inline-block;
margin-right: 8px;
&:last-child {
margin-right: 0;
}
}
&-item + &-item {
margin-left: 0;
}
&-wrapper {
.reset-component;
display: inline-block;
}
&-wrapper&-has-label {
position: relative;
}
&-wrapper&-has-label & {
padding-top: 17px;
}
&-wrapper &-label.label-disabled {
color: rgba(0, 0, 0, 0.54);
}
&-wrapper &-label {
color: rgba(0, 0, 0, 0.6);
position: absolute;
left: 0;
width: 100%;
transform-origin: 0 0;
transform: scale(0.75) translateY(0) translateZ(0.001px);
}
}
}
@keyframes antCheckboxEffect {
0% {
transform: scale(1);
opacity: 0.5;
}
100% {
transform: scale(1.6);
opacity: 0;
}
}