@rbxts-ui/components 2.0.0 → 2.1.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/dist/Accordion.d.ts +16 -0
- package/dist/Accordion.luau +105 -0
- package/dist/Button.d.ts +15 -0
- package/dist/Button.luau +66 -0
- package/dist/Checkbox.d.ts +13 -0
- package/dist/Checkbox.luau +113 -0
- package/dist/CheckboxRow.d.ts +14 -0
- package/dist/CheckboxRow.luau +52 -0
- package/dist/ClickOutsideOverlay.d.ts +11 -0
- package/dist/ClickOutsideOverlay.luau +35 -0
- package/dist/Dropdown.d.ts +18 -0
- package/dist/Dropdown.luau +160 -0
- package/dist/DropdownButton.d.ts +22 -0
- package/dist/DropdownButton.luau +111 -0
- package/dist/DropdownOptionButton.d.ts +13 -0
- package/dist/DropdownOptionButton.luau +70 -0
- package/dist/FormRow.d.ts +11 -0
- package/dist/FormRow.luau +39 -0
- package/dist/IconRoundButton.d.ts +23 -0
- package/dist/IconRoundButton.luau +149 -0
- package/dist/IconTileButton.d.ts +14 -0
- package/dist/IconTileButton.luau +89 -0
- package/dist/Legend.d.ts +11 -0
- package/dist/Legend.luau +54 -0
- package/dist/Outline.d.ts +16 -0
- package/dist/Outline.luau +102 -0
- package/dist/PillText.d.ts +8 -0
- package/dist/PillText.luau +69 -0
- package/dist/PrimaryButton.d.ts +25 -0
- package/dist/PrimaryButton.luau +89 -0
- package/dist/Radio.d.ts +13 -0
- package/dist/Radio.luau +110 -0
- package/dist/RadioRow.d.ts +10 -0
- package/dist/RadioRow.luau +50 -0
- package/dist/ReactiveButton.d.ts +34 -0
- package/dist/ReactiveButton.luau +168 -0
- package/dist/Section.d.ts +12 -0
- package/dist/Section.luau +54 -0
- package/dist/SegmentedToggle.d.ts +19 -0
- package/dist/SegmentedToggle.luau +120 -0
- package/dist/TextButton.d.ts +32 -0
- package/dist/TextButton.luau +125 -0
- package/dist/TimeAgo.d.ts +8 -0
- package/dist/TimeAgo.luau +48 -0
- package/dist/index.d.ts +26 -0
- package/dist/init.luau +37 -0
- package/dist/theme.d.ts +41 -0
- package/dist/theme.luau +58 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/use-button-animation.d.ts +38 -0
- package/dist/use-button-animation.luau +83 -0
- package/dist/use-button-state.d.ts +13 -0
- package/dist/use-button-state.luau +81 -0
- package/dist/use-input-device.d.ts +7 -0
- package/dist/use-input-device.luau +38 -0
- package/package.json +13 -3
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { type Theme } from "./theme";
|
|
3
|
+
interface SectionProps {
|
|
4
|
+
title: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
cornerRadius?: number;
|
|
7
|
+
sortOrder?: Enum.SortOrder;
|
|
8
|
+
theme?: Theme;
|
|
9
|
+
}
|
|
10
|
+
export declare function Section({ title, children, cornerRadius, sortOrder, theme, }: SectionProps): JSX.Element;
|
|
11
|
+
export type { SectionProps };
|
|
12
|
+
//# sourceMappingURL=Section.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
|
|
5
|
+
local VStack = TS.import(script, TS.getModule(script, "@rbxts-ui", "layout").dist).VStack
|
|
6
|
+
local Text = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Text
|
|
7
|
+
local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
|
|
8
|
+
local function Section(_param)
|
|
9
|
+
local title = _param.title
|
|
10
|
+
local children = _param.children
|
|
11
|
+
local cornerRadius = _param.cornerRadius
|
|
12
|
+
if cornerRadius == nil then
|
|
13
|
+
cornerRadius = 2
|
|
14
|
+
end
|
|
15
|
+
local sortOrder = _param.sortOrder
|
|
16
|
+
if sortOrder == nil then
|
|
17
|
+
sortOrder = Enum.SortOrder.Name
|
|
18
|
+
end
|
|
19
|
+
local theme = _param.theme
|
|
20
|
+
if theme == nil then
|
|
21
|
+
theme = defaultTheme
|
|
22
|
+
end
|
|
23
|
+
local rem = useRem()
|
|
24
|
+
local textSize = rem(3.5)
|
|
25
|
+
return React.createElement(VStack, {
|
|
26
|
+
size = UDim2.new(1, 0, 0, 0),
|
|
27
|
+
automaticSize = Enum.AutomaticSize.Y,
|
|
28
|
+
verticalAlignment = Enum.VerticalAlignment.Top,
|
|
29
|
+
}, React.createElement("uicorner", {
|
|
30
|
+
CornerRadius = UDim.new(0, rem(cornerRadius)),
|
|
31
|
+
}), React.createElement(VStack, {
|
|
32
|
+
size = UDim2.new(1, 0, 0, rem(8)),
|
|
33
|
+
backgroundTransparency = 1,
|
|
34
|
+
}, React.createElement(Text, {
|
|
35
|
+
text = title,
|
|
36
|
+
textSize = rem(3),
|
|
37
|
+
textScaled = true,
|
|
38
|
+
richText = true,
|
|
39
|
+
textColor = theme.palette.crust,
|
|
40
|
+
size = UDim2.new(1, 0, 1, 0),
|
|
41
|
+
textYAlignment = "Center",
|
|
42
|
+
textXAlignment = "Left",
|
|
43
|
+
}, React.createElement("uiflexitem", {
|
|
44
|
+
FlexMode = Enum.UIFlexMode.Fill,
|
|
45
|
+
}))), React.createElement(VStack, {
|
|
46
|
+
spacing = rem(2),
|
|
47
|
+
size = UDim2.new(1, 0, 0, 0),
|
|
48
|
+
automaticSize = Enum.AutomaticSize.Y,
|
|
49
|
+
sortOrder = sortOrder,
|
|
50
|
+
}, children))
|
|
51
|
+
end
|
|
52
|
+
return {
|
|
53
|
+
Section = Section,
|
|
54
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { type Theme } from "./theme";
|
|
3
|
+
export interface SegmentedToggleOption<T extends string> {
|
|
4
|
+
id: T;
|
|
5
|
+
label: string;
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface SegmentedToggleProps<T extends string> {
|
|
9
|
+
options: ReadonlyArray<SegmentedToggleOption<T>>;
|
|
10
|
+
value: T;
|
|
11
|
+
onChange: (id: T) => void;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
size?: "default" | "small";
|
|
14
|
+
label?: string;
|
|
15
|
+
children?: React.ReactNode;
|
|
16
|
+
theme?: Theme;
|
|
17
|
+
}
|
|
18
|
+
export declare function SegmentedToggle<T extends string>({ options, value, onChange, disabled, size, label, children, theme, }: SegmentedToggleProps<T>): JSX.Element;
|
|
19
|
+
//# sourceMappingURL=SegmentedToggle.d.ts.map
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
|
|
5
|
+
local Button = TS.import(script, script.Parent, "Button").Button
|
|
6
|
+
local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
|
|
7
|
+
local Text = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Text
|
|
8
|
+
local _layout = TS.import(script, TS.getModule(script, "@rbxts-ui", "layout").dist)
|
|
9
|
+
local HStack = _layout.HStack
|
|
10
|
+
local VStack = _layout.VStack
|
|
11
|
+
local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
|
|
12
|
+
local function SegmentedToggle(_param)
|
|
13
|
+
local options = _param.options
|
|
14
|
+
local value = _param.value
|
|
15
|
+
local onChange = _param.onChange
|
|
16
|
+
local disabled = _param.disabled
|
|
17
|
+
if disabled == nil then
|
|
18
|
+
disabled = false
|
|
19
|
+
end
|
|
20
|
+
local size = _param.size
|
|
21
|
+
if size == nil then
|
|
22
|
+
size = "default"
|
|
23
|
+
end
|
|
24
|
+
local label = _param.label
|
|
25
|
+
local children = _param.children
|
|
26
|
+
local theme = _param.theme
|
|
27
|
+
if theme == nil then
|
|
28
|
+
theme = defaultTheme
|
|
29
|
+
end
|
|
30
|
+
local rem = useRem()
|
|
31
|
+
local count = #options
|
|
32
|
+
if count == 0 then
|
|
33
|
+
return React.createElement(React.Fragment)
|
|
34
|
+
end
|
|
35
|
+
local height = if size == "small" then rem(4) else rem(5)
|
|
36
|
+
local spacing = rem(1)
|
|
37
|
+
local innerPaddingX = rem(0.6)
|
|
38
|
+
local innerPaddingY = rem(0.5)
|
|
39
|
+
local buttonCorner = UDim.new(0, rem(2))
|
|
40
|
+
local buttonWidthOffset = if count > 1 then -((count - 1) * spacing) / count else 0
|
|
41
|
+
local buttonSize = UDim2.new(1 / count, buttonWidthOffset, 1, 0)
|
|
42
|
+
local handleChange = function(id, optionDisabled)
|
|
43
|
+
if disabled or optionDisabled then
|
|
44
|
+
return nil
|
|
45
|
+
end
|
|
46
|
+
if id == value then
|
|
47
|
+
return nil
|
|
48
|
+
end
|
|
49
|
+
onChange(id)
|
|
50
|
+
end
|
|
51
|
+
local showLabel = label ~= nil and label ~= ""
|
|
52
|
+
local containerHeight = if showLabel then height + rem(3.5) else height
|
|
53
|
+
local labelColor = if disabled then theme.palette.disabled else theme.palette.crust
|
|
54
|
+
local _exp = showLabel and (React.createElement(Text, {
|
|
55
|
+
text = label,
|
|
56
|
+
textSize = rem(3),
|
|
57
|
+
textScaled = true,
|
|
58
|
+
textColor = labelColor,
|
|
59
|
+
size = UDim2.new(1, 0, 0, rem(3)),
|
|
60
|
+
textXAlignment = "Left",
|
|
61
|
+
}))
|
|
62
|
+
local _exp_1 = React.createElement("uistroke", {
|
|
63
|
+
Color = theme.palette.overlay0,
|
|
64
|
+
Transparency = if disabled then 0.6 else 0.3,
|
|
65
|
+
Thickness = 1,
|
|
66
|
+
})
|
|
67
|
+
local _exp_2 = React.createElement("uipadding", {
|
|
68
|
+
PaddingLeft = UDim.new(0, innerPaddingX),
|
|
69
|
+
PaddingRight = UDim.new(0, innerPaddingX),
|
|
70
|
+
PaddingTop = UDim.new(0, innerPaddingY),
|
|
71
|
+
PaddingBottom = UDim.new(0, innerPaddingY),
|
|
72
|
+
})
|
|
73
|
+
-- ▼ ReadonlyArray.map ▼
|
|
74
|
+
local _newValue = table.create(#options)
|
|
75
|
+
local _callback = function(option, index)
|
|
76
|
+
local isSelected = option.id == value
|
|
77
|
+
local optionDisabled = disabled or option.disabled
|
|
78
|
+
local backgroundColor = theme.palette.blue
|
|
79
|
+
return React.createElement(Button, {
|
|
80
|
+
key = `segmented-toggle-{option.id}-{index}`,
|
|
81
|
+
size = buttonSize,
|
|
82
|
+
backgroundColor = backgroundColor,
|
|
83
|
+
backgroundTransparency = if isSelected then 0 else 1,
|
|
84
|
+
onClick = function()
|
|
85
|
+
return handleChange(option.id, optionDisabled)
|
|
86
|
+
end,
|
|
87
|
+
selectable = false,
|
|
88
|
+
cornerRadius = buttonCorner,
|
|
89
|
+
}, React.createElement(Text, {
|
|
90
|
+
size = UDim2.new(1, 0, 1, 0),
|
|
91
|
+
text = option.label,
|
|
92
|
+
textSize = rem(3),
|
|
93
|
+
textScaled = true,
|
|
94
|
+
textColor = theme.palette.crust,
|
|
95
|
+
textXAlignment = "Center",
|
|
96
|
+
textYAlignment = "Center",
|
|
97
|
+
padding = 0.5,
|
|
98
|
+
rem = rem,
|
|
99
|
+
}))
|
|
100
|
+
end
|
|
101
|
+
for _k, _v in options do
|
|
102
|
+
_newValue[_k] = _callback(_v, _k - 1, options)
|
|
103
|
+
end
|
|
104
|
+
-- ▲ ReadonlyArray.map ▲
|
|
105
|
+
return React.createElement(VStack, {
|
|
106
|
+
spacing = rem(1),
|
|
107
|
+
size = UDim2.new(1, 0, 0, containerHeight),
|
|
108
|
+
automaticSize = Enum.AutomaticSize.Y,
|
|
109
|
+
}, _exp, React.createElement(Frame, {
|
|
110
|
+
size = UDim2.new(1, 0, 0, height),
|
|
111
|
+
backgroundColor = theme.palette.surface1,
|
|
112
|
+
backgroundTransparency = 1,
|
|
113
|
+
cornerRadius = UDim.new(0, rem(3)),
|
|
114
|
+
}, _exp_1, React.createElement(HStack, {
|
|
115
|
+
spacing = spacing,
|
|
116
|
+
}, _exp_2, _newValue)), children)
|
|
117
|
+
end
|
|
118
|
+
return {
|
|
119
|
+
SegmentedToggle = SegmentedToggle,
|
|
120
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from "@rbxts/react";
|
|
2
|
+
import { type Theme } from "./theme";
|
|
3
|
+
export declare enum TextButtonVariant {
|
|
4
|
+
Green = 0,
|
|
5
|
+
Red = 1,
|
|
6
|
+
Blue = 2,
|
|
7
|
+
Black = 3,
|
|
8
|
+
DarkGray = 4
|
|
9
|
+
}
|
|
10
|
+
interface TextButtonProps extends React.PropsWithChildren {
|
|
11
|
+
readonly text: string;
|
|
12
|
+
readonly onClick?: () => void;
|
|
13
|
+
readonly onHover?: (hovered: boolean) => void;
|
|
14
|
+
readonly size?: UDim2 | React.Binding<UDim2>;
|
|
15
|
+
readonly position?: UDim2 | React.Binding<UDim2>;
|
|
16
|
+
readonly anchorPoint?: Vector2 | React.Binding<Vector2>;
|
|
17
|
+
readonly overlayGradient?: ColorSequence | React.Binding<ColorSequence>;
|
|
18
|
+
readonly overlayTransparency?: number | React.Binding<number>;
|
|
19
|
+
readonly overlayRotation?: number | React.Binding<number>;
|
|
20
|
+
readonly layoutOrder?: number | React.Binding<number>;
|
|
21
|
+
readonly variant: TextButtonVariant;
|
|
22
|
+
readonly isDisabled?: boolean;
|
|
23
|
+
readonly hasShadow?: boolean;
|
|
24
|
+
readonly padding?: number;
|
|
25
|
+
readonly radius?: number;
|
|
26
|
+
readonly textSize?: number;
|
|
27
|
+
readonly textScaled?: boolean;
|
|
28
|
+
readonly theme?: Theme;
|
|
29
|
+
}
|
|
30
|
+
export declare function TextButton({ text, onClick, onHover, position, anchorPoint, layoutOrder, variant, isDisabled, hasShadow, size, padding, radius, children, textSize, textScaled, theme, }: TextButtonProps): JSX.Element;
|
|
31
|
+
export type { TextButtonProps };
|
|
32
|
+
//# sourceMappingURL=TextButton.d.ts.map
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
4
|
+
local lerpBinding = _pretty_react_hooks.lerpBinding
|
|
5
|
+
local useMotion = _pretty_react_hooks.useMotion
|
|
6
|
+
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
7
|
+
local useRem = TS.import(script, TS.getModule(script, "@rbxts-ui", "rem").dist).useRem
|
|
8
|
+
local Frame = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Frame
|
|
9
|
+
local Outline = TS.import(script, script.Parent, "Outline").Outline
|
|
10
|
+
local ReactiveButton = TS.import(script, script.Parent, "ReactiveButton").ReactiveButton
|
|
11
|
+
local Text = TS.import(script, TS.getModule(script, "@rbxts-ui", "primitives").dist).Text
|
|
12
|
+
local defaultTheme = TS.import(script, script.Parent, "theme").defaultTheme
|
|
13
|
+
local TextButtonVariant
|
|
14
|
+
do
|
|
15
|
+
local _inverse = {}
|
|
16
|
+
TextButtonVariant = setmetatable({}, {
|
|
17
|
+
__index = _inverse,
|
|
18
|
+
})
|
|
19
|
+
TextButtonVariant.Green = 0
|
|
20
|
+
_inverse[0] = "Green"
|
|
21
|
+
TextButtonVariant.Red = 1
|
|
22
|
+
_inverse[1] = "Red"
|
|
23
|
+
TextButtonVariant.Blue = 2
|
|
24
|
+
_inverse[2] = "Blue"
|
|
25
|
+
TextButtonVariant.Black = 3
|
|
26
|
+
_inverse[3] = "Black"
|
|
27
|
+
TextButtonVariant.DarkGray = 4
|
|
28
|
+
_inverse[4] = "DarkGray"
|
|
29
|
+
end
|
|
30
|
+
local function TextButton(_param)
|
|
31
|
+
local text = _param.text
|
|
32
|
+
local onClick = _param.onClick
|
|
33
|
+
local onHover = _param.onHover
|
|
34
|
+
local position = _param.position
|
|
35
|
+
local anchorPoint = _param.anchorPoint
|
|
36
|
+
local layoutOrder = _param.layoutOrder
|
|
37
|
+
local variant = _param.variant
|
|
38
|
+
local isDisabled = _param.isDisabled
|
|
39
|
+
local hasShadow = _param.hasShadow
|
|
40
|
+
local size = _param.size
|
|
41
|
+
local padding = _param.padding
|
|
42
|
+
local radius = _param.radius
|
|
43
|
+
local children = _param.children
|
|
44
|
+
local textSize = _param.textSize
|
|
45
|
+
local textScaled = _param.textScaled
|
|
46
|
+
local theme = _param.theme
|
|
47
|
+
if theme == nil then
|
|
48
|
+
theme = defaultTheme
|
|
49
|
+
end
|
|
50
|
+
local rem = useRem()
|
|
51
|
+
local hover, hoverMotion = useMotion(0)
|
|
52
|
+
local colorVariant = {
|
|
53
|
+
[TextButtonVariant.Green] = theme.palette.green,
|
|
54
|
+
[TextButtonVariant.Red] = theme.palette.red,
|
|
55
|
+
[TextButtonVariant.Blue] = theme.palette.blue,
|
|
56
|
+
[TextButtonVariant.Black] = theme.palette.black,
|
|
57
|
+
[TextButtonVariant.DarkGray] = theme.palette.darkgray,
|
|
58
|
+
}
|
|
59
|
+
local color = colorVariant[variant]
|
|
60
|
+
local textColor = if variant == TextButtonVariant.Black then theme.palette.white else theme.palette.crust
|
|
61
|
+
local _condition = radius
|
|
62
|
+
if _condition == nil then
|
|
63
|
+
_condition = 1
|
|
64
|
+
end
|
|
65
|
+
local cornerRadius = UDim.new(_condition, 0)
|
|
66
|
+
local _exp = React.createElement(Frame, {
|
|
67
|
+
backgroundColor = theme.palette.offwhite,
|
|
68
|
+
backgroundTransparency = if isDisabled then 0.7 else 0,
|
|
69
|
+
cornerRadius = cornerRadius,
|
|
70
|
+
size = UDim2.new(1, 0, 1, 0),
|
|
71
|
+
}, React.createElement("uigradient", {
|
|
72
|
+
Offset = lerpBinding(hover, Vector2.new(), Vector2.new(0, 1)),
|
|
73
|
+
Rotation = 90,
|
|
74
|
+
Transparency = NumberSequence.new(0, 0.1),
|
|
75
|
+
}))
|
|
76
|
+
local _exp_1 = React.createElement(Outline, {
|
|
77
|
+
cornerRadius = cornerRadius,
|
|
78
|
+
innerTransparency = if isDisabled then 1 else 0,
|
|
79
|
+
innerColor = color,
|
|
80
|
+
innerThickness = 1,
|
|
81
|
+
theme = theme,
|
|
82
|
+
})
|
|
83
|
+
local _attributes = {
|
|
84
|
+
key = "mainText",
|
|
85
|
+
size = UDim2.new(1, 0, 1, 0),
|
|
86
|
+
text = text,
|
|
87
|
+
}
|
|
88
|
+
local _condition_1 = textScaled
|
|
89
|
+
if _condition_1 == nil then
|
|
90
|
+
_condition_1 = true
|
|
91
|
+
end
|
|
92
|
+
_attributes.textScaled = _condition_1
|
|
93
|
+
_attributes.textColor = textColor
|
|
94
|
+
_attributes.textXAlignment = "Center"
|
|
95
|
+
_attributes.textYAlignment = "Center"
|
|
96
|
+
_attributes.layoutOrder = 2
|
|
97
|
+
local _condition_2 = padding
|
|
98
|
+
if _condition_2 == nil then
|
|
99
|
+
_condition_2 = 1
|
|
100
|
+
end
|
|
101
|
+
_attributes.padding = _condition_2
|
|
102
|
+
_attributes.textSize = textSize
|
|
103
|
+
_attributes.rem = rem
|
|
104
|
+
return React.createElement(ReactiveButton, {
|
|
105
|
+
onClick = onClick,
|
|
106
|
+
onHover = function(hovered)
|
|
107
|
+
hoverMotion:spring(if hovered then 1 else 0)
|
|
108
|
+
local _result = onHover
|
|
109
|
+
if _result ~= nil then
|
|
110
|
+
_result(hovered)
|
|
111
|
+
end
|
|
112
|
+
end,
|
|
113
|
+
backgroundTransparency = 1,
|
|
114
|
+
anchorPoint = anchorPoint,
|
|
115
|
+
size = size or UDim2.new(0, rem(10), 0, rem(4)),
|
|
116
|
+
position = position,
|
|
117
|
+
layoutOrder = layoutOrder,
|
|
118
|
+
fill = true,
|
|
119
|
+
theme = theme,
|
|
120
|
+
}, _exp, _exp_1, React.createElement(Text, _attributes), children)
|
|
121
|
+
end
|
|
122
|
+
return {
|
|
123
|
+
TextButton = TextButton,
|
|
124
|
+
TextButtonVariant = TextButtonVariant,
|
|
125
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type TextProps } from "@rbxts-ui/primitives";
|
|
2
|
+
interface TimeAgoProps extends Omit<TextProps, "text"> {
|
|
3
|
+
timestamp: number;
|
|
4
|
+
refreshInterval?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function TimeAgo(props: TimeAgoProps): JSX.Element;
|
|
7
|
+
export type { TimeAgoProps };
|
|
8
|
+
//# sourceMappingURL=TimeAgo.d.ts.map
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local Object = TS.import(script, TS.getModule(script, "@rbxts", "object-utils"))
|
|
4
|
+
local useInterval = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out).useInterval
|
|
5
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
6
|
+
local React = _react
|
|
7
|
+
local useState = _react.useState
|
|
8
|
+
local omit = TS.import(script, TS.getModule(script, "@rbxts-ui", "utils").dist).omit
|
|
9
|
+
local PillText = TS.import(script, script.Parent, "PillText").PillText
|
|
10
|
+
local function getTimeAgo(timestamp)
|
|
11
|
+
local now = os.time()
|
|
12
|
+
local seconds = now - timestamp / 1000
|
|
13
|
+
if seconds < 60 then
|
|
14
|
+
return `{math.floor(seconds)}s ago`
|
|
15
|
+
end
|
|
16
|
+
local minutes = math.floor(seconds / 60)
|
|
17
|
+
if minutes < 60 then
|
|
18
|
+
return `{minutes}m ago`
|
|
19
|
+
end
|
|
20
|
+
local hours = math.floor(minutes / 60)
|
|
21
|
+
if hours < 24 then
|
|
22
|
+
return `{hours}h ago`
|
|
23
|
+
end
|
|
24
|
+
local days = math.floor(hours / 24)
|
|
25
|
+
return `{days}d ago`
|
|
26
|
+
end
|
|
27
|
+
local function TimeAgo(props)
|
|
28
|
+
local timeAgo, setTimeAgo = useState(function()
|
|
29
|
+
return getTimeAgo(props.timestamp)
|
|
30
|
+
end)
|
|
31
|
+
local _exp = function()
|
|
32
|
+
setTimeAgo(getTimeAgo(props.timestamp))
|
|
33
|
+
end
|
|
34
|
+
local _condition = props.refreshInterval
|
|
35
|
+
if _condition == nil then
|
|
36
|
+
_condition = 1
|
|
37
|
+
end
|
|
38
|
+
useInterval(_exp, _condition)
|
|
39
|
+
local textProps = Object.assign({}, omit(props, { "timestamp", "refreshInterval" }))
|
|
40
|
+
local _attributes = table.clone(Object.assign({
|
|
41
|
+
text = timeAgo,
|
|
42
|
+
}, textProps))
|
|
43
|
+
setmetatable(_attributes, nil)
|
|
44
|
+
return React.createElement(PillText, _attributes)
|
|
45
|
+
end
|
|
46
|
+
return {
|
|
47
|
+
TimeAgo = TimeAgo,
|
|
48
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,30 @@ export { Checkmark, type CheckmarkProps } from "./Checkmark";
|
|
|
4
4
|
export { DelayRender, type DelayRenderProps } from "./DelayRender";
|
|
5
5
|
export { ErrorBoundary, type ErrorBoundaryProps } from "./ErrorBoundary";
|
|
6
6
|
export { TextField, type TextFieldProps } from "./TextField";
|
|
7
|
+
export { defaultTheme, type Theme } from "./theme";
|
|
8
|
+
export { Outline, type OutlineProps } from "./Outline";
|
|
9
|
+
export { Button, type ButtonProps } from "./Button";
|
|
10
|
+
export { ReactiveButton, type ReactiveButtonProps } from "./ReactiveButton";
|
|
11
|
+
export { ClickOutsideOverlay, ClickOutsideLayer, type ClickOutsideOverlayProps, type ClickOutsideLayerProps } from "./ClickOutsideOverlay";
|
|
12
|
+
export { useInputDevice, type InputDevice } from "./use-input-device";
|
|
13
|
+
export { useButtonState, type ButtonEvents } from "./use-button-state";
|
|
14
|
+
export { useButtonAnimation, type ButtonAnimation } from "./use-button-animation";
|
|
15
|
+
export { Checkbox, type CheckboxProps } from "./Checkbox";
|
|
16
|
+
export { Radio, type RadioProps } from "./Radio";
|
|
17
|
+
export { PrimaryButton, type PrimaryButtonProps } from "./PrimaryButton";
|
|
18
|
+
export { TextButton, TextButtonVariant, type TextButtonProps } from "./TextButton";
|
|
19
|
+
export { IconRoundButton, type IconRoundButtonProps } from "./IconRoundButton";
|
|
20
|
+
export { IconTileButton, type IconTileButtonProps } from "./IconTileButton";
|
|
21
|
+
export { FormRow, type FormRowProps } from "./FormRow";
|
|
22
|
+
export { CheckboxRow, type CheckboxRowProps } from "./CheckboxRow";
|
|
23
|
+
export { RadioRow, type RadioRowProps } from "./RadioRow";
|
|
24
|
+
export { SegmentedToggle, type SegmentedToggleProps, type SegmentedToggleOption } from "./SegmentedToggle";
|
|
25
|
+
export { Section, type SectionProps } from "./Section";
|
|
26
|
+
export { Accordion, type AccordionProps } from "./Accordion";
|
|
27
|
+
export { Dropdown, type DropdownProps, type DropdownOption } from "./Dropdown";
|
|
28
|
+
export { DropdownButton, type DropdownButtonProps } from "./DropdownButton";
|
|
29
|
+
export { DropdownOptionButton, type DropdownOptionButtonProps } from "./DropdownOptionButton";
|
|
30
|
+
export { TimeAgo, type TimeAgoProps } from "./TimeAgo";
|
|
31
|
+
export { Legend, type LegendProps } from "./Legend";
|
|
32
|
+
export { PillText, type PillTextProps } from "./PillText";
|
|
7
33
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/init.luau
CHANGED
|
@@ -7,4 +7,41 @@ exports.Checkmark = TS.import(script, script, "Checkmark").Checkmark
|
|
|
7
7
|
exports.DelayRender = TS.import(script, script, "DelayRender").DelayRender
|
|
8
8
|
exports.ErrorBoundary = TS.import(script, script, "ErrorBoundary").ErrorBoundary
|
|
9
9
|
exports.TextField = TS.import(script, script, "TextField").TextField
|
|
10
|
+
-- Theme
|
|
11
|
+
exports.defaultTheme = TS.import(script, script, "theme").defaultTheme
|
|
12
|
+
-- Utilities
|
|
13
|
+
exports.Outline = TS.import(script, script, "Outline").Outline
|
|
14
|
+
exports.Button = TS.import(script, script, "Button").Button
|
|
15
|
+
exports.ReactiveButton = TS.import(script, script, "ReactiveButton").ReactiveButton
|
|
16
|
+
local _ClickOutsideOverlay = TS.import(script, script, "ClickOutsideOverlay")
|
|
17
|
+
exports.ClickOutsideOverlay = _ClickOutsideOverlay.ClickOutsideOverlay
|
|
18
|
+
exports.ClickOutsideLayer = _ClickOutsideOverlay.ClickOutsideLayer
|
|
19
|
+
exports.useInputDevice = TS.import(script, script, "use-input-device").useInputDevice
|
|
20
|
+
exports.useButtonState = TS.import(script, script, "use-button-state").useButtonState
|
|
21
|
+
exports.useButtonAnimation = TS.import(script, script, "use-button-animation").useButtonAnimation
|
|
22
|
+
-- Form Inputs
|
|
23
|
+
exports.Checkbox = TS.import(script, script, "Checkbox").Checkbox
|
|
24
|
+
exports.Radio = TS.import(script, script, "Radio").Radio
|
|
25
|
+
-- Buttons
|
|
26
|
+
exports.PrimaryButton = TS.import(script, script, "PrimaryButton").PrimaryButton
|
|
27
|
+
local _TextButton = TS.import(script, script, "TextButton")
|
|
28
|
+
exports.TextButton = _TextButton.TextButton
|
|
29
|
+
exports.TextButtonVariant = _TextButton.TextButtonVariant
|
|
30
|
+
exports.IconRoundButton = TS.import(script, script, "IconRoundButton").IconRoundButton
|
|
31
|
+
exports.IconTileButton = TS.import(script, script, "IconTileButton").IconTileButton
|
|
32
|
+
-- Form Layout
|
|
33
|
+
exports.FormRow = TS.import(script, script, "FormRow").FormRow
|
|
34
|
+
exports.CheckboxRow = TS.import(script, script, "CheckboxRow").CheckboxRow
|
|
35
|
+
exports.RadioRow = TS.import(script, script, "RadioRow").RadioRow
|
|
36
|
+
exports.SegmentedToggle = TS.import(script, script, "SegmentedToggle").SegmentedToggle
|
|
37
|
+
exports.Section = TS.import(script, script, "Section").Section
|
|
38
|
+
exports.Accordion = TS.import(script, script, "Accordion").Accordion
|
|
39
|
+
-- Dropdown
|
|
40
|
+
exports.Dropdown = TS.import(script, script, "Dropdown").Dropdown
|
|
41
|
+
exports.DropdownButton = TS.import(script, script, "DropdownButton").DropdownButton
|
|
42
|
+
exports.DropdownOptionButton = TS.import(script, script, "DropdownOptionButton").DropdownOptionButton
|
|
43
|
+
-- Display
|
|
44
|
+
exports.TimeAgo = TS.import(script, script, "TimeAgo").TimeAgo
|
|
45
|
+
exports.Legend = TS.import(script, script, "Legend").Legend
|
|
46
|
+
exports.PillText = TS.import(script, script, "PillText").PillText
|
|
10
47
|
return exports
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { SpringOptions } from "@rbxts/ripple";
|
|
2
|
+
export interface Theme {
|
|
3
|
+
palette: {
|
|
4
|
+
white: Color3;
|
|
5
|
+
offwhite: Color3;
|
|
6
|
+
black: Color3;
|
|
7
|
+
darkgray: Color3;
|
|
8
|
+
crust: Color3;
|
|
9
|
+
overlay0: Color3;
|
|
10
|
+
disabled: Color3;
|
|
11
|
+
blue: Color3;
|
|
12
|
+
green: Color3;
|
|
13
|
+
red: Color3;
|
|
14
|
+
yellow: Color3;
|
|
15
|
+
blueishColor: Color3;
|
|
16
|
+
text: Color3;
|
|
17
|
+
surface1: Color3;
|
|
18
|
+
};
|
|
19
|
+
fonts: {
|
|
20
|
+
inter: {
|
|
21
|
+
regular: Font;
|
|
22
|
+
medium: Font;
|
|
23
|
+
bold: Font;
|
|
24
|
+
};
|
|
25
|
+
roboto: {
|
|
26
|
+
light: Font;
|
|
27
|
+
regular: Font;
|
|
28
|
+
medium: Font;
|
|
29
|
+
bold: Font;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
springs: {
|
|
33
|
+
slow: SpringOptions;
|
|
34
|
+
bubbly: SpringOptions;
|
|
35
|
+
responsive: SpringOptions;
|
|
36
|
+
gentle: SpringOptions;
|
|
37
|
+
world: SpringOptions;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export declare const defaultTheme: Theme;
|
|
41
|
+
//# sourceMappingURL=theme.d.ts.map
|
package/dist/theme.luau
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
-- Compiled with roblox-ts v3.0.0
|
|
2
|
+
local TS = _G[script]
|
|
3
|
+
local config = TS.import(script, TS.getModule(script, "@rbxts", "ripple").src).config
|
|
4
|
+
local defaultPalette = {
|
|
5
|
+
white = Color3.fromRGB(255, 255, 255),
|
|
6
|
+
offwhite = Color3.fromRGB(234, 238, 253),
|
|
7
|
+
black = Color3.fromRGB(0, 0, 0),
|
|
8
|
+
darkgray = Color3.fromRGB(69, 69, 79),
|
|
9
|
+
crust = Color3.fromRGB(17, 17, 27),
|
|
10
|
+
overlay0 = Color3.fromRGB(108, 112, 134),
|
|
11
|
+
disabled = Color3.fromRGB(108, 112, 134),
|
|
12
|
+
blue = Color3.fromRGB(137, 180, 250),
|
|
13
|
+
green = Color3.fromRGB(166, 227, 161),
|
|
14
|
+
red = Color3.fromRGB(243, 139, 168),
|
|
15
|
+
yellow = Color3.fromRGB(249, 226, 175),
|
|
16
|
+
blueishColor = Color3.fromRGB(0, 204, 255),
|
|
17
|
+
text = Color3.fromRGB(205, 214, 244),
|
|
18
|
+
surface1 = Color3.fromRGB(69, 71, 90),
|
|
19
|
+
}
|
|
20
|
+
local defaultFonts = {
|
|
21
|
+
inter = {
|
|
22
|
+
regular = Font.new("rbxassetid://12187365364"),
|
|
23
|
+
medium = Font.new("rbxassetid://12187365364", Enum.FontWeight.Medium),
|
|
24
|
+
bold = Font.new("rbxassetid://12187365364", Enum.FontWeight.Bold),
|
|
25
|
+
},
|
|
26
|
+
roboto = {
|
|
27
|
+
light = Font.fromName("Roboto", Enum.FontWeight.Light),
|
|
28
|
+
regular = Font.fromName("Roboto", Enum.FontWeight.Regular),
|
|
29
|
+
medium = Font.fromName("Roboto", Enum.FontWeight.Medium),
|
|
30
|
+
bold = Font.fromName("Roboto", Enum.FontWeight.Bold),
|
|
31
|
+
},
|
|
32
|
+
}
|
|
33
|
+
local _object = table.clone(config.spring)
|
|
34
|
+
setmetatable(_object, nil)
|
|
35
|
+
_object.bubbly = {
|
|
36
|
+
tension = 400,
|
|
37
|
+
friction = 14,
|
|
38
|
+
}
|
|
39
|
+
_object.responsive = {
|
|
40
|
+
tension = 400,
|
|
41
|
+
}
|
|
42
|
+
_object.gentle = {
|
|
43
|
+
tension = 250,
|
|
44
|
+
friction = 30,
|
|
45
|
+
}
|
|
46
|
+
_object.world = {
|
|
47
|
+
tension = 180,
|
|
48
|
+
friction = 30,
|
|
49
|
+
}
|
|
50
|
+
local defaultSprings = _object
|
|
51
|
+
local defaultTheme = {
|
|
52
|
+
palette = defaultPalette,
|
|
53
|
+
fonts = defaultFonts,
|
|
54
|
+
springs = defaultSprings,
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
defaultTheme = defaultTheme,
|
|
58
|
+
}
|