@hero-design/rn 8.16.0 → 8.17.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.
- package/.turbo/turbo-build.log +9 -9
- package/es/index.js +229 -77
- package/lib/index.js +229 -75
- package/package.json +7 -5
- package/rollup.config.js +1 -0
- package/src/components/Error/StyledError.tsx +6 -0
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +183 -33
- package/src/components/Error/__tests__/index.spec.tsx +18 -0
- package/src/components/Error/index.tsx +44 -11
- package/src/components/Skeleton/StyledSkeleton.tsx +25 -0
- package/src/components/Skeleton/__tests__/__snapshots__/index.spec.tsx.snap +498 -0
- package/src/components/Skeleton/__tests__/index.spec.tsx +30 -0
- package/src/components/Skeleton/index.tsx +134 -0
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +15 -0
- package/src/theme/components/skeleton.ts +22 -0
- package/src/theme/getTheme.ts +3 -0
- package/types/components/Error/StyledError.d.ts +7 -1
- package/types/components/Error/index.d.ts +4 -3
- package/types/components/Skeleton/StyledSkeleton.d.ts +17 -0
- package/types/components/Skeleton/index.d.ts +13 -0
- package/types/index.d.ts +2 -1
- package/types/theme/components/skeleton.d.ts +17 -0
- package/types/theme/getTheme.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.17.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.
|
|
24
|
+
"@hero-design/colors": "8.17.0",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"react": "18.0.0",
|
|
33
33
|
"react-native": "0.69.7",
|
|
34
34
|
"react-native-gesture-handler": "^1.10.3 | ~2.1.0",
|
|
35
|
+
"react-native-linear-gradient": "^2.6.2",
|
|
35
36
|
"react-native-pager-view": "^5.4.25",
|
|
36
37
|
"react-native-safe-area-context": "^3.0.2",
|
|
37
38
|
"react-native-vector-icons": "^9.1.0",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
"@babel/preset-typescript": "^7.17.12",
|
|
45
46
|
"@babel/runtime": "^7.18.9",
|
|
46
47
|
"@emotion/jest": "^11.9.3",
|
|
47
|
-
"@hero-design/eslint-plugin": "8.
|
|
48
|
+
"@hero-design/eslint-plugin": "8.17.0",
|
|
48
49
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
49
50
|
"@react-native-community/slider": "4.1.12",
|
|
50
51
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -60,12 +61,13 @@
|
|
|
60
61
|
"@types/react-native": "^0.67.7",
|
|
61
62
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
62
63
|
"babel-plugin-inline-import": "^3.0.0",
|
|
63
|
-
"eslint-config-hd": "8.
|
|
64
|
+
"eslint-config-hd": "8.17.0",
|
|
64
65
|
"jest": "^27.3.1",
|
|
65
|
-
"prettier-config-hd": "8.
|
|
66
|
+
"prettier-config-hd": "8.17.0",
|
|
66
67
|
"react": "18.0.0",
|
|
67
68
|
"react-native": "0.69.7",
|
|
68
69
|
"react-native-gesture-handler": "~2.1.0",
|
|
70
|
+
"react-native-linear-gradient": "^2.6.2",
|
|
69
71
|
"react-native-pager-view": "^5.4.25",
|
|
70
72
|
"react-native-safe-area-context": "^3.0.2",
|
|
71
73
|
"react-native-vector-icons": "^9.1.0",
|
package/rollup.config.js
CHANGED
|
@@ -50,6 +50,11 @@ const StyledErrorButtonSecondary = styled(Button)(({ theme }) => ({
|
|
|
50
50
|
padding: theme.__hd__.error.space.button.padding,
|
|
51
51
|
}));
|
|
52
52
|
|
|
53
|
+
const StyledErrorImageContainer = styled(View)(({ theme }) => ({
|
|
54
|
+
marginBottom: theme.__hd__.error.space.imageMarginBottom,
|
|
55
|
+
width: theme.__hd__.error.sizes.image,
|
|
56
|
+
height: theme.__hd__.error.sizes.image,
|
|
57
|
+
}));
|
|
53
58
|
const StyledErrorImage = styled(Image)(({ theme }) => ({
|
|
54
59
|
marginBottom: theme.__hd__.error.space.imageMarginBottom,
|
|
55
60
|
width: theme.__hd__.error.sizes.image,
|
|
@@ -83,4 +88,5 @@ export {
|
|
|
83
88
|
StyledErrorContent,
|
|
84
89
|
StyledErrorTitle,
|
|
85
90
|
StyledErrorDescription,
|
|
91
|
+
StyledErrorImageContainer,
|
|
86
92
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Error renders error screen with image correctly 1`] = `
|
|
3
|
+
exports[`Error renders error screen with custom image element correctly 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
style={
|
|
6
6
|
Array [
|
|
@@ -30,32 +30,169 @@ exports[`Error renders error screen with image correctly 1`] = `
|
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
>
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
<View
|
|
34
|
+
style={
|
|
35
|
+
Array [
|
|
36
|
+
Object {
|
|
37
|
+
"height": 176,
|
|
38
|
+
"marginBottom": 32,
|
|
39
|
+
"width": 176,
|
|
40
|
+
},
|
|
41
|
+
undefined,
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
<Image
|
|
46
|
+
source={
|
|
47
|
+
Object {
|
|
48
|
+
"uri": "path_to_image",
|
|
49
|
+
}
|
|
37
50
|
}
|
|
51
|
+
style={
|
|
52
|
+
Array [
|
|
53
|
+
Object {
|
|
54
|
+
"borderRadius": 0,
|
|
55
|
+
"height": 72,
|
|
56
|
+
"width": 72,
|
|
57
|
+
},
|
|
58
|
+
undefined,
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
testID="error-image"
|
|
62
|
+
/>
|
|
63
|
+
</View>
|
|
64
|
+
<Text
|
|
65
|
+
allowFontScaling={false}
|
|
66
|
+
style={
|
|
67
|
+
Array [
|
|
68
|
+
Object {
|
|
69
|
+
"color": "#001f23",
|
|
70
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
71
|
+
"fontSize": 14,
|
|
72
|
+
"letterSpacing": 0.42,
|
|
73
|
+
"lineHeight": 22,
|
|
74
|
+
},
|
|
75
|
+
Array [
|
|
76
|
+
Object {
|
|
77
|
+
"color": "#001f23",
|
|
78
|
+
"fontFamily": "RebondGrotesque-SemiBold",
|
|
79
|
+
"fontSize": 24,
|
|
80
|
+
"marginBottom": 8,
|
|
81
|
+
"textAlign": "center",
|
|
82
|
+
},
|
|
83
|
+
undefined,
|
|
84
|
+
],
|
|
85
|
+
]
|
|
38
86
|
}
|
|
87
|
+
themeFontSize="medium"
|
|
88
|
+
themeFontWeight="regular"
|
|
89
|
+
themeIntent="body"
|
|
90
|
+
themeTypeface="neutral"
|
|
91
|
+
>
|
|
92
|
+
We’re sorry, something went wrong
|
|
93
|
+
</Text>
|
|
94
|
+
<Text
|
|
95
|
+
allowFontScaling={false}
|
|
39
96
|
style={
|
|
40
97
|
Array [
|
|
41
98
|
Object {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
99
|
+
"color": "#001f23",
|
|
100
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
101
|
+
"fontSize": 14,
|
|
102
|
+
"letterSpacing": 0.42,
|
|
103
|
+
"lineHeight": 22,
|
|
45
104
|
},
|
|
46
105
|
Array [
|
|
47
106
|
Object {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
107
|
+
"color": "#4d6265",
|
|
108
|
+
"fontFamily": "RebondGrotesque",
|
|
109
|
+
"fontSize": 18,
|
|
110
|
+
"textAlign": "center",
|
|
52
111
|
},
|
|
53
112
|
undefined,
|
|
54
113
|
],
|
|
55
114
|
]
|
|
56
115
|
}
|
|
57
|
-
|
|
58
|
-
|
|
116
|
+
themeFontSize="medium"
|
|
117
|
+
themeFontWeight="regular"
|
|
118
|
+
themeIntent="body"
|
|
119
|
+
themeTypeface="neutral"
|
|
120
|
+
>
|
|
121
|
+
Please try again later
|
|
122
|
+
</Text>
|
|
123
|
+
</View>
|
|
124
|
+
</View>
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
exports[`Error renders error screen with image correctly 1`] = `
|
|
128
|
+
<View
|
|
129
|
+
style={
|
|
130
|
+
Array [
|
|
131
|
+
Object {
|
|
132
|
+
"backgroundColor": "#f6f6f7",
|
|
133
|
+
"display": "flex",
|
|
134
|
+
"flex": 1,
|
|
135
|
+
"flexDirection": "column",
|
|
136
|
+
},
|
|
137
|
+
undefined,
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
themeVariant="in-page"
|
|
141
|
+
>
|
|
142
|
+
<View
|
|
143
|
+
style={
|
|
144
|
+
Array [
|
|
145
|
+
Object {
|
|
146
|
+
"alignItems": "center",
|
|
147
|
+
"display": "flex",
|
|
148
|
+
"flex": 1,
|
|
149
|
+
"flexDirection": "column",
|
|
150
|
+
"justifyContent": "center",
|
|
151
|
+
"padding": 24,
|
|
152
|
+
},
|
|
153
|
+
undefined,
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
>
|
|
157
|
+
<View
|
|
158
|
+
style={
|
|
159
|
+
Array [
|
|
160
|
+
Object {
|
|
161
|
+
"height": 176,
|
|
162
|
+
"marginBottom": 32,
|
|
163
|
+
"width": 176,
|
|
164
|
+
},
|
|
165
|
+
undefined,
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
>
|
|
169
|
+
<Image
|
|
170
|
+
source={
|
|
171
|
+
Object {
|
|
172
|
+
"uri": "path_to_image",
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
style={
|
|
176
|
+
Array [
|
|
177
|
+
Object {
|
|
178
|
+
"borderRadius": 0,
|
|
179
|
+
"height": 72,
|
|
180
|
+
"width": 72,
|
|
181
|
+
},
|
|
182
|
+
Array [
|
|
183
|
+
Object {
|
|
184
|
+
"height": 176,
|
|
185
|
+
"marginBottom": 32,
|
|
186
|
+
"resizeMode": "contain",
|
|
187
|
+
"width": 176,
|
|
188
|
+
},
|
|
189
|
+
undefined,
|
|
190
|
+
],
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
testID="error-image"
|
|
194
|
+
/>
|
|
195
|
+
</View>
|
|
59
196
|
<Text
|
|
60
197
|
allowFontScaling={false}
|
|
61
198
|
style={
|
|
@@ -165,32 +302,45 @@ exports[`Error renders full screen error page correctly 1`] = `
|
|
|
165
302
|
]
|
|
166
303
|
}
|
|
167
304
|
>
|
|
168
|
-
<
|
|
169
|
-
source={
|
|
170
|
-
Object {
|
|
171
|
-
"uri": "path_to_image",
|
|
172
|
-
}
|
|
173
|
-
}
|
|
305
|
+
<View
|
|
174
306
|
style={
|
|
175
307
|
Array [
|
|
176
308
|
Object {
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
"width":
|
|
309
|
+
"height": 176,
|
|
310
|
+
"marginBottom": 32,
|
|
311
|
+
"width": 176,
|
|
180
312
|
},
|
|
313
|
+
undefined,
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
>
|
|
317
|
+
<Image
|
|
318
|
+
source={
|
|
319
|
+
Object {
|
|
320
|
+
"uri": "path_to_image",
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
style={
|
|
181
324
|
Array [
|
|
182
325
|
Object {
|
|
183
|
-
"
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
"width": 176,
|
|
326
|
+
"borderRadius": 0,
|
|
327
|
+
"height": 72,
|
|
328
|
+
"width": 72,
|
|
187
329
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
330
|
+
Array [
|
|
331
|
+
Object {
|
|
332
|
+
"height": 176,
|
|
333
|
+
"marginBottom": 32,
|
|
334
|
+
"resizeMode": "contain",
|
|
335
|
+
"width": 176,
|
|
336
|
+
},
|
|
337
|
+
undefined,
|
|
338
|
+
],
|
|
339
|
+
]
|
|
340
|
+
}
|
|
341
|
+
testID="error-image"
|
|
342
|
+
/>
|
|
343
|
+
</View>
|
|
194
344
|
<Text
|
|
195
345
|
allowFontScaling={false}
|
|
196
346
|
style={
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { fireEvent } from '@testing-library/react-native';
|
|
3
3
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
4
|
import Error from '..';
|
|
5
|
+
import Image from '../../Image';
|
|
5
6
|
|
|
6
7
|
const title = `We’re sorry, something went wrong`;
|
|
7
8
|
const description = 'Please try again later';
|
|
@@ -26,6 +27,23 @@ describe('Error', () => {
|
|
|
26
27
|
expect(getByTestId('error-image')).toBeTruthy();
|
|
27
28
|
expect(toJSON()).toMatchSnapshot();
|
|
28
29
|
});
|
|
30
|
+
it('renders error screen with custom image element correctly', () => {
|
|
31
|
+
const image = (
|
|
32
|
+
<Image
|
|
33
|
+
source={{
|
|
34
|
+
uri: 'path_to_image',
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
const { toJSON, getByText, getByTestId } = renderWithTheme(
|
|
39
|
+
<Error title={title} description={description} image={image} />
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(getByText(title)).toBeTruthy();
|
|
43
|
+
expect(getByText(description)).toBeTruthy();
|
|
44
|
+
expect(getByTestId('error-image')).toBeTruthy();
|
|
45
|
+
expect(toJSON()).toMatchSnapshot();
|
|
46
|
+
});
|
|
29
47
|
it('renders full screen error page correctly', () => {
|
|
30
48
|
const { toJSON, getByText, getByTestId } = renderWithTheme(
|
|
31
49
|
<Error
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
ReactElement,
|
|
3
|
+
isValidElement,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import type {
|
|
9
|
+
ImageSourcePropType,
|
|
10
|
+
ViewProps,
|
|
11
|
+
ImageProps as RNImageProps,
|
|
12
|
+
} from 'react-native';
|
|
4
13
|
import {
|
|
5
14
|
ErrorVariant,
|
|
6
15
|
StyledErrorButtonContainer,
|
|
@@ -10,10 +19,12 @@ import {
|
|
|
10
19
|
StyledErrorContent,
|
|
11
20
|
StyledErrorDescription,
|
|
12
21
|
StyledErrorImage,
|
|
22
|
+
StyledErrorImageContainer,
|
|
13
23
|
StyledErrorModal,
|
|
14
24
|
StyledErrorTitle,
|
|
15
25
|
} from './StyledError';
|
|
16
26
|
import { useDeprecation } from '../../utils/hooks';
|
|
27
|
+
import { ImageProps } from '../Image/index';
|
|
17
28
|
|
|
18
29
|
interface ErrorProps extends ViewProps {
|
|
19
30
|
/**
|
|
@@ -37,7 +48,10 @@ interface ErrorProps extends ViewProps {
|
|
|
37
48
|
/**
|
|
38
49
|
* Image of the error
|
|
39
50
|
*/
|
|
40
|
-
image?:
|
|
51
|
+
image?:
|
|
52
|
+
| ReactElement<ImageProps | RNImageProps>
|
|
53
|
+
| ImageSourcePropType
|
|
54
|
+
| string;
|
|
41
55
|
/**
|
|
42
56
|
* Testing id of the component.
|
|
43
57
|
*/
|
|
@@ -62,6 +76,23 @@ interface ErrorProps extends ViewProps {
|
|
|
62
76
|
|
|
63
77
|
type onCloseCallbackType = 'cta' | 'secondaryCta' | null;
|
|
64
78
|
|
|
79
|
+
const renderImage = (
|
|
80
|
+
image: ReactElement<ImageProps | RNImageProps> | ImageSourcePropType | string
|
|
81
|
+
) => {
|
|
82
|
+
if (isValidElement(image)) {
|
|
83
|
+
return React.cloneElement(image, {
|
|
84
|
+
testID: 'error-image',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<StyledErrorImage
|
|
90
|
+
source={typeof image === 'string' ? { uri: image } : image}
|
|
91
|
+
testID="error-image"
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
65
96
|
const ErrorPage = ({
|
|
66
97
|
variant = 'in-page',
|
|
67
98
|
title,
|
|
@@ -79,15 +110,17 @@ const ErrorPage = ({
|
|
|
79
110
|
secondaryCtaText && onSecondaryCtaPress !== undefined;
|
|
80
111
|
const showButtonContainer = showCta || showSecondaryCta;
|
|
81
112
|
return (
|
|
82
|
-
<StyledErrorContainer
|
|
83
|
-
|
|
113
|
+
<StyledErrorContainer
|
|
114
|
+
testID={testID}
|
|
115
|
+
themeVariant={variant}
|
|
116
|
+
{...nativeProps}
|
|
117
|
+
>
|
|
118
|
+
<StyledErrorContent>
|
|
84
119
|
{image && (
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
/>
|
|
120
|
+
<StyledErrorImageContainer>
|
|
121
|
+
{renderImage(image)}
|
|
122
|
+
</StyledErrorImageContainer>
|
|
89
123
|
)}
|
|
90
|
-
|
|
91
124
|
<StyledErrorTitle>{title}</StyledErrorTitle>
|
|
92
125
|
|
|
93
126
|
{description && (
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import styled from '@emotion/native';
|
|
2
|
+
import Box from '../Box';
|
|
3
|
+
|
|
4
|
+
type ThemeIntent = 'light' | 'dark';
|
|
5
|
+
type ThemeVariant = 'circular' | 'rectangular' | 'rounded';
|
|
6
|
+
|
|
7
|
+
const StyledContainer = styled(Box)<{
|
|
8
|
+
themeIntent: ThemeIntent;
|
|
9
|
+
themeVariant: ThemeVariant;
|
|
10
|
+
}>(({ theme, themeIntent, themeVariant }) => ({
|
|
11
|
+
backgroundColor:
|
|
12
|
+
themeIntent === 'light'
|
|
13
|
+
? theme.__hd__.skeleton.colors.lightBackground
|
|
14
|
+
: theme.__hd__.skeleton.colors.darkBackground,
|
|
15
|
+
borderRadius: theme.__hd__.skeleton.radii[themeVariant],
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
const StyledGradientContainer = styled(Box)<{ themeVariant: ThemeVariant }>(
|
|
19
|
+
({ theme, themeVariant }) => ({
|
|
20
|
+
overflow: 'hidden',
|
|
21
|
+
borderRadius: theme.__hd__.skeleton.radii[themeVariant],
|
|
22
|
+
})
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export { StyledContainer, StyledGradientContainer };
|