@nrbx/topbar-components 1.0.10 → 1.0.12

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,4 +1,5 @@
1
1
  import React from '@rbxts/react';
2
+ import { type Stylesheet } from '../style';
2
3
  export interface IconProps extends React.PropsWithChildren {
3
4
  backgroundTransparency?: StateDependent<number>;
4
5
  backgroundColor?: StateDependent<Color3>;
@@ -29,7 +30,7 @@ export interface IconProps extends React.PropsWithChildren {
29
30
  /** When true, dulls the text and icon with a dimming overlay */
30
31
  disabled?: boolean;
31
32
  /** Per-icon stylesheet overrides — merged above the global stylesheet but below explicit props */
32
- style?: Partial<IconProps>;
33
+ style?: Partial<IconProps & Stylesheet['sizing']>;
33
34
  selected?: () => void;
34
35
  deselected?: () => void;
35
36
  hover?: () => void;
@@ -39,24 +39,30 @@ local function Icon(componentProps)
39
39
  local stylesheet = useStylesheet()
40
40
  local _arg0 = location.type ~= "icon"
41
41
  assert(_arg0, "Icons cannot be nested")
42
- local _object = table.clone(stylesheet.icon)
42
+ local _object = table.clone(stylesheet.sizing)
43
43
  setmetatable(_object, nil)
44
- for _k, _v in componentProps do
44
+ for _k, _v in (style or {}) do
45
45
  _object[_k] = _v
46
46
  end
47
- local animatedProps = useAnimateableProps(currentState, _object, unpack(ANIMATEABLE))
47
+ local sizing = _object
48
48
  local _object_1 = table.clone(stylesheet.icon)
49
49
  setmetatable(_object_1, nil)
50
- for _k, _v in (style or {}) do
50
+ for _k, _v in componentProps do
51
51
  _object_1[_k] = _v
52
52
  end
53
+ local animatedProps = useAnimateableProps(currentState, _object_1, unpack(ANIMATEABLE))
54
+ local _object_2 = table.clone(stylesheet.icon)
55
+ setmetatable(_object_2, nil)
56
+ for _k, _v in (style or {}) do
57
+ _object_2[_k] = _v
58
+ end
53
59
  for _k, _v in componentProps do
54
- _object_1[_k] = _v
60
+ _object_2[_k] = _v
55
61
  end
56
62
  for _k, _v in animatedProps do
57
- _object_1[_k] = _v
63
+ _object_2[_k] = _v
58
64
  end
59
- local props = _object_1
65
+ local props = _object_2
60
66
  useMountEffect(function()
61
67
  if props.static then
62
68
  return nil
@@ -116,31 +122,31 @@ local function Icon(componentProps)
116
122
  params.Text = currentText
117
123
  params.Font = stateful(props.fontFace, currentState)
118
124
  params.Size = stateful(props.textSize, currentState)
119
- params.Width = stylesheet.sizing.textMeasurementWidth
125
+ params.Width = sizing.textMeasurementWidth
120
126
  setTextBounds(TextService:GetTextBoundsAsync(params))
121
127
  previousQueryRef.current = currentQuery
122
128
  end), { currentText, props.fontFace, props.textSize, currentState })
123
129
  local imageSizeOff = stateful(props.imageSizeOffset, currentState)
124
130
  local forceHeight = if location.type == "dropdown" then stylesheet.dropdown.forceHeight else nil
125
- local _condition = stylesheet.sizing.iconHeight
131
+ local _condition = sizing.iconHeight
126
132
  if _condition == nil then
127
133
  _condition = forceHeight
128
134
  if _condition == nil then
129
- _condition = inset.Height - stylesheet.sizing.iconVerticalPadding * 2
135
+ _condition = inset.Height - sizing.iconVerticalPadding * 2
130
136
  end
131
137
  end
132
138
  local iconHeight = _condition
133
- local imageSize = iconHeight - stylesheet.sizing.imagePadding * 2 + imageSizeOff
134
- local minLabelWidth = if location.type == "dropdown" then location.desiredIconWidth - stylesheet.sizing.minLabelWidthPadding else inset.Height - stylesheet.sizing.iconHorizontalPadding * 2
139
+ local imageSize = iconHeight - sizing.imagePadding * 2 + imageSizeOff
140
+ local minLabelWidth = if location.type == "dropdown" then location.desiredIconWidth - sizing.minLabelWidthPadding else inset.Height - sizing.iconHorizontalPadding * 2
135
141
  local accumulatedLabelWidth = if currentImage ~= "" and currentImage then textBounds.X else math.max(textBounds.X, minLabelWidth)
136
- local _exp = textBounds.X + stylesheet.sizing.labelPadding * 2
142
+ local _exp = textBounds.X + sizing.labelPadding * 2
137
143
  local _condition_1 = currentImage
138
144
  if _condition_1 ~= "" and _condition_1 then
139
145
  _condition_1 = textBounds.X ~= 0
140
146
  end
141
- local iconSize = Vector2.new(math.max(iconHeight, _exp + (if _condition_1 ~= "" and _condition_1 then imageSize + stylesheet.sizing.imageToTextSpacing else 0)), iconHeight)
142
- local imagePos = stylesheet.sizing.imagePadding + imageSizeOff * -0.5
143
- local textLabelPos = UDim2.new(0, if currentImage ~= "" and currentImage then imageSize + stylesheet.sizing.imagePadding * 2 else stylesheet.sizing.labelPadding, 0.5, 0)
147
+ local iconSize = Vector2.new(math.max(iconHeight, _exp + (if _condition_1 ~= "" and _condition_1 then imageSize + sizing.imageToTextSpacing else 0)), iconHeight)
148
+ local imagePos = sizing.imagePadding + imageSizeOff * -0.5
149
+ local textLabelPos = UDim2.new(0, if currentImage ~= "" and currentImage then imageSize + sizing.imagePadding * 2 else sizing.labelPadding, 0.5, 0)
144
150
  useEffect(function()
145
151
  if props.static then
146
152
  return nil
@@ -236,7 +242,7 @@ local function Icon(componentProps)
236
242
  TextColor3 = stateful(props.textColor, currentState),
237
243
  TextWrapped = false,
238
244
  AnchorPoint = Vector2.new(0, 0.5),
239
- Size = UDim2.new(0, accumulatedLabelWidth, stylesheet.sizing.buttonLabelHeightFraction, 0),
245
+ Size = UDim2.new(0, accumulatedLabelWidth, sizing.buttonLabelHeightFraction, 0),
240
246
  Position = textLabelPos,
241
247
  TextXAlignment = stateful(props.textAlignment, currentState),
242
248
  RichText = stateful(props.richText, currentState),
@@ -254,8 +260,8 @@ local function Icon(componentProps)
254
260
  }), props.disabled and (React.createElement("frame", {
255
261
  key = "DisabledOverlay",
256
262
  Size = UDim2.fromScale(1, 1),
257
- BackgroundTransparency = stylesheet.sizing.disabledOverlayTransparency,
258
- BackgroundColor3 = stylesheet.sizing.disabledOverlayColor,
263
+ BackgroundTransparency = sizing.disabledOverlayTransparency,
264
+ BackgroundColor3 = sizing.disabledOverlayColor,
259
265
  BorderSizePixel = 0,
260
266
  ZIndex = 10,
261
267
  })))))
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nrbx/topbar-components",
3
- "version": "1.0.10",
4
- "main": "out/init.lua",
3
+ "version": "1.0.12",
4
+ "main": "out/init.luau",
5
5
  "scripts": {
6
6
  "build": "rbxtsc",
7
7
  "watch": "rbxtsc -w",