-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstyle.scss
124 lines (98 loc) · 2.52 KB
/
style.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
/*
B.E.M Naming convention:
(Block) .custom-dropdown
The main component
(Element) .custom-dropdown__select
Descendant of .custom-dropdown
(Modifier) .custom-dropdown--*
Different state of .custom-dropdown
*/
@mixin caret($color) {
background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 129 129' fill='#{$color}'><path d='M121.3 34.6c-1.6-1.6-4.2-1.6-5.8 0l-51 51.1-51.1-51.1c-1.6-1.6-4.2-1.6-5.8 0-1.6 1.6-1.6 4.2 0 5.8l53.9 53.9c.8.8 1.8 1.2 2.9 1.2 1 0 2.1-.4 2.9-1.2l53.9-53.9c1.7-1.6 1.7-4.2.1-5.8z'/></svg>");
}
$baseColor: rgba(0, 0, 0, .9);
$disabledColor: rgba(0, 0, 0, .3);
.custom-dropdown {
display: inline-block;
vertical-align: middle;
&--xl {
font-size: 2em;
}
&--lg {
font-size: 1.5em;
}
&--sm {
font-size: .7em;
}
&__select {
font-size: inherit; /* inherit size from .custom-dropdown parent */
padding: .5em;
border-radius: 3px;
background: none;
color: $baseColor;
border: 1px solid;
}
}
@supports (pointer-events: none) and
((-webkit-appearance: none) or
(-moz-appearance: none) or
(appearance: none)) {
.custom-dropdown {
position: relative;
&__select {
padding-right: 2.5em; /* accommodate with the pseudo elements for the dropdown arrow */
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
&::before,
&::after {
content: "";
position: absolute;
pointer-events: none;
}
&::before {
width: 2em;
right: 0;
top: .5em;
bottom: .5em;
border-left: 1px solid $baseColor;
}
&::after {
content: "";
@include caret($baseColor);
background-repeat: no-repeat;
background-position: center;
height: 1em;
width: 2em;
right: 0;
top: 50%;
margin-top: -.5em;
}
}
// Disabled stuff
.custom-dropdown__select[disabled] {
color: $disabledColor;
}
.custom-dropdown.custom-dropdown--disabled::before {
border-color: $disabledColor;
}
.custom-dropdown.custom-dropdown--disabled::after {
@include caret($disabledColor);
}
// Active
.custom-dropdown:focus-within::after {
transform: scale(1.2)
}
}
// Demo
html {
height: 100%;
}
body {
background: linear-gradient(rgba(135, 60, 255, .5), rgba(135, 60, 255, .2) 70%),
linear-gradient(-45deg, rgba(103, 140, 245, 0.8) 25%, rgba(255, 211, 65, 0.8) 75%);
}
.custom-dropdown {
margin: .5em 0;
}