@aristobyte-ui/switch 0.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +4 -0
- package/@types/styles/scss-modules.d.ts +4 -0
- package/assets/svg/i_Copy.svg +1 -0
- package/assets/svg/i_Error.svg +1 -0
- package/assets/svg/i_Info.svg +1 -0
- package/assets/svg/i_Success.svg +1 -0
- package/assets/svg/i_Warning.svg +1 -0
- package/components/Switch/Switch.module.scss +489 -0
- package/components/Switch/index.tsx +88 -0
- package/components/index.ts +1 -0
- package/dist/components/Anchor/index.js +28 -0
- package/dist/components/Button/index.js +35 -0
- package/dist/components/ButtonGroup/index.js +16 -0
- package/dist/components/CodeBlock/index.js +33 -0
- package/dist/components/CodeBlock/types.js +1 -0
- package/dist/components/Dropdown/index.js +73 -0
- package/dist/components/DropdownOption/index.js +13 -0
- package/dist/components/MessageBox/index.js +19 -0
- package/dist/components/Radio/index.js +10 -0
- package/dist/components/RadioGroup/index.js +21 -0
- package/dist/components/Spinner/index.js +6 -0
- package/dist/components/Switch/index.js +15 -0
- package/dist/components/TabSwitchWithSlidingIndicator/index.js +10 -0
- package/dist/components/index.js +12 -0
- package/dist/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/components/Anchor/index.d.ts +6 -0
- package/dist/types/components/Anchor/index.d.ts.map +1 -0
- package/dist/types/components/Button/index.d.ts +15 -0
- package/dist/types/components/Button/index.d.ts.map +1 -0
- package/dist/types/components/ButtonGroup/index.d.ts +13 -0
- package/dist/types/components/ButtonGroup/index.d.ts.map +1 -0
- package/dist/types/components/CodeBlock/index.d.ts +11 -0
- package/dist/types/components/CodeBlock/index.d.ts.map +1 -0
- package/dist/types/components/CodeBlock/types.d.ts +3 -0
- package/dist/types/components/CodeBlock/types.d.ts.map +1 -0
- package/dist/types/components/Dropdown/index.d.ts +14 -0
- package/dist/types/components/Dropdown/index.d.ts.map +1 -0
- package/dist/types/components/DropdownOption/index.d.ts +12 -0
- package/dist/types/components/DropdownOption/index.d.ts.map +1 -0
- package/dist/types/components/MessageBox/index.d.ts +14 -0
- package/dist/types/components/MessageBox/index.d.ts.map +1 -0
- package/dist/types/components/Radio/index.d.ts +17 -0
- package/dist/types/components/Radio/index.d.ts.map +1 -0
- package/dist/types/components/RadioGroup/index.d.ts +18 -0
- package/dist/types/components/RadioGroup/index.d.ts.map +1 -0
- package/dist/types/components/Spinner/index.d.ts +9 -0
- package/dist/types/components/Spinner/index.d.ts.map +1 -0
- package/dist/types/components/Switch/index.d.ts +18 -0
- package/dist/types/components/Switch/index.d.ts.map +1 -0
- package/dist/types/components/TabSwitchWithSlidingIndicator/index.d.ts +9 -0
- package/dist/types/components/TabSwitchWithSlidingIndicator/index.d.ts.map +1 -0
- package/dist/types/components/index.d.ts +2 -0
- package/dist/types/components/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/utils/Portal.d.ts +5 -0
- package/dist/types/utils/Portal.d.ts.map +1 -0
- package/dist/types/utils/icons.d.ts +8 -0
- package/dist/types/utils/icons.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/ripple.d.ts +9 -0
- package/dist/types/utils/ripple.d.ts.map +1 -0
- package/dist/utils/Portal.js +12 -0
- package/dist/utils/icons.js +12 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/ripple.js +38 -0
- package/eslint.config.mjs +2 -0
- package/index.ts +1 -0
- package/package.json +43 -0
- package/styles/_settings.scss +179 -0
- package/tsconfig.json +11 -0
- package/turbo/generators/config.ts +30 -0
- package/turbo/generators/templates/component.hbs +8 -0
- package/utils/Portal.tsx +17 -0
- package/utils/icons.ts +13 -0
- package/utils/index.ts +2 -0
- package/utils/ripple.tsx +54 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-copy-icon lucide-copy"><rect width="14" height="14" x="8" y="8" rx="2" ry="2"/><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-octagon-x-icon lucide-octagon-x"><path d="m15 9-6 6"/><path d="M2.586 16.726A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2h6.624a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586z"/><path d="m9 9 6 6"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-info-icon lucide-info"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-circle-check-icon lucide-circle-check"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-octagon-alert-icon lucide-octagon-alert"><path d="M12 16h.01"/><path d="M12 8v4"/><path d="M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z"/></svg>
|
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
@use "../../styles/settings" as *;
|
|
2
|
+
|
|
3
|
+
.switch {
|
|
4
|
+
align-items: center;
|
|
5
|
+
cursor: pointer;
|
|
6
|
+
display: flex;
|
|
7
|
+
gap: 10px;
|
|
8
|
+
max-width: max-content;
|
|
9
|
+
user-select: none;
|
|
10
|
+
position: relative;
|
|
11
|
+
|
|
12
|
+
&-align-label {
|
|
13
|
+
&--horizontal {
|
|
14
|
+
flex-direction: row;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
&--vertical {
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&--disabled {
|
|
23
|
+
opacity: 0.5;
|
|
24
|
+
cursor: not-allowed;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&-size {
|
|
28
|
+
&--xsm {
|
|
29
|
+
.switch {
|
|
30
|
+
&__track {
|
|
31
|
+
height: 1rem;
|
|
32
|
+
width: 1.8rem;
|
|
33
|
+
|
|
34
|
+
&-icon {
|
|
35
|
+
height: calc(0.8rem - 0.16rem * 2);
|
|
36
|
+
width: calc(0.8rem - 0.16rem * 2);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
&__thumb {
|
|
41
|
+
border-radius: calc(0.8rem / 2);
|
|
42
|
+
height: 0.8rem;
|
|
43
|
+
left: 0.16rem;
|
|
44
|
+
width: 0.8rem;
|
|
45
|
+
|
|
46
|
+
&-icon {
|
|
47
|
+
height: 0.6rem;
|
|
48
|
+
width: 0.6rem;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
&__label {
|
|
53
|
+
color: $white;
|
|
54
|
+
font-size: 0.625rem; // 10px
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
input {
|
|
59
|
+
+ .switch__track .switch__track-icon {
|
|
60
|
+
&--checked {
|
|
61
|
+
left: -2rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&--unchecked {
|
|
65
|
+
right: 0.18rem;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
&:checked + .switch__track {
|
|
70
|
+
.switch__track-icon {
|
|
71
|
+
&--checked {
|
|
72
|
+
left: 0.18rem;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
&--unchecked {
|
|
76
|
+
right: -2rem;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.switch__thumb {
|
|
81
|
+
transform: translate(calc(1.8rem - 0.8rem - 0.16rem * 2), -50%);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&:active {
|
|
86
|
+
+ .switch__track .switch__thumb {
|
|
87
|
+
width: 1rem;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&:checked + .switch__track .switch__thumb {
|
|
91
|
+
transform: translate(calc(0.8rem / 2 + 0.08rem), -50%);
|
|
92
|
+
width: 1rem;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
&--sm {
|
|
99
|
+
.switch {
|
|
100
|
+
&__track {
|
|
101
|
+
height: 1.4rem;
|
|
102
|
+
width: 2.6rem;
|
|
103
|
+
|
|
104
|
+
&-icon {
|
|
105
|
+
height: calc(1.2rem - 0.2rem * 2);
|
|
106
|
+
width: calc(1.2rem - 0.2rem * 2);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
&__thumb {
|
|
111
|
+
border-radius: calc(1rem / 2);
|
|
112
|
+
height: 1rem;
|
|
113
|
+
left: 0.2rem;
|
|
114
|
+
width: 1rem;
|
|
115
|
+
|
|
116
|
+
&-icon {
|
|
117
|
+
height: 0.8rem;
|
|
118
|
+
width: 0.8rem;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
&__label {
|
|
123
|
+
color: $white;
|
|
124
|
+
font-size: 0.75rem; // 12px
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
input {
|
|
129
|
+
+ .switch__track .switch__track-icon {
|
|
130
|
+
&--checked {
|
|
131
|
+
left: -2rem;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
&--unchecked {
|
|
135
|
+
right: 0.24rem;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
&:checked + .switch__track {
|
|
140
|
+
.switch__track-icon {
|
|
141
|
+
&--checked {
|
|
142
|
+
left: 0.24rem;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
&--unchecked {
|
|
146
|
+
right: -2rem;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.switch__thumb {
|
|
151
|
+
transform: translate(calc(2.6rem - 1rem - 0.2rem * 2), -50%);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
&:active {
|
|
156
|
+
+ .switch__track .switch__thumb {
|
|
157
|
+
width: 1.3rem;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
&:checked + .switch__track .switch__thumb {
|
|
161
|
+
transform: translate(calc(1.3rem / 2 + 0.25rem), -50%);
|
|
162
|
+
width: 1.3rem;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
&--md {
|
|
169
|
+
.switch {
|
|
170
|
+
&__track {
|
|
171
|
+
height: 1.6rem;
|
|
172
|
+
width: 3rem;
|
|
173
|
+
|
|
174
|
+
&-icon {
|
|
175
|
+
height: calc(1.4rem - 0.2rem * 2);
|
|
176
|
+
width: calc(1.4rem - 0.2rem * 2);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
&__thumb {
|
|
181
|
+
border-radius: calc(1.2rem / 2);
|
|
182
|
+
height: 1.2rem;
|
|
183
|
+
left: 0.2rem;
|
|
184
|
+
width: 1.2rem;
|
|
185
|
+
|
|
186
|
+
&-icon {
|
|
187
|
+
height: 0.9rem;
|
|
188
|
+
width: 0.9rem;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
&__label {
|
|
193
|
+
color: $white;
|
|
194
|
+
font-size: 0.875rem; // 14px
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
input {
|
|
199
|
+
+ .switch__track .switch__track-icon {
|
|
200
|
+
&--checked {
|
|
201
|
+
left: -2rem;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
&--unchecked {
|
|
205
|
+
right: 0.3rem;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
&:checked + .switch__track {
|
|
210
|
+
.switch__track-icon {
|
|
211
|
+
&--checked {
|
|
212
|
+
left: 0.3rem;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
&--unchecked {
|
|
216
|
+
right: -2rem;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
.switch__thumb {
|
|
221
|
+
transform: translate(calc(3rem - 1.2rem - 0.2rem * 2), -50%);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
&:active {
|
|
225
|
+
+ .switch__track .switch__thumb {
|
|
226
|
+
width: 1.5rem;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
&:checked + .switch__track .switch__thumb {
|
|
230
|
+
transform: translate(calc(1.5rem / 2 + 0.3rem), -50%);
|
|
231
|
+
width: 1.5rem;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
&--lg {
|
|
238
|
+
.switch {
|
|
239
|
+
&__track {
|
|
240
|
+
height: 1.8rem;
|
|
241
|
+
width: 3.4rem;
|
|
242
|
+
|
|
243
|
+
&-icon {
|
|
244
|
+
height: calc(1.6rem - 0.3rem * 2);
|
|
245
|
+
width: calc(1.6rem - 0.3rem * 2);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
&__thumb {
|
|
250
|
+
border-radius: calc(1.4rem / 2);
|
|
251
|
+
height: 1.4rem;
|
|
252
|
+
left: 0.3rem;
|
|
253
|
+
width: 1.4rem;
|
|
254
|
+
|
|
255
|
+
&-icon {
|
|
256
|
+
height: 1rem;
|
|
257
|
+
width: 1rem;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
&__label {
|
|
262
|
+
color: $white;
|
|
263
|
+
font-size: 1rem; // 16px
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
input {
|
|
268
|
+
+ .switch__track .switch__track-icon {
|
|
269
|
+
&--checked {
|
|
270
|
+
left: -2rem;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
&--unchecked {
|
|
274
|
+
right: 0.34rem;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
&:checked + .switch__track {
|
|
279
|
+
.switch__track-icon {
|
|
280
|
+
&--checked {
|
|
281
|
+
left: 0.34rem;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
&--unchecked {
|
|
285
|
+
right: -2rem;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.switch__thumb {
|
|
290
|
+
transform: translate(
|
|
291
|
+
calc(3.4rem - 1.4rem - 0.3rem * 2 + 0.05rem),
|
|
292
|
+
-50%
|
|
293
|
+
);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
&:active {
|
|
298
|
+
+ .switch__track .switch__thumb {
|
|
299
|
+
width: 1.8rem;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
&:checked + .switch__track .switch__thumb {
|
|
303
|
+
transform: translate(calc(1.8rem / 2 + 0.2rem - 0.05rem), -50%);
|
|
304
|
+
width: 1.8rem;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
&--xlg {
|
|
311
|
+
.switch {
|
|
312
|
+
&__track {
|
|
313
|
+
height: 2rem;
|
|
314
|
+
width: 3.8rem;
|
|
315
|
+
|
|
316
|
+
&-icon {
|
|
317
|
+
height: calc(1.8rem - 0.3rem * 2);
|
|
318
|
+
width: calc(1.8rem - 0.3rem * 2);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
&__thumb {
|
|
323
|
+
border-radius: calc(1.6rem / 2);
|
|
324
|
+
height: 1.6rem;
|
|
325
|
+
left: 0.3rem;
|
|
326
|
+
width: 1.6rem;
|
|
327
|
+
|
|
328
|
+
&-icon {
|
|
329
|
+
height: 1.2rem;
|
|
330
|
+
width: 1.2rem;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
&__label {
|
|
335
|
+
color: $white;
|
|
336
|
+
font-size: 1.125rem; // 18px
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
input {
|
|
341
|
+
+ .switch__track .switch__track-icon {
|
|
342
|
+
&--checked {
|
|
343
|
+
left: -2rem;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
&--unchecked {
|
|
347
|
+
right: 0.38rem;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
&:checked + .switch__track {
|
|
352
|
+
.switch__track-icon {
|
|
353
|
+
&--checked {
|
|
354
|
+
left: 0.38rem;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
&--unchecked {
|
|
358
|
+
right: -2rem;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.switch__thumb {
|
|
363
|
+
transform: translate(calc(3.8rem - 1.6rem - 0.3rem * 2), -50%);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
&:active {
|
|
368
|
+
+ .switch__track .switch__thumb {
|
|
369
|
+
width: 2rem;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
&:checked + .switch__track .switch__thumb {
|
|
373
|
+
transform: translate(calc(2rem / 2 + 0.22rem), -50%);
|
|
374
|
+
width: 2rem;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
&-variant--default input:checked + &__track {
|
|
382
|
+
background-color: $grey-500;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
&-variant--primary input:checked + &__track {
|
|
386
|
+
background-color: $color-primary;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
&-variant--secondary input:checked + &__track {
|
|
390
|
+
background-color: $color-secondary;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
&-variant--success input:checked + &__track {
|
|
394
|
+
background-color: $color-success;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
&-variant--error input:checked + &__track {
|
|
398
|
+
background-color: $color-error;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
&-variant--warning input:checked + &__track {
|
|
402
|
+
background-color: $color-warning;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
input {
|
|
406
|
+
display: none;
|
|
407
|
+
|
|
408
|
+
+ .switch__track .switch__track-icon {
|
|
409
|
+
&--checked {
|
|
410
|
+
opacity: 0;
|
|
411
|
+
transform: translate(0, -50%) scale(0.55);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
&--unchecked {
|
|
415
|
+
opacity: 1;
|
|
416
|
+
transform: translate(0, -50%) scale(1);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
&:checked {
|
|
421
|
+
+ .switch__track .switch__track-icon {
|
|
422
|
+
&--checked {
|
|
423
|
+
opacity: 1;
|
|
424
|
+
transform: translate(0, -50%) scale(1);
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
&--unchecked {
|
|
428
|
+
opacity: 0;
|
|
429
|
+
transform: translate(0, -50%) scale(0.55);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
&__track {
|
|
436
|
+
position: relative;
|
|
437
|
+
background-color: $grey-700;
|
|
438
|
+
border-radius: 999px;
|
|
439
|
+
overflow: hidden;
|
|
440
|
+
position: relative;
|
|
441
|
+
transition: background-color 0.3s ease;
|
|
442
|
+
|
|
443
|
+
&-icon {
|
|
444
|
+
align-items: center;
|
|
445
|
+
display: flex;
|
|
446
|
+
justify-content: center;
|
|
447
|
+
position: absolute;
|
|
448
|
+
top: 50%;
|
|
449
|
+
transition:
|
|
450
|
+
transform 120ms ease-out,
|
|
451
|
+
left 200ms ease-out,
|
|
452
|
+
right 200ms ease-out,
|
|
453
|
+
opacity 100ms ease-out;
|
|
454
|
+
z-index: 0;
|
|
455
|
+
|
|
456
|
+
svg {
|
|
457
|
+
height: 100%;
|
|
458
|
+
width: 100%;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
&__thumb {
|
|
464
|
+
align-items: center;
|
|
465
|
+
background-color: white;
|
|
466
|
+
display: flex;
|
|
467
|
+
justify-content: center;
|
|
468
|
+
position: absolute;
|
|
469
|
+
top: 50%;
|
|
470
|
+
transform: translate(0, -50%);
|
|
471
|
+
transition: all 200ms ease-out;
|
|
472
|
+
z-index: 1;
|
|
473
|
+
|
|
474
|
+
&-icon {
|
|
475
|
+
align-items: center;
|
|
476
|
+
display: flex;
|
|
477
|
+
justify-content: center;
|
|
478
|
+
|
|
479
|
+
svg {
|
|
480
|
+
height: 100%;
|
|
481
|
+
width: 100%;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
&__label {
|
|
487
|
+
color: $white;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import styles from "./Switch.module.scss";
|
|
6
|
+
|
|
7
|
+
export interface ISwitch {
|
|
8
|
+
label?: string;
|
|
9
|
+
alignLabel?: "horizontal" | "vertical";
|
|
10
|
+
switchSize?: "xsm" | "sm" | "md" | "lg" | "xlg";
|
|
11
|
+
variant?:
|
|
12
|
+
| "default"
|
|
13
|
+
| "primary"
|
|
14
|
+
| "secondary"
|
|
15
|
+
| "success"
|
|
16
|
+
| "error"
|
|
17
|
+
| "warning";
|
|
18
|
+
trackIcon?: { checked?: React.ElementType; unchecked?: React.ElementType };
|
|
19
|
+
thumbIcon?: React.ElementType;
|
|
20
|
+
checked?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
className?: string;
|
|
23
|
+
onChange?: () => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
//@TODO: Fix the the switch styling, which is breaking when continuously clicking on the component
|
|
27
|
+
export const Switch: React.FC<ISwitch> = ({
|
|
28
|
+
label,
|
|
29
|
+
alignLabel = "vertical",
|
|
30
|
+
checked,
|
|
31
|
+
switchSize = "md",
|
|
32
|
+
variant = "default",
|
|
33
|
+
disabled = false,
|
|
34
|
+
trackIcon,
|
|
35
|
+
thumbIcon,
|
|
36
|
+
className = "",
|
|
37
|
+
onChange,
|
|
38
|
+
}) => {
|
|
39
|
+
const id = React.useId();
|
|
40
|
+
const [isChecked, setIsChecked] = React.useState<boolean>(!!checked);
|
|
41
|
+
|
|
42
|
+
const handleChange = () => {
|
|
43
|
+
setIsChecked((prev) => !prev);
|
|
44
|
+
|
|
45
|
+
if (onChange) onChange();
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<label
|
|
50
|
+
htmlFor={id}
|
|
51
|
+
className={`${styles["switch"]} ${styles[`switch-size--${switchSize}`]} ${
|
|
52
|
+
styles[`switch-variant--${variant}`]
|
|
53
|
+
} ${styles[`switch-align-label--${alignLabel}`]} ${disabled ? styles["switch--disabled"] : ""} ${className}`}
|
|
54
|
+
>
|
|
55
|
+
<input
|
|
56
|
+
id={id}
|
|
57
|
+
type="checkbox"
|
|
58
|
+
disabled={disabled}
|
|
59
|
+
checked={isChecked}
|
|
60
|
+
onChange={handleChange}
|
|
61
|
+
/>
|
|
62
|
+
<span className={styles["switch__track"]}>
|
|
63
|
+
{trackIcon && trackIcon.checked && (
|
|
64
|
+
<span
|
|
65
|
+
className={`${styles["switch__track-icon"]} ${styles["switch__track-icon--checked"]}`}
|
|
66
|
+
>
|
|
67
|
+
{React.createElement(trackIcon.checked)}
|
|
68
|
+
</span>
|
|
69
|
+
)}
|
|
70
|
+
<span className={styles["switch__thumb"]}>
|
|
71
|
+
{thumbIcon && (
|
|
72
|
+
<span className={styles["switch__thumb-icon"]}>
|
|
73
|
+
{React.createElement(thumbIcon)}
|
|
74
|
+
</span>
|
|
75
|
+
)}
|
|
76
|
+
</span>
|
|
77
|
+
{trackIcon && trackIcon.unchecked && (
|
|
78
|
+
<span
|
|
79
|
+
className={`${styles["switch__track-icon"]} ${styles["switch__track-icon--unchecked"]}`}
|
|
80
|
+
>
|
|
81
|
+
{React.createElement(trackIcon.unchecked)}
|
|
82
|
+
</span>
|
|
83
|
+
)}
|
|
84
|
+
</span>
|
|
85
|
+
{label && <span className={styles["switch__label"]}>{label}</span>}
|
|
86
|
+
</label>
|
|
87
|
+
);
|
|
88
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Switch } from "./Switch";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import * as React from "react";
|
|
15
|
+
import { renderRipple } from "../../utils";
|
|
16
|
+
import styles from "./Anchor.module.scss";
|
|
17
|
+
export const Anchor = (_a) => {
|
|
18
|
+
var { href, variant = "default", className = "", children, onClick } = _a, props = __rest(_a, ["href", "variant", "className", "children", "onClick"]);
|
|
19
|
+
const ref = React.useRef(null);
|
|
20
|
+
const handleClick = (e) => {
|
|
21
|
+
const { clientX, clientY } = e;
|
|
22
|
+
renderRipple({ ref, clientX, clientY });
|
|
23
|
+
if (onClick) {
|
|
24
|
+
onClick(e);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
return (_jsx("a", Object.assign({}, props, { ref: ref, href: href, className: `anchor ${styles["anchor"]} ${styles[`anchor--${variant}`]} ${className}`, onClick: handleClick, children: children })));
|
|
28
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import * as React from "react";
|
|
15
|
+
import { Spinner } from "../Spinner";
|
|
16
|
+
import { renderRipple } from "../../utils";
|
|
17
|
+
import styles from "./Button.module.scss";
|
|
18
|
+
export const Button = (_a) => {
|
|
19
|
+
var { onClick, children, variant = "default", appearance = "solid", size = "md", radius = "md", icon, spinnerType = "default", isLoading = false, disabled, className = "", dangerouslySetInnerHTML } = _a, restProps = __rest(_a, ["onClick", "children", "variant", "appearance", "size", "radius", "icon", "spinnerType", "isLoading", "disabled", "className", "dangerouslySetInnerHTML"]);
|
|
20
|
+
const ref = React.useRef(null);
|
|
21
|
+
const handleClick = (e) => {
|
|
22
|
+
const { clientX, clientY } = e;
|
|
23
|
+
renderRipple({ ref, clientX, clientY });
|
|
24
|
+
if (onClick) {
|
|
25
|
+
onClick(e);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const Children = () => {
|
|
29
|
+
var _a;
|
|
30
|
+
return (_jsxs(_Fragment, { children: [isLoading && (_jsx(Spinner, { size: size, variant: variant, type: spinnerType, className: styles["spinner"] })), icon && (_jsx("span", { className: `${styles["icon"]} ${styles[`icon--${(_a = icon.align) !== null && _a !== void 0 ? _a : "left"}`]}`, children: React.createElement(icon.component) })), children] }));
|
|
31
|
+
};
|
|
32
|
+
return (_jsx("button", Object.assign({ ref: ref, disabled: disabled || isLoading, className: `${styles["button"]} ${styles[`button-variant--${variant}`]} ${styles[`button-appearance--${appearance}`]} ${styles[`button-size--${size}`]} ${styles[`button-radius--${radius}`]} ${isLoading ? styles["button--loading"] : ""} ${className}`, onClick: handleClick }, (dangerouslySetInnerHTML
|
|
33
|
+
? { dangerouslySetInnerHTML }
|
|
34
|
+
: { children: _jsx(Children, {}) }), restProps)));
|
|
35
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import { Button } from "../Button";
|
|
5
|
+
import styles from "./ButtonGroup.module.scss";
|
|
6
|
+
export const ButtonGroup = ({ children, align = "horizontal", variant = "default", size = "md", radius = "md", disabled, className = "", }) => {
|
|
7
|
+
return (_jsx("div", { className: `${styles["button-group"]} ${styles[`button-group-variant--${variant}`]} ${styles[`button-group-size--${size}`]} ${styles[`button-group-radius--${radius}`]} ${styles[`button-group-align--${align}`]} ${className}`, children: React.Children.toArray(children)
|
|
8
|
+
.filter((child) => React.isValidElement(child) && child.type === Button)
|
|
9
|
+
.map((child, index) => React.cloneElement(child, {
|
|
10
|
+
key: index || child.key,
|
|
11
|
+
size: size || child.props.size,
|
|
12
|
+
disabled: disabled || child.props.disabled,
|
|
13
|
+
variant: variant || child.props.variant,
|
|
14
|
+
radius: "none",
|
|
15
|
+
})) }));
|
|
16
|
+
};
|