@lattice-ui/switch 0.3.1 → 0.4.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.
|
@@ -6,25 +6,18 @@ local Slot = _core.Slot
|
|
|
6
6
|
local useSwitchContext = TS.import(script, script.Parent, "context").useSwitchContext
|
|
7
7
|
local function SwitchThumb(props)
|
|
8
8
|
local switchContext = useSwitchContext()
|
|
9
|
-
local visible = switchContext.checked
|
|
10
|
-
local forceMount = props.forceMount == true
|
|
11
|
-
if not visible and not forceMount then
|
|
12
|
-
return nil
|
|
13
|
-
end
|
|
14
9
|
local child = props.children
|
|
15
10
|
if props.asChild then
|
|
16
11
|
if not React.isValidElement(child) then
|
|
17
12
|
error("[SwitchThumb] `asChild` requires a child element.")
|
|
18
13
|
end
|
|
19
|
-
return React.createElement(Slot,
|
|
20
|
-
Visible = visible,
|
|
21
|
-
}, child)
|
|
14
|
+
return React.createElement(Slot, nil, child)
|
|
22
15
|
end
|
|
23
16
|
return React.createElement("frame", {
|
|
24
17
|
BackgroundColor3 = Color3.fromRGB(240, 244, 252),
|
|
25
18
|
BorderSizePixel = 0,
|
|
19
|
+
Position = if switchContext.checked then UDim2.new(1, -18, 0, 2) else UDim2.fromOffset(2, 2),
|
|
26
20
|
Size = UDim2.fromOffset(16, 16),
|
|
27
|
-
Visible = visible,
|
|
28
21
|
}, child)
|
|
29
22
|
end
|
|
30
23
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lattice-ui/switch",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "out/init.luau",
|
|
6
6
|
"types": "out/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"README.md"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@lattice-ui/core": "0.
|
|
12
|
+
"@lattice-ui/core": "0.4.0"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@rbxts/react": "17.3.7-ts.1",
|