expo-snowui 1.0.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 (73) hide show
  1. package/LICENSE.txt +674 -0
  2. package/README.md +16 -0
  3. package/lib/module/component/snow-break.js +15 -0
  4. package/lib/module/component/snow-break.js.map +1 -0
  5. package/lib/module/component/snow-dropdown.js +66 -0
  6. package/lib/module/component/snow-dropdown.js.map +1 -0
  7. package/lib/module/component/snow-fill-view.js +40 -0
  8. package/lib/module/component/snow-fill-view.js.map +1 -0
  9. package/lib/module/component/snow-grid.js +70 -0
  10. package/lib/module/component/snow-grid.js.map +1 -0
  11. package/lib/module/component/snow-header.js +20 -0
  12. package/lib/module/component/snow-header.js.map +1 -0
  13. package/lib/module/component/snow-image-button.js +98 -0
  14. package/lib/module/component/snow-image-button.js.map +1 -0
  15. package/lib/module/component/snow-image-grid.js +84 -0
  16. package/lib/module/component/snow-image-grid.js.map +1 -0
  17. package/lib/module/component/snow-input.js +51 -0
  18. package/lib/module/component/snow-input.js.map +1 -0
  19. package/lib/module/component/snow-label.js +20 -0
  20. package/lib/module/component/snow-label.js.map +1 -0
  21. package/lib/module/component/snow-modal.js +49 -0
  22. package/lib/module/component/snow-modal.js.map +1 -0
  23. package/lib/module/component/snow-range-slider.js +247 -0
  24. package/lib/module/component/snow-range-slider.js.map +1 -0
  25. package/lib/module/component/snow-safe-area.js +22 -0
  26. package/lib/module/component/snow-safe-area.js.map +1 -0
  27. package/lib/module/component/snow-tabs.js +62 -0
  28. package/lib/module/component/snow-tabs.js.map +1 -0
  29. package/lib/module/component/snow-text-button.js +102 -0
  30. package/lib/module/component/snow-text-button.js.map +1 -0
  31. package/lib/module/component/snow-text.js +34 -0
  32. package/lib/module/component/snow-text.js.map +1 -0
  33. package/lib/module/component/snow-toggle.js +38 -0
  34. package/lib/module/component/snow-toggle.js.map +1 -0
  35. package/lib/module/context/snow-focus-context.js +39 -0
  36. package/lib/module/context/snow-focus-context.js.map +1 -0
  37. package/lib/module/context/snow-style-context.js +54 -0
  38. package/lib/module/context/snow-style-context.js.map +1 -0
  39. package/lib/module/index.js +63 -0
  40. package/lib/module/index.js.map +1 -0
  41. package/lib/module/package.json +1 -0
  42. package/lib/module/snow-app.js +40 -0
  43. package/lib/module/snow-app.js.map +1 -0
  44. package/lib/module/snow-style.js +392 -0
  45. package/lib/module/snow-style.js.map +1 -0
  46. package/lib/module/snow-ui.js +19 -0
  47. package/lib/module/snow-ui.js.map +1 -0
  48. package/lib/typescript/package.json +1 -0
  49. package/lib/typescript/src/index.d.ts +42 -0
  50. package/lib/typescript/src/index.d.ts.map +1 -0
  51. package/package.json +163 -0
  52. package/src/component/snow-break.js +9 -0
  53. package/src/component/snow-dropdown.js +64 -0
  54. package/src/component/snow-fill-view.js +36 -0
  55. package/src/component/snow-grid.js +74 -0
  56. package/src/component/snow-header.js +18 -0
  57. package/src/component/snow-image-button.js +98 -0
  58. package/src/component/snow-image-grid.js +87 -0
  59. package/src/component/snow-input.js +47 -0
  60. package/src/component/snow-label.js +18 -0
  61. package/src/component/snow-modal.js +46 -0
  62. package/src/component/snow-range-slider.js +263 -0
  63. package/src/component/snow-safe-area.js +17 -0
  64. package/src/component/snow-tabs.js +62 -0
  65. package/src/component/snow-text-button.js +106 -0
  66. package/src/component/snow-text.js +31 -0
  67. package/src/component/snow-toggle.js +32 -0
  68. package/src/context/snow-focus-context.js +37 -0
  69. package/src/context/snow-style-context.js +46 -0
  70. package/src/index.tsx +63 -0
  71. package/src/snow-app.js +27 -0
  72. package/src/snow-style.js +399 -0
  73. package/src/snow-ui.js +16 -0
