-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path_select.scss
More file actions
173 lines (144 loc) · 5.67 KB
/
_select.scss
File metadata and controls
173 lines (144 loc) · 5.67 KB
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
@use "sass:list";
@use "../utils/helpers" as h;
@use "../utils/variables" as vars;
/* @docs */
$select-height: h.useVar("control-height") !default;
$select-padding: h.useVar("control-padding-vertical")
h.useVar("control-padding-horizontal") !default;
$select-disabled-opacity: h.useVar("control-disabled-opacity") !default;
$select-color: h.useVar("font-color") !default;
$select-font-size: h.useVar("font-size") !default;
$select-font-weight: h.useVar("font-weight") !default;
$select-line-height: h.useVar("line-height") !default;
$select-box-shadow: h.useVar("control-box-shadow-inset") !default;
$select-background-color: h.useVar("control-background-color") !default;
$select-border-color: h.useVar("control-border-color") !default;
$select-border-style: solid !default;
$select-border-width: h.useVar("control-border-width") !default;
$select-border-radius: h.useVar("border-radius") !default;
$select-border-radius-rounded: h.useVar("border-radius-rounded") !default;
$select-multiple-padding: h.useVar("control-spacer") !default;
$select-arrow-color: vars.$font-color !default;
$select-arrow-size: 1em !default;
/* @docs */
@function svg_arrow($color) {
$start: '<svg width="100%" height="100%" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;">';
$content: '<g transform="matrix(5.70052,0,0,5.70052,-1329.79,-547.054)"><path d="M233.451,101.749L235.617,99.422L242.013,105.565L248.463,99.422L250.642,101.749L242.013,110.052L233.451,101.749Z" style="fill:#{$color}"/></g>';
$end: "</svg>";
@return h.svg-encode("#{$start}#{$content}#{$end}");
}
.o-select {
@include h.defineVar("select-height", $select-height);
@include h.defineVar("select-padding", $select-padding);
@include h.defineVar("select-disabled-opacity", $select-disabled-opacity);
@include h.defineVar("select-color", $select-color);
@include h.defineVar("select-font-size", $select-font-size);
@include h.defineVar("select-font-weight", $select-font-weight);
@include h.defineVar("select-line-height", $select-line-height);
@include h.defineVar("select-box-shadow", $select-box-shadow);
@include h.defineVar("select-background-color", $select-background-color);
@include h.defineVar("select-border-color", $select-border-color);
@include h.defineVar("select-border-style", $select-border-style);
@include h.defineVar("select-border-width", $select-border-width);
@include h.defineVar("select-border-radius", $select-border-radius);
@include h.defineVar(
"select-border-radius-rounded",
$select-border-radius-rounded
);
@include h.defineVar("select-arrow-size", $select-arrow-size);
@include h.defineVar(
"select-arrow-background-image",
url(svg_arrow($select-arrow-color))
);
@include h.defineVar("select-multiple-padding", $select-multiple-padding);
// define focus shadow effect
@include h.focusable(".o-select__input");
display: inline-block;
position: relative;
// size variants
@each $name, $value in vars.$sizes {
&--#{$name} {
@include h.defineVar("select-font-size", h.useVar("size-#{$name}"));
}
}
// color variants
@each $name, $pair in vars.$colors {
$color: list.nth($pair, 1);
&--#{$name} {
@include h.defineVar("select-border-color", h.useVar($name));
@include h.defineVar(
"select-arrow-background-image",
url(svg_arrow($color))
);
}
}
&__input {
// remove default appearance
@include h.removeAppearance;
display: inline-block;
position: relative;
height: h.useVar("select-height");
padding: h.useVar("select-padding");
color: h.useVar("select-color");
font-size: h.useVar("select-font-size");
font-weight: h.useVar("select-font-weight");
line-height: h.useVar("select-line-height");
box-shadow: h.useVar("select-box-shadow");
background-color: h.useVar("select-background-color");
border-color: h.useVar("select-border-color");
border-style: h.useVar("select-border-style");
border-width: h.useVar("select-border-width");
border-radius: h.useVar("select-border-radius");
&--arrowed {
background-image: h.useVar("select-arrow-background-image");
background-repeat: no-repeat;
background-size: h.useVar("select-arrow-size");
background-position: calc(
100% - h.useVar("select-arrow-size") * 0.5
)
center;
padding-right: calc(h.useVar("select-arrow-size") * 2);
}
&--iconspace-left {
padding-left: h.useVar("select-height");
}
&--iconspace-right {
padding-right: h.useVar("select-height");
}
}
&--rounded {
@include h.defineVar(
"select-border-radius",
h.useVar("select-border-radius-rounded")
);
}
&--disabled {
@include h.disabled(h.useVar("select-disabled-opacity"));
}
&--expanded {
width: 100%;
flex-grow: 1;
flex-shrink: 1;
.o-select__input {
width: 100%;
}
}
&--multiple .o-select__input {
height: auto;
padding: h.useVar("select-multiple-padding");
}
&__icon-left,
&__icon-right {
position: absolute;
top: 0;
height: 100%;
width: h.useVar("select-height");
z-index: 1;
}
&__icon-right {
right: 0;
}
&__icon-left {
left: 0;
}
}