@coinbase/cds-mobile 8.25.1 → 8.27.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dts/alpha/select/DefaultSelectControl.d.ts +2 -8
  3. package/dts/alpha/select/DefaultSelectControl.d.ts.map +1 -1
  4. package/dts/alpha/select/DefaultSelectDropdown.d.ts.map +1 -1
  5. package/dts/alpha/select/DefaultSelectOptionGroup.d.ts +8 -0
  6. package/dts/alpha/select/DefaultSelectOptionGroup.d.ts.map +1 -0
  7. package/dts/alpha/select/Select.d.ts +23 -366
  8. package/dts/alpha/select/Select.d.ts.map +1 -1
  9. package/dts/alpha/select/index.d.ts +2 -0
  10. package/dts/alpha/select/index.d.ts.map +1 -1
  11. package/dts/alpha/select/types.d.ts +486 -0
  12. package/dts/alpha/select/types.d.ts.map +1 -0
  13. package/dts/alpha/select-chip/SelectChip.d.ts +26 -0
  14. package/dts/alpha/select-chip/SelectChip.d.ts.map +1 -0
  15. package/dts/alpha/select-chip/SelectChipControl.d.ts +14 -0
  16. package/dts/alpha/select-chip/SelectChipControl.d.ts.map +1 -0
  17. package/dts/alpha/select-chip/index.d.ts +3 -0
  18. package/dts/alpha/select-chip/index.d.ts.map +1 -0
  19. package/dts/cells/CellAccessory.d.ts +1 -1
  20. package/dts/cells/CellAccessory.d.ts.map +1 -1
  21. package/dts/chips/Chip.d.ts.map +1 -1
  22. package/dts/chips/SelectChip.d.ts +8 -0
  23. package/dts/chips/SelectChip.d.ts.map +1 -1
  24. package/dts/examples/ExampleScreen.d.ts +26 -1
  25. package/dts/examples/ExampleScreen.d.ts.map +1 -1
  26. package/esm/alpha/select/DefaultSelectControl.js +46 -8
  27. package/esm/alpha/select/DefaultSelectDropdown.js +100 -31
  28. package/esm/alpha/select/DefaultSelectOption.js +1 -1
  29. package/esm/alpha/select/DefaultSelectOptionGroup.js +90 -0
  30. package/esm/alpha/select/Select.js +10 -26
  31. package/esm/alpha/select/index.js +3 -1
  32. package/esm/alpha/select/types.js +50 -0
  33. package/esm/alpha/select-chip/SelectChip.js +31 -0
  34. package/esm/alpha/select-chip/SelectChipControl.js +111 -0
  35. package/esm/alpha/select-chip/__stories__/SelectChip.stories.js +538 -0
  36. package/esm/alpha/select-chip/index.js +2 -0
  37. package/esm/banner/__stories__/Banner.stories.js +133 -294
  38. package/esm/banner/__stories__/BannerActions.stories.js +276 -0
  39. package/esm/banner/__stories__/BannerLayout.stories.js +329 -0
  40. package/esm/cells/Cell.js +1 -1
  41. package/esm/cells/CellAccessory.js +9 -0
  42. package/esm/cells/__stories__/ListCell.stories.js +81 -87
  43. package/esm/cells/__stories__/ListCellFallback.stories.js +1 -0
  44. package/esm/chips/Chip.js +4 -1
  45. package/esm/chips/SelectChip.js +9 -0
  46. package/esm/examples/ExampleScreen.js +79 -58
  47. package/esm/icons/__stories__/IconSheet.js +35 -13
  48. package/esm/illustrations/__stories__/HeroSquare.stories.js +70 -2
  49. package/esm/illustrations/__stories__/Pictogram.stories.js +70 -2
  50. package/esm/illustrations/__stories__/SpotIcon.stories.js +70 -2
  51. package/esm/illustrations/__stories__/SpotRectangle.stories.js +68 -2
  52. package/esm/illustrations/__stories__/SpotSquare.stories.js +68 -2
  53. package/esm/media/__stories__/CarouselMedia.stories.js +2 -5
  54. package/esm/numpad/__stories__/Numpad.stories.js +8 -5
  55. package/esm/page/__stories__/PageFooter.stories.js +5 -4
  56. package/esm/page/__stories__/PageFooterInPage.stories.js +20 -19
  57. package/esm/page/__stories__/PageHeader.stories.js +4 -4
  58. package/esm/page/__stories__/PageHeaderInErrorEmptyState.stories.js +6 -4
  59. package/esm/page/__stories__/PageHeaderInPage.stories.js +20 -18
  60. package/esm/section-header/__stories__/SectionHeader.stories.js +4 -4
  61. package/esm/sticky-footer/__stories__/StickyFooter.stories.js +6 -8
  62. package/esm/tour/__stories__/Tour.stories.js +13 -166
  63. package/esm/typography/__stories__/TextBody.stories.js +2 -0
  64. package/esm/typography/__stories__/TextCaption.stories.js +2 -0
  65. package/esm/typography/__stories__/TextCore.stories.js +2 -0
  66. package/esm/typography/__stories__/TextDisplay1.stories.js +2 -0
  67. package/esm/typography/__stories__/TextDisplay2.stories.js +2 -0
  68. package/esm/typography/__stories__/TextDisplay3.stories.js +2 -0
  69. package/esm/typography/__stories__/TextHeadline.stories.js +2 -0
  70. package/esm/typography/__stories__/TextLabel1.stories.js +2 -0
  71. package/esm/typography/__stories__/TextLabel2.stories.js +2 -0
  72. package/esm/typography/__stories__/TextLegal.stories.js +2 -0
  73. package/esm/typography/__stories__/TextTitle1.stories.js +2 -0
  74. package/esm/typography/__stories__/TextTitle2.stories.js +2 -0
  75. package/esm/typography/__stories__/TextTitle3.stories.js +2 -0
  76. package/esm/typography/__stories__/TextTitle4.stories.js +2 -0
  77. package/package.json +2 -2
  78. package/esm/icons/__stories__/Icon.stories.js +0 -98
  79. package/esm/illustrations/__stories__/getIllustrationSheet.js +0 -164
  80. /package/esm/alpha/select/__stories__/{Select.stories.js → AlphaSelect.stories.js} +0 -0
  81. /package/esm/alpha/tabbed-chips/__stories__/{TabbedChips.stories.js → AlphaTabbedChips.stories.js} +0 -0
