@colisweb/rescript-toolkit 2.14.0 → 2.15.0
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/package.json
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
type size = [#md | #lg]
|
|
2
|
-
|
|
2
|
+
type color = [
|
|
3
|
+
| #info
|
|
4
|
+
| #success
|
|
5
|
+
| #primary
|
|
6
|
+
| #neutral
|
|
7
|
+
| #danger
|
|
8
|
+
]
|
|
3
9
|
let getBulletSize = size =>
|
|
4
10
|
switch size {
|
|
5
11
|
| #md => "w-5 h-5"
|
|
@@ -14,8 +20,8 @@ let getLabelSize = size =>
|
|
|
14
20
|
|
|
15
21
|
let getTranslateBySize = size =>
|
|
16
22
|
switch size {
|
|
17
|
-
| #md => "translate-x-
|
|
18
|
-
| #lg => "translate-x-
|
|
23
|
+
| #md => "translate-x-6"
|
|
24
|
+
| #lg => "translate-x-9"
|
|
19
25
|
}
|
|
20
26
|
|
|
21
27
|
@react.component
|
|
@@ -33,6 +39,7 @@ let make = (
|
|
|
33
39
|
~checkedSwitchClassName="",
|
|
34
40
|
~disabledSwitchClassName="",
|
|
35
41
|
~switchRef: option<ReactDOM.domRef>=?,
|
|
42
|
+
~color=#primary,
|
|
36
43
|
) => {
|
|
37
44
|
let (isChecked, setIsChecked) = React.useState(() => checked->Option.getWithDefault(false))
|
|
38
45
|
|
|
@@ -46,9 +53,17 @@ let make = (
|
|
|
46
53
|
])}>
|
|
47
54
|
<span
|
|
48
55
|
className={cx([
|
|
49
|
-
"flex items-center relative rounded-full py-
|
|
56
|
+
"flex items-center relative rounded-full py-[2px] cursor-pointer border transition-all",
|
|
50
57
|
getLabelSize(size),
|
|
51
|
-
isChecked
|
|
58
|
+
isChecked
|
|
59
|
+
? switch color {
|
|
60
|
+
| #info => "bg-info-500 border-info-500"
|
|
61
|
+
| #success => "bg-success-500 border-success-500"
|
|
62
|
+
| #primary => "bg-primary-700 border-primary-700"
|
|
63
|
+
| #neutral => "bg-neutral-700 border-neutral-700"
|
|
64
|
+
| #danger => "bg-danger-500 border-danger-500"
|
|
65
|
+
}
|
|
66
|
+
: "bg-gray-300",
|
|
52
67
|
switchClassName,
|
|
53
68
|
isChecked ? checkedSwitchClassName : "",
|
|
54
69
|
disabled->Option.getWithDefault(false) ? disabledSwitchClassName : "",
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
type size = [#md | #lg]
|
|
2
|
+
type color = [
|
|
3
|
+
| #info
|
|
4
|
+
| #success
|
|
5
|
+
| #primary
|
|
6
|
+
| #neutral
|
|
7
|
+
| #danger
|
|
8
|
+
]
|
|
2
9
|
|
|
3
10
|
@react.component
|
|
4
11
|
let make: (
|
|
@@ -15,4 +22,5 @@ let make: (
|
|
|
15
22
|
~checkedSwitchClassName: string=?,
|
|
16
23
|
~disabledSwitchClassName: string=?,
|
|
17
24
|
~switchRef: ReactDOM.domRef=?,
|
|
25
|
+
~color: color=?,
|
|
18
26
|
) => React.element
|