@rbxts/react-clean-ui 1.2.5 → 1.2.6

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.
@@ -0,0 +1,8 @@
1
+ import React from "@rbxts/react";
2
+ import { BreakPointElementProps } from "../../Interfaces/";
3
+ export interface BreakpointProviderProps extends BreakPointElementProps {
4
+ name?: string;
5
+ LayoutOrder?: number;
6
+ children?: React.ReactNode;
7
+ }
8
+ export declare const BreakpointProvider: React.ForwardRefExoticComponent<BreakpointProviderProps & React.RefAttributes<Frame>>;
@@ -0,0 +1,67 @@
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 _Contexts = TS.import(script, script.Parent.Parent.Parent, "Contexts")
5
+ local BreakpointContext = _Contexts.BreakpointContext
6
+ local CleanThemeContext = _Contexts.CleanThemeContext
7
+ local BreakpointHelper = TS.import(script, script.Parent.Parent.Parent, "Helpers").BreakpointHelper
8
+ local BreakpointProvider = React.forwardRef(function(props, ref)
9
+ local theme = React.useContext(CleanThemeContext)
10
+ local breakpoints = props.breakpoints or theme.breakpoints
11
+ local frameRef = React.useRef()
12
+ local widthRef = React.useRef(0)
13
+ local value, setValue = React.useState(function()
14
+ return {
15
+ width = 0,
16
+ breakpoint = BreakpointHelper:getBreakpoint(0, breakpoints),
17
+ }
18
+ end)
19
+ local valueRef = React.useRef(value)
20
+ local resolve = function(width)
21
+ widthRef.current = width
22
+ local breakpoint = BreakpointHelper:getBreakpoint(width, breakpoints)
23
+ if breakpoint == valueRef.current.breakpoint then
24
+ return nil
25
+ end
26
+ local resolved = {
27
+ width = width,
28
+ breakpoint = breakpoint,
29
+ }
30
+ valueRef.current = resolved
31
+ setValue(resolved)
32
+ end
33
+ React.useEffect(function()
34
+ local instance = frameRef.current
35
+ resolve(if instance ~= nil then instance.AbsoluteSize.X else widthRef.current)
36
+ end, { breakpoints })
37
+ local setFrame = React.useCallback(function(instance)
38
+ frameRef.current = instance
39
+ local _ref = ref
40
+ if type(_ref) == "function" then
41
+ ref(instance)
42
+ elseif ref ~= nil then
43
+ ref.current = instance
44
+ end
45
+ end, { ref })
46
+ local _attributes = {}
47
+ local _condition = props.name
48
+ if _condition == nil then
49
+ _condition = "BreakpointProvider"
50
+ end
51
+ _attributes.key = _condition
52
+ _attributes.ref = setFrame
53
+ _attributes.LayoutOrder = props.LayoutOrder
54
+ _attributes.Size = UDim2.fromScale(1, 1)
55
+ _attributes.BackgroundTransparency = 1
56
+ _attributes.Change = {
57
+ AbsoluteSize = function(instance)
58
+ return resolve(instance.AbsoluteSize.X)
59
+ end,
60
+ }
61
+ return React.createElement("frame", _attributes, React.createElement(BreakpointContext.Provider, {
62
+ value = value,
63
+ }, props.children))
64
+ end)
65
+ return {
66
+ BreakpointProvider = BreakpointProvider,
67
+ }
@@ -1,5 +1,6 @@
1
1
  export * from './Column';
2
2
  export * from './Accordion';
3
+ export * from './BreakpointProvider';
3
4
  export * from './Container';
4
5
  export * from './Draggable';
5
6
  export * from './Droppable';
@@ -7,6 +7,9 @@ end
7
7
  for _k, _v in TS.import(script, script, "Accordion") or {} do
8
8
  exports[_k] = _v
9
9
  end
10
+ for _k, _v in TS.import(script, script, "BreakpointProvider") or {} do
11
+ exports[_k] = _v
12
+ end
10
13
  for _k, _v in TS.import(script, script, "Container") or {} do
11
14
  exports[_k] = _v
