@rbxts/uiblox 0.2.0-alpha.30 → 0.2.0-alpha.31

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.
@@ -5,5 +5,5 @@ export { applyVariants, CompoundVariant } from "./variants";
5
5
  export { default as componentStyles } from "./componentStyles";
6
6
  export { resolveResponsive, Responsive } from "../../../hooks/breakpoints";
7
7
  export { clearStyleCaches, createStyleCache, styleDepsKey } from "./styleCache";
8
- export { resolveSx, resolvePaletteToken, PaletteToken, ResolvedSx, SxColor, SxInput } from "./resolveSx";
8
+ export { resolveSx, resolvePaletteToken, PaletteToken, ResolvedSx, SxColor, SxGradient, SxInput } from "./resolveSx";
9
9
  export { interactionStyle, InteractionSlots, InteractionState, resolveStyle, StyleSelectorKey, StyleState, StyleWithSelectors, } from "./resolveStyle";
@@ -33,6 +33,11 @@ interface SxTheme {
33
33
  };
34
34
  }
35
35
  export type SxColor = PaletteToken | Color3;
36
+ /** Evenly spaced color stops on a UIGradient child. */
37
+ export interface SxGradient {
38
+ colors: SxColor[];
39
+ rotation?: number;
40
+ }
36
41
  /** CSS-like shorthands + pass-through Instance props. No CSS string parser. */
37
42
  export type SxInput = {
38
43
  width?: Responsive<number | UDim | UDim2>;
@@ -73,6 +78,7 @@ export type SxInput = {
73
78
  visible?: Responsive<boolean>;
74
79
  zIndex?: Responsive<number>;
75
80
  z?: Responsive<number>;
81
+ gradient?: Responsive<SxGradient>;
76
82
  _hover?: SxInput;
77
83
  _pressed?: SxInput;
78
84
  _focus?: SxInput;
@@ -101,6 +107,10 @@ export interface ResolvedSx {
101
107
  CornerRadius: UDim;
102
108
  };
103
109
  gap?: number;
110
+ gradient?: {
111
+ Color: ColorSequence;
112
+ Rotation: number;
113
+ };
104
114
  }
105
115
  /**
106
116
  * Maps sx shorthands / tokens → Instance props (+ UIPadding / UICorner / gap helpers).
@@ -106,7 +106,9 @@ local SHORTHAND = {
106
106
  visible = true,
107
107
  zIndex = true,
108
108
  z = true,
109
+ gradient = true,
109
110
  }
111
+ --* Evenly spaced color stops on a UIGradient child.
110
112
  --* CSS-like shorthands + pass-through Instance props. No CSS string parser.
111
113
  local function pick(value, width)
112
114
  if value == nil then
@@ -440,6 +442,46 @@ local function resolveSx(theme, sx, width)
440
442
  if zIndex ~= nil then
441
443
  root.ZIndex = zIndex
442
444
  end
445
+ local gradientVal = pick(sx.gradient, width)
446
+ local gradient
447
+ if gradientVal ~= nil and #gradientVal.colors > 0 then
448
+ local _exp = gradientVal.colors
449
+ -- ▼ ReadonlyArray.map ▼
450
+ local _newValue = table.create(#_exp)
451
+ local _callback = function(token)
452
+ return resolvePaletteToken(theme.palette, token)
453
+ end
454
+ for _k, _v in _exp do
455
+ _newValue[_k] = _callback(_v, _k - 1, _exp)
456
+ end
457
+ -- ▲ ReadonlyArray.map ▲
458
+ local stops = _newValue
459
+ local last = math.max(#stops - 1, 1)
460
+ -- ▼ ReadonlyArray.map ▼
461
+ local _newValue_1 = table.create(#stops)
462
+ local _callback_1 = function(color, index)
463
+ return ColorSequenceKeypoint.new(if #stops == 1 then 0 else index / last, color)
464
+ end
465
+ for _k, _v in stops do
466
+ _newValue_1[_k] = _callback_1(_v, _k - 1, stops)
467
+ end
468
+ -- ▲ ReadonlyArray.map ▲
469
+ local keypoints = _newValue_1
470
+ if #stops == 1 then
471
+ local _colorSequenceKeypoint = ColorSequenceKeypoint.new(1, stops[1])
472
+ table.insert(keypoints, _colorSequenceKeypoint)
473
+ end
474
+ local _object = {
475
+ Color = ColorSequence.new(keypoints),
476
+ }
477
+ local _left = "Rotation"
478
+ local _condition_4 = gradientVal.rotation
479
+ if _condition_4 == nil then
480
+ _condition_4 = 0
481
+ end
482
+ _object[_left] = _condition_4
483
+ gradient = _object
484
+ end
443
485
  for key, raw in pairs(sx) do
444
486
  local name = key
445
487
  if SHORTHAND[name] == true then
@@ -471,6 +513,9 @@ local function resolveSx(theme, sx, width)
471
513
  if gap ~= nil then
472
514
  resolved.gap = gap
473
515
  end
516
+ if gradient ~= nil then
517
+ resolved.gradient = gradient
518
+ end
474
519
  return resolved
475
520
  end
476
521
  return {
@@ -161,6 +161,7 @@ local function SxHost(props)
161
161
  local painted = {}
162
162
  local hasPad = false
163
163
  local hasCorner = false
164
+ local hasGradient = false
164
165
  for _, node in nodes do
165
166
  if not React.isValidElement(node) then
166
167
  continue
@@ -172,6 +173,9 @@ local function SxHost(props)
172
173
  if kind == "uicorner" then
173
174
  hasCorner = true
174
175
  end
176
+ if kind == "uigradient" then
177
+ hasGradient = true
178
+ end
175
179
  local patch = if kind ~= nil then layoutGapPatch(kind, elementProps(node), paint.gap) else nil
176
180
  local _arg0 = if patch ~= nil then React.cloneElement(node, patch) else node
177
181
  table.insert(painted, _arg0)
@@ -184,6 +188,10 @@ local function SxHost(props)
184
188
  local _arg0 = React.createElement("uicorner", paint.corner)
185
189
  table.insert(painted, _arg0)
186
190
  end
191
+ if not hasGradient and paint.gradient ~= nil then
192
+ local _arg0 = React.createElement("uigradient", paint.gradient)
193
+ table.insert(painted, _arg0)
194
+ end
187
195
  local _object_2 = table.clone(paint.props)
188
196
  setmetatable(_object_2, nil)
189
197
  for _k, _v in rest do
@@ -6,6 +6,7 @@ export interface HostPaint {
6
6
  };
7
7
  padding?: ResolvedSx["padding"];
8
8
  corner?: ResolvedSx["corner"];
9
+ gradient?: ResolvedSx["gradient"];
9
10
  gap?: number;
10
11
  }
11
12
  export declare function paintHostStyle(theme: Parameters<typeof resolveSx>[0], base: object | undefined, className: object | undefined, sx: SxInput | undefined, width: number | undefined, state: StyleState | undefined): HostPaint;
@@ -25,6 +25,7 @@ local function paintHostStyle(theme, base, className, sx, width, state)
25
25
  props = resolveStyle(merged, state or {}),
26
26
  padding = resolved.padding,
27
27
  corner = resolved.corner,
28
+ gradient = resolved.gradient,
28
29
  gap = resolved.gap,
29
30
  }
30
31
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/uiblox",
3
- "version": "0.2.0-alpha.30",
3
+ "version": "0.2.0-alpha.31",
4
4
  "description": "UI Library and theming for roblox-ts projects",
5
5
  "main": "out/init.luau",
6
6
  "packageManager": "pnpm@11.3.0",