@@ -1,6 +1,5 @@
1
1
  import React, { useCallback, useMemo, useRef, useState } from 'react';
2
2
  import { Button as NativeButton, Image } from 'react-native';
3
- import { ScrollView } from 'react-native-gesture-handler';
4
3
  import { ethBackground } from '@coinbase/cds-common/internal/data/assets';
5
4
  import { useTourContext } from '@coinbase/cds-common/tour/TourContext';
6
5
  import { Button } from '../../buttons';
@@ -250,171 +249,19 @@ const TourStory = () => {
250
249
  });
251
250
  }
252
251
  }], []);
253
- return /*#__PURE__*/_jsx(Tour, {
254
- activeTourStep: activeTourStep,
255
- onChange: setActiveTourStep,
256
- steps: tourSteps,
257
- children: /*#__PURE__*/_jsx(ScrollView, {
258
- ref: scrollViewRef,
259
- style: {
260
- flex: 1
261
- },
262
- children: /*#__PURE__*/_jsx(ExampleScreen, {
263
- children: /*#__PURE__*/_jsx(Example, {
264
- children: /*#__PURE__*/_jsx(TourExamples, {
265
- ids: ['step1', 'step2', 'step3', 'step4'],
266
- step2Ref: step2Ref,
267
- step3Ref: step3Ref,
268
- step4Ref: step4Ref
269
- })
270
- })
271
- })
272
- })
273
- });
274
- };
275
- export const TourWithStringLiteralIdStory = () => {
276
- const [activeTourStep, setActiveTourStep] = useState(null);
277
- const scrollViewRef = useRef(null);
278
- const step2Ref = useRef(null);
279
- const step3Ref = useRef(null);
280
- const step4Ref = useRef(null);
281
- const complexIdTourSteps = useMemo(() => [{
282
- id: 'step-id-1',
283
- onBeforeActive: () => console.log('step1 before'),
284
- Component: StepOne
285
- }, {
286
- id: 'step-id-2',
287
- arrowColor: 'yellow',
288
- onBeforeActive: async () => {
289
- console.log('step2 before');
290
- await scrollIntoView(scrollViewRef, step2Ref);
291
- },
292
- Component: () => {
293
- const {
294
- goNextTourStep,
295
- stopTour
296
- } = useTourContext();
297
- return /*#__PURE__*/_jsx(Coachmark, {
298
- action: /*#__PURE__*/_jsx(Button, {
299
- compact: true,
300
- onPress: goNextTourStep,
301
- variant: "secondary",
302
- children: "Next"
303
- }),
304
- closeButtonAccessibilityLabel: "Close",
305
- content: /*#__PURE__*/_jsxs(VStack, {
306
- gap: 2,
307
- children: [/*#__PURE__*/_jsx(Text, {
308
- color: "fgMuted",
309
- font: "caption",
310
- children: "50%"
311
- }), /*#__PURE__*/_jsx(ProgressBar, {
312
- progress: 0.5
313
- }), /*#__PURE__*/_jsx(Text, {
314
- font: "body",
315
- children: "Add up to 3 lines of body copy. Deliver your message with clarity and impact"
316
- })]
317
- }),
318
- media: /*#__PURE__*/_jsx(Image, {
319
- accessibilityIgnoresInvertColors: true,
320
- source: {
321
- uri: ethBackground
322
- },
323
- style: {
324
- width: '100%',
325
- height: 150
326
- }
327
- }),
328
- onClose: stopTour,
329
- title: "My second step"
330
- });
331
- }
332
- }, {
333
- id: 'step-id-3',
334
- onBeforeActive: async () => {
335
- console.log('step3 before');
336
- await scrollIntoView(scrollViewRef, step3Ref);
337
- },
338
- Component: () => {
339
- const {
340
- stopTour,
341
- goNextTourStep,
342
- goPreviousTourStep
343
- } = useTourContext();
344
- return /*#__PURE__*/_jsx(Coachmark, {
345
- action: /*#__PURE__*/_jsxs(HStack, {
346
- gap: 1,
347
- children: [/*#__PURE__*/_jsx(Button, {
348
- compact: true,
349
- onPress: goPreviousTourStep,
350
- variant: "secondary",
351
- children: "Back"
352
- }), /*#__PURE__*/_jsx(Button, {
353
- compact: true,
354
- onPress: goNextTourStep,
355
- variant: "secondary",
356
- children: "Next"
357
- }), /*#__PURE__*/_jsx(Button, {
358
- compact: true,
359
- onPress: stopTour,
360
- variant: "secondary",
361
- children: "Done"
362
- })]
363
- }),
364
- content: "Add up to 3 lines of body copy. Deliver your message with clarity and impact",
365
- title: "My third step",
366
- width: 350
367
- });
368
- }
369
- }, {
370
- id: 'step-id-4',
371
- onBeforeActive: async () => {
372
- console.log('step4 before');
373
- await scrollIntoView(scrollViewRef, step4Ref);
374
- },
375
- Component: () => {
376
- const {
377
- stopTour,
378
- goPreviousTourStep
379
- } = useTourContext();
380
- return /*#__PURE__*/_jsx(Coachmark, {
381
- action: /*#__PURE__*/_jsxs(HStack, {
382
- gap: 1,
383
- children: [/*#__PURE__*/_jsx(Button, {
384
- compact: true,
385
- onPress: goPreviousTourStep,
386
- variant: "secondary",
387
- children: "Back"
388
- }), /*#__PURE__*/_jsx(Button, {
389
- compact: true,
390
- onPress: stopTour,
391
- variant: "secondary",
392
- children: "Done"
393
- })]
394
- }),
395
- content: "Add up to 3 lines of body copy. Deliver your message with clarity and impact",
396
- title: "My last step",
397
- width: 250
398
- });
399
- }
400
- }], []);
401
- return /*#__PURE__*/_jsx(Tour, {
402
- activeTourStep: activeTourStep,
403
- onChange: setActiveTourStep,
404
- steps: complexIdTourSteps,
405
- children: /*#__PURE__*/_jsx(ScrollView, {
406
- ref: scrollViewRef,
407
- style: {
408
- flex: 1
409
- },
410
- children: /*#__PURE__*/_jsx(ExampleScreen, {
411
- children: /*#__PURE__*/_jsx(Example, {
412
- children: /*#__PURE__*/_jsx(TourExamples, {
413
- ids: complexIdTourSteps.map(s => s.id),
414
- step2Ref: step2Ref,
415
- step3Ref: step3Ref,
416
- step4Ref: step4Ref
417
- })
252
+ return /*#__PURE__*/_jsx(ExampleScreen, {
253
+ ref: scrollViewRef,
254
+ children: /*#__PURE__*/_jsx(Example, {
255
+ title: "Tour Example",
256
+ children: /*#__PURE__*/_jsx(Tour, {
257
+ activeTourStep: activeTourStep,
258
+ onChange: setActiveTourStep,
259
+ steps: tourSteps,
260
+ children: /*#__PURE__*/_jsx(TourExamples, {
261
+ ids: ['step1', 'step2', 'step3', 'step4'],
262
+ step2Ref: step2Ref,
263
+ step3Ref: step3Ref,
264
+ step4Ref: step4Ref
418
265
  })
419
266
  })
420
267
  })
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextBody } from '../TextBody';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextBody
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextCaption } from '../TextCaption';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextCaption
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { Text } from '../Text';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: Text
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextDisplay1 } from '../TextDisplay1';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextDisplay1
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextDisplay2 } from '../TextDisplay2';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextDisplay2
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextDisplay3 } from '../TextDisplay3';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextDisplay3
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextHeadline } from '../TextHeadline';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextHeadline
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextLabel1 } from '../TextLabel1';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextLabel1
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextLabel2 } from '../TextLabel2';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextLabel2
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextLegal } from '../TextLegal';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextLegal
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextTitle1 } from '../TextTitle1';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextTitle1
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextTitle2 } from '../TextTitle2';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextTitle2
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextTitle3 } from '../TextTitle3';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextTitle3
@@ -1,6 +1,8 @@
1
1
  import React from 'react';
