@nrbx/topbar-components 1.2.0 → 1.2.2
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/README.md +1 -0
- package/out/components/provider.d.ts +0 -12
- package/out/components/provider.luau +26 -5
- package/out/components/stylesheet.luau +1 -1
- package/out/style.d.ts +6 -0
- package/out/style.luau +2 -1
- package/out/utilities/merge.d.ts +1 -1
- package/out/utilities/merge.luau +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -289,6 +289,7 @@ The stylesheet exposes the following sections for full control:
|
|
|
289
289
|
sizeScale: new Vector2(1, 1),
|
|
290
290
|
insetHeightOffset: 0,
|
|
291
291
|
forceFrameHeight: undefined, // override auto height (e.g. 55)
|
|
292
|
+
centreOffset: undefined, // right-shift for centre dock (auto: 0 on new topbar, 12 on old)
|
|
292
293
|
},
|
|
293
294
|
|
|
294
295
|
// Icon internal sizing
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import React from '@rbxts/react';
|
|
2
2
|
export type SelectionMode = 'Single' | 'Multiple';
|
|
3
|
-
/** Docks icons to the left side of the topbar. */
|
|
4
|
-
export declare function LeftDock({ children, frameRef }: React.PropsWithChildren & {
|
|
5
|
-
frameRef?: React.Ref<Frame>;
|
|
6
|
-
}): React.JSX.Element;
|
|
7
|
-
/** Docks icons to the center of the topbar. */
|
|
8
|
-
export declare function CenterDock({ children, frameRef }: React.PropsWithChildren & {
|
|
9
|
-
frameRef?: React.Ref<Frame>;
|
|
10
|
-
}): React.JSX.Element;
|
|
11
|
-
/** Docks icons to the right side of the topbar. */
|
|
12
|
-
export declare function RightDock({ children, frameRef }: React.PropsWithChildren & {
|
|
13
|
-
frameRef?: React.Ref<Frame>;
|
|
14
|
-
}): React.JSX.Element;
|
|
15
3
|
interface ProviderProps extends React.PropsWithChildren {
|
|
16
4
|
/**
|
|
17
5
|
* How icon selection works across the topbar.
|
|
@@ -53,11 +53,15 @@ end
|
|
|
53
53
|
local function CenterDock(_param)
|
|
54
54
|
local children = _param.children
|
|
55
55
|
local frameRef = _param.frameRef
|
|
56
|
+
local centreOffset = _param.centreOffset
|
|
57
|
+
if centreOffset == nil then
|
|
58
|
+
centreOffset = 0
|
|
59
|
+
end
|
|
56
60
|
local stylesheet = useStylesheet().provider
|
|
57
61
|
return React.createElement(DockFrame, {
|
|
58
62
|
frameRef = frameRef,
|
|
59
63
|
anchor = Vector2.new(0.5, 0.5),
|
|
60
|
-
position = UDim2.new(0.5,
|
|
64
|
+
position = UDim2.new(0.5, centreOffset, 0.5, 0),
|
|
61
65
|
paddingLeft = UDim.new(0, stylesheet.iconGroupSpacing),
|
|
62
66
|
paddingRight = UDim.new(0, stylesheet.iconGroupSpacing),
|
|
63
67
|
children = children,
|
|
@@ -100,6 +104,25 @@ local function TopbarProvider(_param)
|
|
|
100
104
|
local inset = useGuiInset()
|
|
101
105
|
local voiceChatEnabled = useVoicechatEnabled()
|
|
102
106
|
local stylesheet = useStylesheet().provider
|
|
107
|
+
--[[
|
|
108
|
+
*
|
|
109
|
+
* Pixel offset that shifts the centre dock right to visually account for
|
|
110
|
+
* Roblox's default left-side CoreGui icons (menu button, chips bar, etc.).
|
|
111
|
+
*
|
|
112
|
+
* Mirrors TopbarPlus's startInset logic:
|
|
113
|
+
* - New topbar (height > 36): no offset — icons are mathematically centered
|
|
114
|
+
* - Old topbar (height ≤ 36): 12px offset to account for the classic menu button
|
|
115
|
+
*
|
|
116
|
+
* Set `centreOffset` explicitly in the stylesheet to override.
|
|
117
|
+
|
|
118
|
+
]]
|
|
119
|
+
local centreOffset = useMemo(function()
|
|
120
|
+
if stylesheet.centreOffset ~= nil then
|
|
121
|
+
return stylesheet.centreOffset
|
|
122
|
+
end
|
|
123
|
+
local isOldTopbar = inset.Height <= 36
|
|
124
|
+
return if isOldTopbar then 12 else 0
|
|
125
|
+
end, { stylesheet.centreOffset, inset.Height })
|
|
103
126
|
local containerRef = useRef()
|
|
104
127
|
local leftDockRef = useRef()
|
|
105
128
|
local centerDockRef = useRef()
|
|
@@ -255,7 +278,7 @@ local function TopbarProvider(_param)
|
|
|
255
278
|
table.insert(overflowed, _arg0)
|
|
256
279
|
end
|
|
257
280
|
end
|
|
258
|
-
return React.createElement(React.
|
|
281
|
+
return React.createElement(React.Fragment, nil, visible, React.createElement(Overflow, nil, overflowed))
|
|
259
282
|
end
|
|
260
283
|
local hasBetaLabel = gameVoiceChatEnabled and voiceChatEnabled
|
|
261
284
|
local leftPadding = if hasBetaLabel then stylesheet.paddingLeft + 16 else stylesheet.paddingLeft
|
|
@@ -323,13 +346,11 @@ local function TopbarProvider(_param)
|
|
|
323
346
|
frameRef = leftDockRef,
|
|
324
347
|
}, buildDockContent(sorted.groups.left, "left")), React.createElement(CenterDock, {
|
|
325
348
|
frameRef = centerDockRef,
|
|
349
|
+
centreOffset = centreOffset,
|
|
326
350
|
}, buildDockContent(sorted.groups.centre, "centre")), React.createElement(RightDock, {
|
|
327
351
|
frameRef = rightDockRef,
|
|
328
352
|
}, buildDockContent(sorted.groups.right, "right")), sorted.other))
|
|
329
353
|
end
|
|
330
354
|
return {
|
|
331
|
-
LeftDock = LeftDock,
|
|
332
|
-
CenterDock = CenterDock,
|
|
333
|
-
RightDock = RightDock,
|
|
334
355
|
TopbarProvider = TopbarProvider,
|
|
335
356
|
}
|
|
@@ -3,7 +3,7 @@ local TS = _G[script]
|
|
|
3
3
|
local React = TS.import(script, TS.getModule(script, "@rbxts", "react"))
|
|
4
4
|
local StylesheetContext = TS.import(script, script.Parent.Parent, "context").StylesheetContext
|
|
5
5
|
local DefaultStylesheet = TS.import(script, script.Parent.Parent, "style").DefaultStylesheet
|
|
6
|
-
local reconcile = TS.import(script, script.Parent.Parent, "utilities", "merge").
|
|
6
|
+
local reconcile = TS.import(script, script.Parent.Parent, "utilities", "merge").reconcile
|
|
7
7
|
--[[
|
|
8
8
|
*
|
|
9
9
|
* Applies a custom stylesheet to all descendant topbar components.
|
package/out/style.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ export interface Stylesheet {
|
|
|
36
36
|
iconGroupSpacing: number;
|
|
37
37
|
/** Override for the topbar frame height. Uses inset height when `undefined`. */
|
|
38
38
|
forceFrameHeight: number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Pixel offset that shifts the centre dock to the right to visually
|
|
41
|
+
* account for Roblox's default left-side CoreGui icons (menu button,
|
|
42
|
+
* chips bar, etc.). Auto-detected from the topbar type when `undefined`.
|
|
43
|
+
*/
|
|
44
|
+
centreOffset: number | undefined;
|
|
39
45
|
};
|
|
40
46
|
/** Sizing and spacing values shared by all icons. */
|
|
41
47
|
sizing: {
|
package/out/style.luau
CHANGED
|
@@ -52,7 +52,7 @@ local DefaultStylesheet = {
|
|
|
52
52
|
toggleStateOnClick = true,
|
|
53
53
|
static = false,
|
|
54
54
|
disabled = false,
|
|
55
|
-
toggleKey = Enum.KeyCode.
|
|
55
|
+
toggleKey = Enum.KeyCode.None,
|
|
56
56
|
notificationCount = 0,
|
|
57
57
|
iconWidth = 0,
|
|
58
58
|
contentPaddingX = 10,
|
|
@@ -98,6 +98,7 @@ local DefaultStylesheet = {
|
|
|
98
98
|
insetHeightOffset = 0,
|
|
99
99
|
iconGroupSpacing = 0,
|
|
100
100
|
forceFrameHeight = nil,
|
|
101
|
+
centreOffset = nil,
|
|
101
102
|
},
|
|
102
103
|
sizing = {
|
|
103
104
|
iconHeight = nil,
|
package/out/utilities/merge.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare function reconcile(target: object, template: object): object;
|
package/out/utilities/merge.luau
CHANGED