forked from finnhvman/matter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheckbox.css
150 lines (132 loc) · 3.77 KB
/
checkbox.css
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
.matter-checkbox {
--matter-helper-theme: var(--matter-theme-rgb, var(--matter-primary-rgb, 33, 150, 243));
--matter-helper-ontheme: var(--matter-ontheme-rgb, var(--matter-onprimary-rgb, 255, 255, 255));
z-index: 0;
position: relative;
display: inline-block;
color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.87);
font-family: var(--matter-font-family, "Roboto", "Segoe UI", BlinkMacSystemFont, system-ui, -apple-system);
font-size: 16px;
line-height: 1.5;
}
/* Box */
.matter-checkbox > input {
appearance: none;
-moz-appearance: none;
-webkit-appearance: none;
z-index: 1;
position: absolute;
display: block;
box-sizing: border-box;
margin: 3px 1px;
border: solid 2px; /* Safari */
border-color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.6);
border-radius: 2px;
width: 18px;
height: 18px;
outline: none;
cursor: pointer;
transition: border-color 0.2s, background-color 0.2s;
}
/* Span */
.matter-checkbox > input + span {
display: inline-block;
box-sizing: border-box;
padding-left: 30px;
width: inherit;
cursor: pointer;
}
/* Highlight */
.matter-checkbox > input + span::before {
content: "";
position: absolute;
left: -10px;
top: -8px;
display: block;
border-radius: 50%;
width: 40px;
height: 40px;
background-color: rgb(var(--matter-onsurface-rgb, 0, 0, 0));
opacity: 0;
transform: scale(1);
pointer-events: none;
transition: opacity 0.3s, transform 0.2s;
}
/* Check Mark */
.matter-checkbox > input + span::after {
content: "";
z-index: 1;
display: block;
position: absolute;
top: 3px;
left: 1px;
box-sizing: content-box;
width: 10px;
height: 5px;
border: solid 2px transparent;
border-right-width: 0;
border-top-width: 0;
pointer-events: none;
transform: translate(3px, 4px) rotate(-45deg);
transition: border-color 0.2s;
}
/* Checked, Indeterminate */
.matter-checkbox > input:checked,
.matter-checkbox > input:indeterminate {
border-color: rgb(var(--matter-helper-theme));
background-color: rgb(var(--matter-helper-theme));
}
.matter-checkbox > input:checked + span::before,
.matter-checkbox > input:indeterminate + span::before {
background-color: rgb(var(--matter-helper-theme));
}
.matter-checkbox > input:checked + span::after,
.matter-checkbox > input:indeterminate + span::after {
border-color: rgb(var(--matter-helper-ontheme, 255, 255, 255));
}
.matter-checkbox > input:indeterminate + span::after {
border-left-width: 0;
transform: translate(4px, 3px);
}
/* Hover, Focus */
.matter-checkbox:hover > input + span::before {
opacity: 0.04;
}
.matter-checkbox > input:focus + span::before {
opacity: 0.12;
}
.matter-checkbox:hover > input:focus + span::before {
opacity: 0.16;
}
/* Active */
.matter-checkbox:active > input,
.matter-checkbox:active:hover > input {
border-color: rgb(var(--matter-helper-theme));
}
.matter-checkbox:active > input:checked {
border-color: transparent;
background-color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.6);
}
.matter-checkbox:active > input + span::before {
opacity: 1;
transform: scale(0);
transition: transform 0s, opacity 0s;
}
/* Disabled */
.matter-checkbox > input:disabled {
border-color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.38);
cursor: initial;
}
.matter-checkbox > input:checked:disabled,
.matter-checkbox > input:indeterminate:disabled {
border-color: transparent;
background-color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.38);
}
.matter-checkbox > input:disabled + span {
color: rgba(var(--matter-onsurface-rgb, 0, 0, 0), 0.38);
cursor: initial;
}
.matter-checkbox > input:disabled + span::before {
opacity: 0;
transform: scale(0);
}