2
2
  import { TextTitle4 } from '../TextTitle4';
3
3
  import TextExamplesScreen from './TextExamples';
4
+
5
+ // eslint-disable-next-line internal/example-screen-default
4
6
  import { jsx as _jsx } from "react/jsx-runtime";
5
7
  export default () => /*#__PURE__*/_jsx(TextExamplesScreen, {
6
8
  component: TextTitle4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cds-mobile",
3
- "version": "8.25.1",
3
+ "version": "8.27.0",
4
4
  "description": "Coinbase Design System - Mobile",
5
5
  "repository": {
6
6
  "type": "git",
@@ -154,7 +154,7 @@
154
154
  "react-native-svg": "^14.1.0"
155
155
  },
156
156
  "dependencies": {
157
- "@coinbase/cds-common": "^8.25.1",
157
+ "@coinbase/cds-common": "^8.27.0",
158
158
  "@coinbase/cds-icons": "^5.7.0",
159
159
  "@coinbase/cds-illustrations": "^4.28.0",
160
160
  "@coinbase/cds-lottie-files": "^3.3.3",
@@ -1,98 +0,0 @@
1
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
2
- import { Animated } from 'react-native';
3
- import { convertMotionConfig } from '../../animation/convertMotionConfig';
4
- import { Example, ExampleScreen } from '../../examples/ExampleScreen';
5
- import { useTheme } from '../../hooks/useTheme';
6
- import { HStack } from '../../layout/HStack';
7
- import { VStack } from '../../layout/VStack';
8
- import { Pressable } from '../../system/Pressable';
9
- import { Text } from '../../typography/Text';
10
- import { Icon } from '../Icon';
11
- import { TextIcon } from '../TextIcon';
12
- import { IconSheet } from './IconSheet';
13
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
- const animateInConfig = convertMotionConfig({
15
- easing: 'enterFunctional',
16
- duration: 'moderate1',
17
- toValue: 1,
18
- useNativeDriver: false
19
- });
20
- const animateOutConfig = convertMotionConfig({
21
- easing: 'exitFunctional',
22
- duration: 'moderate1',
23
- toValue: 1,
24
- useNativeDriver: false
25
- });
26
- export const useAnimation = () => {
27
- const animationRef = useRef(new Animated.Value(0));
28
- return useMemo(() => {
29
- const animateIn = Animated.timing(animationRef.current, animateInConfig);
30
- const animateOut = Animated.timing(animationRef.current, animateOutConfig);
31
- return [animationRef.current, animateIn, animateOut];
32
- }, []);
33
- };
34
- const IconScreen = () => {
35
- const theme = useTheme();
36
- const [isToggled, setIsToggled] = useState(false);
37
- const animationRef = useRef(new Animated.Value(0)).current;
38
- useEffect(() => {
39
- Animated.timing(animationRef, isToggled ? animateInConfig : animateOutConfig).start();
40
- }, [isToggled, animationRef]);
41
- const toggle = useCallback(() => setIsToggled(prevIsToggled => !prevIsToggled), []);
42
- const animatedIcon = /*#__PURE__*/_jsx(Icon, {
43
- active: true,
44
- animated: true,
45
- dangerouslySetColor: animationRef.interpolate({
46
- inputRange: [0, 1],
47
- outputRange: [theme.color.bgLine, theme.color.fgPrimary]
48
- }),
49
- name: "star",
50
- size: "l"
51
- });
52
- return /*#__PURE__*/_jsxs(ExampleScreen, {
53
- children: [/*#__PURE__*/_jsx(Example, {
54
- title: "Nesting TextIcons",
55
- children: /*#__PURE__*/_jsxs(VStack, {
56
- gap: 1,
57
- children: [/*#__PURE__*/_jsxs(Text, {
58
- font: "body",
59
- children: [/*#__PURE__*/_jsx(TextIcon, {
60
- active: true,
61
- name: "dot",
62
- size: "xs"
63
- }), /*#__PURE__*/_jsx(Text, {
64
- font: "body",
65
- children: "This is some text"
66
- })]
67
- }), /*#__PURE__*/_jsxs(Text, {
68
- font: "body",
69
- children: [/*#__PURE__*/_jsx(TextIcon, {
70
- active: true,
71
- name: "dot",
72
- size: "xs"
73
- }), /*#__PURE__*/_jsx(Text, {
74
- font: "body",
75
- children: "This is soooooooooooooome reallllllllllllllllly loooooooonnngggggg text"
76
- })]
77
- })]
78
- })
79
- }), /*#__PURE__*/_jsx(Example, {
80
- title: "Animated Icon",
81
- children: /*#__PURE__*/_jsx(Pressable, {
82
- noScaleOnPress: true,
83
- accessibilityHint: "hit star to rate the product",
84
- accessibilityLabel: "rating a product",
85
- background: "transparent",
86
- onPress: toggle,
87
- children: /*#__PURE__*/_jsxs(HStack, {
88
- gap: 1,
89
- children: [animatedIcon, animatedIcon, animatedIcon, animatedIcon]
90
- })
91
- })
92
- }), /*#__PURE__*/_jsx(Example, {
93
- title: "Icon Sheet",
94
- children: /*#__PURE__*/_jsx(IconSheet, {})
95
- })]
96
- });
97
- };
98
- export default IconScreen;
@@ -1,164 +0,0 @@
1
- import React, { memo, useCallback } from 'react';
2
- import { Dimensions, FlatList } from 'react-native';
3
- import { illustrationDimensions, illustrationSizes } from '@coinbase/cds-common/tokens/illustrations';
4
- import heroSquareVersionMap from '@coinbase/cds-illustrations/__generated__/heroSquare/data/versionMap';
5
- import pictogramVersionMap from '@coinbase/cds-illustrations/__generated__/pictogram/data/versionMap';
6
- import spotIconVersionMap from '@coinbase/cds-illustrations/__generated__/spotIcon/data/versionMap';
7
- import spotRectangleVersionMap from '@coinbase/cds-illustrations/__generated__/spotRectangle/data/versionMap';
8
- import spotSquareVersionMap from '@coinbase/cds-illustrations/__generated__/spotSquare/data/versionMap';
9
- import { Divider, VStack } from '../../layout';
10
- import { ThemeProvider } from '../../system/ThemeProvider';
11
- import { defaultTheme } from '../../themes/defaultTheme';
12
- import { Text } from '../../typography/Text';
13
- import { HeroSquare, Pictogram, SpotIcon, SpotRectangle, SpotSquare } from '../index';
14
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
15
- function keys(obj) {
16
- return Object.keys(obj);
17
- }
18
- const images = {
19
- heroSquare: keys(heroSquareVersionMap),
20
- pictogram: keys(pictogramVersionMap),
21
- spotRectangle: keys(spotRectangleVersionMap),
22
- spotSquare: keys(spotSquareVersionMap),
23
- spotIcon: keys(spotIconVersionMap)
24
- };
25
- export function getIllustrationSheet(type) {
26
- /** Constants */
27
- const FLAT_LIST_STYLE = {
28
- width: '100%'
29
- };
30
- const FLAT_LIST_CONTAINER_STYLE = {
31
- marginLeft: 24,
32
- paddingBottom: 24,
33
- alignContent: 'flex-start'
34
- };
35
- const SCREEN_WIDTH = Dimensions.get('window').width - FLAT_LIST_CONTAINER_STYLE.marginLeft * 2;
36
- const SIZES = {
37
- pictogram: {
38
- height: illustrationSizes[illustrationDimensions.pictogram[0]][1],
39
- width: illustrationSizes[illustrationDimensions.pictogram[0]][0],
40
- scaleMultiplier: 1
41
- },
42
- spotSquare: {
43
- height: illustrationSizes[illustrationDimensions.spotSquare[0]][1],
44
- width: illustrationSizes[illustrationDimensions.spotSquare[0]][0],
45
- scaleMultiplier: 0.4
46
- },
47
- spotRectangle: {
48
- height: illustrationSizes[illustrationDimensions.spotRectangle[0]][1],
49
- width: illustrationSizes[illustrationDimensions.spotRectangle[0]][0],
50
- scaleMultiplier: 0.3
51
- },
52
- heroSquare: {
53
- height: illustrationSizes[illustrationDimensions.heroSquare[0]][1],
54
- width: illustrationSizes[illustrationDimensions.heroSquare[0]][0],
55
- scaleMultiplier: 0.24
56
- },
57
- spotIcon: {
58
- height: illustrationSizes[illustrationDimensions.spotIcon[0]][1],
59
- width: illustrationSizes[illustrationDimensions.spotIcon[0]][0],
60
- scaleMultiplier: 1
61
- }
62
- };
63
- const ITEM_COLUMNS = Math.floor(SCREEN_WIDTH / (SIZES[type].width * SIZES[type].scaleMultiplier));
64
- const names = images[type];
65
- const data = [];
66
- names.forEach(name => {
67
- data.push({
68
- name,
69
- colorScheme: 'light'
70
- });
71
- data.push({
72
- name,
73
- colorScheme: 'dark'
74
- });
75
- });
76
- const ListFooterComponent = /*#__PURE__*/memo(function ListFooterComponent() {
77
- // TODO: pull from ui-mobile-playground/helpers/constants via scrollViewEnd constant
78
- return /*#__PURE__*/_jsx(Divider, {
79
- testID: "mobile-playground-scrollview-end"
80
- });
81
- });
82
- const renderItem = _ref => {
83
- let {
84
- item
85
- } = _ref;
86
- const dim = SIZES[type].width + "x" + SIZES[type].height;
87
- return /*#__PURE__*/_jsx(ThemeProvider, {
88
- activeColorScheme: item.colorScheme,
89
- theme: defaultTheme,
90
- children: /*#__PURE__*/_jsxs(VStack, {
91
- background: "bg",
92
- overflow: "hidden",
93
- width: SIZES[type].width * SIZES[type].scaleMultiplier,
94
- children: [type === 'heroSquare' &&
95
- /*#__PURE__*/
96
- // render a 48x48 thumbnail
97
- _jsx(HeroSquare, {
98
- dimension: dim,
99
- name: item.name,
100
- scaleMultiplier: SIZES.heroSquare.scaleMultiplier
101
- }), type === 'spotSquare' &&
102
- /*#__PURE__*/
103
- // render a 48x48 thumbnail
104
- _jsx(SpotSquare, {
105
- name: item.name,
106
- scaleMultiplier: SIZES.spotSquare.scaleMultiplier
107
- }), type === 'spotRectangle' &&
108
- /*#__PURE__*/
109
- // render a 72x36 thumbnail
110
- _jsx(SpotRectangle, {
111
- name: item.name,
112
- scaleMultiplier: SIZES.spotRectangle.scaleMultiplier
113
- }), type === 'pictogram' && /*#__PURE__*/_jsx(Pictogram, {
114
- dimension: dim,
115
- name: item.name,
116
- scaleMultiplier: SIZES.pictogram.scaleMultiplier
117
- }), type === 'spotIcon' && /*#__PURE__*/_jsx(SpotIcon, {
118
- dimension: dim,
119
- name: item.name,
120
- scaleMultiplier: SIZES.spotIcon.scaleMultiplier
121
- }), /*#__PURE__*/_jsx(Text, {
122
- ellipsize: "tail",
123
- font: "legal",
124
- children: item.name
125
- })]
126
- })
127
- });
128
- };
129
- const IllustrationSheet = /*#__PURE__*/memo(function IllustrationSheet() {
130
- const getItemLayout = useCallback(function getItemLayout(_data, index) {
131
- return {
132
- length: SIZES[type].height * SIZES[type].scaleMultiplier,
133
- offset: SIZES[type].height * SIZES[type].scaleMultiplier * index,
134
- index
135
- };
136
- }, []);
137
- const keyExtractor = useCallback(function keyExtractor(item) {
138
- return type + "-" + item.name + "-" + item.colorScheme;
139
- }, []);
140
- return /*#__PURE__*/_jsx(VStack
141
- // TODO: pull from ui-mobile-playground/helpers/constants via screen constant
142
- , {
143
- alignItems: "center",
144
- background: "bg",
145
- flexGrow: 1,
146
- justifyContent: "center",
147
- testID: "mobile-playground-screen",
148
- children: /*#__PURE__*/_jsx(FlatList, {
149
- ListFooterComponent: ListFooterComponent,
150
- contentContainerStyle: FLAT_LIST_CONTAINER_STYLE,
151
- data: data,
152
- getItemLayout: getItemLayout,
153
- keyExtractor: keyExtractor,
154
- numColumns: ITEM_COLUMNS,
155
- renderItem: renderItem,
156
- style: FLAT_LIST_STYLE
157
- // TODO: pull from ui-mobile-playground/helpers/constants via scrollView constant
158
- ,
159
- testID: "mobile-playground-scrollview"
160
- })
161
- });
162
- });
163
- return IllustrationSheet;
164
- }