@hero-design/rn 8.36.3 → 8.38.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 +1 -1
- package/es/index.js +763 -782
- package/lib/index.js +3518 -3536
- package/package.json +7 -7
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +4 -15
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +12 -42
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +36 -29
- package/src/components/FAB/ActionGroup/index.tsx +18 -29
- package/src/components/HeroDesignProvider/__tests__/__snapshots__/index.spec.tsx.snap +52 -0
- package/src/components/HeroDesignProvider/__tests__/index.spec.tsx +78 -0
- package/src/components/HeroDesignProvider/index.tsx +14 -0
- package/src/components/TextInput/__tests__/StyledTextInput.spec.tsx +2 -2
- package/src/components/TextInput/__tests__/__snapshots__/StyledTextInput.spec.tsx.snap +5 -14
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +0 -6
- package/src/theme/components/fab.ts +0 -6
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +2 -7
- package/types/components/FAB/ActionGroup/index.d.ts +5 -0
- package/types/components/HeroDesignProvider/index.d.ts +3 -0
- package/types/index.d.ts +2 -1
- package/types/theme/components/fab.d.ts +0 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.38.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,14 +21,14 @@
|
|
|
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.38.0",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21",
|
|
28
28
|
"nanoid": "^4.0.2"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@hero-design/react-native-month-year-picker": "^8.
|
|
31
|
+
"@hero-design/react-native-month-year-picker": "^8.38.0",
|
|
32
32
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
33
33
|
"@react-native-community/slider": "4.1.12",
|
|
34
34
|
"react": "18.0.0",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"@babel/preset-typescript": "^7.17.12",
|
|
49
49
|
"@babel/runtime": "^7.18.9",
|
|
50
50
|
"@emotion/jest": "^11.9.3",
|
|
51
|
-
"@hero-design/eslint-plugin": "8.
|
|
52
|
-
"@hero-design/react-native-month-year-picker": "^8.
|
|
51
|
+
"@hero-design/eslint-plugin": "8.38.0",
|
|
52
|
+
"@hero-design/react-native-month-year-picker": "^8.38.0",
|
|
53
53
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
54
54
|
"@react-native-community/slider": "4.1.12",
|
|
55
55
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -65,10 +65,10 @@
|
|
|
65
65
|
"@types/react-native": "^0.67.7",
|
|
66
66
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
67
67
|
"babel-plugin-inline-import": "^3.0.0",
|
|
68
|
-
"eslint-config-hd": "8.
|
|
68
|
+
"eslint-config-hd": "8.38.0",
|
|
69
69
|
"eslint-plugin-import": "^2.27.5",
|
|
70
70
|
"jest": "^27.3.1",
|
|
71
|
-
"prettier-config-hd": "8.
|
|
71
|
+
"prettier-config-hd": "8.38.0",
|
|
72
72
|
"react": "18.0.0",
|
|
73
73
|
"react-native": "0.69.7",
|
|
74
74
|
"react-native-gesture-handler": "~2.5.0",
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { Animated, View } from 'react-native';
|
|
1
|
+
import { Animated, Pressable, View } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
3
|
import type { ComponentProps } from 'react';
|
|
4
4
|
import type { ViewProps } from 'react-native';
|
|
5
5
|
import FAB from '../FAB';
|
|
6
|
-
import Typography from '../../Typography';
|
|
7
|
-
import type { TextProps } from '../../Typography/Text';
|
|
8
6
|
|
|
9
7
|
const StyledContainer = styled(View)<ViewProps>({
|
|
10
8
|
position: 'absolute',
|
|
@@ -40,9 +38,8 @@ const StyledFAB = styled(FAB)(({ theme }) => ({
|
|
|
40
38
|
alignSelf: 'flex-end',
|
|
41
39
|
}));
|
|
42
40
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
>(({ theme }) => ({
|
|
41
|
+
const AnimatedPressable = Animated.createAnimatedComponent(Pressable);
|
|
42
|
+
const StyledBackdrop = styled(AnimatedPressable)(({ theme }) => ({
|
|
46
43
|
position: 'absolute',
|
|
47
44
|
left: 0,
|
|
48
45
|
right: 0,
|
|
@@ -52,18 +49,10 @@ const StyledBackdrop = styled(Animated.View)<
|
|
|
52
49
|
backgroundColor: theme.__hd__.fab.colors.backdropBackground,
|
|
53
50
|
}));
|
|
54
51
|
|
|
55
|
-
const StyledHeaderText = styled(Typography.Title)<TextProps>(({ theme }) => ({
|
|
56
|
-
color: theme.__hd__.fab.colors.headerText,
|
|
57
|
-
marginRight: theme.__hd__.fab.space.headerTextMarginRight,
|
|
58
|
-
marginBottom: theme.__hd__.fab.space.headerTextMarginBottom,
|
|
59
|
-
textAlign: 'right',
|
|
60
|
-
}));
|
|
61
|
-
|
|
62
52
|
export {
|
|
63
|
-
|
|
53
|
+
StyledActionGroupContainer,
|
|
64
54
|
StyledBackdrop,
|
|
65
55
|
StyledContainer,
|
|
66
56
|
StyledContainerInModal,
|
|
67
|
-
StyledActionGroupContainer,
|
|
68
57
|
StyledFAB,
|
|
69
58
|
};
|
|
@@ -307,7 +307,18 @@ exports[`ActionGroup has active true 1`] = `
|
|
|
307
307
|
}
|
|
308
308
|
>
|
|
309
309
|
<View
|
|
310
|
+
accessible={true}
|
|
310
311
|
collapsable={false}
|
|
312
|
+
focusable={true}
|
|
313
|
+
onBlur={[Function]}
|
|
314
|
+
onClick={[Function]}
|
|
315
|
+
onFocus={[Function]}
|
|
316
|
+
onResponderGrant={[Function]}
|
|
317
|
+
onResponderMove={[Function]}
|
|
318
|
+
onResponderRelease={[Function]}
|
|
319
|
+
onResponderTerminate={[Function]}
|
|
320
|
+
onResponderTerminationRequest={[Function]}
|
|
321
|
+
onStartShouldSetResponder={[Function]}
|
|
311
322
|
style={
|
|
312
323
|
Object {
|
|
313
324
|
"backgroundColor": "#000000",
|
|
@@ -323,6 +334,7 @@ exports[`ActionGroup has active true 1`] = `
|
|
|
323
334
|
/>
|
|
324
335
|
<View
|
|
325
336
|
collapsable={false}
|
|
337
|
+
pointerEvents="box-none"
|
|
326
338
|
style={
|
|
327
339
|
Object {
|
|
328
340
|
"alignItems": "flex-end",
|
|
@@ -333,48 +345,6 @@ exports[`ActionGroup has active true 1`] = `
|
|
|
333
345
|
}
|
|
334
346
|
testID="action-group"
|
|
335
347
|
>
|
|
336
|
-
<View
|
|
337
|
-
collapsable={false}
|
|
338
|
-
style={
|
|
339
|
-
Object {
|
|
340
|
-
"transform": Array [
|
|
341
|
-
Object {
|
|
342
|
-
"translateY": 50,
|
|
343
|
-
},
|
|
344
|
-
],
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
>
|
|
348
|
-
<Text
|
|
349
|
-
allowFontScaling={false}
|
|
350
|
-
style={
|
|
351
|
-
Array [
|
|
352
|
-
Object {
|
|
353
|
-
"color": "#001f23",
|
|
354
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
355
|
-
"fontSize": 24,
|
|
356
|
-
"letterSpacing": 0,
|
|
357
|
-
"lineHeight": 32,
|
|
358
|
-
},
|
|
359
|
-
Array [
|
|
360
|
-
Object {
|
|
361
|
-
"color": "#001f23",
|
|
362
|
-
"marginBottom": 24,
|
|
363
|
-
"marginRight": 24,
|
|
364
|
-
"textAlign": "right",
|
|
365
|
-
},
|
|
366
|
-
undefined,
|
|
367
|
-
],
|
|
368
|
-
]
|
|
369
|
-
}
|
|
370
|
-
testID="header-text"
|
|
371
|
-
themeIntent="body"
|
|
372
|
-
themeLevel="h4"
|
|
373
|
-
themeTypeface="neutral"
|
|
374
|
-
>
|
|
375
|
-
What would you like to create?
|
|
376
|
-
</Text>
|
|
377
|
-
</View>
|
|
378
348
|
<View
|
|
379
349
|
style={
|
|
380
350
|
Array [
|
|
@@ -10,40 +10,37 @@ describe('ActionGroup', () => {
|
|
|
10
10
|
${true}
|
|
11
11
|
${false}
|
|
12
12
|
`('has active $active', ({ active }) => {
|
|
13
|
-
const { toJSON, getByTestId,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
13
|
+
const { toJSON, getByTestId, queryByTestId } = renderWithTheme(
|
|
14
|
+
<ActionGroup
|
|
15
|
+
fabTitle="Shout out"
|
|
16
|
+
active={active}
|
|
17
|
+
items={[
|
|
18
|
+
{
|
|
19
|
+
icon: 'speaker',
|
|
20
|
+
title: 'Give shout out',
|
|
21
|
+
testID: 'speaker-action-item',
|
|
22
|
+
},
|
|
23
|
+
{ icon: 'target', title: 'Goal', testID: 'target-action-item' },
|
|
24
|
+
{
|
|
25
|
+
icon: 'plane',
|
|
26
|
+
title: 'Leave request',
|
|
27
|
+
testID: 'plane-action-item',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
icon: 'health-bag',
|
|
31
|
+
title: 'Safety incident',
|
|
32
|
+
testID: 'health-bag-action-item',
|
|
33
|
+
},
|
|
34
|
+
{ icon: 'clock', title: 'Timesheets', testID: 'clock-action-item' },
|
|
35
|
+
]}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
40
38
|
|
|
41
39
|
expect(toJSON()).toMatchSnapshot();
|
|
42
40
|
|
|
43
41
|
if (active) {
|
|
44
42
|
// verify backdrop appears
|
|
45
43
|
expect(queryByTestId('back-drop')).toBeDefined();
|
|
46
|
-
expect(getByText('What would you like to create?')).toBeDefined();
|
|
47
44
|
expect(getByTestId('speaker-action-item')).toBeDefined();
|
|
48
45
|
expect(getByTestId('target-action-item')).toBeDefined();
|
|
49
46
|
expect(getByTestId('plane-action-item')).toBeDefined();
|
|
@@ -51,7 +48,6 @@ describe('ActionGroup', () => {
|
|
|
51
48
|
} else {
|
|
52
49
|
// verify backdrop disappears
|
|
53
50
|
expect(queryByTestId('back-drop')).toBeNull();
|
|
54
|
-
expect(queryByText('What would you like to create?')).toBeNull();
|
|
55
51
|
}
|
|
56
52
|
});
|
|
57
53
|
|
|
@@ -74,4 +70,15 @@ describe('ActionGroup', () => {
|
|
|
74
70
|
expect(onPressSpy).toBeCalledTimes(1);
|
|
75
71
|
});
|
|
76
72
|
});
|
|
73
|
+
|
|
74
|
+
describe('when user presses backdrop', () => {
|
|
75
|
+
it('calls onBackdropPress when active = true', () => {
|
|
76
|
+
const onBackdropPressSpy = jest.fn();
|
|
77
|
+
const { getByTestId } = renderWithTheme(
|
|
78
|
+
<ActionGroup onBackdropPress={onBackdropPressSpy} active />
|
|
79
|
+
);
|
|
80
|
+
fireEvent(getByTestId('back-drop'), 'press');
|
|
81
|
+
expect(onBackdropPressSpy).toBeCalledTimes(1);
|
|
82
|
+
});
|
|
83
|
+
});
|
|
77
84
|
});
|
|
@@ -10,11 +10,11 @@ import {
|
|
|
10
10
|
StyledContainer,
|
|
11
11
|
StyledContainerInModal,
|
|
12
12
|
StyledFAB,
|
|
13
|
-
StyledHeaderText,
|
|
14
13
|
} from './StyledActionGroup';
|
|
15
14
|
|
|
16
15
|
import Box from '../../Box';
|
|
17
16
|
import { FABHandles } from '../FAB';
|
|
17
|
+
import { useDeprecation } from '../../../utils/hooks';
|
|
18
18
|
|
|
19
19
|
export type ActionGroupHandles = {
|
|
20
20
|
showFAB: () => void;
|
|
@@ -24,6 +24,7 @@ export type ActionGroupHandles = {
|
|
|
24
24
|
|
|
25
25
|
export interface ActionGroupProps {
|
|
26
26
|
/**
|
|
27
|
+
* @deprecated headerTitle will be removed in the next major release.
|
|
27
28
|
* Title of the action group header.
|
|
28
29
|
*/
|
|
29
30
|
headerTitle?: string;
|
|
@@ -32,7 +33,10 @@ export interface ActionGroupProps {
|
|
|
32
33
|
* This function is called on pressing the FAB button.
|
|
33
34
|
* */
|
|
34
35
|
onPress?: () => void;
|
|
35
|
-
|
|
36
|
+
/**
|
|
37
|
+
* This function is called on pressing the FAB backdrop.
|
|
38
|
+
* */
|
|
39
|
+
onBackdropPress?: () => void;
|
|
36
40
|
/**
|
|
37
41
|
* Specify if the FAB button is in active state and the action group is shown.
|
|
38
42
|
* */
|
|
@@ -74,20 +78,20 @@ const ActionGroup = forwardRef<ActionGroupHandles, ActionGroupProps>(
|
|
|
74
78
|
items,
|
|
75
79
|
testID,
|
|
76
80
|
fabTitle,
|
|
81
|
+
onBackdropPress,
|
|
77
82
|
fabIcon = 'add',
|
|
78
83
|
},
|
|
79
84
|
ref
|
|
80
85
|
) => {
|
|
86
|
+
useDeprecation(
|
|
87
|
+
`FAB.ActionGroup's headerTitle prop will be removed in the next major release. Please remove it.`,
|
|
88
|
+
headerTitle !== undefined
|
|
89
|
+
);
|
|
90
|
+
|
|
81
91
|
const fabRef = useRef<FABHandles>(null);
|
|
82
92
|
const tranlateXAnimation = useRef<Animated.Value>(
|
|
83
93
|
new Animated.Value(active ? 1 : 0)
|
|
84
94
|
);
|
|
85
|
-
const titleTranslateYValue = React.useRef(new Animated.Value(0));
|
|
86
|
-
|
|
87
|
-
const titleTranslateY = titleTranslateYValue.current.interpolate({
|
|
88
|
-
inputRange: [0, 1],
|
|
89
|
-
outputRange: [50, 0],
|
|
90
|
-
});
|
|
91
95
|
|
|
92
96
|
React.useImperativeHandle(
|
|
93
97
|
ref,
|
|
@@ -100,16 +104,10 @@ const ActionGroup = forwardRef<ActionGroupHandles, ActionGroupProps>(
|
|
|
100
104
|
);
|
|
101
105
|
|
|
102
106
|
React.useEffect(() => {
|
|
103
|
-
Animated.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}),
|
|
108
|
-
Animated.spring(titleTranslateYValue.current, {
|
|
109
|
-
toValue: active ? 1 : 0,
|
|
110
|
-
useNativeDriver: Platform.OS !== 'web',
|
|
111
|
-
}),
|
|
112
|
-
]).start();
|
|
107
|
+
Animated.spring(tranlateXAnimation.current, {
|
|
108
|
+
toValue: active ? 1 : 0,
|
|
109
|
+
useNativeDriver: Platform.OS !== 'web',
|
|
110
|
+
}).start();
|
|
113
111
|
}, [active]);
|
|
114
112
|
const interpolatedActionGroupOpacityAnimation =
|
|
115
113
|
tranlateXAnimation.current.interpolate({
|
|
@@ -148,23 +146,14 @@ const ActionGroup = forwardRef<ActionGroupHandles, ActionGroupProps>(
|
|
|
148
146
|
statusBarTranslucent
|
|
149
147
|
>
|
|
150
148
|
<StyledContainerInModal testID={testID} style={[style]}>
|
|
151
|
-
<StyledBackdrop testID="back-drop" />
|
|
149
|
+
<StyledBackdrop testID="back-drop" onPress={onBackdropPress} />
|
|
152
150
|
<StyledActionGroupContainer
|
|
153
151
|
testID="action-group"
|
|
152
|
+
pointerEvents="box-none"
|
|
154
153
|
style={{
|
|
155
154
|
opacity: interpolatedActionGroupOpacityAnimation,
|
|
156
155
|
}}
|
|
157
156
|
>
|
|
158
|
-
{!!headerTitle && (
|
|
159
|
-
<Animated.View
|
|
160
|
-
style={{ transform: [{ translateY: titleTranslateY }] }}
|
|
161
|
-
>
|
|
162
|
-
<StyledHeaderText testID="header-text" level="h4">
|
|
163
|
-
{headerTitle}
|
|
164
|
-
</StyledHeaderText>
|
|
165
|
-
</Animated.View>
|
|
166
|
-
)}
|
|
167
|
-
|
|
168
157
|
<Box style={[style, { paddingBottom: 0 }]}>
|
|
169
158
|
{items?.map((itemProp, index) => (
|
|
170
159
|
<ActionItem
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`HeroDesignProvider renders children correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"flex": 1,
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
>
|
|
11
|
+
<Text
|
|
12
|
+
allowFontScaling={false}
|
|
13
|
+
style={
|
|
14
|
+
Array [
|
|
15
|
+
Object {
|
|
16
|
+
"color": "#401960",
|
|
17
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
18
|
+
"fontSize": 42,
|
|
19
|
+
"letterSpacing": 0,
|
|
20
|
+
"lineHeight": 50,
|
|
21
|
+
},
|
|
22
|
+
undefined,
|
|
23
|
+
]
|
|
24
|
+
}
|
|
25
|
+
themeIntent="primary"
|
|
26
|
+
themeLevel="h1"
|
|
27
|
+
themeTypeface="neutral"
|
|
28
|
+
>
|
|
29
|
+
Test component
|
|
30
|
+
</Text>
|
|
31
|
+
<View
|
|
32
|
+
pointerEvents="box-none"
|
|
33
|
+
position="bottom"
|
|
34
|
+
style={
|
|
35
|
+
Array [
|
|
36
|
+
Object {
|
|
37
|
+
"bottom": 0,
|
|
38
|
+
"elevation": 9999,
|
|
39
|
+
"flexDirection": "column-reverse",
|
|
40
|
+
"left": 0,
|
|
41
|
+
"paddingHorizontal": 24,
|
|
42
|
+
"paddingVertical": 16,
|
|
43
|
+
"position": "absolute",
|
|
44
|
+
"right": 0,
|
|
45
|
+
"top": 0,
|
|
46
|
+
},
|
|
47
|
+
undefined,
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
/>
|
|
51
|
+
</View>
|
|
52
|
+
`;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { waitFor, within } from '@testing-library/react-native';
|
|
3
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
|
+
import Typography from '../../Typography';
|
|
5
|
+
import HeroDesignProvider from '..';
|
|
6
|
+
import { getTheme } from '../../../theme';
|
|
7
|
+
import Toast from '../../Toast';
|
|
8
|
+
import Box from '../../Box';
|
|
9
|
+
import Portal from '../../Portal';
|
|
10
|
+
|
|
11
|
+
const TestComponent = () => (
|
|
12
|
+
<Typography.Title intent="primary">Test component</Typography.Title>
|
|
13
|
+
);
|
|
14
|
+
const theme = getTheme();
|
|
15
|
+
|
|
16
|
+
describe('HeroDesignProvider', () => {
|
|
17
|
+
it('renders children correctly', () => {
|
|
18
|
+
const { toJSON, getByText } = renderWithTheme(
|
|
19
|
+
<HeroDesignProvider theme={theme}>
|
|
20
|
+
<TestComponent />
|
|
21
|
+
</HeroDesignProvider>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
expect(toJSON()).toMatchSnapshot();
|
|
25
|
+
expect(getByText('Test component')).toBeTruthy();
|
|
26
|
+
expect(getByText('Test component')).toHaveStyle({
|
|
27
|
+
color: theme.colors.primary,
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renders toast correctly', async () => {
|
|
32
|
+
const Component = () => {
|
|
33
|
+
const toast = Toast.useToast();
|
|
34
|
+
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
toast.show({
|
|
37
|
+
content: 'Your timesheet has been deleted.',
|
|
38
|
+
intent: 'warning',
|
|
39
|
+
variant: 'round',
|
|
40
|
+
duration: 50,
|
|
41
|
+
});
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
return <TestComponent />;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const { queryByText } = renderWithTheme(
|
|
48
|
+
<HeroDesignProvider theme={theme}>
|
|
49
|
+
<Component />
|
|
50
|
+
</HeroDesignProvider>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeTruthy();
|
|
54
|
+
|
|
55
|
+
await waitFor(() =>
|
|
56
|
+
expect(queryByText('Your timesheet has been deleted.')).toBeFalsy()
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('renders portal content correctly', async () => {
|
|
61
|
+
const { getByTestId } = renderWithTheme(
|
|
62
|
+
<HeroDesignProvider theme={theme}>
|
|
63
|
+
<Box testID="portal-wrapper">
|
|
64
|
+
<Portal.Host name="host" />
|
|
65
|
+
</Box>
|
|
66
|
+
<Portal hostName="host">
|
|
67
|
+
<Typography.Body>Portal content</Typography.Body>;
|
|
68
|
+
</Portal>
|
|
69
|
+
</HeroDesignProvider>
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
await waitFor(() =>
|
|
73
|
+
expect(
|
|
74
|
+
within(getByTestId('portal-wrapper')).getByText('Portal content')
|
|
75
|
+
).toBeDefined()
|
|
76
|
+
);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ThemeProvider, { ThemeProviderProps } from '../../theme/ThemeProvider';
|
|
3
|
+
import Toast from '../Toast';
|
|
4
|
+
import Portal from '../Portal';
|
|
5
|
+
|
|
6
|
+
const HeroDesignProvider = ({ theme, children }: ThemeProviderProps) => (
|
|
7
|
+
<ThemeProvider theme={theme}>
|
|
8
|
+
<Toast.Provider>
|
|
9
|
+
<Portal.Provider>{children}</Portal.Provider>
|
|
10
|
+
</Toast.Provider>
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export default HeroDesignProvider;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
-
import { StyledHeaderText } from '../../FAB/ActionGroup/StyledActionGroup';
|
|
4
3
|
import {
|
|
4
|
+
StyledHelperText,
|
|
5
5
|
StyledLabel,
|
|
6
6
|
StyledTextInput,
|
|
7
7
|
StyledMaxLengthMessage,
|
|
@@ -113,7 +113,7 @@ describe('StyledMaxLengthMessage', () => {
|
|
|
113
113
|
describe('StyledHelperText', () => {
|
|
114
114
|
it('renders correctly', (): void => {
|
|
115
115
|
const { toJSON } = renderWithTheme(
|
|
116
|
-
<
|
|
116
|
+
<StyledHelperText>helper text</StyledHelperText>
|
|
117
117
|
);
|
|
118
118
|
|
|
119
119
|
expect(toJSON()).toMatchSnapshot();
|
|
@@ -659,24 +659,15 @@ exports[`StyledHelperText renders correctly 1`] = `
|
|
|
659
659
|
Object {
|
|
660
660
|
"color": "#001f23",
|
|
661
661
|
"fontFamily": "BeVietnamPro-Regular",
|
|
662
|
-
"fontSize":
|
|
663
|
-
"letterSpacing": 0,
|
|
664
|
-
"lineHeight":
|
|
662
|
+
"fontSize": 12,
|
|
663
|
+
"letterSpacing": 0.48,
|
|
664
|
+
"lineHeight": 16,
|
|
665
665
|
},
|
|
666
|
-
|
|
667
|
-
Object {
|
|
668
|
-
"color": "#001f23",
|
|
669
|
-
"marginBottom": 24,
|
|
670
|
-
"marginRight": 24,
|
|
671
|
-
"textAlign": "right",
|
|
672
|
-
},
|
|
673
|
-
undefined,
|
|
674
|
-
],
|
|
666
|
+
undefined,
|
|
675
667
|
]
|
|
676
668
|
}
|
|
669
|
+
themeFontWeight="regular"
|
|
677
670
|
themeIntent="body"
|
|
678
|
-
themeLevel="h1"
|
|
679
|
-
themeTypeface="neutral"
|
|
680
671
|
>
|
|
681
672
|
helper text
|
|
682
673
|
</Text>
|
package/src/index.ts
CHANGED
|
@@ -34,6 +34,7 @@ import Drawer from './components/Drawer';
|
|
|
34
34
|
import Empty from './components/Empty';
|
|
35
35
|
import Error from './components/Error';
|
|
36
36
|
import FAB from './components/FAB';
|
|
37
|
+
import HeroDesignProvider from './components/HeroDesignProvider';
|
|
37
38
|
import Icon from './components/Icon';
|
|
38
39
|
import Image from './components/Image';
|
|
39
40
|
import List from './components/List';
|
|
@@ -100,6 +101,7 @@ export {
|
|
|
100
101
|
FAB,
|
|
101
102
|
Icon,
|
|
102
103
|
Image,
|
|
104
|
+
HeroDesignProvider,
|
|
103
105
|
List,
|
|
104
106
|
Modal,
|
|
105
107
|
PinInput,
|
|
@@ -473,23 +473,19 @@ Object {
|
|
|
473
473
|
"buttonActiveBackground": "#33144d",
|
|
474
474
|
"buttonBackground": "#401960",
|
|
475
475
|
"buttonPressedBackground": "#33144d",
|
|
476
|
-
"headerText": "#001f23",
|
|
477
476
|
"icon": "#ffffff",
|
|
478
477
|
"titleText": "#ffffff",
|
|
479
478
|
},
|
|
480
479
|
"fontSizes": Object {
|
|
481
480
|
"actionItemText": 16,
|
|
482
|
-
"header": 24,
|
|
483
481
|
"title": 16,
|
|
484
482
|
},
|
|
485
483
|
"fonts": Object {
|
|
486
484
|
"actionItemText": "BeVietnamPro-Regular",
|
|
487
|
-
"header": "BeVietnamPro-SemiBold",
|
|
488
485
|
"title": "BeVietnamPro-SemiBold",
|
|
489
486
|
},
|
|
490
487
|
"lineHeights": Object {
|
|
491
488
|
"actionItemText": 22,
|
|
492
|
-
"header": 32,
|
|
493
489
|
"icon": 24,
|
|
494
490
|
"title": 24,
|
|
495
491
|
},
|
|
@@ -520,8 +516,6 @@ Object {
|
|
|
520
516
|
"buttonMarginRight": 24,
|
|
521
517
|
"buttonMarginTop": 24,
|
|
522
518
|
"containerPadding": 20,
|
|
523
|
-
"headerTextMarginBottom": 24,
|
|
524
|
-
"headerTextMarginRight": 24,
|
|
525
519
|
"titleMarginHorizontal": 8,
|
|
526
520
|
},
|
|
527
521
|
},
|
|
@@ -6,7 +6,6 @@ const getFABTheme = (theme: GlobalTheme) => {
|
|
|
6
6
|
buttonPressedBackground: theme.colors.pressedSurface,
|
|
7
7
|
buttonActiveBackground: theme.colors.pressedSurface,
|
|
8
8
|
icon: theme.colors.onPrimary,
|
|
9
|
-
headerText: theme.colors.onDefaultGlobalSurface,
|
|
10
9
|
actionItemBackground: theme.colors.secondary,
|
|
11
10
|
actionItemPressedBackground: theme.colors.pressedSurface,
|
|
12
11
|
backdropBackground: theme.colors.overlayGlobalSurface,
|
|
@@ -22,19 +21,16 @@ const getFABTheme = (theme: GlobalTheme) => {
|
|
|
22
21
|
};
|
|
23
22
|
|
|
24
23
|
const fonts = {
|
|
25
|
-
header: theme.fonts.neutral.semiBold,
|
|
26
24
|
actionItemText: theme.fonts.neutral.regular,
|
|
27
25
|
title: theme.fonts.neutral.semiBold,
|
|
28
26
|
};
|
|
29
27
|
|
|
30
28
|
const fontSizes = {
|
|
31
|
-
header: theme.fontSizes.xxxlarge,
|
|
32
29
|
actionItemText: theme.fontSizes.large,
|
|
33
30
|
title: theme.fontSizes.large,
|
|
34
31
|
};
|
|
35
32
|
|
|
36
33
|
const lineHeights = {
|
|
37
|
-
header: theme.lineHeights.xxxlarge,
|
|
38
34
|
actionItemText: theme.lineHeights.medium,
|
|
39
35
|
title: theme.lineHeights.large,
|
|
40
36
|
icon: theme.lineHeights.large,
|
|
@@ -55,8 +51,6 @@ const getFABTheme = (theme: GlobalTheme) => {
|
|
|
55
51
|
actionItemTextPaddingLeft: theme.space.xsmall,
|
|
56
52
|
buttonMarginTop: theme.space.large,
|
|
57
53
|
buttonMarginRight: theme.space.large,
|
|
58
|
-
headerTextMarginRight: theme.space.large,
|
|
59
|
-
headerTextMarginBottom: theme.space.large,
|
|
60
54
|
containerPadding: theme.space.large - theme.space.xsmall,
|
|
61
55
|
titleMarginHorizontal: theme.space.small,
|
|
62
56
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { Animated, View } from 'react-native';
|
|
3
3
|
import type { ViewProps } from 'react-native';
|
|
4
|
-
import type { TextProps } from '../../Typography/Text';
|
|
5
4
|
declare const StyledContainer: import("@emotion/native").StyledComponent<ViewProps & {
|
|
6
5
|
theme?: import("@emotion/react").Theme | undefined;
|
|
7
6
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -24,14 +23,10 @@ declare const StyledFAB: import("@emotion/native").StyledComponent<import("../FA
|
|
|
24
23
|
theme?: import("@emotion/react").Theme | undefined;
|
|
25
24
|
as?: import("react").ElementType<any> | undefined;
|
|
26
25
|
}, {}, {}>;
|
|
27
|
-
declare const StyledBackdrop: import("@emotion/native").StyledComponent<Animated.AnimatedProps<
|
|
26
|
+
declare const StyledBackdrop: import("@emotion/native").StyledComponent<Animated.AnimatedProps<import("react-native").PressableProps & import("react").RefAttributes<View>> & {
|
|
28
27
|
children?: import("react").ReactNode;
|
|
29
28
|
} & {
|
|
30
29
|
theme?: import("@emotion/react").Theme | undefined;
|
|
31
30
|
as?: import("react").ElementType<any> | undefined;
|
|
32
31
|
}, {}, {}>;
|
|
33
|
-
|
|
34
|
-
theme?: import("@emotion/react").Theme | undefined;
|
|
35
|
-
as?: import("react").ElementType<any> | undefined;
|
|
36
|
-
} & TextProps, {}, {}>;
|
|
37
|
-
export { StyledHeaderText, StyledBackdrop, StyledContainer, StyledContainerInModal, StyledActionGroupContainer, StyledFAB, };
|
|
32
|
+
export { StyledActionGroupContainer, StyledBackdrop, StyledContainer, StyledContainerInModal, StyledFAB, };
|