@nrbx/topbar-components 1.2.1 → 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 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
@@ -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, 0, 0.5, 0),
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()
@@ -323,6 +346,7 @@ 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))
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.Unknown,
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrbx/topbar-components",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "main": "out/init.luau",
5
5
  "scripts": {
6
6
  "build": "rbxtsc",