app-studio 0.0.7 → 0.0.8

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,488 +0,0 @@
1
- import React from 'react';
2
- import Color from 'color-convert';
3
- import styled from 'styled-components';
4
- import { useTheme } from '../providers/Theme';
5
- import { shadows } from '../utils/shadow';
6
- export const TransformStyleProps = [
7
- 'transform',
8
- 'transformMatrix',
9
- 'rotation',
10
- 'scaleX',
11
- 'scaleY',
12
- 'translateX',
13
- 'translateY',
14
- // 'perspective',
15
- // 'rotate',
16
- // 'rotateX',
17
- // 'rotateY',
18
- // 'rotateZ',
19
- // 'scale',
20
- // 'skewX',
21
- // 'skewY',
22
- 'testID',
23
- 'decomposedMatrix',
24
- ];
25
-
26
- export const ImageStyleProps = [
27
- 'borderTopRightRadius',
28
- 'backfaceVisibility',
29
- 'borderBottomLeftRadius',
30
- 'borderBottomRightRadius',
31
- 'borderColor',
32
- 'borderRadius',
33
- 'borderTopLeftRadius',
34
- 'backgroundColor',
35
- 'borderWidth',
36
- 'opacity',
37
- 'overflow',
38
- 'overflowX',
39
- 'overflowY',
40
- 'resizeMode',
41
- 'tintColor',
42
- 'overlayColor',
43
- ];
44
-
45
- export const LayoutStyleProps = [
46
- 'alignContent',
47
- 'alignItems',
48
- 'alignSelf',
49
- 'aspectRatio',
50
- 'borderBottomWidth',
51
- 'borderEndWidth',
52
- 'borderLeftWidth',
53
- 'borderRightWidth',
54
- 'borderStartWidth',
55
- 'borderTopWidth',
56
- 'borderWidth',
57
- 'bottom',
58
- 'direction',
59
- 'display',
60
- 'end',
61
- 'flex',
62
- 'flexBasis',
63
- 'flexDirection',
64
- 'flexGrow',
65
- 'flexShrink',
66
- 'flexWrap',
67
- 'height',
68
- 'justifyContent',
69
- 'left',
70
- 'margin',
71
- 'marginBottom',
72
- 'marginEnd',
73
- 'marginHorizontal',
74
- 'marginLeft',
75
- 'marginRight',
76
- 'marginStart',
77
- 'marginTop',
78
- 'marginVertical',
79
- 'maxHeight',
80
- 'maxWidth',
81
- 'minHeight',
82
- 'minWidth',
83
- 'overflow',
84
- 'overflowX',
85
- 'overflowY',
86
- 'padding',
87
- 'paddingBottom',
88
- 'paddingEnd',
89
- 'paddingHorizontal',
90
- 'paddingLeft',
91
- 'paddingRight',
92
- 'paddingStart',
93
- 'paddingTop',
94
- 'paddingVertical',
95
- 'position',
96
- 'right',
97
- 'start',
98
- 'top',
99
- 'width',
100
- 'zIndex',
101
- ];
102
-
103
- export const ShadowStyleProps = [
104
- 'shadowColor',
105
- 'shadowOffset',
106
- 'shadowOpacity',
107
- 'shadowRadius',
108
- ];
109
- export const TextStyleProps = [
110
- 'textShadowOffset',
111
- 'color',
112
- 'fontSize',
113
- 'fontStyle',
114
- 'fontWeight',
115
- 'lineHeight',
116
- 'textAlign',
117
- 'textDecorationLine',
118
- 'textShadowColor',
119
- 'fontFamily',
120
- 'textShadowRadius',
121
- 'includeFontPadding',
122
- 'textAlignVertical',
123
- 'fontVariant',
124
- 'letterSpacing',
125
- 'textDecorationColor',
126
- 'textDecorationStyle',
127
- 'textTransform',
128
- 'writingDirection',
129
- ];
130
-
131
- export const ViewStyleProps = [
132
- 'borderRightColor',
133
- 'backfaceVisibility',
134
- 'borderBottomColor',
135
- 'borderBottomEndRadius',
136
- 'borderBottomLeftRadius',
137
- 'borderBottomRightRadius',
138
- 'borderBottomStartRadius',
139
- 'borderBottomWidth',
140
- 'borderColor',
141
- 'borderEndColor',
142
- 'borderLeftColor',
143
- 'borderLeftWidth',
144
- 'borderRadius',
145
- 'backgroundColor',
146
- 'borderRightWidth',
147
- 'borderStartColor',
148
- 'borderStyle',
149
- 'borderTopColor',
150
- 'borderTopEndRadius',
151
- 'borderTopLeftRadius',
152
- 'borderTopRightRadius',
153
- 'borderTopStartRadius',
154
- 'borderTopWidth',
155
- 'borderWidth',
156
- 'border',
157
- 'opacity',
158
- 'elevation',
159
- 'size',
160
- ];
161
-
162
- export const ScrollViewStyleProps = [
163
- 'alwaysBounceHorizontal',
164
- 'alwaysBounceVertical',
165
- 'automaticallyAdjustContentInsets',
166
- 'bounces',
167
- 'bouncesZoom',
168
- 'canCancelContentTouches',
169
- 'centerContent',
170
- 'contentLayoutStyle',
171
- 'contentInset',
172
- 'contentInsetAdjustmentBehavior',
173
- 'contentOffset',
174
- 'decelerationRate',
175
- 'directionalLockEnabled',
176
- 'disableIntervalMomentum',
177
- 'disableScrollViewPanResponder',
178
- 'endFillColor',
179
- 'fadingEdgeLength',
180
- 'horizontal',
181
- 'indicatorStyle',
182
- 'invertStickyHeaders',
183
- 'keyboardDismissMode',
184
- 'keyboardShouldPersistTaps',
185
- 'maintainVisibleContentPosition',
186
- 'maximumZoomScale',
187
- 'minimumZoomScale',
188
- 'nestedScrollEnabled',
189
- 'onContentSizeChange',
190
- 'onMomentumScrollBegin',
191
- 'onMomentumScrollEnd',
192
- 'onScroll',
193
- 'onScrollBeginDrag',
194
- 'onScrollEndDrag',
195
- 'onScrollToTop',
196
- 'overScrollMode',
197
- 'pagingEnabled',
198
- 'persistentScrollbar',
199
- 'pinchGestureEnabled',
200
- 'refreshControl',
201
- 'removeClippedSubviews',
202
- 'scrollBarThumbImage',
203
- 'scrollEnabled',
204
- 'scrollEventThrottle',
205
- 'scrollIndicatorInsets',
206
- 'scrollPerfTag',
207
- 'scrollToOverflowEnabled',
208
- 'scrollsToTop',
209
- 'DEPRECATED_sendUpdatedChildFrames',
210
- 'showsHorizontalScrollIndicator',
211
- 'showsVerticalScrollIndicator',
212
- 'snapToAlignment',
213
- 'snapToEnd',
214
- 'snapToInterval',
215
- 'snapToOffsets',
216
- 'snapToStart',
217
- 'stickyHeaderIndices',
218
- 'zoomScale',
219
- ];
220
-
221
- export const BaseStyleProperty: any = {};
222
- LayoutStyleProps.concat(ShadowStyleProps, TransformStyleProps).map(
223
- (property) => {
224
- BaseStyleProperty[property] = true;
225
- }
226
- );
227
-
228
- export const ViewStyleProperty: any = BaseStyleProperty;
229
- ViewStyleProps.map((property) => {
230
- ViewStyleProperty[property] = true;
231
- });
232
-
233
- export const ScrollViewStyleProperty: any = ViewStyleProperty;
234
- ScrollViewStyleProps.map((property) => {
235
- ScrollViewStyleProperty[property] = true;
236
- });
237
-
238
- export const ImageStyleProperty: any = ViewStyleProperty;
239
- ImageStyleProps.map((property) => {
240
- ImageStyleProperty[property] = true;
241
- });
242
-
243
- export const TextStyleProperty: any = BaseStyleProperty;
244
- TextStyleProps.map((property) => {
245
- TextStyleProperty[property] = true;
246
- });
247
-
248
- export const allStyleProps: string[] = LayoutStyleProps.concat(
249
- ShadowStyleProps,
250
- TransformStyleProps,
251
- ViewStyleProps,
252
- ScrollViewStyleProps,
253
- TextStyleProps,
254
- ImageStyleProps
255
- );
256
-
257
- const WidthWords = ['X', 'Width', 'Horizontal', 'Right', 'Left'];
258
-
259
- export const WidthStyleProperty = ['x', 'width', 'right', 'left'].concat(
260
- allStyleProps.filter((property) => {
261
- return WidthWords.some((item) => property.indexOf(item) >= 0);
262
- })
263
- );
264
- export const WidthStyleProps: any = {};
265
- WidthStyleProperty.map((property) => {
266
- WidthStyleProps[property] = true;
267
- });
268
-
269
- const HeightWords = ['Y', 'Height', 'Vertical', 'top', 'bottom'];
270
-
271
- export const HeightStyleProperty = ['y', 'height', 'top', 'bottom'].concat(
272
- allStyleProps.filter((property) => {
273
- return HeightWords.some((item) => property.indexOf(item) >= 0);
274
- })
275
- );
276
-
277
- export const HeightStyleProps: any = {};
278
- HeightStyleProperty.map((property) => {
279
- HeightStyleProps[property] = true;
280
- });
281
-
282
- export const SizeProps: any = {};
283
- HeightStyleProperty.concat(WidthStyleProperty).map((property) => {
284
- SizeProps[property] = true;
285
- });
286
-
287
- export const StyleProps: any = {};
288
- allStyleProps.map((property) => {
289
- StyleProps[property] = true;
290
- });
291
-
292
- const NumberPropsStyle: any = {};
293
- const NumberProps = [
294
- 'numberOfLines',
295
- 'fontWeight',
296
- 'timeStamp',
297
- 'flex',
298
- 'flexGrow',
299
- 'flexShrink',
300
- 'order',
301
- 'zIndex',
302
- 'aspectRatio',
303
- 'shadowOpacity',
304
- 'shadowRadius',
305
- 'scale',
306
- 'opacity',
307
- 'min',
308
- 'max',
309
- 'now',
310
- ];
311
-
312
- NumberProps.map((property: string) => {
313
- NumberPropsStyle[property] = true;
314
- });
315
-
316
- export const setSize = (newSize: string | number, newProps: any) => {
317
- newProps.height = newProps.width = newSize;
318
- };
319
-
320
- export const applyStyle = (props: any) => {
321
- const { getColor } = useTheme();
322
-
323
- const newProps: any = {};
324
-
325
- if (props.onClick) {
326
- newProps.cursor = 'pointer';
327
- }
328
-
329
- const size =
330
- props.height !== undefined &&
331
- props.width !== undefined &&
332
- props.height === props.width
333
- ? props.height
334
- : props.size
335
- ? props.size
336
- : null;
337
-
338
- if (size) {
339
- setSize(size, newProps);
340
- }
341
-
342
- if (props.paddingHorizontal) {
343
- newProps.paddingLeft = props.paddingHorizontal;
344
- newProps.paddingRight = props.paddingHorizontal;
345
- }
346
-
347
- if (props.marginHorizontal) {
348
- newProps.marginLeft = props.marginHorizontal;
349
- newProps.marginRight = props.marginHorizontal;
350
- }
351
-
352
- if (props.paddingVertical) {
353
- newProps.paddingTop = props.paddingVertical;
354
- newProps.paddingBottom = props.paddingVertical;
355
- }
356
-
357
- if (props.marginVertical) {
358
- newProps.marginTop = props.marginVertical;
359
- newProps.marginBottom = props.marginVertical;
360
- }
361
-
362
- if (props.shadow) {
363
- if (typeof props.shadow === 'number' || typeof props.shadow === 'boolean') {
364
- const shawdowValue: number =
365
- typeof props.shadow === 'number' && shadows[props.shadow] !== undefined
366
- ? props.shadow
367
- : 2;
368
-
369
- if (shadows[shawdowValue]) {
370
- const shadowColor = Color.hex
371
- .rgb(shadows[shawdowValue].shadowColor)
372
- .join(',');
373
-
374
- newProps[
375
- 'boxShadow'
376
- ] = `${shadows[shawdowValue].shadowOffset.height}px ${shadows[shawdowValue].shadowOffset.width}px ${shadows[shawdowValue].shadowRadius}px rgba(${shadowColor},${shadows[shawdowValue].shadowOpacity})`;
377
- }
378
- } else {
379
- const shadowColor = Color.hex.rgb(props.shadow.shadowColor).join(',');
380
-
381
- newProps[
382
- 'boxShadow'
383
- ] = `${props.shadow.shadowOffset.height}px ${props.shadow.shadowOffset.width}px ${props.shadow.shadowRadius}px rgba(${shadowColor},${props.shadow.shadowOpacity})`;
384
- }
385
- }
386
-
387
- Object.keys(props).map((property) => {
388
- if (StyleProps[property] !== undefined || property == 'on') {
389
- if (
390
- typeof props[property] === 'number' &&
391
- NumberPropsStyle[property] === undefined
392
- ) {
393
- newProps[property] = props[property] + 'px';
394
- } else if (property.toLowerCase().indexOf('color') !== -1) {
395
- newProps[property] = getColor(props[property]);
396
- } else if (typeof props[property] === 'object') {
397
- if (property === 'on') {
398
- for (const event in props[property]) {
399
- newProps['&:' + event] = applyStyle(props[property][event]);
400
- }
401
- } else {
402
- newProps[property] = applyStyle(props[property]);
403
- }
404
- } else {
405
- newProps[property] = props[property];
406
- }
407
- }
408
- });
409
-
410
- return newProps;
411
- };
412
-
413
- // function convertToCSS(props: any) {
414
- // return Object.entries(props).reduce((str, [key, val]) => {
415
- // const casedKey = key.replace(
416
- // /[A-Z]/g,
417
- // (match) => `-${match.toLowerCase()}`
418
- // );
419
- // return `${str}${casedKey}:${typeof val === 'number' ? val + 'px' : val};\n`;
420
- // }, '');
421
- // }
422
-
423
- // export const getResponsiveMediaQueries = (props: any) => {
424
- // const { breakpointKeys, breakpoints } = useResponsive();
425
- // console.log('mediaQueries', props);
426
-
427
- // const mediaQueries = breakpointKeys
428
- // .map((size) => {
429
- // return props && props[size] !== undefined
430
- // ? `
431
- // @media ${
432
- // breakpoints[size].min
433
- // ? ' (min-width:' +
434
- // (breakpoints[size].min > 0 ? breakpoints[size].min : 0) +
435
- // 'px)'
436
- // : ''
437
- // } ${
438
- // breakpoints[size].min &&
439
- // breakpoints[size].max &&
440
- // breakpoints[size].max >= 0 &&
441
- // breakpoints[size].max < Infinity
442
- // ? ' and '
443
- // : ''
444
- // } ${
445
- // breakpoints[size].max &&
446
- // breakpoints[size].max >= 0 &&
447
- // breakpoints[size].max < Infinity
448
- // ? ' (max-width:' + breakpoints[size].max + 'px)'
449
- // : ''
450
- // } {
451
- // ${convertToCSS(props[size])}
452
- // }`
453
- // : '';
454
- // })
455
- // .join('\n');
456
-
457
- // return mediaQueries;
458
- // };
459
-
460
- export const StyledView = styled.div((props: any) => {
461
- return applyStyle(props);
462
- });
463
-
464
- export const StyledImage = styled.img((props: any) => {
465
- return applyStyle(props);
466
- });
467
-
468
- export class ViewElement extends React.PureComponent<any> {
469
- render() {
470
- let { onClick } = this.props;
471
- if (this.props.onPress !== undefined) {
472
- onClick = this.props.onPress;
473
- }
474
-
475
- //console.log(this.props);
476
- return <StyledView {...this.props} onClick={onClick} />;
477
- }
478
- }
479
-
480
- export class ImageElement extends React.PureComponent<any> {
481
- render() {
482
- let { onClick } = this.props;
483
- if (this.props.onPress !== undefined) {
484
- onClick = this.props.onPress;
485
- }
486
- return <StyledImage {...this.props} onClick={onClick} />;
487
- }
488
- }
@@ -1,49 +0,0 @@
1
- import React from 'react';
2
- import { CSSProperties } from 'styled-components';
3
- import { ImageElement } from './Element';
4
- import { View } from './View';
5
- import { ImageStyleProps } from '../types/style';
6
- import { Shadow } from '../utils/shadow';
7
-
8
- export interface ImageProps
9
- extends Omit<ImageStyleProps, 'pointerEvents' | 'source'>,
10
- CSSProperties {
11
- size?: number;
12
- on?: Record<string, CSSProperties>;
13
- onPress?: (...args: any) => void;
14
- src: string | any;
15
- shadow?: boolean | number | Shadow;
16
- }
17
-
18
- export interface ImageBackgroundProps extends ImageProps {
19
- src: string;
20
- }
21
-
22
- export class ImageBackground extends React.PureComponent<ImageBackgroundProps> {
23
- render() {
24
- const { src, onClick, onPress, ...props } = this.props;
25
-
26
- return (
27
- <View
28
- style={{
29
- backgroundSize: 'contain',
30
- backgroundImage: `url("${src}")`,
31
- backgroundPosition: 'center center',
32
- backgroundRepeat: 'no-repeat',
33
- }}
34
- onClick={onClick ? onClick : onPress}
35
- {...props}
36
- />
37
- );
38
- }
39
- }
40
-
41
- export const Image = (props: ImageProps) => <ImageElement {...props} />;
42
-
43
- export const RoundedImage = ({ size, src, ...props }: any) => (
44
- <ImageBackground borderRadius={size / 2} size={size} src={src} {...props} />
45
- );
46
-
47
- export const SquaredImage = ({ size, src, ...props }: any) => (
48
- <ImageBackground {...props} size={size} src={src} />
49
- );
@@ -1,49 +0,0 @@
1
- import React from 'react';
2
- import { View } from './View';
3
-
4
- export const Layout = (props: any) => <View {...props} />;
5
-
6
- export const Horizontal = (props: any) => (
7
- <View display={'flex'} flexDirection="row" {...props} />
8
- );
9
-
10
- export const Inline = (props: any) => (
11
- <View
12
- display={'flex'}
13
- flexDirection="row"
14
- wordBreak="break-word"
15
- {...props}
16
- />
17
- );
18
-
19
- export const Vertical = (props: any) => (
20
- <View flexDirection="column" {...props} />
21
- );
22
-
23
- export const Center = (props: any) => (
24
- <View
25
- display={'flex'}
26
- justifyContent="center"
27
- alignItems={'center'}
28
- {...props}
29
- />
30
- );
31
-
32
- export const AlignStart = (props: any) => (
33
- <View display={'flex'} justifyContent="flex-start" {...props} />
34
- );
35
-
36
- export const AlignCenter = (props: any) => (
37
- <View display={'flex'} justifyContent="center" width={'100%'} {...props} />
38
- );
39
-
40
- export const AlignEnd = (props: any) => (
41
- <View display={'flex'} justifyContent="flex-end" width={'100%'} {...props} />
42
- );
43
-
44
- export const Start = (props: any) => (
45
- <View display={'flex'} alignSelf="flex-end" {...props} />
46
- );
47
- export const End = (props: any) => (
48
- <View display={'flex'} alignSelf="flex-end" {...props} />
49
- );
@@ -1,61 +0,0 @@
1
- import React from 'react';
2
- import { CSSProperties } from 'styled-components';
3
- import styled from 'styled-components';
4
- import { applyStyle } from './Element';
5
- import { TextStyleProps } from '../types/style';
6
- import { Shadow } from '../utils/shadow';
7
-
8
- export interface TextProps
9
- extends Omit<TextStyleProps, 'pointerEvents' | 'onPress'>,
10
- CSSProperties {
11
- on?: Record<string, CSSProperties>;
12
- onPress?: (...args: any) => void;
13
- paddingHorizontal?: number | string;
14
- marginHorizontal?: number | string;
15
- paddingVertical?: number | string;
16
- marginVertical?: number | string;
17
- toUpperCase?: boolean;
18
- toFormat?: boolean;
19
- shadow?: boolean | number | Shadow;
20
- }
21
-
22
- export const TextSpan: React.FC<CSSProperties> = styled.div(
23
- (props: CSSProperties) => {
24
- props.display = 'inherit';
25
- props.flexDirection = 'column';
26
- return applyStyle(props);
27
- }
28
- );
29
-
30
- export class Text extends React.PureComponent<TextProps> {
31
- render() {
32
- const {
33
- toUpperCase = false,
34
- children,
35
- toFormat = false,
36
- ...props
37
- } = this.props;
38
- let content: any = children;
39
-
40
- if (children && typeof children === 'string') {
41
- content = children.toString().trim();
42
- }
43
-
44
- if (typeof content === 'string' && toUpperCase) {
45
- content = content.toUpperCase();
46
- }
47
-
48
- if (typeof content === 'string' && toFormat) {
49
- content = content.split('\n').map((item, key) => {
50
- return (
51
- <span key={key.toString()}>
52
- {item}
53
- <br />
54
- </span>
55
- );
56
- });
57
- }
58
-
59
- return <TextSpan {...props}>{content}</TextSpan>;
60
- }
61
- }
@@ -1,6 +0,0 @@
1
-
2
- View element:
3
-
4
- ```jsx padded
5
- <View backgroundColor="red" color="white" padding={20}>Push Me</View>
6
- ```
@@ -1,24 +0,0 @@
1
- import React from 'react';
2
- import { ViewElement } from './Element';
3
- import { ViewStyleProps } from '../types/style';
4
- import { CSSProperties } from 'styled-components';
5
- import { Shadow } from '../utils/shadow';
6
-
7
- export interface ViewProps
8
- extends Omit<ViewStyleProps, 'pointerEvents'>,
9
- CSSProperties {
10
- size?: number;
11
- on?: Record<string, CSSProperties>;
12
- onPress?: (...args: any) => void;
13
- paddingHorizontal?: number | string;
14
- marginHorizontal?: number | string;
15
- paddingVertical?: number | string;
16
- marginVertical?: number | string;
17
- shadow?: boolean | number | Shadow;
18
- }
19
-
20
- export const View = (props: ViewProps) => <ViewElement {...props} />;
21
-
22
- export const SafeArea = View;
23
-
24
- export const Scroll = (props: any) => <View overflow={'auto'} {...props} />;
@@ -1,11 +0,0 @@
1
- import * as React from 'react';
2
- import { ResponsiveProvider, ThemeProvider } from '..';
3
- export default class Wrapper extends React.Component<{}, {}> {
4
- render() {
5
- return (
6
- <ThemeProvider>
7
- <ResponsiveProvider>{this.props.children}</ResponsiveProvider>
8
- </ThemeProvider>
9
- );
10
- }
11
- }
@@ -1,6 +0,0 @@
1
- import { useEffect } from 'react';
2
- export const useMount = (callback: () => void) => {
3
- useEffect(() => {
4
- callback();
5
- }, []);
6
- };