12
15
  end
@@ -0,0 +1,10 @@
1
+ import React from "@rbxts/react";
2
+ import { IconElementProps, IntentElementProps, ScalableElementProps } from "../../Interfaces/";
3
+ export interface BadgeProps extends IntentElementProps, ScalableElementProps, IconElementProps {
4
+ text: string;
5
+ name?: string;
6
+ LayoutOrder?: number;
7
+ Position?: UDim2;
8
+ AnchorPoint?: Vector2;
9
+ }
10
+ export declare const Badge: React.ForwardRefExoticComponent<BadgeProps & React.RefAttributes<ImageLabel>>;
@@ -0,0 +1,89 @@
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 CleanThemeContext = TS.import(script, script.Parent.Parent.Parent, "Contexts").CleanThemeContext
5
+ local _Decorator = TS.import(script, script.Parent.Parent, "Decorator")
6
+ local Corners = _Decorator.Corners
7
+ local Gradient = _Decorator.Gradient
8
+ local Padding = _Decorator.Padding
9
+ local Text = TS.import(script, script.Parent.Parent, "Typography").Text
10
+ local _Helpers = TS.import(script, script.Parent.Parent.Parent, "Helpers")
11
+ local ColorHelper = _Helpers.ColorHelper
12
+ local CssHelper = _Helpers.CssHelper
13
+ local SpacingHelper = _Helpers.SpacingHelper
14
+ local TypographyHelper = _Helpers.TypographyHelper
15
+ local HStack = TS.import(script, script.Parent.Parent, "Layout").HStack
16
+ local Icon = TS.import(script, script.Parent, "Icon").Icon
17
+ local Badge = React.forwardRef(function(props, ref)
18
+ local theme = React.useContext(CleanThemeContext)
19
+ local badgeTheme = theme.components.badge
20
+ local scale = props.scale or theme.default.scale
21
+ local intentColors = ColorHelper:getIntentColors(theme, props.intent, "default", badgeTheme.intents)
22
+ local backgroundImage = CssHelper:resolveBackgroundImage(intentColors.backgroundImage)
23
+ local padding = SpacingHelper:GetResolvedPadding(theme, {}, badgeTheme.spacing, badgeTheme.padding, scale)
24
+ local gap = math.ceil(SpacingHelper:GetPadding(theme, scale, badgeTheme.spacing) / 2)
25
+ local _attributes = {}
26
+ local _condition = props.name
27
+ if _condition == nil then
28
+ _condition = "Badge"
29
+ end
30
+ _attributes.key = _condition
31
+ _attributes.ref = ref
32
+ _attributes.Active = false
33
+ _attributes.Selectable = false
34
+ _attributes.Size = UDim2.fromOffset(0, 0)
35
+ _attributes.AutomaticSize = Enum.AutomaticSize.XY
36
+ _attributes.Position = props.Position
37
+ _attributes.AnchorPoint = props.AnchorPoint
38
+ _attributes.LayoutOrder = props.LayoutOrder
39
+ _attributes.BackgroundColor3 = intentColors.backgroundColor
40
+ local _condition_1 = intentColors.backgroundTransparency
41
+ if _condition_1 == nil then
42
+ _condition_1 = 0
43
+ end
44
+ _attributes.BackgroundTransparency = _condition_1
45
+ _attributes.BorderSizePixel = 0
46
+ local _condition_2 = backgroundImage.Image
47
+ if _condition_2 == nil then
48
+ _condition_2 = ""
49
+ end
50
+ _attributes.Image = _condition_2
51
+ _attributes.ImageColor3 = backgroundImage.ImageColor3
52
+ _attributes.ImageTransparency = backgroundImage.ImageTransparency
53
+ _attributes.ScaleType = backgroundImage.ScaleType
54
+ _attributes.SliceCenter = backgroundImage.SliceCenter
55
+ _attributes.SliceScale = backgroundImage.SliceScale
56
+ _attributes.TileSize = backgroundImage.TileSize
57
+ return React.createElement("imagelabel", _attributes, React.createElement(Corners, {
58
+ radius = badgeTheme.cornerRadius,
59
+ }), badgeTheme.borderThickness > 0 and (React.createElement("uistroke", {
60
+ key = "Stroke",
61
+ Thickness = badgeTheme.borderThickness,
62
+ BorderStrokePosition = Enum.BorderStrokePosition.Inner,
63
+ Color = intentColors.borderColor,
64
+ })), React.createElement(Gradient, {
65
+ value = intentColors.backgroundGradient,
66
+ }), React.createElement(Padding, {
67
+ resolvedPadding = padding,
68
+ }), React.createElement(HStack, {
69
+ valign = "Center",
70
+ Wraps = false,
71
+ Padding = UDim.new(0, gap),
72
+ }, props.icon ~= nil and React.createElement(Icon, {
73
+ name = "BadgeIcon",
74
+ LayoutOrder = 1,
75
+ scale = scale,
76
+ icon = props.icon,
77
+ color = intentColors.textColor,
78
+ }), React.createElement(Text, {
79
+ name = "BadgeText",
80
+ LayoutOrder = 2,
81
+ text = props.text,
82
+ TextWrap = false,
83
+ typography = TypographyHelper:getTypography(theme, scale, badgeTheme.typography),
84
+ TextColor3 = intentColors.textColor,
85
+ })))
86
+ end)
87
+ return {
88
+ Badge = Badge,
89
+ }
@@ -1,3 +1,4 @@
1
+ export * from './Badge';
1
2
  export * from './Box';
