@hero-design/rn 8.74.1 → 8.75.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "8.74.1",
3
+ "version": "8.75.0",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -0,0 +1,32 @@
1
+ import styled from '@emotion/native';
2
+ import Box from '../Box';
3
+ import Icon from '../Icon';
4
+
5
+ const StyledWrapper = styled.TouchableOpacity(({ theme }) => ({
6
+ alignSelf: 'flex-start',
7
+ position: 'absolute',
8
+ left: '50%',
9
+ zIndex: 9999,
10
+ flexDirection: 'row',
11
+ justifyContent: 'center',
12
+ alignItems: 'center',
13
+ padding: theme.__hd__.floatingIsland.space.wrapperPadding,
14
+ borderRadius: theme.__hd__.floatingIsland.radii.wrapper,
15
+ backgroundColor: theme.__hd__.floatingIsland.colors.wrapperBackground,
16
+ top: theme.__hd__.floatingIsland.space.wrapperTop,
17
+ ...theme.__hd__.floatingIsland.shadows.wrapper,
18
+ }));
19
+
20
+ const StyledPrefixWrapper = styled(Box)(({ theme }) => ({
21
+ marginRight: theme.__hd__.floatingIsland.space.prefixMarginRight,
22
+ }));
23
+
24
+ const StyledSuffixWrapper = styled(Box)(({ theme }) => ({
25
+ marginLeft: theme.__hd__.floatingIsland.space.suffixMarginLeft,
26
+ }));
27
+
28
+ const StyledIcon = styled(Icon)(({ theme }) => ({
29
+ padding: theme.__hd__.floatingIsland.space.iconPadding,
30
+ }));
31
+
32
+ export { StyledWrapper, StyledPrefixWrapper, StyledSuffixWrapper, StyledIcon };
@@ -0,0 +1,561 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`FloatingIsland renders correctly 1`] = `
4
+ <View
5
+ style={
6
+ {
7
+ "flex": 1,
8
+ }
9
+ }
10
+ >
11
+ <View
12
+ accessibilityState={
13
+ {
14
+ "busy": undefined,
15
+ "checked": undefined,
16
+ "disabled": true,
17
+ "expanded": undefined,
18
+ "selected": undefined,
19
+ }
20
+ }
21
+ accessibilityValue={
22
+ {
23
+ "max": undefined,
24
+ "min": undefined,
25
+ "now": undefined,
26
+ "text": undefined,
27
+ }
28
+ }
29
+ accessible={true}
30
+ collapsable={false}
31
+ focusable={false}
32
+ onClick={[Function]}
33
+ onLayout={[Function]}
34
+ onResponderGrant={[Function]}
35
+ onResponderMove={[Function]}
36
+ onResponderRelease={[Function]}
37
+ onResponderTerminate={[Function]}
38
+ onResponderTerminationRequest={[Function]}
39
+ onStartShouldSetResponder={[Function]}
40
+ style={
41
+ {
42
+ "alignItems": "center",
43
+ "alignSelf": "flex-start",
44
+ "backgroundColor": "#ffffff",
45
+ "borderRadius": 999,
46
+ "elevation": 3,
47
+ "flexDirection": "row",
48
+ "justifyContent": "center",
49
+ "left": "50%",
50
+ "opacity": 1,
51
+ "padding": 8,
52
+ "position": "absolute",
53
+ "shadowColor": "#001f23",
54
+ "shadowOffset": {
55
+ "height": 2,
56
+ "width": 0,
57
+ },
58
+ "shadowOpacity": 0.12,
59
+ "shadowRadius": 4,
60
+ "top": 12,
61
+ "zIndex": 9999,
62
+ }
63
+ }
64
+ >
65
+ <Text
66
+ allowFontScaling={false}
67
+ style={
68
+ [
69
+ {
70
+ "color": "#001f23",
71
+ "fontFamily": "BeVietnamPro-Regular",
72
+ "fontSize": 16,
73
+ "letterSpacing": 0.48,
74
+ "lineHeight": 24,
75
+ },
76
+ undefined,
77
+ ]
78
+ }
79
+ themeIntent="body"
80
+ themeTypeface="neutral"
81
+ themeVariant="regular"
82
+ >
83
+ Content
84
+ </Text>
85
+ </View>
86
+ <View
87
+ pointerEvents="box-none"
88
+ position="bottom"
89
+ style={
90
+ [
91
+ {
92
+ "bottom": 0,
93
+ "elevation": 9999,
94
+ "flexDirection": "column-reverse",
95
+ "left": 0,
96
+ "paddingHorizontal": 24,
97
+ "paddingVertical": 16,
98
+ "position": "absolute",
99
+ "right": 0,
100
+ "top": 0,
101
+ },
102
+ undefined,
103
+ ]
104
+ }
105
+ />
106
+ </View>
107
+ `;
108
+
109
+ exports[`FloatingIsland renders icons as prefix and suffix correctly 1`] = `
110
+ <View
111
+ style={
112
+ {
113
+ "flex": 1,
114
+ }
115
+ }
116
+ >
117
+ <View
118
+ accessibilityState={
119
+ {
120
+ "busy": undefined,
121
+ "checked": undefined,
122
+ "disabled": true,
123
+ "expanded": undefined,
124
+ "selected": undefined,
125
+ }
126
+ }
127
+ accessibilityValue={
128
+ {
129
+ "max": undefined,
130
+ "min": undefined,
131
+ "now": undefined,
132
+ "text": undefined,
133
+ }
134
+ }
135
+ accessible={true}
136
+ collapsable={false}
137
+ focusable={false}
138
+ onClick={[Function]}
139
+ onLayout={[Function]}
140
+ onResponderGrant={[Function]}
141
+ onResponderMove={[Function]}
142
+ onResponderRelease={[Function]}
143
+ onResponderTerminate={[Function]}
144
+ onResponderTerminationRequest={[Function]}
145
+ onStartShouldSetResponder={[Function]}
146
+ style={
147
+ {
148
+ "alignItems": "center",
149
+ "alignSelf": "flex-start",
150
+ "backgroundColor": "#ffffff",
151
+ "borderRadius": 999,
152
+ "elevation": 3,
153
+ "flexDirection": "row",
154
+ "justifyContent": "center",
155
+ "left": "50%",
156
+ "opacity": 1,
157
+ "padding": 8,
158
+ "position": "absolute",
159
+ "shadowColor": "#001f23",
160
+ "shadowOffset": {
161
+ "height": 2,
162
+ "width": 0,
163
+ },
164
+ "shadowOpacity": 0.12,
165
+ "shadowRadius": 4,
166
+ "top": 12,
167
+ "zIndex": 9999,
168
+ }
169
+ }
170
+ >
171
+ <View
172
+ style={
173
+ [
174
+ {},
175
+ [
176
+ {
177
+ "marginRight": 8,
178
+ },
179
+ undefined,
180
+ ],
181
+ ]
182
+ }
183
+ >
184
+ <HeroIcon
185
+ name="calendar"
186
+ style={
187
+ [
188
+ {
189
+ "color": "#001f23",
190
+ "fontSize": 20,
191
+ },
192
+ [
193
+ {
194
+ "padding": 12,
195
+ },
196
+ undefined,
197
+ ],
198
+ ]
199
+ }
200
+ testID="floating-island-prefix-icon"
201
+ themeIntent="text"
202
+ themeSize="small"
203
+ />
204
+ </View>
205
+ <Text
206
+ allowFontScaling={false}
207
+ style={
208
+ [
209
+ {
210
+ "color": "#001f23",
211
+ "fontFamily": "BeVietnamPro-Regular",
212
+ "fontSize": 16,
213
+ "letterSpacing": 0.48,
214
+ "lineHeight": 24,
215
+ },
216
+ undefined,
217
+ ]
218
+ }
219
+ themeIntent="body"
220
+ themeTypeface="neutral"
221
+ themeVariant="regular"
222
+ >
223
+ Content
224
+ </Text>
225
+ <View
226
+ style={
227
+ [
228
+ {},
229
+ [
230
+ {
231
+ "marginLeft": 16,
232
+ },
233
+ undefined,
234
+ ],
235
+ ]
236
+ }
237
+ >
238
+ <HeroIcon
239
+ name="cancel"
240
+ style={
241
+ [
242
+ {
243
+ "color": "#001f23",
244
+ "fontSize": 20,
245
+ },
246
+ [
247
+ {
248
+ "padding": 12,
249
+ },
250
+ undefined,
251
+ ],
252
+ ]
253
+ }
254
+ testID="floating-island-suffix-icon"
255
+ themeIntent="text"
256
+ themeSize="small"
257
+ />
258
+ </View>
259
+ </View>
260
+ <View
261
+ pointerEvents="box-none"
262
+ position="bottom"
263
+ style={
264
+ [
265
+ {
266
+ "bottom": 0,
267
+ "elevation": 9999,
268
+ "flexDirection": "column-reverse",
269
+ "left": 0,
270
+ "paddingHorizontal": 24,
271
+ "paddingVertical": 16,
272
+ "position": "absolute",
273
+ "right": 0,
274
+ "top": 0,
275
+ },
276
+ undefined,
277
+ ]
278
+ }
279
+ />
280
+ </View>
281
+ `;
282
+
283
+ exports[`FloatingIsland renders prefix correctly 1`] = `
284
+ <View
285
+ style={
286
+ {
287
+ "flex": 1,
288
+ }
289
+ }
290
+ >
291
+ <View
292
+ accessibilityState={
293
+ {
294
+ "busy": undefined,
295
+ "checked": undefined,
296
+ "disabled": true,
297
+ "expanded": undefined,
298
+ "selected": undefined,
299
+ }
300
+ }
301
+ accessibilityValue={
302
+ {
303
+ "max": undefined,
304
+ "min": undefined,
305
+ "now": undefined,
306
+ "text": undefined,
307
+ }
308
+ }
309
+ accessible={true}
310
+ collapsable={false}
311
+ focusable={false}
312
+ onClick={[Function]}
313
+ onLayout={[Function]}
314
+ onResponderGrant={[Function]}
315
+ onResponderMove={[Function]}
316
+ onResponderRelease={[Function]}
317
+ onResponderTerminate={[Function]}
318
+ onResponderTerminationRequest={[Function]}
319
+ onStartShouldSetResponder={[Function]}
320
+ style={
321
+ {
322
+ "alignItems": "center",
323
+ "alignSelf": "flex-start",
324
+ "backgroundColor": "#ffffff",
325
+ "borderRadius": 999,
326
+ "elevation": 3,
327
+ "flexDirection": "row",
328
+ "justifyContent": "center",
329
+ "left": "50%",
330
+ "opacity": 1,
331
+ "padding": 8,
332
+ "position": "absolute",
333
+ "shadowColor": "#001f23",
334
+ "shadowOffset": {
335
+ "height": 2,
336
+ "width": 0,
337
+ },
338
+ "shadowOpacity": 0.12,
339
+ "shadowRadius": 4,
340
+ "top": 12,
341
+ "zIndex": 9999,
342
+ }
343
+ }
344
+ >
345
+ <View
346
+ style={
347
+ [
348
+ {},
349
+ [
350
+ {
351
+ "marginRight": 8,
352
+ },
353
+ undefined,
354
+ ],
355
+ ]
356
+ }
357
+ >
358
+ <Text
359
+ allowFontScaling={false}
360
+ style={
361
+ [
362
+ {
363
+ "color": "#001f23",
364
+ "fontFamily": "BeVietnamPro-Regular",
365
+ "fontSize": 16,
366
+ "letterSpacing": 0.48,
367
+ "lineHeight": 24,
368
+ },
369
+ undefined,
370
+ ]
371
+ }
372
+ themeIntent="body"
373
+ themeTypeface="neutral"
374
+ themeVariant="regular"
375
+ >
376
+ Prefix
377
+ </Text>
378
+ </View>
379
+ <Text
380
+ allowFontScaling={false}
381
+ style={
382
+ [
383
+ {
384
+ "color": "#001f23",
385
+ "fontFamily": "BeVietnamPro-Regular",
386
+ "fontSize": 16,
387
+ "letterSpacing": 0.48,
388
+ "lineHeight": 24,
389
+ },
390
+ undefined,
391
+ ]
392
+ }
393
+ themeIntent="body"
394
+ themeTypeface="neutral"
395
+ themeVariant="regular"
396
+ >
397
+ Content
398
+ </Text>
399
+ </View>
400
+ <View
401
+ pointerEvents="box-none"
402
+ position="bottom"
403
+ style={
404
+ [
405
+ {
406
+ "bottom": 0,
407
+ "elevation": 9999,
408
+ "flexDirection": "column-reverse",
409
+ "left": 0,
410
+ "paddingHorizontal": 24,
411
+ "paddingVertical": 16,
412
+ "position": "absolute",
413
+ "right": 0,
414
+ "top": 0,
415
+ },
416
+ undefined,
417
+ ]
418
+ }
419
+ />
420
+ </View>
421
+ `;
422
+
423
+ exports[`FloatingIsland renders suffix correctly 1`] = `
424
+ <View
425
+ style={
426
+ {
427
+ "flex": 1,
428
+ }
429
+ }
430
+ >
431
+ <View
432
+ accessibilityState={
433
+ {
434
+ "busy": undefined,
435
+ "checked": undefined,
436
+ "disabled": true,
437
+ "expanded": undefined,
438
+ "selected": undefined,
439
+ }
440
+ }
441
+ accessibilityValue={
442
+ {
443
+ "max": undefined,
444
+ "min": undefined,
445
+ "now": undefined,
446
+ "text": undefined,
447
+ }
448
+ }
449
+ accessible={true}
450
+ collapsable={false}
451
+ focusable={false}
452
+ onClick={[Function]}
453
+ onLayout={[Function]}
454
+ onResponderGrant={[Function]}
455
+ onResponderMove={[Function]}
456
+ onResponderRelease={[Function]}
457
+ onResponderTerminate={[Function]}
458
+ onResponderTerminationRequest={[Function]}
459
+ onStartShouldSetResponder={[Function]}
460
+ style={
461
+ {
462
+ "alignItems": "center",
463
+ "alignSelf": "flex-start",
464
+ "backgroundColor": "#ffffff",
465
+ "borderRadius": 999,
466
+ "elevation": 3,
467
+ "flexDirection": "row",
468
+ "justifyContent": "center",
469
+ "left": "50%",
470
+ "opacity": 1,
471
+ "padding": 8,
472
+ "position": "absolute",
473
+ "shadowColor": "#001f23",
474
+ "shadowOffset": {
475
+ "height": 2,
476
+ "width": 0,
477
+ },
478
+ "shadowOpacity": 0.12,
479
+ "shadowRadius": 4,
480
+ "top": 12,
481
+ "zIndex": 9999,
482
+ }
483
+ }
484
+ >
485
+ <Text
486
+ allowFontScaling={false}
487
+ style={
488
+ [
489
+ {
490
+ "color": "#001f23",
491
+ "fontFamily": "BeVietnamPro-Regular",
492
+ "fontSize": 16,
493
+ "letterSpacing": 0.48,
494
+ "lineHeight": 24,
495
+ },
496
+ undefined,
497
+ ]
498
+ }
499
+ themeIntent="body"
500
+ themeTypeface="neutral"
501
+ themeVariant="regular"
502
+ >
503
+ Content
504
+ </Text>
505
+ <View
506
+ style={
507
+ [
508
+ {},
509
+ [
510
+ {
511
+ "marginLeft": 16,
512
+ },
513
+ undefined,
514
+ ],
515
+ ]
516
+ }
517
+ >
518
+ <Text
519
+ allowFontScaling={false}
520
+ style={
521
+ [
522
+ {
523
+ "color": "#001f23",
524
+ "fontFamily": "BeVietnamPro-Regular",
525
+ "fontSize": 16,
526
+ "letterSpacing": 0.48,
527
+ "lineHeight": 24,
528
+ },
529
+ undefined,
530
+ ]
531
+ }
532
+ themeIntent="body"
533
+ themeTypeface="neutral"
534
+ themeVariant="regular"
535
+ >
536
+ Suffix
537
+ </Text>
538
+ </View>
539
+ </View>
540
+ <View
541
+ pointerEvents="box-none"
542
+ position="bottom"
543
+ style={
544
+ [
545
+ {
546
+ "bottom": 0,
547
+ "elevation": 9999,
548
+ "flexDirection": "column-reverse",
549
+ "left": 0,
550
+ "paddingHorizontal": 24,
551
+ "paddingVertical": 16,
552
+ "position": "absolute",
553
+ "right": 0,
554
+ "top": 0,
555
+ },
556
+ undefined,
557
+ ]
558
+ }
559
+ />
560
+ </View>
561
+ `;
@@ -0,0 +1,67 @@
1
+ import { fireEvent } from '@testing-library/react-native';
2
+ import React from 'react';
3
+ import FloatingIsland from '..';
4
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
5
+ import Typography from '../../Typography';
6
+
7
+ const Content = () => <Typography.Body>Content</Typography.Body>;
8
+
9
+ describe('FloatingIsland', () => {
10
+ it('renders correctly', () => {
11
+ const { toJSON, getByText } = renderWithTheme(
12
+ <FloatingIsland>
13
+ <Content />
14
+ </FloatingIsland>
15
+ );
16
+
17
+ expect(toJSON()).toMatchSnapshot();
18
+ expect(getByText('Content')).toBeDefined();
19
+ });
20
+
21
+ it('calls onPress correctly', () => {
22
+ const onPress = jest.fn();
23
+ const { getByText } = renderWithTheme(
24
+ <FloatingIsland onPress={onPress}>
25
+ <Content />
26
+ </FloatingIsland>
27
+ );
28
+
29
+ fireEvent.press(getByText('Content'));
30
+
31
+ expect(onPress).toHaveBeenCalled();
32
+ });
33
+
34
+ it('renders icons as prefix and suffix correctly', () => {
35
+ const { toJSON, getByTestId } = renderWithTheme(
36
+ <FloatingIsland prefix="calendar" suffix="cancel">
37
+ <Content />
38
+ </FloatingIsland>
39
+ );
40
+
41
+ expect(toJSON()).toMatchSnapshot();
42
+ expect(getByTestId('floating-island-prefix-icon')).toBeDefined();
43
+ expect(getByTestId('floating-island-suffix-icon')).toBeDefined();
44
+ });
45
+
46
+ it('renders prefix correctly', () => {
47
+ const { toJSON, getByText } = renderWithTheme(
48
+ <FloatingIsland prefix={<Typography.Body>Prefix</Typography.Body>}>
49
+ <Content />
50
+ </FloatingIsland>
51
+ );
52
+
53
+ expect(toJSON()).toMatchSnapshot();
54
+ expect(getByText('Prefix')).toBeDefined();
55
+ });
56
+
57
+ it('renders suffix correctly', () => {
58
+ const { toJSON, getByText } = renderWithTheme(
59
+ <FloatingIsland suffix={<Typography.Body>Suffix</Typography.Body>}>
60
+ <Content />
61
+ </FloatingIsland>
62
+ );
63
+
64
+ expect(toJSON()).toMatchSnapshot();
65
+ expect(getByText('Content')).toBeDefined();
66
+ });
67
+ });