-
Notifications
You must be signed in to change notification settings - Fork 359
Expand file tree
/
Copy pathCheckbox.module.scss
More file actions
159 lines (135 loc) · 3.59 KB
/
Checkbox.module.scss
File metadata and controls
159 lines (135 loc) · 3.59 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
@import "~@vibe/style/dist/mixins";
@import "../../styles/typography";
@import "../../styles/states";
$checkbox-size: 16px;
@mixin hover-selected {
background-color: var(--primary-hover-color);
border-color: transparent;
}
@mixin hover-unselected {
border-color: var(--secondary-text-color);
}
.wrapper {
position: relative;
display: flex;
align-items: center;
width: fit-content;
height: min-content;
}
.checkbox {
cursor: pointer;
visibility: visible;
display: flex;
justify-content: center;
flex-direction: column;
height: $checkbox-size;
width: $checkbox-size;
border: 1px solid;
border-color: var(--ui-border-color);
border-radius: 2px;
transition: transform var(--motion-productive-short) var(--motion-timing-enter);
position: relative;
overflow: hidden;
background-color: var(--secondary-background-color);
}
.checkbox:after {
content: " ";
background-color: transparent;
position: absolute;
height: $checkbox-size;
z-index: 2;
inset-inline: 0;
width: 100%;
}
.checkbox:hover {
@include hover-unselected;
}
.icon {
width: 100%;
color: var(--text-color-on-primary);
visibility: hidden;
}
.label {
@include smoothing-text;
cursor: pointer;
user-select: none;
margin-inline-start: var(--space-8);
}
/* Since it is not possible to change the design of the checkbox according to the requirements using css, */
/* we hide the checkbox and draw a new one instead. */
/* In order to allow accessibility, all operations will be performed on the hidden checkbox and be reflected */
.input {
@include hidden-element();
}
/* For any active attribute in the hidden checkbox, we will change the appearance of the checkbox we drew in its place. */
.input:focus + .checkbox {
@include hover-unselected;
}
.input:focus:checked + .checkbox {
@include hover-selected;
}
.input:focus-visible + .checkbox {
outline: none;
border: 1px solid;
border-color: var(--primary-color);
box-shadow: 0 0 0 3px hsla(209, 100%, 50%, 0.5);
border-radius: 2px;
}
.input:checked:focus + .checkbox:after,
.input:indeterminate:focus + .checkbox:after {
background-color: var(--primary-hover-color);
}
.input:checked + .checkbox,
.input:indeterminate + .checkbox {
animation: checkboxGrowAnimation var(--motion-productive-short);
background-color: var(--primary-color);
border-color: transparent;
}
.input:checked + .checkbox:hover,
.input:indeterminate + .checkbox:hover {
@include hover-selected;
}
.input:checked + .checkbox:hover:after,
.input:indeterminate + .checkbox:hover:after {
background-color: var(--primary-hover-color);
}
.input:checked + .checkbox:after,
.input:indeterminate + .checkbox:after {
content: " ";
background-color: var(--primary-color);
height: $checkbox-size;
transform: scaleX(0);
transition: transform var(--motion-productive-long);
transform-origin: right;
inset-inline-start: 0;
}
.input:checked + .checkbox > .icon,
.input:indeterminate + .checkbox > .icon {
visibility: visible;
}
.input:checked:disabled + .checkbox:after,
.input:indeterminate:disabled + .checkbox:after {
background-color: var(--disabled-background-color);
}
.input:disabled + .checkbox .icon,
.input:disabled + .checkbox:hover .icon {
color: var(--disabled-text-color);
}
.input:disabled + .checkbox,
.input:disabled + .checkbox:hover {
cursor: not-allowed;
background-color: var(--disabled-background-color);
border-color: var(--ui-border-color);
}
.input:disabled ~ .label {
cursor: not-allowed;
color: var(--disabled-text-color);
}
@keyframes checkboxGrowAnimation {
0% {
transform: scale(0.8);
}
100% {
transform: scale(1);
}
}