2
3
  export * from './Card';
3
4
  export * from './Icon';
@@ -1,6 +1,9 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
3
  local exports = {}
4
+ for _k, _v in TS.import(script, script, "Badge") or {} do
5
+ exports[_k] = _v
6
+ end
4
7
  for _k, _v in TS.import(script, script, "Box") or {} do
5
8
  exports[_k] = _v
6
9
  end
@@ -0,0 +1,9 @@
1
+ import React from "@rbxts/react";
2
+ import { Breakpoint, ResponsiveValue } from "../Interfaces/responsive.types";
3
+ export interface BreakpointContextValue {
4
+ width: number;
5
+ breakpoint: Breakpoint;
6
+ }
7
+ export declare const BreakpointContext: React.Context<BreakpointContextValue | undefined>;
8
+ export declare function useBreakpoint(): Breakpoint;
9
+ export declare function useBreakpointValue<T>(value: ResponsiveValue<T> | undefined): T | undefined;
@@ -0,0 +1,65 @@
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 Workspace = TS.import(script, TS.getModule(script, "@rbxts", "services")).Workspace
5
+ local BreakpointHelper = TS.import(script, script.Parent.Parent, "Helpers", "breakpoint.helper").BreakpointHelper
6
+ local SizeHelper = TS.import(script, script.Parent.Parent, "Helpers", "size.helper").SizeHelper
7
+ local CleanThemeContext = TS.import(script, script.Parent, "theme.context").CleanThemeContext
8
+ local BreakpointContext = React.createContext(nil)
9
+ local function getViewportBreakpoint(breakpoints)
10
+ local camera = Workspace.CurrentCamera
11
+ if camera == nil then
12
+ return nil
13
+ end
14
+ return BreakpointHelper:getBreakpoint(camera.ViewportSize.X, breakpoints)
15
+ end
16
+ local function useBreakpoint()
17
+ local context = React.useContext(BreakpointContext)
18
+ local theme = React.useContext(CleanThemeContext)
19
+ local viewportBreakpoint, setViewportBreakpoint = React.useState(function()
20
+ return (if context == nil then getViewportBreakpoint(theme.breakpoints) else nil) or "xs"
21
+ end)
22
+ React.useEffect(function()
23
+ if context ~= nil then
24
+ return nil
25
+ end
26
+ local viewportConnection
27
+ local update = function()
28
+ local resolved = getViewportBreakpoint(theme.breakpoints)
29
+ if resolved ~= nil then
30
+ setViewportBreakpoint(resolved)
31
+ end
32
+ end
33
+ local bindCamera = function()
34
+ local _result = viewportConnection
35
+ if _result ~= nil then
36
+ _result:Disconnect()
37
+ end
38
+ viewportConnection = nil
39
+ local camera = Workspace.CurrentCamera
40
+ if camera ~= nil then
41
+ viewportConnection = camera:GetPropertyChangedSignal("ViewportSize"):Connect(update)
42
+ end
43
+ update()
44
+ end
45
+ local cameraConnection = Workspace:GetPropertyChangedSignal("CurrentCamera"):Connect(bindCamera)
46
+ bindCamera()
47
+ return function()
48
+ cameraConnection:Disconnect()
49
+ local _result = viewportConnection
50
+ if _result ~= nil then
51
+ _result:Disconnect()
52
+ end
53
+ end
54
+ end, { context == nil, theme.breakpoints })
55
+ return if context ~= nil then context.breakpoint else viewportBreakpoint
56
+ end
57
+ local function useBreakpointValue(value)
58
+ local breakpoint = useBreakpoint()
59
+ return SizeHelper:resolveResponsiveValue(value, breakpoint)
60
+ end
61
+ return {
62
+ useBreakpoint = useBreakpoint,
63
+ useBreakpointValue = useBreakpointValue,
64
+ BreakpointContext = BreakpointContext,
65
+ }
@@ -1,3 +1,4 @@
1
+ export * from './breakpoint.context';
1
2
  export * from './draggable.context';
