@nrbx/topbar-components 1.0.5 → 1.0.7

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.
@@ -1,5 +1,4 @@
1
1
  import React from '@rbxts/react';
2
- export type Dock = 'Left' | 'Center' | 'Right';
3
2
  export interface IconProps extends React.PropsWithChildren {
4
3
  backgroundTransparency?: StateDependent<number>;
5
4
  backgroundColor?: StateDependent<Color3>;
@@ -25,7 +24,6 @@ export interface IconProps extends React.PropsWithChildren {
25
24
  textAlignment?: StateDependent<Enum.TextXAlignment>;
26
25
  richText?: StateDependent<boolean>;
27
26
  toggleStateOnClick?: boolean;
28
- dock?: Dock;
29
27
  /** When true, renders as a non-interactive label (no clicks, no hovers, no state changes) */
30
28
  static?: boolean;
31
29
  /** When true, dulls the text and icon with a dimming overlay */
@@ -1,8 +1,11 @@
1
1
  import React from '@rbxts/react';
2
2
  export type SelectionMode = 'Single' | 'Multiple';
3
+ export declare function LeftDock({ children }: React.PropsWithChildren): React.JSX.Element;
4
+ export declare function CenterDock({ children }: React.PropsWithChildren): React.JSX.Element;
5
+ export declare function RightDock({ children }: React.PropsWithChildren): React.JSX.Element;
3
6
  interface ProviderProps extends React.PropsWithChildren {
4
7
  selectionMode?: SelectionMode;
5
8
  gameVoiceChatEnabled?: boolean;
6
9
  }
7
- export declare function TopbarProvider({ selectionMode, gameVoiceChatEnabled, children }: ProviderProps): React.JSX.Element;
10
+ export declare function TopbarProvider({ selectionMode, gameVoiceChatEnabled, children, }: ProviderProps): React.JSX.Element;
8
11
  export {};
@@ -9,49 +9,55 @@ local useStylesheet = _context.useStylesheet
9
9
  local useGuiInset = TS.import(script, script.Parent.Parent, "hooks", "use-gui-inset").useGuiInset
10
10
  local useVoicechatEnabled = TS.import(script, script.Parent.Parent, "hooks", "use-voicechat-enabled").useVoicechatEnabled
11
11
  local debugLog = TS.import(script, script.Parent.Parent, "utilities", "debug").debugLog
12
- local function sortByDock(children)
13
- local left = {}
14
- local center = {}
15
- local right = {}
16
- local li = 0
17
- local ci = 0
18
- local ri = 0
19
- React.Children.forEach(children, function(child)
20
- if child == nil then
21
- return nil
22
- end
23
- local childObj = child
24
- local props = childObj.props
25
- local _dockValue = props
26
- if _dockValue ~= nil then
27
- _dockValue = _dockValue.dock
28
- end
29
- local dockValue = _dockValue
30
- local _exp = `sortByDock child: hasProps={props ~= nil}`
31
- local _result = props
32
- if _result ~= nil then
33
- _result = _result.text
34
- end
35
- local _exp_1 = `text={_result}`
36
- local _result_1 = props
37
- if _result_1 ~= nil then
38
- _result_1 = _result_1.static
39
- end
40
- debugLog(_exp, _exp_1, `static={_result_1}`, `dock="{dockValue}"`, `→ {if dockValue == "Center" then "Center" elseif dockValue == "Right" then "Right" else "Left"}`)
41
- if dockValue == "Center" then
42
- center[ci + 1] = child
43
- ci += 1
44
- elseif dockValue == "Right" then
45
- right[ri + 1] = child
46
- ri += 1
47
- else
48
- left[li + 1] = child
49
- li += 1
50
- end
51
- end)
52
- debugLog(`sortByDock totals: left={#left} center={#center} right={#right}`)
53
- return { left, center, right }
12
+ -- ── Dock container components ───────────────────────────────────────────────
13
+ local function DockFrame(props)
14
+ local stylesheet = useStylesheet().provider
15
+ return React.createElement("frame", {
16
+ BackgroundTransparency = 1,
17
+ AnchorPoint = props.anchor,
18
+ Position = props.position,
19
+ Size = UDim2.fromScale(0, 1),
20
+ AutomaticSize = Enum.AutomaticSize.X,
21
+ }, (props.paddingLeft ~= nil or props.paddingRight ~= nil) and (React.createElement("uipadding", {
22
+ PaddingLeft = props.paddingLeft or UDim.new(0, 0),
23
+ PaddingRight = props.paddingRight or UDim.new(0, 0),
24
+ })), React.createElement("uilistlayout", {
25
+ FillDirection = Enum.FillDirection.Horizontal,
26
+ SortOrder = Enum.SortOrder.LayoutOrder,
27
+ Padding = UDim.new(0, stylesheet.iconSpacing),
28
+ VerticalAlignment = Enum.VerticalAlignment.Center,
29
+ }), props.children)
30
+ end
31
+ local function LeftDock(_param)
32
+ local children = _param.children
33
+ return React.createElement(DockFrame, {
34
+ anchor = Vector2.new(0, 0.5),
35
+ position = UDim2.new(0, 0, 0.5, 0),
36
+ children = children,
37
+ })
54
38
  end
39
+ local function CenterDock(_param)
40
+ local children = _param.children
41
+ local stylesheet = useStylesheet().provider
42
+ return React.createElement(DockFrame, {
43
+ anchor = Vector2.new(0.5, 0.5),
44
+ position = UDim2.new(0.5, 0, 0.5, 0),
45
+ paddingLeft = UDim.new(0, stylesheet.iconGroupSpacing),
46
+ paddingRight = UDim.new(0, stylesheet.iconGroupSpacing),
47
+ children = children,
48
+ })
49
+ end
50
+ local function RightDock(_param)
51
+ local children = _param.children
52
+ local stylesheet = useStylesheet().provider
53
+ return React.createElement(DockFrame, {
54
+ anchor = Vector2.new(1, 0.5),
55
+ position = UDim2.new(1, 0, 0.5, 0),
56
+ paddingLeft = UDim.new(0, stylesheet.iconGroupSpacing),
57
+ children = children,
58
+ })
59
+ end
60
+ -- ── Provider ────────────────────────────────────────────────────────────────
55
61
  local function TopbarProvider(_param)
56
62
  local selectionMode = _param.selectionMode
57
63
  if selectionMode == nil then
@@ -68,12 +74,6 @@ local function TopbarProvider(_param)
68
74
  local rawHeight = inset.Height - stylesheet.insetHeightOffset
69
75
  local frameHeight = if stylesheet.forceFrameHeight ~= nil then stylesheet.forceFrameHeight else rawHeight
70
76
  debugLog(`TopbarProvider frame: inset.Height={inset.Height}, inset.Width={inset.Width}`, `insetHeightOffset={stylesheet.insetHeightOffset}`, `rawHeight={rawHeight}`, `forceFrameHeight={stylesheet.forceFrameHeight}`, `finalHeight={frameHeight}`, `sizeScale=({stylesheet.sizeScale.X}, {stylesheet.sizeScale.Y})`)
71
- local _binding = sortByDock(children)
72
- local leftChildren = _binding[1]
73
- local centerChildren = _binding[2]
74
- local rightChildren = _binding[3]
75
- local hasCenter = #centerChildren > 0
76
- local hasRight = #rightChildren > 0
77
77
  return React.createElement(LocationContext.Provider, {
78
78
  value = {
79
79
  type = "provider",
@@ -132,49 +132,11 @@ local function TopbarProvider(_param)
132
132
  PaddingRight = UDim.new(0, stylesheet.paddingRight),
133
133
  PaddingTop = UDim.new(0, stylesheet.paddingTop),
134
134
  PaddingBottom = UDim.new(0, stylesheet.paddingBottom),
135
- }), React.createElement("frame", {
136
- key = "LeftDock",
137
- BackgroundTransparency = 1,
138
- AnchorPoint = Vector2.new(0, 0.5),
139
- Position = UDim2.new(0, 0, 0.5, 0),
140
- Size = UDim2.fromScale(0, 1),
141
- AutomaticSize = Enum.AutomaticSize.X,
142
- }, React.createElement("uilistlayout", {
143
- FillDirection = Enum.FillDirection.Horizontal,
144
- SortOrder = Enum.SortOrder.LayoutOrder,
145
- Padding = UDim.new(0, stylesheet.iconSpacing),
146
- VerticalAlignment = Enum.VerticalAlignment.Center,
147
- }), leftChildren), hasCenter and (React.createElement("frame", {
148
- key = "CenterDock",
149
- BackgroundTransparency = 1,
150
- AnchorPoint = Vector2.new(0.5, 0.5),
151
- Position = UDim2.new(0.5, 0, 0.5, 0),
152
- Size = UDim2.fromScale(0, 1),
153
- AutomaticSize = Enum.AutomaticSize.X,
154
- }, React.createElement("uipadding", {
155
- PaddingLeft = UDim.new(0, stylesheet.iconGroupSpacing),
156
- PaddingRight = UDim.new(0, stylesheet.iconGroupSpacing),
157
- }), React.createElement("uilistlayout", {
158
- FillDirection = Enum.FillDirection.Horizontal,
159
- SortOrder = Enum.SortOrder.LayoutOrder,
160
- Padding = UDim.new(0, stylesheet.iconSpacing),
161
- VerticalAlignment = Enum.VerticalAlignment.Center,
162
- }), centerChildren)), hasRight and (React.createElement("frame", {
163
- key = "RightDock",
164
- BackgroundTransparency = 1,
165
- AnchorPoint = Vector2.new(1, 0.5),
166
- Position = UDim2.new(1, 0, 0.5, 0),
167
- Size = UDim2.fromScale(0, 1),
168
- AutomaticSize = Enum.AutomaticSize.X,
169
- }, React.createElement("uipadding", {
170
- PaddingLeft = UDim.new(0, stylesheet.iconGroupSpacing),
171
- }), React.createElement("uilistlayout", {
172
- FillDirection = Enum.FillDirection.Horizontal,
173
- SortOrder = Enum.SortOrder.LayoutOrder,
174
- Padding = UDim.new(0, stylesheet.iconSpacing),
175
- VerticalAlignment = Enum.VerticalAlignment.Center,
176
- }), rightChildren))))
135
+ }), children))
177
136
  end
178
137
  return {
138
+ LeftDock = LeftDock,
139
+ CenterDock = CenterDock,
140
+ RightDock = RightDock,
179
141
  TopbarProvider = TopbarProvider,
180
142
  }
package/out/style.luau CHANGED
@@ -48,7 +48,6 @@ local DefaultStylesheet = {
48
48
  defaultState = "deselected",
49
49
  forcedState = "deselected",
50
50
  toggleStateOnClick = true,
51
- dock = "Left",
52
51
  static = false,
53
52
  disabled = false,
54
53
  selected = noop,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nrbx/topbar-components",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "main": "out/init.lua",
5
5
  "scripts": {
6
6
  "build": "rbxtsc",