@rbxts/uiblox 0.1.18 → 0.1.20

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,13 +1,19 @@
1
+ import { ComponentType } from "@rbxts/react";
1
2
  import { CustomizedProps } from "../../../../theme/index";
2
3
  export interface PreloaderAssets {
3
4
  [key: string]: string | PreloaderAssets;
4
5
  }
6
+ export interface CustomAdornmentProps {
7
+ progress: number;
8
+ }
5
9
  export interface PreloaderProps {
6
- assetMap: Map<string, PreloaderAssets>;
7
- logoSrc?: string;
10
+ preloaderAssets: Map<string, PreloaderAssets>;
11
+ icon?: string;
8
12
  showPercentage?: boolean;
9
13
  loaderPrecision?: number;
14
+ hideProgressBar?: boolean;
10
15
  showAssetName?: boolean;
16
+ adornment?: ComponentType<CustomAdornmentProps>;
11
17
  }
12
18
  declare function Preloader(props: CustomizedProps<Frame, PreloaderProps>): JSX.Element;
13
19
  export default Preloader;
@@ -12,7 +12,8 @@ local ProgressBar = TS.import(script, script.Parent.Parent.Parent, "progressBar"
12
12
  local usePreloaderStyles = TS.import(script, script.Parent, "Preloader.styles").default
13
13
  local function Preloader(props)
14
14
  local _binding = props
15
- local assetMap = _binding.assetMap
15
+ local preloaderAssets = _binding.preloaderAssets
16
+ local icon = _binding.icon
16
17
  local showPercentage = _binding.showPercentage
17
18
  if showPercentage == nil then
18
19
  showPercentage = false
@@ -21,10 +22,16 @@ local function Preloader(props)
21
22
  if loaderPrecision == nil then
22
23
  loaderPrecision = 0
23
24
  end
25
+ local hideProgressBar = _binding.hideProgressBar
26
+ if hideProgressBar == nil then
27
+ hideProgressBar = false
28
+ end
24
29
  local showAssetName = _binding.showAssetName
25
30
  if showAssetName == nil then
26
31
  showAssetName = false
27
32
  end
33
+ local Adornment = _binding.adornment
34
+ local className = _binding.className
28
35
  local children = _binding.children
29
36
  local percentage, setPercentage = useState(0)
30
37
  local loaded, setLoaded = useState(false)
@@ -55,8 +62,8 @@ local function Preloader(props)
55
62
  local _callback = function(assets, category)
56
63
  scan(assets, `{category}`)
57
64
  end
58
- for _k, _v in assetMap do
59
- _callback(_v, _k, assetMap)
65
+ for _k, _v in preloaderAssets do
66
+ _callback(_v, _k, preloaderAssets)
60
67
  end
61
68
  -- ▲ ReadonlyMap.forEach ▲
62
69
  return { contentIds, contentNamesById }
@@ -79,6 +86,12 @@ local function Preloader(props)
79
86
  end)
80
87
  setCurrentAsset(nil)
81
88
  end), {})
89
+ local percentageStr = useMemo(function()
90
+ if not showPercentage then
91
+ return nil
92
+ end
93
+ return `{string.format(`%.{loaderPrecision}f`, percentage)}%`
94
+ end, { showPercentage, loaderPrecision, percentage })
82
95
  local _result
83
96
  if loaded then
84
97
  _result = ({
@@ -91,16 +104,31 @@ local function Preloader(props)
91
104
  for _k, _v in container do
92
105
  _attributes[_k] = _v
93
106
  end
94
- local _attributes_1 = table.clone(logo)
95
- setmetatable(_attributes_1, nil)
96
- local _exp = React.createElement("imagelabel", _attributes_1)
97
- local _attributes_2 = table.clone(label)
98
- setmetatable(_attributes_2, nil)
99
- _attributes_2.Text = `Loading {if currentAsset ~= nil then currentAsset else "resources"}... {if showPercentage then string.format(`%.{loaderPrecision}f\%`, percentage) else ""}`
100
- _result = (React.createElement("frame", _attributes, _exp, React.createElement("textlabel", _attributes_2), React.createElement(ProgressBar, {
101
- className = progressBar,
107
+ if className then
108
+ for _k, _v in className do
109
+ _attributes[_k] = _v
110
+ end
111
+ end
112
+ local _exp = Adornment ~= nil and React.createElement(Adornment, {
102
113
  progress = percentage,
103
- })))
114
+ })
115
+ local _condition = icon ~= nil
116
+ if _condition then
117
+ local _attributes_1 = table.clone(logo)
118
+ setmetatable(_attributes_1, nil)
119
+ _condition = React.createElement("imagelabel", _attributes_1)
120
+ end
121
+ local _condition_1 = not hideProgressBar
122
+ if _condition_1 then
123
+ local _attributes_1 = table.clone(label)
124
+ setmetatable(_attributes_1, nil)
125
+ _attributes_1.Text = `Loading {if currentAsset ~= nil then currentAsset else "resources"}... {percentageStr}`
126
+ _condition_1 = (React.createElement(React.Fragment, nil, React.createElement("textlabel", _attributes_1), React.createElement(ProgressBar, {
127
+ className = progressBar,
128
+ progress = percentage,
129
+ })))
130
+ end
131
+ _result = (React.createElement("frame", _attributes, _exp, _condition, _condition_1))
104
132
  end
105
133
  return React.createElement(React.Fragment, nil, _result)
106
134
  end
@@ -4,11 +4,6 @@ local _theme = TS.import(script, script.Parent.Parent.Parent.Parent.Parent, "the
4
4
  local createStyles = _theme.createStyles
5
5
  local makeStyles = _theme.makeStyles
6
6
  local usePreloaderStyles = makeStyles(function(theme, props)
7
- local getLogoSrc = function(props)
8
- local _binding = props
9
- local logoSrc = _binding.logoSrc
10
- return logoSrc
11
- end
12
7
  return createStyles({
13
8
  container = {
14
9
  Size = UDim2.new(1, 0, 1, 0),
@@ -22,7 +17,7 @@ local usePreloaderStyles = makeStyles(function(theme, props)
22
17
  AnchorPoint = Vector2.new(0.5, 0.5),
23
18
  BackgroundTransparency = 1,
24
19
  BorderSizePixel = 0,
25
- Image = getLogoSrc(props),
20
+ Image = props.icon,
26
21
  ScaleType = Enum.ScaleType.Fit,
27
22
  ZIndex = 110000,
28
23
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rbxts/uiblox",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "description": "UI Library and theming for roblox-ts projects",
5
5
  "main": "out/init.lua",
6
6
  "scripts": {