2
3
  export * from './droppable.context';
3
4
  export * from './modal.context';
@@ -1,6 +1,9 @@
1
1
  -- Compiled with roblox-ts v3.0.0
2
2
  local TS = _G[script]
3
3
  local exports = {}
4
+ for _k, _v in TS.import(script, script, "breakpoint.context") or {} do
5
+ exports[_k] = _v
6
+ end
4
7
  for _k, _v in TS.import(script, script, "draggable.context") or {} do
5
8
  exports[_k] = _v
6
9
  end
@@ -55,6 +55,14 @@ export interface ThemeTemplate {
55
55
  backgroundGradient?: CssBackgroundGradient;
56
56
  intents?: Partial<Record<Intent, InlineIntentColors>>;
57
57
  };
58
+ badge: {
59
+ cornerRadius: CssSize;
60
+ borderThickness: number;
61
+ spacing?: ScaleSizeValue<number>;
62
+ padding?: ScaledCssPadding;
63
+ typography?: Partial<TypographyStyle> | ScaledTypographyStyle;
64
+ intents?: Partial<Record<Intent, InlineIntentColors>>;
65
+ };
58
66
  button: {
59
67
  backgroundTransparency: number;
60
68
  cornerRadius: CssSize;
@@ -150,6 +150,48 @@ local DarkTheme = createTheme({
150
150
  cornerRadius = 8,
151
151
  boxShadow = "2px 2px 8px 0px",
152
152
  },
153
+ badge = {
154
+ cornerRadius = "50%",
155
+ borderThickness = 1,
156
+ intents = {
157
+ primary = {
158
+ default = {
159
+ textColor = Color3.fromHex("#E8EDF8"),
160
+ backgroundColor = Color3.fromHex("#252B36"),
161
+ borderColor = Color3.fromHex("#343B49"),
162
+ backgroundTransparency = 0,
163
+ },
164
+ },
165
+ success = {
166
+ default = {
167
+ textColor = Color3.fromHex("#75E0A7"),
168
+ backgroundColor = Color3.fromHex("#1B3A2A"),
169
+ borderColor = Color3.fromHex("#258A56"),
170
+ },
171
+ },
172
+ info = {
173
+ default = {
174
+ textColor = Color3.fromHex("#8DD0FF"),
175
+ backgroundColor = Color3.fromHex("#1B3345"),
176
+ borderColor = Color3.fromHex("#2F79B4"),
177
+ },
178
+ },
179
+ warning = {
180
+ default = {
181
+ textColor = Color3.fromHex("#FFD978"),
182
+ backgroundColor = Color3.fromHex("#3A2F17"),
183
+ borderColor = Color3.fromHex("#B68522"),
184
+ },
185
+ },
186
+ danger = {
187
+ default = {
188
+ textColor = Color3.fromHex("#FF8D8D"),
189
+ backgroundColor = Color3.fromHex("#3F1F1F"),
190
+ borderColor = Color3.fromHex("#B93A3A"),
191
+ },
192
+ },
193
+ },
194
+ },
153
195
  button = {
154
196
  backgroundTransparency = 0,
155
197
  borderThickness = 1,
@@ -148,6 +148,77 @@ local DefaultTheme = {
148
148
  cornerRadius = 8,
149
149
  boxShadow = "2px 2px 2px 2px",
150
150
  },
151
+ badge = {
152
+ cornerRadius = "50%",
153
+ borderThickness = 1,
154
+ padding = {
155
+ xs = "1px 4px",
156
+ sm = "2px 6px",
157
+ md = "2px 8px",
158
+ lg = "4px 10px",
159
+ xl = "6px 14px",
160
+ },
161
+ typography = {
162
+ xs = {
163
+ weight = Enum.FontWeight.Bold,
164
+ size = Enum.FontSize.Size10,
165
+ },
166
+ sm = {
167
+ weight = Enum.FontWeight.Bold,
168
+ size = Enum.FontSize.Size12,
169
+ },
170
+ md = {
171
+ weight = Enum.FontWeight.Bold,
172
+ size = Enum.FontSize.Size14,
173
+ },
174
+ lg = {
175
+ weight = Enum.FontWeight.Bold,
176
+ size = Enum.FontSize.Size18,
177
+ },
178
+ xl = {
179
+ weight = Enum.FontWeight.Bold,
180
+ size = Enum.FontSize.Size24,
181
+ },
182
+ },
183
+ intents = {
184
+ primary = {
185
+ default = {
186
+ textColor = Color3.fromHex("#1D2433"),
187
+ backgroundColor = Color3.fromHex("#EEF1F6"),
188
+ borderColor = Color3.fromHex("#D9DEE8"),
189
+ backgroundTransparency = 0,
190
+ },
191
+ },
192
+ success = {
193
+ default = {
194
+ textColor = Color3.fromHex("#FFFFFF"),
195
+ backgroundColor = Color3.fromHex("#2E9D63"),
196
+ borderColor = Color3.fromHex("#237D4D"),
197
+ },
198
+ },
199
+ info = {
200
+ default = {
201
+ textColor = Color3.fromHex("#FFFFFF"),
202
+ backgroundColor = Color3.fromHex("#3187C8"),
203
+ borderColor = Color3.fromHex("#266CA2"),
204
+ },
205
+ },
206
+ warning = {
207
+ default = {
208
+ textColor = Color3.fromHex("#FFFFFF"),
209
+ backgroundColor = Color3.fromHex("#E7A92F"),
210
+ borderColor = Color3.fromHex("#C58B1D"),
211
+ },
212
+ },
213
+ danger = {
214
+ default = {
215
+ textColor = Color3.fromHex("#FFFFFF"),
216
+ backgroundColor = Color3.fromHex("#D64545"),
217
+ borderColor = Color3.fromHex("#B53535"),
218
+ },
219
+ },
220
+ },
221
+ },
151
222
  button = {
152
223
  backgroundTransparency = 0,
153
224
  borderThickness = 1,
@@ -150,6 +150,48 @@ local SandstoneTheme = createTheme({
150
150
  cornerRadius = 4,
151
151
  boxShadow = "0px 3px 8px 0px",
152
152
  },
153
+ badge = {
154
+ cornerRadius = 4,
155
+ borderThickness = 1,
156
+ intents = {
157
+ primary = {
158
+ default = {
159
+ textColor = Color3.fromHex("#244F4A"),
160
+ backgroundColor = Color3.fromHex("#D9E9E5"),
161
+ borderColor = Color3.fromHex("#4E8179"),
162
+ backgroundTransparency = 0,
163
+ },
164
+ },
165
+ success = {
166
+ default = {
167
+ textColor = Color3.fromHex("#2E6245"),
168
+ backgroundColor = Color3.fromHex("#DDEBDD"),
169
+ borderColor = Color3.fromHex("#5B8A6A"),
170
+ },
171
+ },
172
+ info = {
173
+ default = {
174
+ textColor = Color3.fromHex("#365F78"),
175
+ backgroundColor = Color3.fromHex("#DDEAF0"),
176
+ borderColor = Color3.fromHex("#6F98AE"),
177
+ },
178
+ },
179
+ warning = {
180
+ default = {
181
+ textColor = Color3.fromHex("#7A5721"),
182
+ backgroundColor = Color3.fromHex("#F5E8C8"),
183
+ borderColor = Color3.fromHex("#C3994C"),
184
+ },
185
+ },
186
+ danger = {
187
+ default = {
188
+ textColor = Color3.fromHex("#8A3D3A"),
189
+ backgroundColor = Color3.fromHex("#F2D9D5"),
190
+ borderColor = Color3.fromHex("#B46861"),
191
+ },
192
+ },
193
+ },
194
+ },
153
195
  button = {
154
196
  backgroundTransparency = 0,
155
197
  borderThickness = 1,
@@ -42,6 +42,76 @@ local WoodenTheme = createTheme({
42
42
  },
43
43
  },
44
44
  components = {
45
+ badge = {
46
+ cornerRadius = "4px",
47
+ borderThickness = 2,
48
+ padding = "2px 10px",
49
+ typography = {
50
+ xs = {
51
+ font = font,
52
+ size = Enum.FontSize.Size18,
53
+ weight = Enum.FontWeight.Regular,
54
+ },
55
+ sm = {
56
+ font = font,
57
+ size = Enum.FontSize.Size18,
58
+ weight = Enum.FontWeight.Regular,
59
+ },
60
+ md = {
61
+ font = font,
62
+ size = Enum.FontSize.Size18,
63
+ weight = Enum.FontWeight.Regular,
64
+ },
65
+ lg = {
66
+ font = font,
67
+ size = Enum.FontSize.Size18,
68
+ weight = Enum.FontWeight.Regular,
69
+ },
70
+ xl = {
71
+ font = font,
72
+ size = Enum.FontSize.Size18,
73
+ weight = Enum.FontWeight.Regular,
74
+ },
75
+ },
76
+ intents = {
77
+ primary = {
78
+ default = {
79
+ textColor = Color3.fromHex("#FFF7CF"),
80
+ borderColor = Color3.fromHex("#3D2712"),
81
+ backgroundColor = Color3.fromHex("#7A4A20"),
82
+ backgroundTransparency = 0,
83
+ },
84
+ },
85
+ success = {
86
+ default = {
87
+ textColor = Color3.fromHex("#FFF7CF"),
88
+ borderColor = Color3.fromHex("#3D2712"),
89
+ backgroundColor = Color3.fromHex("#4E6A24"),
90
+ },
91
+ },
92
+ info = {
93
+ default = {
94
+ textColor = Color3.fromHex("#FFF7CF"),
95
+ borderColor = Color3.fromHex("#3D2712"),
96
+ backgroundColor = Color3.fromHex("#2C5270"),
97
+ },
98
+ },
99
+ warning = {
100
+ default = {
101
+ textColor = Color3.fromHex("#FFF7CF"),
102
+ borderColor = Color3.fromHex("#3D2712"),
103
+ backgroundColor = Color3.fromHex("#A67A20"),
104
+ },
105
+ },
106
+ danger = {
107
+ default = {
108
+ textColor = Color3.fromHex("#FFF7CF"),
109
+ borderColor = Color3.fromHex("#3D2712"),
110
+ backgroundColor = Color3.fromHex("#7A3220"),
111
+ },
112
+ },
113
+ },
114
+ },
45
115
  button = {
46
116
  cornerRadius = 0,
47
117
  backgroundTransparency = 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/react-clean-ui",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "A clean UI library for Roblox TypeScript projects",
5
5
  "main": "out/init.lua",
6
6
  "scripts": {