/
_select.scss
154 lines (132 loc) · 4.04 KB
/
_select.scss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// @page Pattern Library/Forms
// @name Selects
//
// @description
// Select boxes allow users to choose an option or options from a list of options.
//
// #### Best practices
// * Use select boxes when choosing one or more options from a list of related, but mutually exclusive options e.g. profession, title, month.
// * It can be tempting to put many things in a select box for users to choose from. Try to keep the list of options to between 4 and 15 so the user doesn't become overwhelmed with choices.
//
// @state .us-form-select--multiple - Removes the drop down arrow and adjusts the padding of <option> elements. Useful when using <select> elements that have the size="" attribute set to anything higher than 1.
// @state .us-form-select--blocked - Fluid style.
// @state .us-form-select--error - Visual feedback for when the input has an error.
// @state .us-form-select--success - Visual feedback for when success needs to be communicated to the user.
// @state .us-form-select--disabled - Inactive state for select boxes. You may also just add the disabled attribute to the <select> element in order to achieve the same effect.
//
// @markup
// <select class="us-form-select {$modifiers}">
// <option>A select menu</option>
// <option>With lots of options</option>
// <option>And a few more</option>
// </select>
$select-default-color: $c-form-element-border !default;
$select-hover-color: $c-form-element-border-hover !default;
@function select-arrow($color) {
@return url("data:image/svg+xml;charset=utf-8;base64," + base64encode("<svg version='1.1' baseProfile='tiny' xmlns='http://www.w3.org/2000/svg' x='0px' y='0px' width='40px' height='6px' viewBox='0 0 40 6'><polygon fill='#{$color}' points='25.3,0 20.3,6 15.3,0 '/></svg>"));
}
@mixin select-background($color, $color--active: false) {
background-image: select-arrow($color);
&:hover,
&:focus {
background-image: select-arrow(if($color--active, $color--active, $color));
}
}
// [deprecated]
.us-form-select-wrap {
position: relative;
display: inline-block;
}
.us-form-select {
@extend %base-form-element;
@include select-background($select-default-color, $select-hover-color);
@include input-sizing();
max-width: 100%;
padding-right: 40px;
cursor: pointer;
background-position: 100% 50%;
background-repeat: no-repeat;
outline: 0;
// [nodoc] Fix for FF < 35 https://gist.github.com/joaocunha/6273016/
@-moz-document url-prefix() {
text-indent: .01px;
text-overflow: "";
-moz-appearance: none;
}
&:focus {
&:-moz-focusring {
color: transparent;
text-shadow: 0 0 0 $c-form-element-text;
}
}
&::-ms-expand {
display: none;
}
@if $media-query-legacy-support {
.ie8 & {
padding: $form-element-base-padding;
}
}
.ie9 & {
padding: $form-element-base-padding;
}
}
.us-form-select-wrap--multiple, // [deprecated]
.us-form-select--multiple,
.us-form-select[multiple],
.us-form-select[size] {
&,
.us-form-select {
height: auto;
overflow: hidden {
x: auto;
y: auto;
};
vertical-align: middle;
cursor: default;
background-image: none;
-webkit-overflow-scrolling: touch;
}
&:hover,
&:focus {
background-image: none;
}
option {
cursor: pointer;
}
&::-webkit-scrollbar {
width: 16px;
height: 16px;
&:window-inactive {
opacity: 0;
}
}
&::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, .2);
border: 4px solid rgba(0, 0, 0, 0);
border-radius: 8px;
background-clip: padding-box;
}
&::-webkit-scrollbar-corner {
background-color: transparent;
}
}
.us-form-select-wrap--blocked, // [deprecated]
.us-form-select--blocked {
width: 100%;
}
.us-form-select-wrap--disabled, // [deprecated]
.us-form-select--disabled,
.us-form-select:disabled {
&,
.us-form-select {
@include form-element-disabled;
@include select-background($c-form-element-disabled-fg);
}
}
.us-form-select--error {
@extend %base-form-element--error;
}
.us-form-select--success {
@extend %base-form-element--success;
}