ant-design/components/checkbox/style/mixin.less

184 lines
3.9 KiB
Plaintext
Raw Normal View History

@import "../../style/mixins/index";
.antCheckboxFn(@checkbox-prefix-cls: ~"@{ant-prefix}-checkbox") {
@checkbox-inner-prefix-cls: ~"@{checkbox-prefix-cls}-inner";
// 一般状态
.@{checkbox-prefix-cls} {
white-space: nowrap;
cursor: pointer;
outline: none;
display: inline-block;
line-height: 1;
position: relative;
2017-09-21 18:12:53 +08:00
vertical-align: middle;
top: -0.8px;
2017-03-29 11:24:35 +08:00
.@{checkbox-prefix-cls}-wrapper:hover &-inner,
2017-02-28 11:37:29 +08:00
&:hover &-inner,
&-input:focus + &-inner {
border-color: @primary-color;
}
&-checked:after {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: @border-radius-sm;
border: 1px solid @primary-color;
content: '';
animation: antCheckboxEffect 0.36s ease-in-out;
animation-fill-mode: both;
visibility: hidden;
}
&:hover:after,
.@{checkbox-prefix-cls}-wrapper:hover &:after {
visibility: visible;
}
&-inner {
position: relative;
top: 0;
left: 0;
display: block;
width: 14px;
height: 14px;
border: @border-width-base @border-style-base @border-color-base;
border-radius: @border-radius-sm;
background-color: #fff;
transition: all .3s;
&:after {
transform: rotate(45deg) scale(0);
position: absolute;
left: 4px;
top: 1px;
display: table;
width: 5px;
height: 8px;
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 {
content: ' ';
transform: scale(1);
position: absolute;
left: 2px;
top: 5px;
width: 8px;
height: 1px;
}
.@{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;
left: 4px;
top: 1px;
display: table;
width: 5px;
height: 8px;
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: @primary-color;
2016-11-09 20:38:57 +08:00
border-color: @primary-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} {
2017-08-04 17:58:32 +08:00
border-color: @border-color-base !important;
background-color: @input-disabled-bg;
&:after {
animation-name: none;
border-color: @input-disabled-bg;
}
}
2016-06-23 11:15:24 +08:00
& + span {
color: @disabled-color;
cursor: not-allowed;
2016-06-23 11:15:24 +08:00
}
}
.@{checkbox-prefix-cls}-wrapper {
cursor: pointer;
font-size: @font-size-base;
display: inline-block;
&:not(:last-child) {
margin-right: 8px;
2016-06-27 14:52:46 +08:00
}
}
.@{checkbox-prefix-cls}-wrapper + span,
.@{checkbox-prefix-cls} + span {
padding-left: 8px;
padding-right: 8px;
}
.@{checkbox-prefix-cls}-group {
font-size: @font-size-base;
&-item {
display: inline-block;
}
}
}
@keyframes antCheckboxEffect {
0% {
transform: scale(1);
opacity: 0.5;
}
100% {
transform: scale(1.6);
opacity: 0;
}
}