@@ -0,0 +1,399 @@
1
+ import { Platform, Dimensions } from 'react-native';
2
+
3
+ const isTV = Platform.isTV
4
+ const isAndroid = Platform.OS === 'android'
5
+ const isWeb = Platform.OS === 'web'
6
+ const isPortrait = Dimensions.get('window').width < Dimensions.get('window').height
7
+ import _ from 'lodash'
8
+
9
+ let scaleMultiplier = 0.75
10
+
11
+ if (isTV) {
12
+ scaleMultiplier = 0.5
13
+ }
14
+
15
+ const scaled = (input) => {
16
+ return Math.round(input * scaleMultiplier)
17
+ }
18
+
19
+ export function getWindowHeight() {
20
+ return Dimensions.get('window').height
21
+ }
22
+
23
+ export function getWindowWidth() {
24
+ return Dimensions.get('window').width
25
+ }
26
+
27
+ export function createStyle(overrides) {
28
+ let AppStyle = {
29
+ color: {
30
+ background: 'black',
31
+ text: 'rgb(235, 235, 235)',
32
+ textDark: 'rgb(22, 22, 22)',
33
+ active: 'rgb(150, 150, 150)',
34
+ hover: 'rgb(119, 139, 255)',
35
+ core: 'rgb(219, 158, 44)',
36
+ coreDark: 'rgb(136, 98, 27)',
37
+ outlineDark: 'rgb(63, 63, 63)',
38
+ fade: 'rgb(23, 23, 23)',
39
+ transparentDark: 'rgba(0,0,0,0.6)',
40
+ panel: 'rgb(50, 50, 50)',
41
+ },
42
+ fontSize: {
43
+ header: 40,
44
+ label: 26
45
+ },
46
+ surface: {
47
+ uhd: {
48
+ width: 3840,
49
+ height: 2160
50
+ },
51
+ fhd: {
52
+ width: 1920,
53
+ height: 1080
54
+ }
55
+ },
56
+ button: {
57
+ borderRadius: 6
58
+ },
59
+ imageButton: {
60
+ wrapper: {
61
+ normal: {
62
+ height: scaled(425),
63
+ width: scaled(310)
64
+ },
65
+ wide: {
66
+ height: scaled(280),
67
+ width: scaled(310)
68
+ },
69
+ square: {
70
+ height: scaled(250),
71
+ width: scaled(250)
72
+ }
73
+ },
74
+ image: {
75
+ normal: {
76
+ height: scaled(315),
77
+ width: scaled(260)
78
+ },
79
+ wide: {
80
+ height: scaled(165),
81
+ width: scaled(260)
82
+ },
83
+ square: {
84
+ height: scaled(200),
85
+ width: scaled(200)
86
+ }
87
+ },
88
+ fontSize: {
89
+ normal: scaled(25),
90
+ small: scaled(20)
91
+ },
92
+ textBox: {
93
+ marginTop: isAndroid ? -10 : 0
94
+ }
95
+ },
96
+ textButton: {
97
+ wrapper: {
98
+ normal: {
99
+ height: 35
100
+ }
101
+ },
102
+ fontSize: {
103
+ normal: 16,
104
+ small: 12
105
+ },
106
+ textBox: {
107
+ height: isAndroid ? 25 : 15
108
+ }
109
+ },
110
+ rangeSlider: {
111
+ borderRadius: 16,
112
+ thumbSize: 60,
113
+ trackSize: 30
114
+ }
115
+ }
116
+ if (overrides) {
117
+ // Apply color overrides before generating the rest of the style
118
+ AppStyle = _.merge({}, AppStyle, overrides)
119
+ }
120
+
121
+
122
+ AppStyle.component = {
123
+ break: {
124
+ borderBottomColor: AppStyle.color.coreDark,
125
+ borderBottomWidth: 2,
126
+ },
127
+ fillView: {
128
+ default: {
129
+ flex: 1
130
+ },
131
+ flexStart: {
132
+ justifyContent: 'flex-start'
133
+ }
134
+ },
135
+ grid: {
136
+ list: {
137
+ justifyContent: 'space-evenly'
138
+ },
139
+ short: {
140
+ padding: 0
141
+ }
142
+ },
143
+ header: {
144
+ fontSize: AppStyle.fontSize.header,
145
+ color: AppStyle.color.text,
146
+ margin: 10,
147
+ padding: 10
148
+ },
149
+ imageButton: {
150
+ wrapper: {
151
+ height: AppStyle.imageButton.wrapper.normal.height,
152
+ width: AppStyle.imageButton.wrapper.normal.width,
153
+ margin: 10,
154
+ marginLeft: 'auto',
155
+ marginRight: 'auto',
156
+ borderColor: AppStyle.color.background,
157
+ borderWidth: AppStyle.button.borderRadius,
158
+ },
159
+ wrapperWide: {
160
+ height: AppStyle.imageButton.wrapper.wide.height,
161
+ width: AppStyle.imageButton.wrapper.wide.width,
162
+ },
163
+ wrapperSquare: {
164
+ height: AppStyle.imageButton.wrapper.square.height,
165
+ width: AppStyle.imageButton.wrapper.square.width
166
+ },
167
+ selected: {
168
+ borderColor: AppStyle.color.active
169
+ },
170
+ focused: {
171
+ borderColor: AppStyle.color.hover
172
+ },
173
+ dull: {
174
+ backgroundColor: AppStyle.color.coreDark,
175
+ borderColor: AppStyle.color.coreDark,
176
+ },
177
+ image: {
178
+ height: AppStyle.imageButton.image.normal.height,
179
+ width: AppStyle.imageButton.image.normal.width,
180
+ marginTop: 5,
181
+ paddingBottom: 5,
182
+ marginLeft: 'auto',
183
+ marginRight: 'auto'
184
+ },
185
+ imageWide: {
186
+ height: AppStyle.imageButton.image.wide.height,
187
+ width: AppStyle.imageButton.image.wide.width,
188
+ },
189
+ imageSquare: {
190
+ height: AppStyle.imageButton.image.square.height,
191
+ width: AppStyle.imageButton.image.square.width,
192
+ },
193
+ text: {
194
+ height: 25,
195
+ color: AppStyle.color.textDark,
196
+ fontSize: AppStyle.imageButton.fontSize.normal,
197
+ fontWeight: 'bold',
198
+ padding: 0,
199
+ margin: 0,
200
+ textAlign: 'center'
201
+ },
202
+ smallText: {
203
+ fontSize: AppStyle.imageButton.fontSize.small
204
+ },
205
+ textWrapper: {
206
+ marginLeft: 'auto',
207
+ marginRight: 'auto',
208
+ marginTop: 5,
209
+ width: '100%',
210
+ height: 41,
211
+ backgroundColor: AppStyle.color.core,
212
+ borderColor: AppStyle.color.core,
213
+ borderRadius: AppStyle.button.borderRadius,
214
+ justifyContent: 'center',
215
+ alignItems: 'center',
216
+ padding: 2
217
+ }
218
+ },
219
+ input: {
220
+ text: {
221
+ border: 'solid white 2px',
222
+ backgroundColor: AppStyle.color.core,
223
+ color: 'white',
224
+ margin: 10,
225
+ padding: 10
226
+ },
227
+ small: {
228
+ margin: 1,
229
+ padding: 1,
230
+ fontSize: 10
231
+ }
232
+ },
233
+ label: {
234
+ fontSize: AppStyle.fontSize.label,
235
+ color: AppStyle.color.text,
236
+ margin: 10,
237
+ padding: 10
238
+ },
239
+ modal: {
240
+ prompt: {
241
+ backgroundColor: AppStyle.color.background
242
+ },
243
+ transparent: {
244
+ backgroundColor: AppStyle.color.transparentDark
245
+ },
246
+ center: {
247
+ justifyContent: 'center',
248
+ alignItems: 'center',
249
+ textAlign: 'center'
250
+ }
251
+ },
252
+ rangeSlider: {
253
+ wrapper: {
254
+ alignItems: "center",
255
+ marginVertical: AppStyle.rangeSlider.trackSize
256
+ },
257
+ trackWrapper: {
258
+ height: AppStyle.rangeSlider.trackSize,
259
+ borderRadius: AppStyle.rangeSlider.borderRadius,
260
+ flexDirection: "row",
261
+ alignItems: "center",
262
+ backgroundColor: "transparent",
263
+ width: 400
264
+ },
265
+ leftTrack: {
266
+ height: "100%",
267
+ borderTopLeftRadius: AppStyle.rangeSlider.borderRadius,
268
+ borderBottomLeftRadius: AppStyle.rangeSlider.borderRadius,
269
+ backgroundColor: AppStyle.color.coreDark
270
+ },
271
+ rightTrack: {
272
+ flex: 1,
273
+ height: "100%",
274
+ borderTopRightRadius: AppStyle.rangeSlider.borderRadius,
275
+ borderBottomRightRadius: AppStyle.rangeSlider.borderRadius,
276
+ backgroundColor: AppStyle.color.outlineDark
277
+ },
278
+ thumb: {
279
+ position: "absolute",
280
+ width: AppStyle.rangeSlider.thumbSize,
281
+ height: AppStyle.rangeSlider.thumbSize,
282
+ borderRadius: AppStyle.rangeSlider.thumbSize / 2,
283
+ borderWidth: 4,
284
+ backgroundColor: AppStyle.color.core,
285
+ borderColor: AppStyle.color.coreDark
286
+ }
287
+ },
288
+ safeArea: {
289
+ padding: 30,
290
+ backgroundColor: AppStyle.color.background,
291
+ flex: 1
292
+ },
293
+ tabs: {
294
+ panel: {
295
+ backgroundColor: AppStyle.color.panel,
296
+ marginTop: isWeb ? -16 : -18,
297
+ borderRadius: AppStyle.button.borderRadius,
298
+ borderWidth: 1,
299
+ borderColor: 'transparent',
300
+ paddingTop: 30,
301
+ paddingBottom: 30
302
+ }
303
+ },
304
+ textButton: {
305
+ wrapper: {
306
+ margin: 10,
307
+ padding: 10,
308
+ height: AppStyle.textButton.wrapper.normal.height,
309
+ justifyContent: 'center', // Horizontally center each line
310
+ alignItems: 'center', // Vertically center each line
311
+ alignContent: 'center', // Multiline vertical center of parent
312
+ textAlign: 'center', // Ensure text objects are horizontally centered
313
+ backgroundColor: AppStyle.color.core,
314
+ borderWidth: AppStyle.button.borderRadius,
315
+ borderColor: AppStyle.color.core,
316
+ borderRadius: AppStyle.button.borderRadius
317
+ },
318
+ tallWrapper: {
319
+ height: 80,
320
+ padding: 0
321
+ },
322
+ shortWrapper: {
323
+ height: 10,
324
+ margin: 1
325
+ },
326
+ selected: {
327
+ borderColor: AppStyle.color.active
328
+ },
329
+ focused: {
330
+ borderColor: AppStyle.color.hover
331
+ },
332
+ disabled: {
333
+ opacity: 0.5
334
+ },
335
+ fade: {
336
+ backgroundColor: AppStyle.color.fade
337
+ },
338
+ text: {
339
+ color: AppStyle.color.textDark,
340
+ fontSize: AppStyle.textButton.fontSize.normal,
341
+ padding: 0,
342
+ margin: 0,
343
+ textAlign: 'center',
344
+ height: AppStyle.textButton.textBox.height
345
+ },
346
+ smallText: {
347
+ fontSize: AppStyle.textButton.fontSize.small
348
+ },
349
+ fadeText: {
350
+
351
+ }
352
+ },
353
+ text: {
354
+ text: {
355
+ color: AppStyle.color.text
356
+ },
357
+ normal: {
358
+ margin: 10,
359
+ padding: 10
360
+ },
361
+ normal: {
362
+ margin: 10,
363
+ padding: 10
364
+ },
365
+ center: {
366
+ width: '100%',
367
+ alignItems: 'center'
368
+ },
369
+ noSelect: {
370
+ noSelect: {
371
+ userSelect: 'none',
372
+ WebkitUserSelect: 'none',
373
+ MozUserSelect: 'none',
374
+ msUserSelect: 'none',
375
+ }
376
+ }
377
+ },
378
+ toggle: {
379
+ center: {
380
+ flex: 1,
381
+ display: 'flex',
382
+ marginLeft: 'auto',
383
+ marginRight: 'auto',
384
+ marginBottom: 30
385
+ }
386
+ }
387
+ }
388
+
389
+ AppStyle.isTV = isTV
390
+ AppStyle.isWeb = isWeb
391
+ AppStyle.isAndroid = isAndroid
392
+ AppStyle.isPortrait = isPortrait
393
+
394
+ if (overrides) {
395
+ AppStyle = _.merge({}, AppStyle, overrides)
396
+ }
397
+
398
+ return AppStyle
399
+ }
package/src/snow-ui.js ADDED
@@ -0,0 +1,16 @@
1
+ import React from 'react'
2
+ import { FocusContextProvider } from './context/snow-focus-context'
3
+ import { GuiContextProvider } from './context/snow-gui-context'
4
+
5
+ export function SnowUi(props) {
6
+ if (!props.children) {
7
+ return (<React.Text>Children are required to use SnowUI</React.Text>)
8
+ }
9
+ return (
10
+ <FocusContextProvider>
11
+ <GuiContextProvider>
12
+ {props.children}
13
+ </GuiContextProvider>
14
+ </FocusContextProvider>
15
+ )
16
+ }