@ledgerhq/lumen-ui-rnative 0.0.69 → 0.0.71

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 (83) hide show
  1. package/.storybook/mocks/blur.tsx +1 -2
  2. package/.storybook/preview.tsx +4 -0
  3. package/dist/package.json +4 -4
  4. package/dist/src/index.d.ts +1 -0
  5. package/dist/src/index.d.ts.map +1 -1
  6. package/dist/src/index.js +1 -0
  7. package/dist/src/lib/Animations/Pulse/Pulse.d.ts +3 -0
  8. package/dist/src/lib/Animations/Pulse/Pulse.d.ts.map +1 -0
  9. package/dist/src/lib/Animations/Pulse/Pulse.js +46 -0
  10. package/dist/src/lib/Animations/Pulse/Pulse.stories.d.ts +9 -0
  11. package/dist/src/lib/Animations/Pulse/Pulse.stories.d.ts.map +1 -0
  12. package/dist/src/lib/Animations/Pulse/Pulse.stories.js +38 -0
  13. package/dist/src/lib/Animations/Pulse/index.d.ts +3 -0
  14. package/dist/src/lib/Animations/Pulse/index.d.ts.map +1 -0
  15. package/dist/src/lib/Animations/Pulse/index.js +2 -0
  16. package/dist/src/lib/Animations/Pulse/types.d.ts +18 -0
  17. package/dist/src/lib/Animations/Pulse/types.d.ts.map +1 -0
  18. package/dist/src/lib/Animations/Pulse/types.js +1 -0
  19. package/dist/src/lib/Animations/Spin/Spin.d.ts +3 -0
  20. package/dist/src/lib/Animations/Spin/Spin.d.ts.map +1 -0
  21. package/dist/src/lib/Animations/Spin/Spin.js +23 -0
  22. package/dist/src/lib/Animations/Spin/Spin.stories.d.ts +9 -0
  23. package/dist/src/lib/Animations/Spin/Spin.stories.d.ts.map +1 -0
  24. package/dist/src/lib/Animations/Spin/Spin.stories.js +27 -0
  25. package/dist/src/lib/Animations/Spin/index.d.ts +3 -0
  26. package/dist/src/lib/Animations/Spin/index.d.ts.map +1 -0
  27. package/dist/src/lib/Animations/Spin/index.js +2 -0
  28. package/dist/src/lib/Animations/Spin/types.d.ts +14 -0
  29. package/dist/src/lib/Animations/Spin/types.d.ts.map +1 -0
  30. package/dist/src/lib/Animations/Spin/types.js +1 -0
  31. package/dist/src/lib/Animations/index.d.ts +4 -0
  32. package/dist/src/lib/Animations/index.d.ts.map +1 -0
  33. package/dist/src/lib/Animations/index.js +3 -0
  34. package/dist/src/lib/Animations/types.d.ts +2 -0
  35. package/dist/src/lib/Animations/types.d.ts.map +1 -0
  36. package/dist/src/lib/Animations/types.js +1 -0
  37. package/dist/src/lib/Components/AmountDisplay/AmountDisplay.d.ts +5 -7
  38. package/dist/src/lib/Components/AmountDisplay/AmountDisplay.d.ts.map +1 -1
  39. package/dist/src/lib/Components/AmountDisplay/AmountDisplay.js +7 -6
  40. package/dist/src/lib/Components/AmountDisplay/AmountDisplay.stories.d.ts +1 -0
  41. package/dist/src/lib/Components/AmountDisplay/AmountDisplay.stories.d.ts.map +1 -1
  42. package/dist/src/lib/Components/AmountDisplay/AmountDisplay.stories.js +5 -0
  43. package/dist/src/lib/Components/AmountDisplay/types.d.ts +7 -1
  44. package/dist/src/lib/Components/AmountDisplay/types.d.ts.map +1 -1
  45. package/dist/src/lib/Components/CardButton/CardButton.js +3 -3
  46. package/dist/src/lib/Components/Spinner/Spinner.d.ts.map +1 -1
  47. package/dist/src/lib/Components/Spinner/Spinner.js +2 -23
  48. package/dist/src/lib/Components/TabBar/TabBar.d.ts +1 -0
  49. package/dist/src/lib/Components/TabBar/TabBar.d.ts.map +1 -1
  50. package/dist/src/lib/Components/TabBar/TabBar.js +2 -1
  51. package/dist/src/lib/Components/TabBar/index.d.ts +1 -1
  52. package/dist/src/lib/Components/TabBar/index.d.ts.map +1 -1
  53. package/dist/src/lib/Components/TabBar/index.js +1 -1
  54. package/dist/src/lib/Components/TileButton/TileButton.d.ts +4 -3
  55. package/dist/src/lib/Components/TileButton/TileButton.d.ts.map +1 -1
  56. package/dist/src/lib/Components/TileButton/TileButton.js +3 -4
  57. package/dist/src/styles/types/factories.types.d.ts +1 -1
  58. package/dist/src/styles/types/factories.types.d.ts.map +1 -1
  59. package/package.json +4 -4
  60. package/src/index.ts +1 -0
  61. package/src/lib/Animations/Pulse/Pulse.mdx +86 -0
  62. package/src/lib/Animations/Pulse/Pulse.stories.tsx +90 -0
  63. package/src/lib/Animations/Pulse/Pulse.tsx +55 -0
  64. package/src/lib/Animations/Pulse/index.ts +2 -0
  65. package/src/lib/Animations/Pulse/types.ts +18 -0
  66. package/src/lib/Animations/Spin/Spin.mdx +85 -0
  67. package/src/lib/Animations/Spin/Spin.stories.tsx +72 -0
  68. package/src/lib/Animations/Spin/Spin.tsx +34 -0
  69. package/src/lib/Animations/Spin/index.ts +2 -0
  70. package/src/lib/Animations/Spin/types.ts +14 -0
  71. package/src/lib/Animations/index.ts +3 -0
  72. package/src/lib/Animations/types.ts +11 -0
  73. package/src/lib/Components/AmountDisplay/AmountDisplay.mdx +6 -0
  74. package/src/lib/Components/AmountDisplay/AmountDisplay.stories.tsx +12 -0
  75. package/src/lib/Components/AmountDisplay/AmountDisplay.test.tsx +13 -0
  76. package/src/lib/Components/AmountDisplay/AmountDisplay.tsx +39 -35
  77. package/src/lib/Components/AmountDisplay/types.ts +7 -1
  78. package/src/lib/Components/CardButton/CardButton.tsx +3 -3
  79. package/src/lib/Components/Spinner/Spinner.tsx +3 -35
  80. package/src/lib/Components/TabBar/TabBar.tsx +2 -1
  81. package/src/lib/Components/TabBar/index.ts +1 -1
  82. package/src/lib/Components/TileButton/TileButton.tsx +35 -44
  83. package/src/styles/types/factories.types.ts +1 -1
