-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToggleSwitcher.jsx
92 lines (89 loc) · 2.29 KB
/
ToggleSwitcher.jsx
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
import React from 'react';
import classes from './ToggleSwitcher.module.css';
export const toggleSwitcherTypes = {
WHITE: {
container: classes.toggleContainerWhite,
input: classes.toggleInputWhite,
slider: classes.toggleSliderWhite
},
MAIN: {
container: classes.toggleContainerMain,
input: classes.toggleInputMain,
slider: classes.toggleSliderMain
}
};
export const ToggleSwitcher = ({
onChange,
checked,
label1,
label2,
containerClassName,
labelClassName,
toggleType
}) => {
if (toggleType === toggleSwitcherTypes.MAIN)
return (
<div className={toggleType.container}>
<label>
<input
type="checkbox"
className={`${classes.toggleInput} ${
toggleType ? toggleType.input : ''
}`}
onChange={onChange}
checked={checked}
/>
<span
className={`${classes.toggleSlider} ${classes.toggleRound} ${
toggleType ? toggleType.slider : ''
}`}
></span>
</label>
<div
className={`${classes.toggleLabelMain} ${classes.toggleLabelMain1} ${
!checked ? classes.toggleLabelMainActive : ''
}`}
onClick={onChange}
>
{label1}
</div>
<div
className={`${classes.toggleLabelMain} ${classes.toggleLabelMain2} ${
checked ? classes.toggleLabelMainActive : ''
}`}
onClick={onChange}
>
{label2}
</div>
</div>
);
return (
<div
className={`${classes.toggleBox} ${
containerClassName ? containerClassName : ''
}`}
>
<b className={labelClassName}>{label1}</b>
<label
className={`${classes.toggleContainer} ${
toggleType ? toggleType.container : ''
}`}
>
<input
type="checkbox"
className={`${classes.toggleInput} ${
toggleType ? toggleType.input : ''
}`}
onChange={onChange}
checked={checked}
/>
<span
className={`${classes.toggleSlider} ${classes.toggleRound} ${
toggleType ? toggleType.slider : ''
}`}
></span>
</label>
<b className={labelClassName}>{label2}</b>
</div>
);
};