@rbxts/uiblox 0.1.0

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.
Files changed (251) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +263 -0
  3. package/out/index.d.ts +2 -0
  4. package/out/init.lua +10 -0
  5. package/out/theme/components/ThemeProvider.d.ts +7 -0
  6. package/out/theme/components/ThemeProvider.lua +37 -0
  7. package/out/theme/components/ThemeStore.d.ts +14 -0
  8. package/out/theme/components/ThemeStore.lua +29 -0
  9. package/out/theme/components/ThemeWrapper.d.ts +7 -0
  10. package/out/theme/components/ThemeWrapper.lua +52 -0
  11. package/out/theme/components/index.d.ts +8 -0
  12. package/out/theme/components/init.lua +10 -0
  13. package/out/theme/constants/NumberConstants.d.ts +6 -0
  14. package/out/theme/constants/NumberConstants.lua +18 -0
  15. package/out/theme/constants/ThemeConstants.d.ts +5 -0
  16. package/out/theme/constants/ThemeConstants.lua +104 -0
  17. package/out/theme/constants/index.d.ts +2 -0
  18. package/out/theme/constants/init.lua +10 -0
  19. package/out/theme/index.d.ts +20 -0
  20. package/out/theme/init.lua +27 -0
  21. package/out/theme/interfaces/IconSizes/IconSizes.d.ts +5 -0
  22. package/out/theme/interfaces/IconSizes/IconSizes.lua +2 -0
  23. package/out/theme/interfaces/IconSizes/index.d.ts +1 -0
  24. package/out/theme/interfaces/IconSizes/init.lua +2 -0
  25. package/out/theme/interfaces/Palette/ColorTokens/ColorTokens.d.ts +5 -0
  26. package/out/theme/interfaces/Palette/ColorTokens/ColorTokens.lua +2 -0
  27. package/out/theme/interfaces/Palette/ColorTokens/index.d.ts +1 -0
  28. package/out/theme/interfaces/Palette/ColorTokens/init.lua +2 -0
  29. package/out/theme/interfaces/Palette/Colors/Blue.d.ts +3 -0
  30. package/out/theme/interfaces/Palette/Colors/Blue.lua +21 -0
  31. package/out/theme/interfaces/Palette/Colors/Colors.d.ts +43 -0
  32. package/out/theme/interfaces/Palette/Colors/Colors.lua +2 -0
  33. package/out/theme/interfaces/Palette/Colors/Common.d.ts +7 -0
  34. package/out/theme/interfaces/Palette/Colors/Common.lua +9 -0
  35. package/out/theme/interfaces/Palette/Colors/Dark.d.ts +3 -0
  36. package/out/theme/interfaces/Palette/Colors/Dark.lua +24 -0
  37. package/out/theme/interfaces/Palette/Colors/Gray.d.ts +3 -0
  38. package/out/theme/interfaces/Palette/Colors/Gray.lua +21 -0
  39. package/out/theme/interfaces/Palette/Colors/Green.d.ts +3 -0
  40. package/out/theme/interfaces/Palette/Colors/Green.lua +21 -0
  41. package/out/theme/interfaces/Palette/Colors/Light.d.ts +3 -0
  42. package/out/theme/interfaces/Palette/Colors/Light.lua +8 -0
  43. package/out/theme/interfaces/Palette/Colors/Magenta.d.ts +3 -0
  44. package/out/theme/interfaces/Palette/Colors/Magenta.lua +21 -0
  45. package/out/theme/interfaces/Palette/Colors/Orange.d.ts +3 -0
  46. package/out/theme/interfaces/Palette/Colors/Orange.lua +21 -0
  47. package/out/theme/interfaces/Palette/Colors/Purple.d.ts +3 -0
  48. package/out/theme/interfaces/Palette/Colors/Purple.lua +21 -0
  49. package/out/theme/interfaces/Palette/Colors/Red.d.ts +3 -0
  50. package/out/theme/interfaces/Palette/Colors/Red.lua +21 -0
  51. package/out/theme/interfaces/Palette/Colors/Turquoise.d.ts +3 -0
  52. package/out/theme/interfaces/Palette/Colors/Turquoise.lua +21 -0
  53. package/out/theme/interfaces/Palette/Colors/Yellow.d.ts +3 -0
  54. package/out/theme/interfaces/Palette/Colors/Yellow.lua +21 -0
  55. package/out/theme/interfaces/Palette/Colors/index.d.ts +13 -0
  56. package/out/theme/interfaces/Palette/Colors/init.lua +16 -0
  57. package/out/theme/interfaces/Palette/Palette.d.ts +27 -0
  58. package/out/theme/interfaces/Palette/Palette.lua +2 -0
  59. package/out/theme/interfaces/Palette/index.d.ts +3 -0
  60. package/out/theme/interfaces/Palette/init.lua +7 -0
  61. package/out/theme/interfaces/Spacing/Borders.d.ts +4 -0
  62. package/out/theme/interfaces/Spacing/Borders.lua +2 -0
  63. package/out/theme/interfaces/Spacing/Padding.d.ts +4 -0
  64. package/out/theme/interfaces/Spacing/Padding.lua +2 -0
  65. package/out/theme/interfaces/Spacing/Shape.d.ts +3 -0
  66. package/out/theme/interfaces/Spacing/Shape.lua +2 -0
  67. package/out/theme/interfaces/Spacing/Spacing.d.ts +4 -0
  68. package/out/theme/interfaces/Spacing/Spacing.lua +2 -0
  69. package/out/theme/interfaces/Spacing/index.d.ts +4 -0
  70. package/out/theme/interfaces/Spacing/init.lua +2 -0
  71. package/out/theme/interfaces/Theme/Theme.d.ts +14 -0
  72. package/out/theme/interfaces/Theme/Theme.lua +2 -0
  73. package/out/theme/interfaces/Theme/ThemeConstants.d.ts +25 -0
  74. package/out/theme/interfaces/Theme/ThemeConstants.lua +2 -0
  75. package/out/theme/interfaces/Theme/ThemeOptions.d.ts +4 -0
  76. package/out/theme/interfaces/Theme/ThemeOptions.lua +2 -0
  77. package/out/theme/interfaces/Theme/index.d.ts +3 -0
  78. package/out/theme/interfaces/Theme/init.lua +2 -0
  79. package/out/theme/interfaces/Tokens/Tokens.d.ts +1 -0
  80. package/out/theme/interfaces/Tokens/Tokens.lua +2 -0
  81. package/out/theme/interfaces/Tokens/index.d.ts +1 -0
  82. package/out/theme/interfaces/Tokens/init.lua +2 -0
  83. package/out/theme/interfaces/index.d.ts +13 -0
  84. package/out/theme/interfaces/init.lua +16 -0
  85. package/out/theme/interfaces/typography/FontFamilies.d.ts +2 -0
  86. package/out/theme/interfaces/typography/FontFamilies.lua +11 -0
  87. package/out/theme/interfaces/typography/FontFamilyOptions.d.ts +5 -0
  88. package/out/theme/interfaces/typography/FontFamilyOptions.lua +2 -0
  89. package/out/theme/interfaces/typography/FontSizeOptions.d.ts +4 -0
  90. package/out/theme/interfaces/typography/FontSizeOptions.lua +2 -0
  91. package/out/theme/interfaces/typography/FontSizes.d.ts +3 -0
  92. package/out/theme/interfaces/typography/FontSizes.lua +15 -0
  93. package/out/theme/interfaces/typography/ThemeTypography.d.ts +7 -0
  94. package/out/theme/interfaces/typography/ThemeTypography.lua +2 -0
  95. package/out/theme/interfaces/typography/Variants.d.ts +18 -0
  96. package/out/theme/interfaces/typography/Variants.lua +24 -0
  97. package/out/theme/interfaces/typography/index.d.ts +8 -0
  98. package/out/theme/interfaces/typography/init.lua +13 -0
  99. package/out/theme/styles/index.d.ts +5 -0
  100. package/out/theme/styles/init.lua +7 -0
  101. package/out/theme/styles/types/WriteableStyle.d.ts +3 -0
  102. package/out/theme/styles/types/WriteableStyle.lua +2 -0
  103. package/out/theme/styles/types/index.d.ts +2 -0
  104. package/out/theme/styles/types/init.lua +2 -0
  105. package/out/theme/styles/types/styles.d.ts +4 -0
  106. package/out/theme/styles/types/styles.lua +2 -0
  107. package/out/theme/styles/utilities/classNames.d.ts +8 -0
  108. package/out/theme/styles/utilities/classNames.lua +31 -0
  109. package/out/theme/styles/utilities/createStyles.d.ts +3 -0
  110. package/out/theme/styles/utilities/createStyles.lua +8 -0
  111. package/out/theme/styles/utilities/index.d.ts +3 -0
  112. package/out/theme/styles/utilities/init.lua +7 -0
  113. package/out/theme/styles/utilities/makeStyles.d.ts +7 -0
  114. package/out/theme/styles/utilities/makeStyles.lua +32 -0
  115. package/out/theme/themes/DarkTheme.d.ts +3 -0
  116. package/out/theme/themes/DarkTheme.lua +99 -0
  117. package/out/theme/themes/LightTheme.d.ts +3 -0
  118. package/out/theme/themes/LightTheme.lua +99 -0
  119. package/out/theme/themes/index.d.ts +3 -0
  120. package/out/theme/themes/init.lua +7 -0
  121. package/out/theme/types/index.d.ts +7 -0
  122. package/out/theme/types/init.lua +2 -0
  123. package/out/theme/types/types.d.ts +16 -0
  124. package/out/theme/types/types.lua +3 -0
  125. package/out/theme/utilites/Color3FromHex.d.ts +2 -0
  126. package/out/theme/utilites/Color3FromHex.lua +14 -0
  127. package/out/theme/utilites/index.d.ts +1 -0
  128. package/out/theme/utilites/init.lua +5 -0
  129. package/out/ui/constants/ImageConstants.d.ts +2 -0
  130. package/out/ui/constants/ImageConstants.lua +7 -0
  131. package/out/ui/constants/LayoutConstants.d.ts +1 -0
  132. package/out/ui/constants/LayoutConstants.lua +7 -0
  133. package/out/ui/constants/index.d.ts +2 -0
  134. package/out/ui/constants/init.lua +10 -0
  135. package/out/ui/enums/Directions.d.ts +8 -0
  136. package/out/ui/enums/Directions.lua +23 -0
  137. package/out/ui/enums/Icons.d.ts +40 -0
  138. package/out/ui/enums/Icons.lua +87 -0
  139. package/out/ui/enums/Orientations.d.ts +4 -0
  140. package/out/ui/enums/Orientations.lua +15 -0
  141. package/out/ui/enums/index.d.ts +3 -0
  142. package/out/ui/enums/init.lua +7 -0
  143. package/out/ui/index.d.ts +34 -0
  144. package/out/ui/init.lua +24 -0
  145. package/out/ui/packages/button/components/Button.d.ts +26 -0
  146. package/out/ui/packages/button/components/Button.lua +175 -0
  147. package/out/ui/packages/button/components/Button.styles.d.ts +3 -0
  148. package/out/ui/packages/button/components/Button.styles.lua +149 -0
  149. package/out/ui/packages/button/index.d.ts +6 -0
  150. package/out/ui/packages/button/init.lua +8 -0
  151. package/out/ui/packages/button/types/ButtonColor.d.ts +1 -0
  152. package/out/ui/packages/button/types/ButtonColor.lua +2 -0
  153. package/out/ui/packages/button/types/ButtonSize.d.ts +1 -0
  154. package/out/ui/packages/button/types/ButtonSize.lua +2 -0
  155. package/out/ui/packages/button/types/ButtonVariant.d.ts +1 -0
  156. package/out/ui/packages/button/types/ButtonVariant.lua +2 -0
  157. package/out/ui/packages/button/types/index.d.ts +3 -0
  158. package/out/ui/packages/button/types/init.lua +2 -0
  159. package/out/ui/packages/divider/components/Divider.d.ts +18 -0
  160. package/out/ui/packages/divider/components/Divider.lua +27 -0
  161. package/out/ui/packages/divider/components/Divider.styles.d.ts +3 -0
  162. package/out/ui/packages/divider/components/Divider.styles.lua +42 -0
  163. package/out/ui/packages/divider/index.d.ts +3 -0
  164. package/out/ui/packages/divider/init.lua +8 -0
  165. package/out/ui/packages/icon/components/Icon.d.ts +11 -0
  166. package/out/ui/packages/icon/components/Icon.lua +31 -0
  167. package/out/ui/packages/icon/components/Icon.styles.d.ts +3 -0
  168. package/out/ui/packages/icon/components/Icon.styles.lua +47 -0
  169. package/out/ui/packages/icon/index.d.ts +3 -0
  170. package/out/ui/packages/icon/init.lua +8 -0
  171. package/out/ui/packages/iconButton/components/IconButton.d.ts +13 -0
  172. package/out/ui/packages/iconButton/components/IconButton.lua +48 -0
  173. package/out/ui/packages/iconButton/components/IconButton.styles.d.ts +3 -0
  174. package/out/ui/packages/iconButton/components/IconButton.styles.lua +47 -0
  175. package/out/ui/packages/iconButton/index.d.ts +3 -0
  176. package/out/ui/packages/iconButton/init.lua +8 -0
  177. package/out/ui/packages/index.d.ts +11 -0
  178. package/out/ui/packages/init.lua +37 -0
  179. package/out/ui/packages/input/components/Input.d.ts +26 -0
  180. package/out/ui/packages/input/components/Input.lua +165 -0
  181. package/out/ui/packages/input/components/Input.styles.d.ts +3 -0
  182. package/out/ui/packages/input/components/Input.styles.lua +156 -0
  183. package/out/ui/packages/input/index.d.ts +6 -0
  184. package/out/ui/packages/input/init.lua +8 -0
  185. package/out/ui/packages/input/types/InputColor.d.ts +1 -0
  186. package/out/ui/packages/input/types/InputColor.lua +2 -0
  187. package/out/ui/packages/input/types/InputMargin.d.ts +1 -0
  188. package/out/ui/packages/input/types/InputMargin.lua +2 -0
  189. package/out/ui/packages/input/types/InputVariant.d.ts +1 -0
  190. package/out/ui/packages/input/types/InputVariant.lua +2 -0
  191. package/out/ui/packages/input/types/index.d.ts +3 -0
  192. package/out/ui/packages/input/types/init.lua +2 -0
  193. package/out/ui/packages/progressBar/components/ProgressBar.d.ts +9 -0
  194. package/out/ui/packages/progressBar/components/ProgressBar.lua +76 -0
  195. package/out/ui/packages/progressBar/components/ProgressBar.styles.d.ts +2 -0
  196. package/out/ui/packages/progressBar/components/ProgressBar.styles.lua +47 -0
  197. package/out/ui/packages/progressBar/index.d.ts +3 -0
  198. package/out/ui/packages/progressBar/init.lua +8 -0
  199. package/out/ui/packages/shadow/components/Shadow.d.ts +3 -0
  200. package/out/ui/packages/shadow/components/Shadow.lua +72 -0
  201. package/out/ui/packages/shadow/components/Shadow.styles.d.ts +2 -0
  202. package/out/ui/packages/shadow/components/Shadow.styles.lua +20 -0
  203. package/out/ui/packages/shadow/index.d.ts +2 -0
  204. package/out/ui/packages/shadow/init.lua +8 -0
  205. package/out/ui/packages/sidebar/components/Sidebar.d.ts +11 -0
  206. package/out/ui/packages/sidebar/components/Sidebar.lua +46 -0
  207. package/out/ui/packages/sidebar/components/Sidebar.styles.d.ts +3 -0
  208. package/out/ui/packages/sidebar/components/Sidebar.styles.lua +38 -0
  209. package/out/ui/packages/sidebar/index.d.ts +4 -0
  210. package/out/ui/packages/sidebar/init.lua +8 -0
  211. package/out/ui/packages/sidebar/types/SidebarType.d.ts +1 -0
  212. package/out/ui/packages/sidebar/types/SidebarType.lua +2 -0
  213. package/out/ui/packages/sidebar/types/index.d.ts +1 -0
  214. package/out/ui/packages/sidebar/types/init.lua +2 -0
  215. package/out/ui/packages/toast/components/Toast.d.ts +11 -0
  216. package/out/ui/packages/toast/components/Toast.lua +94 -0
  217. package/out/ui/packages/toast/components/Toast.styles.d.ts +3 -0
  218. package/out/ui/packages/toast/components/Toast.styles.lua +74 -0
  219. package/out/ui/packages/toast/enums/ToastVariants.d.ts +7 -0
  220. package/out/ui/packages/toast/enums/ToastVariants.lua +20 -0
  221. package/out/ui/packages/toast/index.d.ts +5 -0
  222. package/out/ui/packages/toast/init.lua +9 -0
  223. package/out/ui/packages/toast/interfaces/ToastEvent.d.ts +5 -0
  224. package/out/ui/packages/toast/interfaces/ToastEvent.lua +2 -0
  225. package/out/ui/packages/treeView/components/TreeView.d.ts +11 -0
  226. package/out/ui/packages/treeView/components/TreeView.lua +339 -0
  227. package/out/ui/packages/treeView/components/TreeView.styles.d.ts +2 -0
  228. package/out/ui/packages/treeView/components/TreeView.styles.lua +91 -0
  229. package/out/ui/packages/treeView/index.d.ts +6 -0
  230. package/out/ui/packages/treeView/init.lua +8 -0
  231. package/out/ui/packages/treeView/interfaces/Branch.d.ts +6 -0
  232. package/out/ui/packages/treeView/interfaces/Branch.lua +2 -0
  233. package/out/ui/packages/treeView/interfaces/Leaf.d.ts +4 -0
  234. package/out/ui/packages/treeView/interfaces/Leaf.lua +2 -0
  235. package/out/ui/packages/treeView/interfaces/Tree.d.ts +5 -0
  236. package/out/ui/packages/treeView/interfaces/Tree.lua +2 -0
  237. package/out/ui/packages/typography/components/Typography.d.ts +21 -0
  238. package/out/ui/packages/typography/components/Typography.lua +47 -0
  239. package/out/ui/packages/typography/components/Typography.styles.d.ts +3 -0
  240. package/out/ui/packages/typography/components/Typography.styles.lua +97 -0
  241. package/out/ui/packages/typography/index.d.ts +6 -0
  242. package/out/ui/packages/typography/init.lua +8 -0
  243. package/out/ui/packages/typography/types/TypographyAlignment.d.ts +1 -0
  244. package/out/ui/packages/typography/types/TypographyAlignment.lua +2 -0
  245. package/out/ui/packages/typography/types/TypographyColor.d.ts +1 -0
  246. package/out/ui/packages/typography/types/TypographyColor.lua +2 -0
  247. package/out/ui/packages/typography/types/TypographyDisplay.d.ts +1 -0
  248. package/out/ui/packages/typography/types/TypographyDisplay.lua +2 -0
  249. package/out/ui/packages/typography/types/index.d.ts +3 -0
  250. package/out/ui/packages/typography/types/init.lua +2 -0
  251. package/package.json +68 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Brandon LaRouche
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,263 @@
1
+ <img src=docs/logo.png width=60%>
2
+
3
+ # uiblox-rbxts
4
+
5
+ > This package is a work in progress.
6
+
7
+ UI library and theming for roblox-ts projects.
8
+
9
+ ## Background
10
+
11
+ Roblox has their own internal design system, coined "uiblox-web", that it uses for its new
12
+ web-facing products. This system offers reusable components, implemented in
13
+ React Typescript, that are derived from material UI (MUI). As well, it offers a
14
+ common theme/pallete for consistent UI/UX.
15
+
16
+ Anyone is able to view their design system as
17
+ [UIBlox-Web](https://uiblox.roblox.com). You can see that they leverage
18
+ [Storybook](https://storybook.js.org), a UI component explorer for frontend
19
+ developers, to render component previews.
20
+
21
+ Design systems all help engineers cut down on implementation time and ensure
22
+ consitent UX across products.
23
+
24
+ ## Overview
25
+
26
+ So what is uiblox-rbxts? Simply put, its my stab at a design system that mimics
27
+ uiblox-web for games written using roblox-ts.
28
+
29
+ UIBlox-rbxts aims to provide extensible components that can be reusable by
30
+ anyone who installs this npm package. It also offers a theme and styling system
31
+ that aids UI/UX consistentency.
32
+
33
+ How does it do this? Well, there are two main exports from this package:
34
+
35
+ - @rbxts/uiblox -> theme
36
+ - An extensible Theme type + default Dark (default) and Light themes
37
+ - ... Light theme palette is a WIP
38
+ - makeStyles/createStyles utilities to serve up Instance-extended property
39
+ tables that can be applied to your Roact Components
40
+ - ThemeProvider which can wrap your application and uses Rodux to tell
41
+ sub-components which theme to style off of (via makeStyles)
42
+ - Uses Rodux
43
+ - @rbxts/uiblox -> ui
44
+ - Packaged and reusable typed Roact components
45
+
46
+ # How to use
47
+
48
+ ### Installation
49
+
50
+ Install the package to get started.
51
+
52
+ `npm install @rbxts/uiblox`
53
+
54
+ ## Example
55
+
56
+ Below is an example usage of how you could use ThemeProvider,
57
+ makeStyles/createStyles, and a Button component. This is just an example of how
58
+ to mount and configure your UI -- you can set things up however you want (so
59
+ long as it works...).
60
+
61
+ ### Shared
62
+
63
+ You can house all of your components within shared.
64
+
65
+ #### src/shared/ui/app/App.tsx
66
+
67
+ The top-level class for our UI. Loads the actual ApplLayout into ScreenGui. This
68
+ is what we later pass to `Roact.mount()`.
69
+
70
+ ```javascript
71
+ import Roact, { Component } from "@rbxts/roact";
72
+
73
+ class App extends Component {
74
+ render() {
75
+ return (
76
+ <screengui IgnoreGuiInset ZIndexBehavior={Enum.ZIndexBehavior.Global}>
77
+ <AppLayout />
78
+ </screengui>
79
+ );
80
+ }
81
+ }
82
+
83
+ export default App;
84
+ ```
85
+
86
+ #### src/shared/ui/app/AppLayout.tsx
87
+
88
+ Start actually adding in components to render, but wrap them in a
89
+ `ThemeProvider`. Here I just use DarkTheme, which is also exported as
90
+ DefaultTheme. If no theme is provided, it would use DarkTheme anyways. If the
91
+ theme prop changes, then sub-components will be re-rendered with the new theme.
92
+
93
+ You can also choose to create your own theme with the `Theme` interface exported
94
+ from `@rbxts/uiblox`.
95
+
96
+ ```javascript
97
+ import Roact, { Component } from "@rbxts/roact";
98
+ import { Storyblox } from "shared/ui/storyblox";
99
+ import { DarkTheme, ThemeProvider } from "@rbxts/uiblox";
100
+ import usePageLayoutStyles from "./PageLayout.styles";
101
+
102
+ class AppLayout extends Component {
103
+ render() {
104
+ return (
105
+ <ThemeProvider theme={DarkTheme}>
106
+ <frame
107
+ Key={"AppLayout"}
108
+ Size={new UDim2(1, 0, 1, 0)}
109
+ BackgroundTransparency={1}
110
+ >
111
+ <MyComponent />
112
+ </frame>
113
+ </ThemeProvider>
114
+ );
115
+ }
116
+ }
117
+
118
+ export default AppLayout;
119
+ ```
120
+
121
+ #### src/shared/ui/myComponent/MyComponent.tsx
122
+
123
+ My actual component. Just loads a dummy button and passes props to be used to
124
+ make styles.
125
+
126
+ If you omit the props type from myStyles usage in the styles file,
127
+ then you can omit props without a type warning (i.e. `makeStyles(theme => {})`
128
+ instead of `makeStyles<MyComponentProps>((theme, props) => {})`).
129
+
130
+ ```javascript
131
+ import Roact from "@rbxts/roact";
132
+ import { useState } from "@rbxts/roact-hooked";
133
+ import useMyComponentStyles from "./MyComponent.styles";
134
+ import { Button } from "@rbxts/uiblox";
135
+
136
+ export interface MyComponentProps {
137
+ title?: string;
138
+ bolded?: boolean;
139
+ transparent?: boolean;
140
+ }
141
+
142
+ // Hooked components are very handy
143
+ const MyComponent =
144
+ hooked <
145
+ MyComponentProps >
146
+ ((props) => {
147
+ const { title, bolded = false } = props;
148
+ const { root, button } = useMyComponentStyles(props);
149
+
150
+ return (
151
+ <frame Key="MyComponent" {...root}>
152
+ <Button
153
+ variant="outlined"
154
+ text={title}
155
+ size="small"
156
+ color="secondary"
157
+ family={bolded ? "bold" : "default"}
158
+ className={button}
159
+ ></Button>
160
+ </frame>
161
+ );
162
+ });
163
+
164
+ export default MyComponent;
165
+ ```
166
+
167
+ #### src/shared/ui/myComponent/MyComponent.styles.ts
168
+
169
+ Actually compute styles based on theme and props. You can simplify the arrow
170
+ function if you do not care about props and just directly return `createStyles`.
171
+
172
+ For more complex dendencies, you'd likely use some helper methods within the
173
+ arrow function of `makeStyles` (i.e. `makeRootStyles()`).
174
+
175
+ Make sure that the type given to each style matches the component it will be
176
+ applied to (i.e. `frameStyles: { ... } as WriteableStyle<Frame>` =>
177
+ `<frame {...frameStyles} />`).
178
+
179
+ ```javascript
180
+ import { createStyles, Icons, makeStyles, ROBLOX_UI_OFFSET, Theme, WriteableStyle } from "@rbxts/uiblox";
181
+ import { MyComponentProps } from "./MyComponent";
182
+
183
+ const useMyComponentStyles = makeStyles<MyComponentProps>((theme: Theme, props: MyComponentProps) => {
184
+ const { transparent = false } = props; // Defaults to false
185
+ const transparency = transparent ? 1 : 0;
186
+
187
+ return createStyles({
188
+ root: {
189
+ Size: new UDim2(0, theme.spacing.calc(6), 0, theme.spacing.calc(6)),
190
+ BackgroundColor3: Color3.fromRGB(0, 0, 0),
191
+ BackgroundTransparency: transparency,
192
+ BorderSizePixel: 0,
193
+ ClipsDescendants: true,
194
+ ZIndex: 100,
195
+ } as WriteableStyle<Frame>,
196
+ button: {
197
+ Position: new UDim2(0.5, theme.padding.calc(2), 0.5, theme.padding.calc(2)),
198
+ AnchorPoint: new Vector2(0.5, 0.5),
199
+ ZIndex: 200,
200
+ } as WriteableStyle<TextButton>
201
+ })
202
+ });
203
+
204
+ export default useMyComponentStyles;
205
+ ```
206
+
207
+ ### Client
208
+
209
+ Some sample logic for mounting app when player spawns (on client).
210
+
211
+ #### src/client/Controllers/Apploader.tsx
212
+
213
+ Mount the App in the LocalPlayer's `PlayerGui`.
214
+
215
+ ```javascript
216
+ import Roact, { Tree } from "@rbxts/roact";
217
+ import { Players } from "@rbxts/services";
218
+ import { App } from "shared/ui/App";
219
+
220
+ class AppLoader {
221
+ protected _tree: Tree | undefined;
222
+
223
+ Mount() {
224
+ const playerGui = Players.LocalPlayer.FindFirstChild("PlayerGui") as PlayerGui;
225
+
226
+ const appComponent = <App />;
227
+ this._tree = Roact.mount(appComponent, playerGui, "App");
228
+ print("App mounted");
229
+ }
230
+
231
+ Unmount() {
232
+ if (this._tree) {
233
+ Roact.unmount(this._tree);
234
+ print("App unmounted");
235
+ }
236
+ }
237
+ }
238
+
239
+ export default AppLoader;
240
+ ```
241
+
242
+ #### src/client/main.client.ts
243
+
244
+ When the client loads, call our AppLoader() to mount the UI.
245
+
246
+ ```javascript
247
+ import { AppLoader } from "./Controllers";
248
+
249
+ // Load the UI App
250
+ new AppLoader().Mount();
251
+ ```
252
+
253
+ # Future work
254
+
255
+ - More UI packages
256
+ - Finish palette for LightTheme
257
+
258
+ # See Also
259
+
260
+ - [Storyblox](https://github.com/bjlarouche/storyblox) a UI component explorer for roblox-ts developers
261
+ - <img src=docs/storyblox-preview.png width=40%>
262
+ - Test it out here [Storyblox Pre-Release Experience](https://www.roblox.com/games/9159382473)
263
+ - Similar to [hoarcekat](https://github.com/Kampfkarren/hoarcekat) by Kampfkarren
package/out/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./theme";
2
+ export * from "./ui";
package/out/init.lua ADDED
@@ -0,0 +1,10 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local TS = _G[script]
3
+ local exports = {}
4
+ for _k, _v in TS.import(script, script, "theme") or {} do
5
+ exports[_k] = _v
6
+ end
7
+ for _k, _v in TS.import(script, script, "ui") or {} do
8
+ exports[_k] = _v
9
+ end
10
+ return exports
@@ -0,0 +1,7 @@
1
+ import Roact from "@rbxts/roact";
2
+ import { Theme } from "../interfaces/theme";
3
+ export interface ThemeProviderProps {
4
+ theme?: Theme;
5
+ }
6
+ declare const ThemeProvider: (props: ThemeProviderProps) => Roact.Element;
7
+ export default ThemeProvider;
@@ -0,0 +1,37 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local TS = _G[script]
3
+ local withHooks = TS.import(script, TS.getModule(script, "@rbxts", "roact-hooked").src).withHooks
4
+ local StoreProvider = TS.import(script, TS.getModule(script, "@rbxts", "roact-rodux-hooked").src).StoreProvider
5
+ local Roact = TS.import(script, TS.getModule(script, "@rbxts", "roact").src)
6
+ local themeStore = TS.import(script, script.Parent, "ThemeStore").themeStore
7
+ local ThemeWrapper = TS.import(script, script.Parent, "ThemeWrapper").default
8
+ local ThemeProvider = withHooks(function(props)
9
+ local _binding = props
10
+ local theme = _binding.theme
11
+ local children = _binding[Roact.Children]
12
+ local _attributes = {
13
+ store = themeStore,
14
+ }
15
+ local _children = {}
16
+ local _length = #_children
17
+ local _attributes_1 = {
18
+ theme = theme,
19
+ }
20
+ local _children_1 = {}
21
+ local _length_1 = #_children_1
22
+ if children then
23
+ for _k, _v in children do
24
+ if type(_k) == "number" then
25
+ _children_1[_length_1 + _k] = _v
26
+ else
27
+ _children_1[_k] = _v
28
+ end
29
+ end
30
+ end
31
+ _children[_length + 1] = Roact.createElement(ThemeWrapper, _attributes_1, _children_1)
32
+ return Roact.createElement(StoreProvider, _attributes, _children)
33
+ end)
34
+ local default = ThemeProvider
35
+ return {
36
+ default = default,
37
+ }
@@ -0,0 +1,14 @@
1
+ /// <reference types="rodux" />
2
+ import { Theme } from "../interfaces/theme";
3
+ import { Store } from "@rbxts/rodux";
4
+ export type ThemeState = {
5
+ theme: Theme;
6
+ };
7
+ export type ThemeAction = {
8
+ type: "set";
9
+ newTheme?: Theme;
10
+ };
11
+ export declare const themeReducer: import("@rbxts/rodux").Reducer<ThemeState, ThemeAction>;
12
+ export declare const themeStore: Store<ThemeState, ThemeAction>;
13
+ export type TThemeStore = typeof themeStore;
14
+ export declare const selectTheme: import("@rbxts/roselect").OutputSelector<ThemeState, Theme, (res: Theme) => Theme>;
@@ -0,0 +1,29 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local TS = _G[script]
3
+ local _rodux = TS.import(script, TS.getModule(script, "@rbxts", "rodux").src)
4
+ local createReducer = _rodux.createReducer
5
+ local Store = _rodux.Store
6
+ local createSelector = TS.import(script, TS.getModule(script, "@rbxts", "roselect").src).createSelector
7
+ local DefaultTheme = TS.import(script, script.Parent.Parent, "themes").default
8
+ local themeReducer = createReducer({
9
+ theme = DefaultTheme,
10
+ }, {
11
+ set = function(_param, _param_1)
12
+ local theme = _param.theme
13
+ local newTheme = _param_1.newTheme
14
+ return {
15
+ theme = newTheme or theme,
16
+ }
17
+ end,
18
+ })
19
+ local themeStore = Store.new(themeReducer)
20
+ local selectTheme = createSelector(function(state)
21
+ return state.theme
22
+ end, function(theme)
23
+ return theme
24
+ end)
25
+ return {
26
+ themeReducer = themeReducer,
27
+ themeStore = themeStore,
28
+ selectTheme = selectTheme,
29
+ }
@@ -0,0 +1,7 @@
1
+ import Roact from "@rbxts/roact";
2
+ import { Theme } from "../interfaces/theme";
3
+ export interface ThemeWrapperProps {
4
+ theme?: Theme;
5
+ }
6
+ declare const ThemeWrapper: (props: ThemeWrapperProps) => Roact.Element;
7
+ export default ThemeWrapper;
@@ -0,0 +1,52 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local TS = _G[script]
3
+ local _roact_hooked = TS.import(script, TS.getModule(script, "@rbxts", "roact-hooked").src)
4
+ local withHooks = _roact_hooked.withHooks
5
+ local useEffect = _roact_hooked.useEffect
6
+ local useRef = _roact_hooked.useRef
7
+ local _roact_rodux_hooked = TS.import(script, TS.getModule(script, "@rbxts", "roact-rodux-hooked").src)
8
+ local useDispatch = _roact_rodux_hooked.useDispatch
9
+ local useSelector = _roact_rodux_hooked.useSelector
10
+ local Roact = TS.import(script, TS.getModule(script, "@rbxts", "roact").src)
11
+ local selectTheme = TS.import(script, script.Parent, "ThemeStore").selectTheme
12
+ local DefaultTheme = TS.import(script, script.Parent.Parent, "themes").default
13
+ local ThemeWrapper = withHooks(function(props)
14
+ local _binding = props
15
+ local theme = _binding.theme
16
+ local children = _binding[Roact.Children]
17
+ local dispatch = useDispatch()
18
+ local ref = useRef()
19
+ local currentTheme = useSelector(selectTheme)
20
+ -- When theme changes
21
+ useEffect(function()
22
+ dispatch({
23
+ type = "set",
24
+ newTheme = theme or DefaultTheme,
25
+ })
26
+ end, { theme })
27
+ local _attributes = {
28
+ BackgroundTransparency = 1,
29
+ Size = UDim2.new(1, 0, 1, 0),
30
+ ZIndex = 500000,
31
+ [Roact.Ref] = ref,
32
+ }
33
+ local _children = {}
34
+ local _length = #_children
35
+ local _child = currentTheme and children
36
+ if _child then
37
+ for _k, _v in _child do
38
+ if type(_k) == "number" then
39
+ _children[_length + _k] = _v
40
+ else
41
+ _children[_k] = _v
42
+ end
43
+ end
44
+ end
45
+ return Roact.createFragment({
46
+ ["ThemeWrapper-" .. currentTheme.type] = Roact.createElement("Frame", _attributes, _children),
47
+ })
48
+ end)
49
+ local default = ThemeWrapper
50
+ return {
51
+ default = default,
52
+ }
@@ -0,0 +1,8 @@
1
+ export { default as ThemeProvider } from "./ThemeProvider";
2
+ export { ThemeProviderProps } from "./ThemeProvider";
3
+ export * from "./ThemeProvider";
4
+ export { ThemeState } from "./ThemeStore";
5
+ export { ThemeAction } from "./ThemeStore";
6
+ export { themeReducer } from "./ThemeStore";
7
+ export { themeStore } from "./ThemeStore";
8
+ export { TThemeStore } from "./ThemeStore";
@@ -0,0 +1,10 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local TS = _G[script]
3
+ local exports = {}
4
+ exports.ThemeProvider = TS.import(script, script, "ThemeProvider").default
5
+ for _k, _v in TS.import(script, script, "ThemeProvider") or {} do
6
+ exports[_k] = _v
7
+ end
8
+ exports.themeReducer = TS.import(script, script, "ThemeStore").themeReducer
9
+ exports.themeStore = TS.import(script, script, "ThemeStore").themeStore
10
+ return exports
@@ -0,0 +1,6 @@
1
+ import IconSizes from "../interfaces/IconSizes/IconSizes";
2
+ export declare const SPACING_BASE = 12;
3
+ export declare const PADDING_BASE = 4;
4
+ export declare const BORDER_RADIUS = 4;
5
+ export declare const CONTENT_WIDTH = 1024;
6
+ export declare const ICON_SIZES: IconSizes;
@@ -0,0 +1,18 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local SPACING_BASE = 12
3
+ local PADDING_BASE = 4
4
+ -- align with UIBlox design
5
+ local BORDER_RADIUS = 4
6
+ local CONTENT_WIDTH = 1024
7
+ local ICON_SIZES = {
8
+ small = 16,
9
+ medium = 36,
10
+ large = 48,
11
+ }
12
+ return {
13
+ SPACING_BASE = SPACING_BASE,
14
+ PADDING_BASE = PADDING_BASE,
15
+ BORDER_RADIUS = BORDER_RADIUS,
16
+ CONTENT_WIDTH = CONTENT_WIDTH,
17
+ ICON_SIZES = ICON_SIZES,
18
+ }
@@ -0,0 +1,5 @@
1
+ import { Borders } from "../interfaces/spacing";
2
+ import { Colors } from "../interfaces/palette";
3
+ export declare const DARK_THEME_COLORS: Colors;
4
+ export declare const LIGHT_THEME_COLORS: Colors;
5
+ export declare const DEFAULT_BORDERS: Borders;
@@ -0,0 +1,104 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local TS = _G[script]
3
+ local _palette = TS.import(script, script.Parent.Parent, "interfaces", "palette")
4
+ local Common = _palette.Common
5
+ local Gray = _palette.Gray
6
+ local Green = _palette.Green
7
+ local Red = _palette.Red
8
+ local Purple = _palette.Purple
9
+ local Blue = _palette.Blue
10
+ local Yellow = _palette.Yellow
11
+ -- dark theme
12
+ local DARK_THEME_COLORS = {
13
+ backgroundDefault = Common.Black,
14
+ backgroundContrast = Gray[110],
15
+ backgroundMuted = Gray[90],
16
+ backgroundUIDefault = Gray[90],
17
+ backgroundUIMuted = Gray[100],
18
+ backgroundUIContrast = Gray[100],
19
+ UIDefault = Gray[70],
20
+ UIMuted = Gray[100],
21
+ UIEmphasis = Gray[80],
22
+ textDefault = Common.White,
23
+ textMuted = Gray[50],
24
+ textEmphasis = Common.White,
25
+ iconDefault = Common.White,
26
+ iconEmphasis = Common.White,
27
+ iconOnHover = Common.White,
28
+ systemPrimaryDefault = Common.White,
29
+ systemPrimaryOnHover = Gray[40],
30
+ systemPrimaryContent = Common.Black,
31
+ contextualPrimaryDefault = Green[50],
32
+ contextualPrimaryOnHover = Green[40],
33
+ contextualPrimaryContent = Common.Black,
34
+ secondaryDefault = Common.White,
35
+ secondaryOnHover = Gray[40],
36
+ secondaryContent = Common.White,
37
+ divider = Gray[70],
38
+ overlay = Common.Black,
39
+ dropShadow = Common.Black,
40
+ navigationBar = Gray[110],
41
+ badge = Common.White,
42
+ badgeContent = Common.Black,
43
+ placeholder = Gray[100],
44
+ online = Green[50],
45
+ offline = Gray[50],
46
+ alert = Red[60],
47
+ success = Green[50],
48
+ accent = Purple[50],
49
+ link = Blue[50],
50
+ caution = Yellow[50],
51
+ text = Common.White,
52
+ background = Common.Black,
53
+ }
54
+ local LIGHT_THEME_COLORS = {
55
+ backgroundDefault = Common.White,
56
+ backgroundContrast = Gray[40],
57
+ backgroundMuted = Gray[30],
58
+ backgroundUIDefault = Gray[30],
59
+ backgroundUIMuted = Gray[50],
60
+ backgroundUIContrast = Gray[50],
61
+ UIDefault = Gray[70],
62
+ UIMuted = Gray[50],
63
+ UIEmphasis = Gray[80],
64
+ textDefault = Common.Black,
65
+ textMuted = Gray[50],
66
+ textEmphasis = Common.Black,
67
+ iconDefault = Common.Black,
68
+ iconEmphasis = Common.Black,
69
+ iconOnHover = Common.Black,
70
+ systemPrimaryDefault = Common.Black,
71
+ systemPrimaryOnHover = Gray[40],
72
+ systemPrimaryContent = Common.White,
73
+ contextualPrimaryDefault = Green[60],
74
+ contextualPrimaryOnHover = Green[40],
75
+ contextualPrimaryContent = Common.White,
76
+ secondaryDefault = Common.Black,
77
+ secondaryOnHover = Gray[40],
78
+ secondaryContent = Common.Black,
79
+ divider = Gray[70],
80
+ overlay = Common.White,
81
+ dropShadow = Common.White,
82
+ navigationBar = Gray[40],
83
+ badge = Common.Black,
84
+ badgeContent = Common.White,
85
+ placeholder = Gray[50],
86
+ online = Green[60],
87
+ offline = Gray[50],
88
+ alert = Red[60],
89
+ success = Green[60],
90
+ accent = Purple[50],
91
+ link = Blue[50],
92
+ caution = Yellow[50],
93
+ text = Common.Black,
94
+ background = Common.White,
95
+ }
96
+ local DEFAULT_BORDERS = {
97
+ default = 1,
98
+ divider = 2,
99
+ }
100
+ return {
101
+ DARK_THEME_COLORS = DARK_THEME_COLORS,
102
+ LIGHT_THEME_COLORS = LIGHT_THEME_COLORS,
103
+ DEFAULT_BORDERS = DEFAULT_BORDERS,
104
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./NumberConstants";
2
+ export * from "./ThemeConstants";
@@ -0,0 +1,10 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local TS = _G[script]
3
+ local exports = {}
4
+ for _k, _v in TS.import(script, script, "NumberConstants") or {} do
5
+ exports[_k] = _v
6
+ end
7
+ for _k, _v in TS.import(script, script, "ThemeConstants") or {} do
8
+ exports[_k] = _v
9
+ end
10
+ return exports
@@ -0,0 +1,20 @@
1
+ export { default as Theme } from "./interfaces/theme/Theme";
2
+ export { ThemeProvider } from "./components";
3
+ export { themeStore } from "./components";
4
+ export { ThemeState } from "./components";
5
+ export * from "./components";
6
+ export * from "./constants";
7
+ export * from "./interfaces";
8
+ export * from "./styles";
9
+ export * from "./themes";
10
+ export { default as DefaultTheme } from "./themes";
11
+ export { default as DarkTheme } from "./themes/DarkTheme";
12
+ export { default as LightTheme } from "./themes/LightTheme";
13
+ export { CommonProps } from "./types";
14
+ export { BaseDefaultProps } from "./types";
15
+ export { BaseCustomizedProps } from "./types";
16
+ export { DefaultProps } from "./types";
17
+ export { CustomizedProps } from "./types";
18
+ export { CustomizedRef } from "./types";
19
+ export { CustomizedForwardRefComponent } from "./types";
20
+ export * from "./utilites";
@@ -0,0 +1,27 @@
1
+ -- Compiled with roblox-ts v2.2.0
2
+ local TS = _G[script]
3
+ local exports = {}
4
+ exports.ThemeProvider = TS.import(script, script, "components").ThemeProvider
5
+ exports.themeStore = TS.import(script, script, "components").themeStore
6
+ for _k, _v in TS.import(script, script, "components") or {} do
7
+ exports[_k] = _v
8
+ end
9
+ for _k, _v in TS.import(script, script, "constants") or {} do
10
+ exports[_k] = _v
11
+ end
12
+ for _k, _v in TS.import(script, script, "interfaces") or {} do
13
+ exports[_k] = _v
14
+ end
15
+ for _k, _v in TS.import(script, script, "styles") or {} do
16
+ exports[_k] = _v
17
+ end
18
+ for _k, _v in TS.import(script, script, "themes") or {} do
19
+ exports[_k] = _v
20
+ end
21
+ exports.DefaultTheme = TS.import(script, script, "themes").default
22
+ exports.DarkTheme = TS.import(script, script, "themes", "DarkTheme").default
23
+ exports.LightTheme = TS.import(script, script, "themes", "LightTheme").default
24
+ for _k, _v in TS.import(script, script, "utilites") or {} do
25
+ exports[_k] = _v
26
+ end
27
+ return exports
@@ -0,0 +1,5 @@
1
+ export default interface IconSizes {
2
+ small: number;
3
+ medium: number;
4
+ large: number;
5
+ }