@hero-design/rn 8.56.0 → 8.56.1
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
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
[1msrc/index.ts[22m → [1mlib/index.js, es/index.js[22m...[39m
|
|
3
3
|
[1m[33m(!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.[39m[22m
|
|
4
4
|
[1m[33m(!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/home/runner/work/hero-design/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning[39m[22m
|
|
5
|
-
[32mcreated [1mlib/index.js, es/index.js[22m in [
|
|
5
|
+
[32mcreated [1mlib/index.js, es/index.js[22m in [1m43.9s[22m[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @hero-design/rn
|
|
2
2
|
|
|
3
|
+
## 8.56.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2673](https://github.com/Thinkei/hero-design/pull/2673) [`4ced86d15`](https://github.com/Thinkei/hero-design/commit/4ced86d15b3c4baf62fb44154eebc1cdd92130e3) Thanks [@vinhphan-eh](https://github.com/vinhphan-eh)! - [ScrollViewWithFAB][flatlistwithfab][SectionListWithFAB] Add unit tests and visual tests
|
|
8
|
+
|
|
3
9
|
## 8.56.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/package.json
CHANGED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTheme } from '@emotion/react';
|
|
3
|
+
import { fireEvent } from '@testing-library/react-native';
|
|
4
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
5
|
+
import { FlatListWithFAB, ScrollViewWithFAB, SectionListWithFAB } from '..';
|
|
6
|
+
import Box from '../../Box';
|
|
7
|
+
import { ActionGroupProps } from '../../FAB/ActionGroup';
|
|
8
|
+
import { FABProps } from '../../FAB/FAB';
|
|
9
|
+
import Typography from '../../Typography';
|
|
10
|
+
import { ScrollViewWithFABProps } from '../ScrollViewWithFAB';
|
|
11
|
+
import { FlatListWithFABProps } from '../FlatListWithFAB';
|
|
12
|
+
import SectionHeading from '../../SectionHeading';
|
|
13
|
+
|
|
14
|
+
const ExampleScrollViewWithFAB = ({ fabProps }: ScrollViewWithFABProps) => (
|
|
15
|
+
<ScrollViewWithFAB fabProps={fabProps} testID="scrollable-with-fab">
|
|
16
|
+
<Box style={{ height: 2000 }} justifyContent="space-between">
|
|
17
|
+
<Typography.Body>Content 1</Typography.Body>
|
|
18
|
+
<Typography.Body>Content 2</Typography.Body>
|
|
19
|
+
<Typography.Body>Content 3</Typography.Body>
|
|
20
|
+
</Box>
|
|
21
|
+
</ScrollViewWithFAB>
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
function ExampleFlatListWithFAB<T>({ fabProps }: FlatListWithFABProps<T>) {
|
|
25
|
+
return (
|
|
26
|
+
<FlatListWithFAB
|
|
27
|
+
testID="scrollable-with-fab"
|
|
28
|
+
fabProps={fabProps}
|
|
29
|
+
data={Array.from({ length: 30 }, (_, i) => ({
|
|
30
|
+
id: i,
|
|
31
|
+
title: `Content ${i}`,
|
|
32
|
+
}))}
|
|
33
|
+
renderItem={({ item }) => (
|
|
34
|
+
<Box marginBottom="xxxxlarge">
|
|
35
|
+
<Typography.Title level="h5">{item.title}</Typography.Title>
|
|
36
|
+
<Typography.Body>Item {item.id}</Typography.Body>
|
|
37
|
+
</Box>
|
|
38
|
+
)}
|
|
39
|
+
/>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function ExampleSectionListWithFAB<T>({ fabProps }: FlatListWithFABProps<T>) {
|
|
44
|
+
const theme = useTheme();
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<SectionListWithFAB
|
|
48
|
+
testID="scrollable-with-fab"
|
|
49
|
+
fabProps={fabProps}
|
|
50
|
+
sections={[
|
|
51
|
+
{
|
|
52
|
+
title: 'Title 1',
|
|
53
|
+
data: ['Content 1', 'Content 2', 'Content 3', 'Content 4'],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: 'Title 2',
|
|
57
|
+
data: ['Content 5', 'Content 6', 'Content 7'],
|
|
58
|
+
},
|
|
59
|
+
]}
|
|
60
|
+
renderSectionHeader={({ section: { title } }) => (
|
|
61
|
+
<SectionHeading text={title} />
|
|
62
|
+
)}
|
|
63
|
+
renderItem={({ item }) => (
|
|
64
|
+
<Typography.Title style={{ marginBottom: theme.space.xxxxlarge }}>
|
|
65
|
+
{item}
|
|
66
|
+
</Typography.Title>
|
|
67
|
+
)}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const defaultFabProps: FABProps = {
|
|
73
|
+
icon: 'speaker',
|
|
74
|
+
title: 'Shout out',
|
|
75
|
+
animated: true,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const defaultActionGroupProps: ActionGroupProps = {
|
|
79
|
+
fabTitle: 'Shout out',
|
|
80
|
+
items: [
|
|
81
|
+
{ icon: 'speaker', title: 'Announcements' },
|
|
82
|
+
{ icon: 'target', title: 'Goal' },
|
|
83
|
+
],
|
|
84
|
+
active: false,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
describe('Scrollables With FAB', () => {
|
|
88
|
+
it.each`
|
|
89
|
+
fabComponent | ScrollComponent
|
|
90
|
+
${'FAB'} | ${ExampleScrollViewWithFAB}
|
|
91
|
+
${'ActionGroup'} | ${ExampleScrollViewWithFAB}
|
|
92
|
+
${'FAB'} | ${ExampleFlatListWithFAB}
|
|
93
|
+
${'ActionGroup'} | ${ExampleFlatListWithFAB}
|
|
94
|
+
${'FAB'} | ${ExampleSectionListWithFAB}
|
|
95
|
+
${'ActionGroup'} | ${ExampleSectionListWithFAB}
|
|
96
|
+
`(
|
|
97
|
+
'$ScrollComponent renders $fabComponent correctly',
|
|
98
|
+
({ fabComponent, ScrollComponent }) => {
|
|
99
|
+
const fabProps =
|
|
100
|
+
fabComponent === 'FAB' ? defaultFabProps : defaultActionGroupProps;
|
|
101
|
+
|
|
102
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
103
|
+
<ScrollComponent fabProps={fabProps} />
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(toJSON()).toMatchSnapshot();
|
|
107
|
+
expect(getByText('Content 1')).toBeDefined();
|
|
108
|
+
expect(getByText('Content 2')).toBeDefined();
|
|
109
|
+
expect(getByText('Content 3')).toBeDefined();
|
|
110
|
+
expect(getByText('Shout out')).toBeDefined();
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
it.each`
|
|
115
|
+
fabComponent | ScrollComponent
|
|
116
|
+
${'FAB'} | ${ExampleScrollViewWithFAB}
|
|
117
|
+
${'ActionGroup'} | ${ExampleScrollViewWithFAB}
|
|
118
|
+
${'FAB'} | ${ExampleFlatListWithFAB}
|
|
119
|
+
${'ActionGroup'} | ${ExampleFlatListWithFAB}
|
|
120
|
+
${'FAB'} | ${ExampleSectionListWithFAB}
|
|
121
|
+
${'ActionGroup'} | ${ExampleSectionListWithFAB}
|
|
122
|
+
`(
|
|
123
|
+
'$ScrollComponent animates $fabComponent correctly',
|
|
124
|
+
({ fabComponent, ScrollComponent }) => {
|
|
125
|
+
const fabProps =
|
|
126
|
+
fabComponent === 'FAB' ? defaultFabProps : defaultActionGroupProps;
|
|
127
|
+
|
|
128
|
+
const { getByText, queryByText, getByTestId, queryByTestId } =
|
|
129
|
+
renderWithTheme(<ScrollComponent fabProps={fabProps} />);
|
|
130
|
+
|
|
131
|
+
// Scrolling down
|
|
132
|
+
expect(getByText('Shout out')).toBeDefined();
|
|
133
|
+
|
|
134
|
+
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
135
|
+
nativeEvent: {
|
|
136
|
+
contentSize: { height: 1000 },
|
|
137
|
+
contentOffset: { y: 10 },
|
|
138
|
+
layoutMeasurement: { height: 2000, width: 400 },
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// Collapsed
|
|
143
|
+
expect(queryByText('Shout out')).toBeNull();
|
|
144
|
+
expect(getByTestId('animated-fab-icon')).toBeDefined();
|
|
145
|
+
|
|
146
|
+
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
147
|
+
nativeEvent: {
|
|
148
|
+
contentSize: { height: 1000 },
|
|
149
|
+
contentOffset: { y: 400 },
|
|
150
|
+
layoutMeasurement: { height: 2000, width: 400 },
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// Hidden
|
|
155
|
+
expect(queryByText('Shout out')).toBeNull();
|
|
156
|
+
expect(queryByTestId('styled-fab-icon')).toBeNull();
|
|
157
|
+
|
|
158
|
+
// Scrolling up
|
|
159
|
+
fireEvent.scroll(getByTestId('scrollable-with-fab'), {
|
|
160
|
+
nativeEvent: {
|
|
161
|
+
contentSize: { height: 1000 },
|
|
162
|
+
contentOffset: { y: -10 },
|
|
163
|
+
layoutMeasurement: { height: 2000, width: 400 },
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// Collapsed
|
|
168
|
+
expect(queryByText('Shout out')).toBeNull();
|
|
169
|
+
expect(getByTestId('animated-fab-icon')).toBeDefined();
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
});
|