@nrbx/topbar-components 1.1.4 → 1.1.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.
package/out/components/icon.luau
CHANGED
|
@@ -3,7 +3,6 @@ local TS = _G[script]
|
|
|
3
3
|
local deepEquals = TS.import(script, TS.getModule(script, "@rbxts", "object-utils")).deepEquals
|
|
4
4
|
local _pretty_react_hooks = TS.import(script, TS.getModule(script, "@rbxts", "pretty-react-hooks").out)
|
|
5
5
|
local mapBinding = _pretty_react_hooks.mapBinding
|
|
6
|
-
local useAsyncEffect = _pretty_react_hooks.useAsyncEffect
|
|
7
6
|
local useMotion = _pretty_react_hooks.useMotion
|
|
8
7
|
local useMountEffect = _pretty_react_hooks.useMountEffect
|
|
9
8
|
local useUnmountEffect = _pretty_react_hooks.useUnmountEffect
|
|
@@ -149,7 +148,7 @@ local function Icon(componentProps)
|
|
|
149
148
|
local currentImage = stateful(props.imageId, currentState)
|
|
150
149
|
local currentText = stateful(props.text, currentState)
|
|
151
150
|
local previousQueryRef = useRef()
|
|
152
|
-
|
|
151
|
+
useEffect(function()
|
|
153
152
|
local currentQuery = {
|
|
154
153
|
Font = stateful(props.fontFace, currentState),
|
|
155
154
|
Size = stateful(props.textSize, currentState),
|
|
@@ -170,9 +169,10 @@ local function Icon(componentProps)
|
|
|
170
169
|
params.Font = stateful(props.fontFace, currentState)
|
|
171
170
|
params.Size = stateful(props.textSize, currentState)
|
|
172
171
|
params.Width = sizing.textMeasurementWidth
|
|
173
|
-
|
|
172
|
+
local bounds = TextService:GetTextBoundsAsync(params)
|
|
173
|
+
setTextBounds(bounds)
|
|
174
174
|
previousQueryRef.current = currentQuery
|
|
175
|
-
end
|
|
175
|
+
end, { currentText, props.fontFace, props.textSize, currentState })
|
|
176
176
|
local imageSizeOff = stateful(props.imageSizeOffset, currentState)
|
|
177
177
|
local forceHeight = if location.type == "dropdown" then stylesheet.dropdown.forceHeight else nil
|
|
178
178
|
local _condition = sizing.iconHeight
|
|
@@ -199,21 +199,22 @@ local function Icon(componentProps)
|
|
|
199
199
|
end
|
|
200
200
|
local imageToTextGap = _condition_3
|
|
201
201
|
local imageSize = iconHeight - contentPadY * 2 + imageSizeOff
|
|
202
|
-
local
|
|
203
|
-
local
|
|
204
|
-
|
|
202
|
+
local _exp = (if currentImage ~= "" and currentImage then imageSize else 0)
|
|
203
|
+
local _condition_4 = currentImage
|
|
204
|
+
if _condition_4 ~= "" and _condition_4 then
|
|
205
|
+
_condition_4 = currentText
|
|
206
|
+
end
|
|
207
|
+
local contentWidth = _exp + (if _condition_4 ~= "" and _condition_4 then imageToTextGap else 0) + (if currentText ~= "" and currentText then textBounds.X else 0)
|
|
205
208
|
local autoWidth = contentWidth + contentPadX * 2
|
|
206
|
-
local
|
|
207
|
-
if not (
|
|
208
|
-
|
|
209
|
-
if not (
|
|
210
|
-
|
|
209
|
+
local _condition_5 = props.iconWidth
|
|
210
|
+
if not (_condition_5 ~= 0 and _condition_5 == _condition_5 and _condition_5) then
|
|
211
|
+
_condition_5 = sizing.iconWidth
|
|
212
|
+
if not (_condition_5 ~= 0 and _condition_5 == _condition_5 and _condition_5) then
|
|
213
|
+
_condition_5 = math.max(iconHeight, autoWidth)
|
|
211
214
|
end
|
|
212
215
|
end
|
|
213
|
-
local iconWidth =
|
|
216
|
+
local iconWidth = _condition_5
|
|
214
217
|
local iconSize = Vector2.new(iconWidth, iconHeight)
|
|
215
|
-
local imagePosY = (iconHeight - imageSize) / 2 + imageSizeOff * -0.5
|
|
216
|
-
local textLabelPos = UDim2.new(0, if currentImage ~= "" and currentImage then contentPadX + imageSize + imageToTextGap else contentPadX, 0.5, 0)
|
|
217
218
|
useEffect(function()
|
|
218
219
|
if props.static then
|
|
219
220
|
return nil
|
|
@@ -259,7 +260,10 @@ local function Icon(componentProps)
|
|
|
259
260
|
Size = UDim2.new(1, 0, 0, iconSize.Y),
|
|
260
261
|
Active = not props.static,
|
|
261
262
|
Selectable = not props.static,
|
|
262
|
-
AutoButtonColor =
|
|
263
|
+
AutoButtonColor = false,
|
|
264
|
+
Text = "",
|
|
265
|
+
BackgroundTransparency = animatedProps.backgroundTransparency,
|
|
266
|
+
BackgroundColor3 = animatedProps.backgroundColor,
|
|
263
267
|
Event = {
|
|
264
268
|
MouseButton1Click = function()
|
|
265
269
|
if props.static then
|
|
@@ -304,16 +308,26 @@ local function Icon(componentProps)
|
|
|
304
308
|
props.unhover()
|
|
305
309
|
end,
|
|
306
310
|
},
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
+
}, React.createElement("uipadding", {
|
|
312
|
+
PaddingLeft = UDim.new(0, contentPadX),
|
|
313
|
+
PaddingRight = UDim.new(0, contentPadX),
|
|
314
|
+
PaddingTop = UDim.new(0, contentPadY),
|
|
315
|
+
PaddingBottom = UDim.new(0, contentPadY),
|
|
316
|
+
}), React.createElement("frame", {
|
|
317
|
+
Size = UDim2.fromScale(1, 1),
|
|
318
|
+
BackgroundTransparency = 1,
|
|
319
|
+
}, React.createElement("uilistlayout", {
|
|
320
|
+
FillDirection = Enum.FillDirection.Horizontal,
|
|
321
|
+
VerticalAlignment = Enum.VerticalAlignment.Center,
|
|
322
|
+
HorizontalAlignment = Enum.HorizontalAlignment.Center,
|
|
323
|
+
Padding = UDim.new(0, imageToTextGap),
|
|
324
|
+
SortOrder = Enum.SortOrder.LayoutOrder,
|
|
325
|
+
}), currentImage ~= nil and currentImage ~= "" and (React.createElement("imagelabel", {
|
|
311
326
|
Size = UDim2.fromOffset(imageSize, imageSize),
|
|
312
|
-
Position = UDim2.fromOffset(contentPadX, imagePosY),
|
|
313
327
|
Image = currentImage,
|
|
314
328
|
BackgroundTransparency = 1,
|
|
315
|
-
ImageColor3 =
|
|
316
|
-
ImageTransparency =
|
|
329
|
+
ImageColor3 = animatedProps.imageColor,
|
|
330
|
+
ImageTransparency = animatedProps.imageTransparency,
|
|
317
331
|
ImageRectOffset = stateful(props.imageRectOffset, currentState),
|
|
318
332
|
ImageRectSize = stateful(props.imageRectSize, currentState),
|
|
319
333
|
})), currentText ~= nil and currentText ~= "" and (React.createElement("textlabel", {
|
|
@@ -321,9 +335,8 @@ local function Icon(componentProps)
|
|
|
321
335
|
TextSize = stateful(props.textSize, currentState),
|
|
322
336
|
TextColor3 = stateful(props.textColor, currentState),
|
|
323
337
|
TextWrapped = false,
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
Position = textLabelPos,
|
|
338
|
+
Size = UDim2.fromOffset(textBounds.X, 0),
|
|
339
|
+
AutomaticSize = Enum.AutomaticSize.Y,
|
|
327
340
|
TextXAlignment = stateful(props.textAlignment, currentState),
|
|
328
341
|
RichText = stateful(props.richText, currentState),
|
|
329
342
|
BackgroundTransparency = 1,
|
|
@@ -332,7 +345,7 @@ local function Icon(componentProps)
|
|
|
332
345
|
Thickness = stateful(props.strokeThickness, currentState),
|
|
333
346
|
Color = stateful(props.strokeColor, currentState),
|
|
334
347
|
Transparency = stateful(props.strokeTransparency, currentState),
|
|
335
|
-
}))), React.createElement("uicorner", {
|
|
348
|
+
})))), children, React.createElement("uicorner", {
|
|
336
349
|
CornerRadius = if location.type == "dropdown" then stylesheet.dropdown.iconCornerRadius else stateful(props.cornerRadius, currentState),
|
|
337
350
|
}), props.disabled and (React.createElement("frame", {
|
|
338
351
|
Size = UDim2.fromScale(1, 1),
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
-- Compiled with roblox-ts v3.0.0
|
|
2
2
|
local TS = _G[script]
|
|
3
|
-
local
|
|
4
|
-
local
|
|
3
|
+
local _react = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
|
+
local useEffect = _react.useEffect
|
|
5
|
+
local useState = _react.useState
|
|
5
6
|
local _services = TS.import(script, TS.getModule(script, "@rbxts", "services"))
|
|
6
7
|
local Players = _services.Players
|
|
7
8
|
local VoiceChatService = _services.VoiceChatService
|
|
8
9
|
local function useVoicechatEnabled()
|
|
9
10
|
local enabled, setEnabled = useState(false)
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
useEffect(function()
|
|
12
|
+
TS.Promise.try(function()
|
|
13
|
+
return VoiceChatService:IsVoiceEnabledForUserIdAsync(Players.LocalPlayer)
|
|
14
|
+
end):andThen(setEnabled)
|
|
15
|
+
end, {})
|
|
13
16
|
return enabled
|
|
14
17
|
end
|
|
15
18
|
return {
|
package/out/style.luau
CHANGED
|
@@ -54,8 +54,8 @@ local DefaultStylesheet = {
|
|
|
54
54
|
toggleKey = Enum.KeyCode.Unknown,
|
|
55
55
|
notificationCount = 0,
|
|
56
56
|
iconWidth = 0,
|
|
57
|
-
contentPaddingX =
|
|
58
|
-
contentPaddingY =
|
|
57
|
+
contentPaddingX = 2,
|
|
58
|
+
contentPaddingY = 2,
|
|
59
59
|
imageToTextSpacing = 6,
|
|
60
60
|
selected = noop,
|
|
61
61
|
deselected = noop,
|
|
@@ -105,8 +105,8 @@ local DefaultStylesheet = {
|
|
|
105
105
|
imageToTextSpacing = 6,
|
|
106
106
|
iconHorizontalPadding = 6,
|
|
107
107
|
iconVerticalPadding = 6,
|
|
108
|
-
contentPaddingX =
|
|
109
|
-
contentPaddingY =
|
|
108
|
+
contentPaddingX = 2,
|
|
109
|
+
contentPaddingY = 2,
|
|
110
110
|
textMeasurementWidth = 99999,
|
|
111
111
|
minLabelWidthPadding = 12,
|
|
112
112
|
buttonLabelHeightFraction = 0.8,
|