naive-ui/styles/Radio.scss

267 lines
7.9 KiB
SCSS
Raw Normal View History

@import './mixins/mixins.scss';
2020-02-11 14:44:29 +08:00
2019-12-13 17:54:57 +08:00
@mixin radio-group-size-mixin ($size) {
@include m($size + '-size') {
@include m(button-group) {
line-height: map-get($--n-height, $size);
height: map-get($--n-height, $size);
}
2019-12-13 17:54:57 +08:00
@include b(radio-button) {
line-height: map-get($--n-height, $size);
height: map-get($--n-height, $size);
font-size: map-get($--n-font-size, $size);
}
@include e(splitor) {
height: map-get($--n-height, $size);
}
}
}
@mixin radio-size-mixin ($size) {
@include m($size + '-size') {
font-size: map-get($--n-font-size, $size);
@include e(control) {
height: map-get($--n-radio-size, $size);
width: map-get($--n-radio-size, $size);
}
}
}
2019-10-21 14:49:08 +08:00
@include themes-mixin {
@include b(radio) {
@include once {
@include radio-size-mixin('small');
@include radio-size-mixin('medium');
@include radio-size-mixin('large');
outline: none;
position: relative;
user-select: none;
display: inline-flex;
vertical-align: middle;
align-items: center;
@include e(radio-input) {
width: 0;
height: 0;
opacity: 0;
margin: 0;
}
}
2019-10-21 14:49:08 +08:00
@include e(control) {
2020-02-20 13:22:48 +08:00
@include once {
transition:
background-color .3s $--n-ease-in-out-cubic-bezier,
box-shadow .3s $--n-ease-in-out-cubic-bezier;
margin-right: 9px;
position: relative;
border-radius: 50%;
2020-02-20 13:22:48 +08:00
}
background-color: map-get($--radio-background-color, 'default');
2019-10-21 14:49:08 +08:00
box-shadow: map-get($--radio-box-shadow, 'default');
&::before {
2020-02-20 13:22:48 +08:00
@include once {
content: "";
opacity: 0;
position: absolute;
left: 4px;
top: 4px;
height: calc(100% - 8px);
width: calc(100% - 8px);
border-radius: 50%;
2020-02-20 13:22:48 +08:00
transform: scale(.8);
transition:
opacity .3s $--n-ease-in-out-cubic-bezier,
background-color .3s $--n-ease-in-out-cubic-bezier,
transform .3s $--n-ease-in-out-cubic-bezier;
}
2019-10-21 14:49:08 +08:00
background-color: map-get($--radio-control-background-color, 'active');
}
2019-10-21 14:49:08 +08:00
@include m(checked) {
box-shadow: map-get($--radio-box-shadow, 'active');
2020-02-20 13:22:48 +08:00
@include once {
&::before {
opacity: 1;
transform: scale(1);
}
}
}
}
2019-10-21 14:49:08 +08:00
@include e(label) {
2020-02-20 13:22:48 +08:00
@include once {
display: inline-block;
white-space: nowrap;
transition: color .3s $--n-ease-in-out-cubic-bezier;
}
color: map-get($--radio-label-text-color, 'default');
2019-10-21 14:49:08 +08:00
}
@include not-m(disabled) {
2020-02-20 13:22:48 +08:00
@include once {
cursor: pointer;
}
2019-10-21 14:49:08 +08:00
&:hover {
@include e(control) {
box-shadow: map-get($--radio-box-shadow, 'hover');
}
}
@include m(focus) {
&:not(:active) {
@include e(control) {
box-shadow: map-get($--radio-box-shadow, 'focus');
}
2019-10-21 14:49:08 +08:00
}
2019-07-16 17:20:43 +08:00
}
}
2019-10-21 14:49:08 +08:00
@include m(disabled) {
2020-02-20 13:22:48 +08:00
@include once {
cursor: not-allowed;
}
2019-10-21 14:49:08 +08:00
@include e(control) {
box-shadow: map-get($--radio-box-shadow, 'disabled');
2020-02-20 13:22:48 +08:00
background-color: map-get($--radio-background-color, 'disabled');
2019-10-21 14:49:08 +08:00
&::before {
background-color: map-get($--radio-control-background-color, 'disabled');
}
2020-02-20 13:22:48 +08:00
@include once {
@include m(checked) {
2019-10-21 14:49:08 +08:00
transform: scale(1);
opacity: 1;
}
}
}
@include e(label) {
2020-02-20 13:22:48 +08:00
color: map-get($--radio-label-text-color, 'disabled');
2019-10-21 14:49:08 +08:00
}
2019-07-16 17:20:43 +08:00
}
}
}
2019-10-21 14:49:08 +08:00
@include themes-mixin {
@include b(radio-group) {
2019-12-13 17:54:57 +08:00
@include once {
@include radio-group-size-mixin('small');
@include radio-group-size-mixin('medium');
@include radio-group-size-mixin('large');
2019-10-21 14:49:08 +08:00
display: inline-block;
2020-03-03 14:34:24 +08:00
@include b(radio) {
margin-right: 18px;
}
2020-01-28 23:15:39 +08:00
@include m(button-group) {
white-space: nowrap;
height: 28px;
line-height: 28px;
2020-01-28 23:15:39 +08:00
}
@include m(transition-disabled) {
@include b(radio-button) {
transition: none !important;
}
}
2019-12-13 17:54:57 +08:00
}
@include b(radio-button) {
@include once {
vertical-align: bottom;
outline: none;
position: relative;
user-select: none;
display: inline-block;
height: 28px;
line-height: 28px;
box-sizing: border-box;
padding-left: 14px;
padding-right: 14px;
white-space: nowrap;
transition: background-color .3s $--n-ease-in-out-cubic-bezier, opacity .3s $--n-ease-in-out-cubic-bezier, border-color .3s $--n-ease-in-out-cubic-bezier, color .3s $--n-ease-in-out-cubic-bezier;
@include e(radio-input) {
width: 0;
height: 0;
opacity: 0;
margin: 0;
}
2019-12-13 17:54:57 +08:00
@include e(border-mask) {
pointer-events: none;
position: absolute;
box-shadow: inset 0 0 0 $--radio-border-mask-width transparent;
transition: box-shadow .3s $--n-ease-in-out-cubic-bezier;
2019-12-13 17:54:57 +08:00
left: -1px;
bottom: -1px;
right: -1px;
top: -1px;
}
}
color: map-get($--radio-button-label-color, 'default');
2019-10-21 14:49:08 +08:00
border-top: 1px solid map-get($--radio-button-border-color, 'default');
border-bottom: 1px solid map-get($--radio-button-border-color, 'default');
2019-12-13 17:54:57 +08:00
2019-10-21 14:49:08 +08:00
&:first-child {
2019-12-13 17:54:57 +08:00
@include once {
2020-02-28 22:57:10 +08:00
border-top-left-radius: $--n-radio-button-border-radius;
border-bottom-left-radius: $--n-radio-button-border-radius;
2019-12-13 17:54:57 +08:00
@include e(border-mask) {
2020-02-28 22:57:10 +08:00
border-top-left-radius: $--n-radio-button-border-radius;
border-bottom-left-radius: $--n-radio-button-border-radius;
2019-12-13 17:54:57 +08:00
}
2019-10-21 14:49:08 +08:00
}
2019-12-13 17:54:57 +08:00
border-left: 1px solid map-get($--radio-button-border-color, 'default');
2019-10-21 14:49:08 +08:00
}
&:last-child {
2019-12-13 17:54:57 +08:00
@include once {
2020-02-28 22:57:10 +08:00
border-top-right-radius: $--n-radio-button-border-radius;
border-bottom-right-radius: $--n-radio-button-border-radius;
2019-12-13 17:54:57 +08:00
@include e(border-mask) {
2020-02-28 22:57:10 +08:00
border-top-right-radius: $--n-radio-button-border-radius;
border-bottom-right-radius: $--n-radio-button-border-radius;
2019-12-13 17:54:57 +08:00
}
2019-10-21 14:49:08 +08:00
}
2019-12-13 17:54:57 +08:00
border-right: 1px solid map-get($--radio-button-border-color, 'default');
2019-10-21 14:49:08 +08:00
}
@include not-m(disabled) {
2019-12-13 17:54:57 +08:00
@include once {
cursor: pointer;
}
2019-10-21 14:49:08 +08:00
&:hover {
@include e(border-mask) {
2019-11-28 14:42:11 +08:00
box-shadow: map-get($--radio-button-box-shadow, 'hover');
2019-12-13 17:54:57 +08:00
@include once {
transition: box-shadow .3s $--n-ease-in-out-cubic-bezier;
2019-12-13 17:54:57 +08:00
}
2019-10-21 14:49:08 +08:00
}
@include not-m(checked) {
color: map-get($--radio-button-label-color, 'hover');
}
}
@include m(focus) {
&:not(:active) {
@include e(border-mask) {
box-shadow: map-get($--radio-button-box-shadow, 'focus')
}
2019-10-21 14:49:08 +08:00
}
}
}
@include m(checked) {
background-color: map-get($--radio-button-background-color, 'active');
color: map-get($--radio-button-label-color, 'active');
border-color: map-get($--radio-button-border-color, 'active');
}
@include m(disabled) {
2019-12-13 17:54:57 +08:00
@include once {
cursor: not-allowed;
}
2019-10-21 14:49:08 +08:00
opacity: $--radio-disabled-opacity;
2019-07-16 17:20:43 +08:00
}
}
2019-10-21 14:49:08 +08:00
@include e(splitor) {
2019-12-13 17:54:57 +08:00
@include once {
display: inline-block;
vertical-align: bottom;
height: 28px;
width: 1px;
transition: background-color .3s $--n-ease-in-out-cubic-bezier, opacity .3s $--n-ease-in-out-cubic-bezier;
2019-12-13 17:54:57 +08:00
}
2019-10-21 14:49:08 +08:00
background-color: map-get($--radio-button-border-color, 'default');
@include m(checked) {
background-color: map-get($--radio-button-border-color, 'active');
}
@include m(disabled) {
opacity: $--radio-disabled-opacity;
2019-07-16 17:20:43 +08:00
}
}
}
}