amis/scss/components/form/_select.scss

319 lines
7.0 KiB
SCSS
Raw Normal View History

2019-04-30 11:11:25 +08:00
.#{$ns}Select {
2019-11-14 20:27:49 +08:00
display: inline-flex;
vertical-align: middle;
text-align: left;
outline: none;
position: relative;
border: $Form-select-borderWidth solid $Form-select-borderColor;
background: $Form-select-bg;
border-radius: $Form-select-borderRadius;
2019-12-16 10:56:07 +08:00
min-height: $Form-selectOption-height;
2019-11-14 20:27:49 +08:00
$paddingY: (
$Form-selectOption-height - $Form-input-lineHeight * $Form-input-fontSize -
$Form-select-borderWidth * 2
)/2;
padding: $paddingY 0 $paddingY $Form-select-paddingX;
cursor: pointer;
color: $Form-select-color;
&:hover {
background: $Form-select-onHover-bg;
border-color: $Form-select-onHover-borderColor;
.#{$ns}Select-arrow:before {
color: $Form-select-caret-onHover-iconColor;
}
}
2019-04-30 11:11:25 +08:00
2019-11-14 20:27:49 +08:00
&.is-disabled {
color: $text--muted-color;
background: $Form-input-onDisabled-bg;
border-color: $Form-input-onDisabled-borderColor;
}
2019-08-12 21:14:33 +08:00
2019-11-14 20:27:49 +08:00
&-valueWrap {
user-select: none;
position: relative;
flex-grow: 1;
line-height: 1;
2019-12-16 11:00:39 +08:00
// width: 0;
max-width: 100%;
2019-11-14 20:27:49 +08:00
}
&-placeholder {
color: $Form-select-placeholderColor;
line-height: $Form-input-lineHeight;
user-select: none;
2020-04-10 11:46:50 +08:00
white-space: nowrap;
2019-11-14 20:27:49 +08:00
}
&-value {
line-height: $Form-input-lineHeight * $Form-input-fontSize;
2019-12-16 10:56:07 +08:00
// white-space: nowrap;
2019-11-14 20:27:49 +08:00
max-width: 100%;
overflow: hidden;
text-overflow: ellipsis;
}
&--multi {
height: auto;
min-height: $Form-selectOption-height;
.#{$ns}Select-valueWrap {
margin-bottom: -$gap-xs;
> input {
display: inline-block;
width: px2rem(100px);
margin-bottom: $gap-xs;
}
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
.#{$ns}Select-values + .#{$ns}Select-input {
transform: translateY(0);
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
.#{$ns}Select-value {
position: static;
user-select: none;
line-height: $Form-input-lineHeight * $Form-input-fontSize - px2rem(2px);
display: inline-block;
vertical-align: middle;
font-size: $Form-selectValue-fontSize;
color: $Form-selectValue-color;
background: $Form-selectValue-bg;
border: px2rem(1px) solid $Form-selectValue-borderColor;
border-radius: px2rem(2px);
margin-right: $gap-xs;
margin-bottom: $gap-xs;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
.#{$ns}Select-valueLabel {
padding: 0 $gap-xs;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
}
2019-04-30 11:11:25 +08:00
2019-11-14 20:27:49 +08:00
&-valueIcon {
cursor: pointer;
border-right: px2rem(1px) solid $Form-selectValue-borderColor;
padding: 1px 5px;
2019-11-14 20:27:49 +08:00
&:hover {
background-color: darken($Form-selectValue-bg, 5%);
}
&.is-disabled {
pointer-events: none;
display: none;
cursor: not-allowed;
background-color: lighten($Form-selectValue-bg, 5%);
background: lighten($Form-selectValue-bg, 5%);
}
2019-11-14 20:27:49 +08:00
}
2019-04-30 11:11:25 +08:00
2019-11-14 20:27:49 +08:00
&-arrow {
margin-right: $gap-xs;
// margin-left: $gap-xs;
width: px2rem(20px);
text-align: center;
display: flex;
align-items: center;
justify-content: center;
line-height: 1;
2020-06-08 17:41:30 +08:00
> svg {
2019-11-14 20:27:49 +08:00
transition: transform 0.3s;
display: inline-block;
color: $Form-select-caret-iconColor;
2020-06-08 17:41:30 +08:00
width: 10px;
height: 10px;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
}
2020-06-08 17:41:30 +08:00
&.is-opened &-arrow > svg {
2019-11-14 20:27:49 +08:00
transform: rotate(180deg);
}
2019-04-30 11:11:25 +08:00
2019-11-14 20:27:49 +08:00
&-menu {
max-height: px2rem(300px);
overflow: auto;
user-select: none;
}
2019-04-30 11:11:25 +08:00
2019-11-14 20:27:49 +08:00
&-input {
cursor: pointer;
outline: none;
border: none;
margin: 0 $Form-select-paddingX;
height: $Form-select-search-height;
font-size: $Form-select-input-fontSize;
border-bottom: 1px solid $borderColor;
display: flex;
align-items: center;
// &.is-focused {
2019-12-06 21:20:23 +08:00
// border-color: $Form-input-onFocused-borderColor;
2019-11-14 20:27:49 +08:00
// }
> svg {
fill: #999;
width: px2rem(14px);
min-width: px2rem(14px);
height: px2rem(14px);
margin-right: px2rem(5px);
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
> input {
outline: none;
border: none;
flex-grow: 1;
background: transparent;
position: relative;
top: 0.125em;
}
}
2019-04-30 11:11:25 +08:00
2019-11-14 20:27:49 +08:00
&-option {
cursor: pointer;
min-width: px2rem(120px);
padding: (
$Form-select-menu-height - $Form-input-lineHeight * $Form-input-fontSize
)/2 $Form-select-paddingX;
&.is-active {
color: $Form-select-menu-onActive-color;
background-color: $Form-select-menu-onActive-bg;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
&.is-highlight {
color: $Form-select-menu-onHover-color;
background-color: $Form-select-menu-onHover-bg;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
&.is-disabled {
color: $Form-select-menu-onDisabled-color;
background-color: $Form-select-menu-onDisabled-bg;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
&--placeholder {
color: $Form-input-placeholderColor;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
> label {
display: block;
}
2019-11-14 20:27:49 +08:00
> a {
float: right;
margin-left: px2rem(5px);
display: none;
}
2019-11-14 20:27:49 +08:00
&.is-highlight > a {
display: block;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
}
&-noResult {
color: $Form-select-placeholderColor;
line-height: $Form-input-lineHeight;
font-size: $Form-select-input-fontSize;
user-select: none;
padding: (
$Form-select-menu-height - $Form-input-lineHeight * $Form-input-fontSize
)/2 $Form-select-paddingX;
}
&-option-hl {
color: $red;
}
&-addBtn {
display: block;
cursor: pointer;
padding: (
$Form-select-menu-height - $Form-input-lineHeight * $Form-input-fontSize
)/2 $Form-select-paddingX;
2019-04-30 11:11:25 +08:00
2019-11-14 20:27:49 +08:00
&:hover {
text-decoration: none;
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
> svg {
width: px2rem(14px);
height: px2rem(14px);
margin-right: $Checkbox-gap;
}
}
2019-11-14 20:27:49 +08:00
&.is-focused,
&.is-opened {
border-color: $Form-input-onFocused-borderColor;
2019-11-14 20:27:49 +08:00
@if ($Form-select-onFocused-color !=$Form-select-color) {
color: $Form-select-onFocused-color;
}
2019-11-14 20:27:49 +08:00
}
2019-11-14 20:27:49 +08:00
&-spinner {
line-height: $Form-input-lineHeight * $Form-input-fontSize;
}
2019-11-14 20:27:49 +08:00
&-clear {
padding: px2rem(3px);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
position: relative;
z-index: 2;
2019-04-30 11:11:25 +08:00
2019-11-14 20:27:49 +08:00
svg {
fill: $Form-input-iconColor;
width: px2rem(10px);
height: px2rem(10px);
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
&:hover svg {
fill: darken($color: $Form-input-iconColor, $amount: 20%);
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
}
2019-04-30 11:11:25 +08:00
}
.#{$ns}Select-popover {
2019-11-14 20:27:49 +08:00
margin-top: $Form-select-popoverGap - $Form-select-outer-borderWidth;
background: $Form-select-menu-bg;
color: $Form-select-menu-color;
border: $Form-select-outer-borderWidth solid $Form-input-onFocused-borderColor;
box-shadow: $Form-select-outer-boxShadow;
border-top-left-radius: 0;
border-top-right-radius: 0;
min-width: px2rem(100px);
z-index: 10;
&.#{$ns}PopOver--leftTopLeftBottom {
margin-top: -($Form-select-popoverGap - $Form-select-outer-borderWidth);
}
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
.#{$ns}SelectControl:not(.is-inline) > .#{$ns}Select {
display: flex;
2019-04-30 11:11:25 +08:00
}
// 需要能撑开
@include media-breakpoint-up(sm) {
2019-11-14 20:27:49 +08:00
.#{$ns}Form-control--sizeXs > .#{$ns}Select,
.#{$ns}Form-control--sizeSm > .#{$ns}Select,
.#{$ns}Form-control--sizeMd > .#{$ns}Select,
.#{$ns}Form-control--sizeLg > .#{$ns}Select {
min-width: 100%;
max-width: 100%;
display: inline-flex !important;
.#{$ns}Select-valueWrap {
width: 0; // ! 没有这个会撑开。
2019-04-30 11:11:25 +08:00
}
2019-11-14 20:27:49 +08:00
}
}