@import '@devui/theme/styles-var/devui-var.scss';
$font-size-map: (
lg: $devui-font-size-lg,
md: $devui-font-size-md,
sm: $devui-font-size-sm,
);
$checkbox-width-map: (
lg: 18px,
md: 16px,
sm: 14px,
);
$checkbox-label-height-map: (
lg: $devui-size-lg,
md: $devui-size-md,
sm: $devui-size-sm,
);
.#{$devui-prefix}-checkbox {
position: relative;
display: flex;
display: -ms-flexbox;
align-items: center;
-ms-flex-align: center;
height: 100%;
margin: 0;
.#{$devui-prefix}-checkbox__tick-wrap {
position: absolute;
width: 14px;
height: 14px;
.#{$devui-prefix}-checkbox__tick {
stroke: $devui-light-text;
stroke-dasharray: 13 13;
stroke-dashoffset: 13;
opacity: 0;
transform: scale(0);
transform-origin: 50% 50%;
transition: stroke-dashoffset $devui-animation-duration-base $devui-animation-ease-in-out,
opacity $devui-animation-duration-base $devui-animation-ease-in-out,
transform $devui-animation-duration-base $devui-animation-ease-in-out;
}
}
&.active:not(.half-checked) .#{$devui-prefix}-checkbox__tick {
opacity: 1;
stroke-dashoffset: 0;
transform: scale(1);
transition: stroke-dashoffset $devui-animation-duration-slow $devui-animation-ease-in,
opacity $devui-animation-duration-base $devui-animation-ease-in-out;
}
&.active,
&.half-checked {
&:not(.disabled) .#{$devui-prefix}-checkbox__material:not(.custom-color) {
border-color: $devui-brand;
}
.#{$devui-prefix}-checkbox--bordered {
border-color: $devui-brand;
}
}
&.active:not(.disabled) {
.#{$devui-prefix}-checkbox__material {
background-size: 100% 100%;
transition: background-size 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
}
&.unchecked:not(.disabled) {
&:hover {
.#{$devui-prefix}-checkbox__material:not(.custom-color) {
border-color: $devui-brand;
}
}
.#{$devui-prefix}-checkbox__material:not(.custom-color) {
background-size: 0% 0%;
transition: background-size $devui-animation-duration-base $devui-animation-ease-in-out,
border-color $devui-animation-duration-base $devui-animation-ease-in-out;
}
}
&.unchecked:not(.disabled) {
.#{$devui-prefix}-checkbox__material.custom-color {
background-size: 0% 0%;
transition: background-size 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
}
&.half-checked {
.#{$devui-prefix}-checkbox__material:not(.custom-color) {
background-color: $devui-brand;
& > .#{$devui-prefix}-checkbox__halfchecked-bg {
opacity: 1;
transform: scale(0.4288);
transition: transform 0.2s cubic-bezier(0.755, 0.05, 0.855, 0.06);
background-color: $devui-light-text;
}
}
}
&.half-checked {
.#{$devui-prefix}-checkbox__material.custom-color {
& > .#{$devui-prefix}-checkbox__halfchecked-bg {
opacity: 1;
transform: scale(0.4288);
transition: transform 0.2s cubic-bezier(0.755, 0.05, 0.855, 0.06);
background-color: $devui-light-text;
}
}
}
.#{$devui-prefix}-checkbox__material {
text-align: initial;
height: 14px;
width: 14px;
position: relative;
user-select: none;
border: 1px solid $devui-line;
border-radius: $devui-border-radius;
background: linear-gradient($devui-brand, $devui-brand) no-repeat 50%/0;
margin-right: 8px;
vertical-align: text-bottom;
&.#{$devui-prefix}-checkbox__default-background {
background-color: $devui-base-bg;
}
&.#{$devui-prefix}-checkbox--no-label {
margin-right: 0;
}
& > .#{$devui-prefix}-checkbox__halfchecked-bg {
display: inline-block;
position: absolute;
content: '';
background-color: $devui-light-text;
top: 0;
left: 0;
height: 100%;
width: 100%;
transform: scale(1);
opacity: 0;
}
& > svg {
width: 14px;
height: 14px;
}
}
&:not(.disabled).half-checked {
.#{$devui-prefix}-checkbox__material:not(.custom-color) {
&:focus,
&:active,
&:hover {
background-color: $devui-brand;
}
&:active,
&:focus,
&:hover:active,
&:hover:focus {
background-color: $devui-brand-active-focus;
}
}
}
&--glow-style {
.#{$devui-prefix}-checkbox__glow-box {
position: absolute;
width: 16px;
height: 16px;
.glow-bg {
display: block;
width: 16px;
height: 16px;
user-select: none;
border-radius: $devui-border-radius;
box-shadow: none;
transition: box-shadow $devui-animation-duration-slow $devui-animation-ease-in-out-smooth;
}
}
&:not(.disabled):hover {
.glow-bg {
box-shadow: 0 0 0 6px $devui-range-item-hover-bg;
}
}
}
&--checkbox-bordered {
.#{$devui-prefix}-checkbox__material {
vertical-align: text-bottom !important;
}
&.#{$devui-prefix}-checkbox--checkbox-xs,
&.#{$devui-prefix}-checkbox--checkbox-sm {
.#{$devui-prefix}-checkbox__glow-box {
left: 11px;
}
}
&.#{$devui-prefix}-checkbox--checkbox-md,
&.#{$devui-prefix}-checkbox--checkbox-lg {
.#{$devui-prefix}-checkbox__glow-box {
left: 12px;
}
}
}
&__input {
opacity: 0;
position: absolute;
margin: 0;
z-index: -1;
width: 0;
height: 0;
overflow: hidden;
left: 0;
pointer-events: none;
}
& label {
position: relative;
font-weight: 400;
height: 16px;
line-height: 16px;
cursor: pointer;
color: $devui-text;
margin: 0;
display: flex;
align-items: center;
@each $size in ('lg', 'md', 'sm') {
&.#{$devui-prefix}-checkbox--#{$size} {
display: flex;
align-items: center;
font-size: map-get($font-size-map, #{$size});
.#{$devui-prefix}-checkbox__material {
width: map-get($checkbox-width-map, #{$size});
height: map-get($checkbox-width-map, #{$size});
& > svg {
width: map-get($checkbox-width-map, #{$size});
height: map-get($checkbox-width-map, #{$size});
}
}
&.#{$devui-prefix}-checkbox--bordered {
height: map-get($checkbox-label-height-map, #{$size});
padding: 0 15px 0 10px;
}
}
}
&.#{$devui-prefix}-checkbox--bordered {
border: 1px solid $devui-disabled-line;
border-radius: $devui-border-radius;
}
& > span {
display: inline-block;
box-sizing: content-box;
vertical-align: top !important;
&.#{$devui-prefix}-checkbox__material {
flex-shrink: 0;
}
&.#{$devui-prefix}-checkbox__label-text {
flex-shrink: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
&.disabled {
label {
cursor: not-allowed;
color: $devui-disabled-text;
}
.#{$devui-prefix}-checkbox__material {
border-color: $devui-icon-fill-active-disabled;
background-color: $devui-icon-fill-active-disabled;
}
&.unchecked {
.#{$devui-prefix}-checkbox__material {
border-color: $devui-disabled-line;
background-color: $devui-disabled-bg;
}
}
&.half-checked {
.#{$devui-prefix}-checkbox__material {
background-color: $devui-icon-fill-active-disabled;
.#{$devui-prefix}-checkbox__halfchecked-bg {
transform: scale(0.4288);
background-color: $devui-light-text;
opacity: 1;
}
}
}
&.active {
svg polygon {
fill: $devui-light-text;
}
}
}
}
.#{$devui-prefix}-checkbox--no-animation {
transition: none !important;
}
.#{$devui-prefix}-checkbox__column-margin {
height: 28px;
line-height: 28px;
}
.#{$devui-prefix}-checkbox__wrap .#{$devui-prefix}-checkbox label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}