-
Notifications
You must be signed in to change notification settings - Fork 0
/
_components.scss
184 lines (170 loc) · 4.51 KB
/
_components.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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
@mixin components($type, $dim, $unchecked, $checked, $unchecked-hover, $checked-hover, $unchecked-disabled, $checked-disabled, $unchecked-active: "", $checked-active: "", $indeterminate: "") {
// Based on Ryan Seddon's solution --> http://www.thecssninja.com/css/custom-inputs-using-css
// * works with ie9+ with graceful degradation in previous browser
//
// @params !WARNING USE UNESCAPED STRINGS
// * $type could be checkbox or radio
// * $dim the dimension (square) of the component
//
// * IMAGES (without extension)
// * $unchecked the default state
// * $checked checked state
// * $unchecked-hover hovered image
// * $unchecked-disabled disabled unchecked image
// * $checked-disabled disabled checkd image
// * [$unchecked-active] OPTIONAL unchecked active image
// * [$checked-active] OPTIONAL checked active
// * [$indeterminate] OPTIONAL only for checkbox three state image
//
// * MINIMAL TEMPLATE
// * <span class="cb || rb"><input id type="$type"/><label for></label></span>
@if($type == 'checkbox'){
.cb {
position: relative;
width: $dim;
height: $dim;
display: inline-block;
vertical-align: top;
+label[for]{
cursor: pointer;
@include user-select(none);
}
}
} @else {
.rb {
position: relative;
width: $dim;
height: $dim;
display: inline-block;
vertical-align: top;
+label[for]{
cursor: pointer;
@include user-select(none);
}
}
}
:root .cb,
:root .rb {
input[type=#{$type}] {
padding: 0;
margin: 0;
height: $dim;
width: $dim;
position: absolute;
opacity: 0;
cursor: pointer;
+ label {
padding-left: $dim;
background: transparent url($unchecked) no-repeat center/$dim;
height: $dim;
width: $dim;
margin: 0;
display: inline-block;
position: relative;
z-index: 1;
&[for]{
cursor: pointer;
@include user-select(none);
}
&:hover {
background-image: url($unchecked-hover);
@if $unchecked-active != ""{
&:active {
background-image: url($unchecked-active);
}
}
}
}
&:checked {
+ label {
background-image: url($checked);
@if $checked-active != ""{
&:hover {
&:active {
background-image: url($checked-active);
}
}
}
&:hover {
background-image: url($checked-active);
}
}
}
&:hover{
+label {
background-image: url($unchecked-hover);
}
&:checked {
+ label {
background-image: url($checked-hover);
}
}
&:disabled {
+ label {
background-image: url($unchecked-disabled);
}
&:checked {
+ label {
background-image: url($checked-disabled);
}
}
}
}
&:focus {
+label {
background-image: url($unchecked-hover);
opacity: 0.75;
}
&:checked {
+ label {
background-image: url($checked-hover);
opacity: 0.75;
}
}
}
&:active {
@if $unchecked-active != ""{
+ label {
background-image: url($unchecked-active);
}
}
@if $checked-active != ""{
&:checked {
+ label {
background-image: url($checked-active);
}
}
}
}
&:disabled {
+ label {
background-image: url($unchecked-disabled);
&:hover {
background-image: url($unchecked-disabled);
&:active {
background-image: url($unchecked-disabled);
}
}
}
&:checked {
+ label {
background-image: url($checked-disabled);
&:hover {
background-image: url($checked-disabled);
&:active {
background-image: url($checked-disabled);
}
}
}
}
}
@if($type == 'checkbox' and $indeterminate !=""){
&:indeterminate {
+ label {
background-image: url($indeterminate);
}
}
}
}
}
}