forked from mdbootstrap/mdb-ui-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_checkboxes.scss
153 lines (142 loc) · 4.15 KB
/
_checkboxes.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
// http://www.google.com/design/spec/components/selection-controls.html#selection-controls-checkbox
.checkbox label,
label.checkbox-inline {
padding-left: $bmd-checkbox-size + $bmd-checkbox-label-padding; // absolutely positioned so add the radio size
.checkbox-decorator {
position: absolute;
left: 0;
padding: .7em;
margin: -.7em;
line-height: .7;
vertical-align: middle;
cursor: pointer;
border-radius: 100%;
.check {
position: relative;
z-index: 1;
display: inline-block;
width: $bmd-checkbox-size;
height: $bmd-checkbox-size;
overflow: hidden;
border: $bmd-checkbox-border-size solid $bmd-checkbox-border-color;
border-radius: $border-radius;
// checkbox outline
&::before {
position: absolute;
display: block;
width: 0;
height: 0;
margin-top: -4px;
margin-left: 6px;
// we need a solid color here to avoid glitches in the animation
// it will not look great on non white backgrounds, but this is the
// most common case and it's better support it
color: lighten(rgba($gray, 1), (1 - $gray-alpha) * 100);
content: "";
box-shadow: 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0,
0 0 0 0 inset;
transform: rotate(45deg);
animation: checkbox-off;
.is-focused & {
// Prevent checkbox animation and ripple effect on page load
animation: checkbox-off $bmd-checkbox-animation-check forwards;
}
}
}
}
input[type=checkbox] {
// Hide native checkbox
position: absolute;
left: 0;
z-index: -1;
width: 0;
height: 0;
margin: 0;
overflow: hidden;
pointer-events: none;
opacity: 0;
&:focus + .checkbox-decorator .check::after {
opacity: 0.2;
}
&:checked {
// FIXME: once working - combine further to reduce code
+ .checkbox-decorator .check {
color: $bmd-checkbox-checked-color;
border-color: $bmd-checkbox-checked-color;
}
+ .checkbox-decorator .check::before {
color: $bmd-checkbox-checked-color;
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 032px 0 20px,
-5px 5px 0 10px, 20px -12px 0 11px;
animation: checkbox-on $bmd-checkbox-animation-check forwards;
}
}
&[disabled],
fieldset[disabled] & {
+ .checkbox-decorator .check::after,
.check::after {
background-color: $gray-dark;
transform: rotate(-45deg);
}
+ .checkbox-decorator .check,
.check {
border-color: $bmd-checkbox-border-color-disabled;
}
// No ripple on disabled checkboxes
+ .checkbox-decorator .ripple-container {
display: none;
}
}
}
}
@keyframes checkbox-on {
0% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0 32px 0 20px,
-5px 5px 0 10px, 15px 2px 0 11px;
}
50% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0 32px 0 20px,
-5px 5px 0 10px, 20px 2px 0 11px;
}
100% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0 32px 0 20px,
-5px 5px 0 10px, 20px -12px 0 11px;
}
}
@keyframes checkbox-off {
0% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0 32px 0 20px,
-5px 5px 0 10px, 20px -12px 0 11px, 0 0 0 0 inset;
}
25% {
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0 32px 0 20px,
-5px 5px 0 10px, 20px -12px 0 11px, 0 0 0 0 inset;
}
50% {
width: 0;
height: 0;
margin-top: -4px;
margin-left: 6px;
box-shadow: 0 0 0 10px, 10px -10px 0 10px, 32px 0 0 20px, 0 32px 0 20px,
-5px 5px 0 10px, 15px 2px 0 11px, 0 0 0 0 inset;
transform: rotate(45deg);
}
51% {
width: 20px;
height: 20px;
margin-top: -2px;
margin-left: -2px;
box-shadow: 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0,
0 0 0 10px inset;
transform: rotate(0deg);
}
100% {
width: 20px;
height: 20px;
margin-top: -2px;
margin-left: -2px;
box-shadow: 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0, 0 0 0 0,
0 0 0 0 inset;
transform: rotate(0deg);
}
}