amis/scss/components/form/_checks.scss

292 lines
5.7 KiB
SCSS

.#{$ns}Checkbox {
margin: 0 $gap-sm 0 0;
font-weight: $fontWeightNormal;
user-select: none;
input {
opacity: 0;
position: absolute;
}
&:hover input:not(:disabled) + i {
border-color: $Checkbox-onHover-color;
// box-shadow: 0 0 px2rem(1px) $Checkbox-onHover-color inset;
}
> i {
cursor: pointer;
line-height: 1;
background: $Checkbox-gb;
display: inline-block;
vertical-align: middle;
position: relative;
+ span {
margin-left: $Checkbox-gap;
cursor: pointer;
> a {
float: right;
margin-left: px2rem(5px);
display: none;
}
&:empty {
display: none;
}
}
&:before {
content: '';
position: absolute;
left: 50%;
top: 50%;
width: 0px;
height: 0px;
background-color: transparent;
transition: all 0.2s;
transform-origin: 50% 50%;
transform: translate(-50%, -50%);
}
}
&:hover > i + span > a {
display: inline-block;
}
&--checkbox {
padding-left: $Checkbox-size;
input {
margin-left: -$Checkbox-size;
&:checked + i {
border-color: $Checkbox-onHover-color;
&:before {
width: $Checkbox-inner-size;
height: $Checkbox-inner-size;
background: $Checkbox-onHover-color;
}
}
&[disabled] + i {
border-color: lighten($Checkbox-color, 5%);
cursor: not-allowed;
&:before {
background-color: lighten($Checkbox-color, 5%);
border-color: $white;
}
}
&[disabled] + i + span {
cursor: not-allowed;
color: $text--muted-color;
}
}
> i {
width: $Checkbox-size;
height: $Checkbox-size;
border: px2rem(1px) solid $Checkbox-color;
border-radius: $Checkbox-borderRadius;
margin-left: -$Checkbox-size;
margin-top: px2rem(-3px);
}
}
&--full.#{$ns}Checkbox--checkbox {
&:not(:disabled) + i:hover {
border-color: $Checkbox-color;
}
input {
&:checked + i {
border-color: $Checkbox-onHover-color;
background: $Checkbox-onHover-color;
&:before {
width: $Checkbox--full-inner-size;
height: $Checkbox--full-inner-size / 2;
border-color: $white;
}
}
// &[disabled] + i {
// border-color: lighten($Checkbox-color, 5%);
// &:before {
// background-color: lighten($Checkbox-color, 5%);
// }
// }
&:checked[disabled] + i {
border-color: lighten($Checkbox-color, 5%);
background-color: lighten($Checkbox-color, 5%);
}
}
> i {
position: relative;
cursor: pointer;
&:before {
content: '';
position: absolute;
left: 50%;
top: 50%;
width: 0;
height: 0;
border-color: transparent;
transition: width 0.2s, height 0.2s, transform 0.2s;
border-width: 0 0 px2rem(2px) px2rem(2px);
transform: translate(-50%, -60%) rotate(-40deg);
border-style: solid;
}
}
}
&--radio {
padding-left: $Radio-size;
input {
margin-left: -$Radio-size;
&:checked + i {
border-color: $Radio-onHover-color;
&:before {
width: $Radio-inner-size;
height: $Radio-inner-size;
background-color: $Radio-onHover-color;
border-radius: 50%;
}
}
&[disabled] + i {
border-color: lighten($Radio-color, 5%);
cursor: not-allowed;
&:before {
background-color: lighten($Radio-color, 5%);
}
}
&[disabled] + i + span {
cursor: not-allowed;
color: $text--muted-color;
}
}
> i {
cursor: pointer;
width: $Radio-size;
height: $Radio-size;
border: px2rem(1px) solid $Radio-color;
margin-left: -$Radio-size;
margin-top: px2rem(-2px);
border-radius: 50%;
}
}
&--sm {
padding-left: $Checkbox--sm-size;
input {
margin-left: -$Checkbox--sm-size;
&:checked + i {
&:before {
width: $Checkbox--sm-inner-size;
height: $Checkbox--sm-inner-size;
}
}
}
> i {
width: $Checkbox--sm-size;
height: $Checkbox--sm-size;
margin-left: -$Checkbox--sm-size;
+ span {
margin-left: $gap-xs;
}
}
}
&--sm.#{$ns}Checkbox--full {
input {
&:checked + i {
&:before {
width: $Checkbox--sm--full-inner-size;
height: $Checkbox--sm--full-inner-size / 2;
}
}
}
}
&-desc {
color: $text--muted-color;
margin-left: $Checkbox-gap;
margin-top: $gap-xs;
}
}
.#{$ns}CheckboxControl,
.#{$ns}RadiosControl,
.#{$ns}CheckboxesControl {
padding-top: ($Form-input-height - $Checkbox-size) / 2;
}
.#{$ns}RadiosControl,
.#{$ns}CheckboxesControl {
.#{$ns}Checkbox {
display: block;
margin-bottom: $Form-label-paddingTop;
}
&.is-inline .#{$ns}Checkbox {
display: inline-block;
margin-right: $gap-md;
}
}
.#{$ns}RadiosControl-group,
.#{$ns}CheckboxesControl-group {
.#{$ns}RadiosControl-group,
.#{$ns}CheckboxesControl-group {
padding-left: px2rem(80px);
@include clearfix();
> .#{$ns}RadiosControl-groupLabel,
> .#{$ns}CheckboxesControl-groupLabel {
float: left;
width: px2rem(80px);
margin-left: px2rem(-80px);
}
}
}
.#{$ns}RadiosControl-groupLabel,
.#{$ns}CheckboxesControl-groupLabel {
display: block;
}
.#{$ns}Checkboxes {
&-addBtn {
display: block;
cursor: pointer;
&:hover {
text-decoration: none;
}
> svg {
width: px2rem(14px);
height: px2rem(14px);
margin-right: $Checkbox-gap;
}
}
}