@@ -1,7 +1,7 @@
1
- import React from 'react';
2
- import { View, Text, StyleSheet } from 'react-native';
1
+ import { View, Text } from 'react-native';
3
2
  import { useStyleSheet } from '../../../styles';
4
- import { ViewRef } from '../../types';
3
+ import { Pulse } from '../../Animations/Pulse';
4
+ import { Box } from '../Utility';
5
5
  import { AmountDisplayProps } from './types';
6
6
 
7
7
  const useStyles = () => {
@@ -71,39 +71,43 @@ const useStyles = () => {
71
71
  * <AmountDisplay value={1234.56} formatter={usdFormatter} hidden={true} />
72
72
  * ```
73
73
  */
74
- export const AmountDisplay = React.forwardRef<ViewRef, AmountDisplayProps>(
75
- ({ value, formatter, hidden = false, style, ...props }, ref) => {
76
- const styles = useStyles();
77
- const parts = formatter(value);
74
+ export const AmountDisplay = ({
75
+ value,
76
+ formatter,
77
+ hidden = false,
78
+ loading = false,
79
+ ...props
80
+ }: AmountDisplayProps) => {
81
+ const styles = useStyles();
82
+ const parts = formatter(value);
78
83
 
79
- return (
80
- <View
81
- ref={ref}
82
- style={StyleSheet.flatten([styles.container, style])}
83
- {...props}
84
- >
85
- {(parts.currencyPosition === undefined ||
86
- parts.currencyPosition === 'start') && (
87
- <Text style={[styles.currencyStartText, styles.spacingStart]}>
88
- {parts.currencyText}
84
+ return (
85
+ <Box {...props}>
86
+ <Pulse animate={loading}>
87
+ <View style={styles.container}>
88
+ {(parts.currencyPosition === undefined ||
89
+ parts.currencyPosition === 'start') && (
90
+ <Text style={[styles.currencyStartText, styles.spacingStart]}>
91
+ {parts.currencyText}
92
+ </Text>
93
+ )}
94
+ <Text style={styles.integerText}>
95
+ {hidden ? '••••' : parts.integerPart}
89
96
  </Text>
90
- )}
91
- <Text style={styles.integerText}>
92
- {hidden ? '••••' : parts.integerPart}
93
- </Text>
94
- {parts.decimalPart && !hidden && (
95
- <Text style={styles.decimalText}>
96
- {(parts.decimalSeparator || '.') + parts.decimalPart}
97
- </Text>
98
- )}
99
- {parts.currencyPosition === 'end' && (
100
- <Text style={[styles.currencyEndText, styles.spacingEnd]}>
101
- {parts.currencyText}
102
- </Text>
103
- )}
104
- </View>
105
- );
106
- },
107
- );
97
+ {parts.decimalPart && !hidden && (
98
+ <Text style={styles.decimalText}>
99
+ {(parts.decimalSeparator || '.') + parts.decimalPart}
100
+ </Text>
101
+ )}
102
+ {parts.currencyPosition === 'end' && (
103
+ <Text style={[styles.currencyEndText, styles.spacingEnd]}>
104
+ {parts.currencyText}
105
+ </Text>
106
+ )}
107
+ </View>
108
+ </Pulse>
109
+ </Box>
110
+ );
111
+ };
108
112
 
109
113
  AmountDisplay.displayName = 'AmountDisplay';
@@ -1,4 +1,5 @@
1
1
  import { ViewProps } from 'react-native';
2
+ import { StyledViewProps } from '../../../styles';
2
3
 
3
4
  export type FormattedValue = {
4
5
  /**
@@ -45,4 +46,9 @@ export type AmountDisplayProps = ViewProps & {
45
46
  * @default false
46
47
  */
47
48
  hidden?: boolean;
48
- };
49
+ /**
50
+ * When true, applies a pulse animation to indicate the amount is being fetched or updated.
51
+ * @default false
52
+ */
53
+ loading?: boolean;
54
+ } & Omit<StyledViewProps, 'children'>;
@@ -67,7 +67,7 @@ const useStyles = ({
67
67
  gap: t.spacings.s4,
68
68
  },
69
69
  title: StyleSheet.flatten([
70
- t.typographies.body1SemiBold,
70
+ t.typographies.body2SemiBold,
71
71
  {
72
72
  color: disabled ? t.colors.text.disabled : t.colors.text.base,
73
73
  minWidth: 0,
@@ -75,9 +75,9 @@ const useStyles = ({
75
75
  },
76
76
  ]),
77
77
  description: StyleSheet.flatten([
78
- t.typographies.body2,
78
+ t.typographies.body3,
79
79
  {
80
- color: disabled ? t.colors.text.disabled : t.colors.text.base,
80
+ color: disabled ? t.colors.text.disabled : t.colors.text.muted,
81
81
  minWidth: 0,
82
82
  },
83
83
  ]),
@@ -1,42 +1,10 @@
1
- import { memo, useEffect, useRef, ReactNode } from 'react';
2
- import { Animated, Easing } from 'react-native';
3
1
  import Svg, { Path } from 'react-native-svg';
4
2
  import { useCommonTranslation } from '../../../i18n';
5
3
  import { LumenTextStyle, useResolveTextStyle, useTheme } from '../../../styles';
6
- import { RuntimeConstants } from '../../utils';
4
+ import { Spin } from '../../Animations/Spin';
7
5
  import { Box } from '../Utility';
8
6
  import { SpinnerProps } from './types';
9
7
 
10
- const SpinAnimation = memo(({ children }: { children: ReactNode }) => {
11
- const spinValue = useRef(new Animated.Value(0)).current;
12
-
13
- useEffect(() => {
14
- const animation = Animated.loop(
15
- Animated.timing(spinValue, {
16
- toValue: 1,
17
- duration: 1000,
18
- easing: Easing.linear,
19
- useNativeDriver: RuntimeConstants.isNative,
20
- }),
21
- );
22
- animation.start();
23
-
24
- return () => animation.stop();
25
- }, [spinValue]);
26
-
27
- const spin = spinValue.interpolate({
28
- inputRange: [0, 1],
29
- outputRange: ['0deg', '360deg'],
30
- });
31
-
32
- return (
33
- <Animated.View style={{ transform: [{ rotate: spin }] }}>
34
- {children}
35
- </Animated.View>
36
- );
37
- });
38
- SpinAnimation.displayName = 'SpinAnimation';
39
-
40
8
  /**
41
9
  * A basic spinner component for loading states.
42
10
  *
@@ -66,7 +34,7 @@ export const Spinner = ({
66
34
 
67
35
  return (
68
36
  <Box ref={ref} lx={{ flexShrink: 0, ...lx }} {...props}>
69
- <SpinAnimation>
37
+ <Spin>
70
38
  <Svg
71
39
  width={size}
72
40
  height={size}
@@ -81,7 +49,7 @@ export const Spinner = ({
81
49
  strokeLinecap='round'
82
50
  />
83
51
  </Svg>
84
- </SpinAnimation>
52
+ </Spin>
85
53
  </Box>
86
54
  );
87
55
  };
@@ -15,6 +15,7 @@ import { Box, Pressable } from '../Utility';
15
15
  import { TabBarContextProvider, useTabBarContext } from './TabBarContext';
16
16
  import { TabBarItemProps, TabBarProps } from './types';
17
17
 
18
+ export const TAB_BAR_HEIGHT = 56;
18
19
  const PILL_INSET = 4;
19
20
 
20
21
  /**
@@ -239,7 +240,7 @@ const useStyles = () =>
239
240
  useStyleSheet(
240
241
  (t) => ({
241
242
  container: {
242
- height: t.sizes.s56,
243
+ height: TAB_BAR_HEIGHT,
243
244
  flexDirection: 'row',
244
245
  justifyContent: 'center',
245
246
  padding: t.spacings.s4,
@@ -1,2 +1,2 @@
1
- export { TabBar, TabBarItem } from './TabBar';
1
+ export { TabBar, TabBarItem, TAB_BAR_HEIGHT } from './TabBar';
2
2
  export type { TabBarProps, TabBarItemProps } from './types';
@@ -1,5 +1,5 @@
1
1
  import { isTextChildren } from '@ledgerhq/lumen-utils-shared';
2
- import React, { FC, PropsWithChildren } from 'react';
2
+ import { FC, PropsWithChildren } from 'react';
3
3
  import { StyleSheet, View } from 'react-native';
4
4
  import { useStyleSheet } from '../../../styles';
5
5
  import { IconSize } from '../Icon';
@@ -74,50 +74,41 @@ const useStyles = ({
74
74
  * Settings
75
75
  * </TileButton>
76
76
  */
77
- export const TileButton = React.forwardRef<
78
- React.ElementRef<typeof Pressable>,
79
- TileButtonProps
80
- >(
81
- (
82
- {
83
- lx,
84
- style,
85
- icon: IconProp,
86
- children,
87
- disabled = false,
88
- isFull = false,
89
- numberOfLines = 2,
90
- ...props
91
- },
92
- ref,
93
- ) => {
94
- const rootStyles = useRootStyles({ isFull });
77
+ export const TileButton = ({
78
+ lx,
79
+ style,
80
+ icon: IconProp,
81
+ children,
82
+ disabled = false,
83
+ isFull = false,
84
+ numberOfLines = 2,
85
+ ...props
86
+ }: TileButtonProps) => {
87
+ const rootStyles = useRootStyles({ isFull });
95
88
 
96
- return (
97
- <Pressable
98
- ref={ref}
99
- lx={lx}
100
- style={StyleSheet.flatten([style, rootStyles.root])}
101
- disabled={disabled}
102
- accessibilityRole='button'
103
- accessibilityState={{ disabled }}
104
- {...props}
105
- >
106
- {({ pressed }) => (
107
- <TileButtonContent
108
- disabled={disabled}
109
- pressed={pressed}
110
- isFull={isFull}
111
- IconProp={IconProp}
112
- numberOfLines={numberOfLines}
113
- >
114
- {children}
115
- </TileButtonContent>
116
- )}
117
- </Pressable>
118
- );
119
- },
120
- );
89
+ return (
90
+ <Pressable
91
+ lx={lx}
92
+ style={StyleSheet.flatten([style, rootStyles.root])}
93
+ disabled={disabled}
94
+ accessibilityRole='button'
95
+ accessibilityState={{ disabled }}
96
+ {...props}
97
+ >
98
+ {({ pressed }) => (
99
+ <TileButtonContent
100
+ disabled={disabled}
101
+ pressed={pressed}
102
+ isFull={isFull}
103
+ IconProp={IconProp}
104
+ numberOfLines={numberOfLines}
105
+ >
106
+ {children}
107
+ </TileButtonContent>
108
+ )}
109
+ </Pressable>
110
+ );
111
+ };
121
112
 
122
113
  type TileButtonContentProps = PropsWithChildren<{
123
114
  disabled: boolean;
@@ -1,4 +1,4 @@
1
- import { ComponentPropsWithRef } from 'react';
1
+ import type { ComponentPropsWithRef } from 'react';
2
2
  import {
3
3
  PressableProps,
4
4
  PressableStateCallbackType,