@ledgerhq/lumen-ui-rnative 0.0.67 → 0.0.69
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/.storybook/docs/getting-started/setup.mdx +12 -0
- package/ai-rules/README.md +98 -0
- package/ai-rules/RULES.md +150 -0
- package/dist/package.json +2 -2
- package/dist/src/i18n/locales/de.json +4 -0
- package/dist/src/i18n/locales/en.json +4 -0
- package/dist/src/i18n/locales/es.json +4 -0
- package/dist/src/i18n/locales/fr.json +4 -0
- package/dist/src/i18n/locales/ja.json +4 -0
- package/dist/src/i18n/locales/ko.json +4 -0
- package/dist/src/i18n/locales/pt.json +4 -0
- package/dist/src/i18n/locales/ru.json +4 -0
- package/dist/src/i18n/locales/th.json +4 -0
- package/dist/src/i18n/locales/tr.json +4 -0
- package/dist/src/i18n/locales/zh.json +4 -0
- package/dist/src/lib/Components/Avatar/Avatar.d.ts +19 -0
- package/dist/src/lib/Components/Avatar/Avatar.d.ts.map +1 -0
- package/dist/src/lib/Components/Avatar/Avatar.js +81 -0
- package/dist/src/lib/Components/Avatar/Avatar.stories.d.ts +22 -0
- package/dist/src/lib/Components/Avatar/Avatar.stories.d.ts.map +1 -0
- package/dist/src/lib/Components/Avatar/Avatar.stories.js +72 -0
- package/dist/src/lib/Components/Avatar/index.d.ts +3 -0
- package/dist/src/lib/Components/Avatar/index.d.ts.map +1 -0
- package/dist/src/lib/Components/Avatar/index.js +2 -0
- package/dist/src/lib/Components/Avatar/types.d.ts +26 -0
- package/dist/src/lib/Components/Avatar/types.d.ts.map +1 -0
- package/dist/src/lib/Components/Avatar/types.js +1 -0
- package/dist/src/lib/Components/BottomSheet/BottomSheet.d.ts +1 -1
- package/dist/src/lib/Components/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/src/lib/Components/BottomSheet/BottomSheet.js +5 -1
- package/dist/src/lib/Components/BottomSheet/BottomSheet.stories.d.ts +9 -1
- package/dist/src/lib/Components/BottomSheet/BottomSheet.stories.d.ts.map +1 -1
- package/dist/src/lib/Components/BottomSheet/BottomSheet.stories.js +10 -0
- package/dist/src/lib/Components/BottomSheet/types.d.ts +10 -0
- package/dist/src/lib/Components/BottomSheet/types.d.ts.map +1 -1
- package/dist/src/lib/Components/NavBar/CoinCapsule.d.ts +6 -0
- package/dist/src/lib/Components/NavBar/CoinCapsule.d.ts.map +1 -0
- package/dist/src/lib/Components/NavBar/CoinCapsule.js +23 -0
- package/dist/src/lib/Components/NavBar/NavBar.d.ts +42 -0
- package/dist/src/lib/Components/NavBar/NavBar.d.ts.map +1 -0
- package/dist/src/lib/Components/NavBar/NavBar.js +211 -0
- package/dist/src/lib/Components/NavBar/NavBar.stories.d.ts +10 -0
- package/dist/src/lib/Components/NavBar/NavBar.stories.d.ts.map +1 -0
- package/dist/src/lib/Components/NavBar/NavBar.stories.js +72 -0
- package/dist/src/lib/Components/NavBar/index.d.ts +3 -0
- package/dist/src/lib/Components/NavBar/index.d.ts.map +1 -0
- package/dist/src/lib/Components/NavBar/index.js +2 -0
- package/dist/src/lib/Components/NavBar/types.d.ts +65 -0
- package/dist/src/lib/Components/NavBar/types.d.ts.map +1 -0
- package/dist/src/lib/Components/NavBar/types.js +1 -0
- package/dist/src/lib/Components/PageIndicator/PageIndicator.d.ts +12 -0
- package/dist/src/lib/Components/PageIndicator/PageIndicator.d.ts.map +1 -0
- package/dist/src/lib/Components/PageIndicator/PageIndicator.js +116 -0
- package/dist/src/lib/Components/PageIndicator/PageIndicator.stories.d.ts +27 -0
- package/dist/src/lib/Components/PageIndicator/PageIndicator.stories.d.ts.map +1 -0
- package/dist/src/lib/Components/PageIndicator/PageIndicator.stories.js +42 -0
- package/dist/src/lib/Components/PageIndicator/index.d.ts +3 -0
- package/dist/src/lib/Components/PageIndicator/index.d.ts.map +1 -0
- package/dist/src/lib/Components/PageIndicator/index.js +2 -0
- package/dist/src/lib/Components/PageIndicator/types.d.ts +12 -0
- package/dist/src/lib/Components/PageIndicator/types.d.ts.map +1 -0
- package/dist/src/lib/Components/PageIndicator/types.js +1 -0
- package/dist/src/lib/Components/index.d.ts +3 -0
- package/dist/src/lib/Components/index.d.ts.map +1 -1
- package/dist/src/lib/Components/index.js +3 -0
- package/dist/src/lib/Symbols/Icons/Chart5.d.ts +35 -0
- package/dist/src/lib/Symbols/Icons/Chart5.d.ts.map +1 -0
- package/dist/src/lib/Symbols/Icons/Chart5.js +34 -0
- package/dist/src/lib/Symbols/Icons/Chart5Fill.d.ts +35 -0
- package/dist/src/lib/Symbols/Icons/Chart5Fill.d.ts.map +1 -0
- package/dist/src/lib/Symbols/Icons/Chart5Fill.js +34 -0
- package/dist/src/lib/Symbols/Icons/CurveDown.d.ts +35 -0
- package/dist/src/lib/Symbols/Icons/CurveDown.d.ts.map +1 -0
- package/dist/src/lib/Symbols/Icons/CurveDown.js +34 -0
- package/dist/src/lib/Symbols/Icons/CurveUp.d.ts +35 -0
- package/dist/src/lib/Symbols/Icons/CurveUp.d.ts.map +1 -0
- package/dist/src/lib/Symbols/Icons/CurveUp.js +34 -0
- package/dist/src/lib/Symbols/Icons/Target.d.ts +35 -0
- package/dist/src/lib/Symbols/Icons/Target.d.ts.map +1 -0
- package/dist/src/lib/Symbols/Icons/Target.js +34 -0
- package/dist/src/lib/Symbols/index.d.ts +5 -0
- package/dist/src/lib/Symbols/index.d.ts.map +1 -1
- package/dist/src/lib/Symbols/index.js +5 -0
- package/jest.setup.ts +1 -0
- package/package.json +2 -2
- package/src/i18n/locales/de.json +4 -0
- package/src/i18n/locales/en.json +4 -0
- package/src/i18n/locales/es.json +4 -0
- package/src/i18n/locales/fr.json +4 -0
- package/src/i18n/locales/ja.json +4 -0
- package/src/i18n/locales/ko.json +4 -0
- package/src/i18n/locales/pt.json +4 -0
- package/src/i18n/locales/ru.json +4 -0
- package/src/i18n/locales/th.json +4 -0
- package/src/i18n/locales/tr.json +4 -0
- package/src/i18n/locales/zh.json +4 -0
- package/src/lib/Components/Avatar/Avatar.mdx +323 -0
- package/src/lib/Components/Avatar/Avatar.stories.tsx +127 -0
- package/src/lib/Components/Avatar/Avatar.test.tsx +215 -0
- package/src/lib/Components/Avatar/Avatar.tsx +132 -0
- package/src/lib/Components/Avatar/index.ts +2 -0
- package/src/lib/Components/Avatar/types.ts +26 -0
- package/src/lib/Components/BottomSheet/BottomSheet.stories.tsx +10 -0
- package/src/lib/Components/BottomSheet/BottomSheet.test.tsx +15 -0
- package/src/lib/Components/BottomSheet/BottomSheet.tsx +5 -0
- package/src/lib/Components/BottomSheet/types.ts +10 -0
- package/src/lib/Components/NavBar/CoinCapsule.tsx +36 -0
- package/src/lib/Components/NavBar/NavBar.mdx +260 -0
- package/src/lib/Components/NavBar/NavBar.stories.tsx +159 -0
- package/src/lib/Components/NavBar/NavBar.test.tsx +421 -0
- package/src/lib/Components/NavBar/NavBar.tsx +348 -0
- package/src/lib/Components/NavBar/index.ts +2 -0
- package/src/lib/Components/NavBar/types.ts +76 -0
- package/src/lib/Components/PageIndicator/PageIndicator.mdx +124 -0
- package/src/lib/Components/PageIndicator/PageIndicator.stories.tsx +78 -0
- package/src/lib/Components/PageIndicator/PageIndicator.test.tsx +190 -0
- package/src/lib/Components/PageIndicator/PageIndicator.tsx +235 -0
- package/src/lib/Components/PageIndicator/index.ts +2 -0
- package/src/lib/Components/PageIndicator/types.ts +12 -0
- package/src/lib/Components/index.ts +3 -0
- package/src/lib/Symbols/Icons/Chart5.tsx +53 -0
- package/src/lib/Symbols/Icons/Chart5Fill.tsx +42 -0
- package/src/lib/Symbols/Icons/CurveDown.tsx +69 -0
- package/src/lib/Symbols/Icons/CurveUp.tsx +68 -0
- package/src/lib/Symbols/Icons/Target.tsx +45 -0
- package/src/lib/Symbols/index.ts +5 -0
|
@@ -93,6 +93,18 @@ const ThemeToggle = () => {
|
|
|
93
93
|
```
|
|
94
94
|
|
|
95
95
|
|
|
96
|
+
## (Optional) Setup AI Assistant
|
|
97
|
+
|
|
98
|
+
For better AI assistance (Cursor, Claude, VS Code Copilot, etc.), reference the included rules.
|
|
99
|
+
|
|
100
|
+
**For Cursor**, add to your `.cursorrules`:
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
@node_modules/@ledgerhq/lumen-ui-rnative/ai-rules/RULES.md
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
[Learn more about AI rules →](https://www.npmjs.com/package/@ledgerhq/lumen-ui-rnative#-ai-assistant-setup)
|
|
107
|
+
|
|
96
108
|
## Internationalization
|
|
97
109
|
|
|
98
110
|
The ThemeProvider also manages the app’s locale using React Context.
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Lumen AI Rules for Consumers
|
|
2
|
+
|
|
3
|
+
AI assistant rules to help you use `@ledgerhq/lumen-ui-rnative` correctly in your projects.
|
|
4
|
+
|
|
5
|
+
## What These Rules Do
|
|
6
|
+
|
|
7
|
+
These rules help AI assistants:
|
|
8
|
+
|
|
9
|
+
✅ **Correct imports** - Suggest proper import paths (e.g., `/symbols` for icons)
|
|
10
|
+
✅ **Design tokens** - Use Lumen tokens via the `lx` style system
|
|
11
|
+
✅ **Component catalog** - Know which React Native components are available
|
|
12
|
+
✅ **Style system** - Use the `lx` prop with type-safe design tokens
|
|
13
|
+
✅ **Dark mode** - Understand automatic theme support
|
|
14
|
+
|
|
15
|
+
## Usage by AI Tool
|
|
16
|
+
|
|
17
|
+
### Cursor
|
|
18
|
+
|
|
19
|
+
Add to your project's `.cursorrules` file:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
@node_modules/@ledgerhq/lumen-ui-rnative/ai-rules/RULES.md
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or create `.cursor/rules/lumen-rnative.mdc`:
|
|
26
|
+
|
|
27
|
+
```markdown
|
|
28
|
+
---
|
|
29
|
+
description: Lumen UI React Native design system rules
|
|
30
|
+
globs:
|
|
31
|
+
alwaysApply: true
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
@node_modules/@ledgerhq/lumen-ui-rnative/ai-rules/RULES.md
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Claude / Claude Code
|
|
38
|
+
|
|
39
|
+
Reference the rules file in your conversation:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
Use the design system rules from: node_modules/@ledgerhq/lumen-ui-rnative/ai-rules/RULES.md
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Or copy the content from `node_modules/@ledgerhq/lumen-ui-rnative/ai-rules/RULES.md` into your custom instructions.
|
|
46
|
+
|
|
47
|
+
### VS Code / GitHub Copilot
|
|
48
|
+
|
|
49
|
+
Add to your workspace settings (`.vscode/settings.json`):
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"github.copilot.advanced": {
|
|
54
|
+
"contextFiles": ["node_modules/@ledgerhq/lumen-ui-rnative/ai-rules/RULES.md"]
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### WebStorm / JetBrains AI
|
|
60
|
+
|
|
61
|
+
Add the file `node_modules/@ledgerhq/lumen-ui-rnative/ai-rules/RULES.md` to your AI Assistant settings under "Additional Context".
|
|
62
|
+
|
|
63
|
+
### Manual Setup
|
|
64
|
+
|
|
65
|
+
Copy the rules from `node_modules/@ledgerhq/lumen-ui-rnative/ai-rules/RULES.md` into your preferred AI assistant's configuration.
|
|
66
|
+
|
|
67
|
+
## Example Results
|
|
68
|
+
|
|
69
|
+
With these rules, AI assistants will suggest:
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
// ❌ Without rules
|
|
73
|
+
import { ArrowRight } from '@ledgerhq/lumen-ui-rnative';
|
|
74
|
+
<View style={{ backgroundColor: '#f5f5f5', padding: 16 }}>
|
|
75
|
+
<Text style={{ color: '#666', fontWeight: 'bold' }}>Text</Text>
|
|
76
|
+
</View>;
|
|
77
|
+
|
|
78
|
+
// ✅ With rules
|
|
79
|
+
import { ArrowRight } from '@ledgerhq/lumen-ui-rnative/symbols';
|
|
80
|
+
<Box lx={{ backgroundColor: 'muted', padding: 16 }}>
|
|
81
|
+
<Text lx={{ color: 'muted', fontSize: 'heading-3' }}>Text</Text>
|
|
82
|
+
</Box>;
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Auto-Sync Benefits
|
|
86
|
+
|
|
87
|
+
By referencing the file from node_modules instead of copying:
|
|
88
|
+
|
|
89
|
+
- ✅ Always get the latest rules when you update the package
|
|
90
|
+
- ✅ No manual copy/paste needed
|
|
91
|
+
- ✅ Consistent across your team
|
|
92
|
+
- ✅ Rules are version-locked with your package version
|
|
93
|
+
|
|
94
|
+
## Learn More
|
|
95
|
+
|
|
96
|
+
- [Lumen Documentation](https://ldls.vercel.app)
|
|
97
|
+
- [Package README](../README.md)
|
|
98
|
+
- [Main Repository](https://github.com/LedgerHQ/lumen)
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Lumen UI React Native - AI Assistant Rules
|
|
2
|
+
|
|
3
|
+
## About Lumen
|
|
4
|
+
|
|
5
|
+
**Lumen** (Ledger Design Language System), also known as **Lumen**, is Ledger's comprehensive design system providing:
|
|
6
|
+
|
|
7
|
+
- **UI components** available via `@ledgerhq/lumen-ui-rnative`
|
|
8
|
+
- **Design tokens** (colors, spacing, typography) available via `@ledgerhq/lumen-design-core`
|
|
9
|
+
- **Multiple brand presets**: available via `@ledgerhq/lumen-design-core`
|
|
10
|
+
|
|
11
|
+
## Setup Requirements
|
|
12
|
+
|
|
13
|
+
### Package Installation
|
|
14
|
+
|
|
15
|
+
- Import components from `@ledgerhq/lumen-ui-rnative`
|
|
16
|
+
- Import icons from `@ledgerhq/lumen-ui-rnative/symbols` (not from main package)
|
|
17
|
+
- Import design tokens/presets from `@ledgerhq/lumen-design-core`
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Available React Native Components
|
|
22
|
+
|
|
23
|
+
Below is a complete list of all available Lumen React Native components. Click any component name to view its documentation and interactive examples in Storybook.
|
|
24
|
+
|
|
25
|
+
**Components:**
|
|
26
|
+
|
|
27
|
+
- [Button](https://ldls.vercel.app/?path=/docs/action-button--docs) - Primary action button component
|
|
28
|
+
- [CardButton](https://ldls.vercel.app/?path=/docs/action-cardbutton--docs) - Card-style interactive button
|
|
29
|
+
- [IconButton](https://ldls.vercel.app/?path=/docs/action-iconbutton--docs) - Button with icon only
|
|
30
|
+
- [InteractiveIcon](https://ldls.vercel.app/?path=/docs/action-interactiveicon--docs) - Interactive icon with states
|
|
31
|
+
- [Link](https://ldls.vercel.app/?path=/docs/action-link--docs) - Hyperlink component
|
|
32
|
+
- [TileButton](https://ldls.vercel.app/?path=/docs/action-tilebutton--docs) - Interactive tile button
|
|
33
|
+
- [AmountDisplay](https://ldls.vercel.app/?path=/docs/communication-amountdisplay--docs) - Display formatted amounts with currency
|
|
34
|
+
- [Banner](https://ldls.vercel.app/?path=/docs/communication-banner--docs) - Alert and notification banners
|
|
35
|
+
- [Spinner](https://ldls.vercel.app/?path=/docs/communication-spinner--docs) - Loading spinner indicator
|
|
36
|
+
- [Spot](https://ldls.vercel.app/?path=/docs/communication-spot--docs) - Icon container with background
|
|
37
|
+
- [Subheader](https://ldls.vercel.app/?path=/docs/communication-subheader--docs) - Section subheader component
|
|
38
|
+
- [Tag](https://ldls.vercel.app/?path=/docs/communication-tag--docs) - Label and tag component
|
|
39
|
+
- [Tooltip](https://ldls.vercel.app/?path=/docs/communication-tooltip--docs) - Tooltip overlay component
|
|
40
|
+
- [BottomSheet](https://ldls.vercel.app/?path=/docs/containment-bottomsheet--docs) - Bottom sheet modal component
|
|
41
|
+
- [ListItem](https://ldls.vercel.app/?path=/docs/containment-listitem--docs) - List item with flexible composition
|
|
42
|
+
- [Tile](https://ldls.vercel.app/?path=/docs/containment-tile--docs) - Content container tile
|
|
43
|
+
- [AddressInput](https://ldls.vercel.app/?path=/docs/input-addressinput--docs) - Input field for cryptocurrency addresses
|
|
44
|
+
- [AmountInput](https://ldls.vercel.app/?path=/docs/input-amountinput--docs) - Input field for amount values
|
|
45
|
+
- [SearchInput](https://ldls.vercel.app/?path=/docs/input-searchinput--docs) - Search input field
|
|
46
|
+
- [TextInput](https://ldls.vercel.app/?path=/docs/input-textinput--docs) - Text input field
|
|
47
|
+
- [Divider](https://ldls.vercel.app/?path=/docs/layout-divider--docs) - Visual separator line
|
|
48
|
+
- [TabBar](https://ldls.vercel.app/?path=/docs/navigation-tabbar--docs) - Bottom tab navigation bar
|
|
49
|
+
- [Checkbox](https://ldls.vercel.app/?path=/docs/selection-checkbox--docs) - Checkbox input for selections
|
|
50
|
+
- [Select](https://ldls.vercel.app/?path=/docs/selection-select--docs) - Dropdown select component
|
|
51
|
+
- [Switch](https://ldls.vercel.app/?path=/docs/selection-switch--docs) - Toggle switch component
|
|
52
|
+
|
|
53
|
+
**Symbols:**
|
|
54
|
+
|
|
55
|
+
- [Icon](https://ldls.vercel.app/?path=/docs/symbols-interface-icons--docs) - Interface icon components
|
|
56
|
+
|
|
57
|
+
**Utility Components:**
|
|
58
|
+
|
|
59
|
+
- [Box](https://ldls.vercel.app/?path=/docs/utility-box--docs) - Layout container with style props
|
|
60
|
+
- [LinearGradient](https://ldls.vercel.app/?path=/docs/utility-lineargradient--docs) - Linear gradient component
|
|
61
|
+
- [Pressable](https://ldls.vercel.app/?path=/docs/utility-pressable--docs) - Pressable wrapper with visual feedback
|
|
62
|
+
- [RadialGradient](https://ldls.vercel.app/?path=/docs/utility-radialgradient--docs) - Radial gradient component
|
|
63
|
+
- [Text](https://ldls.vercel.app/?path=/docs/utility-text--docs) - Text component with style props
|
|
64
|
+
|
|
65
|
+
### Icons
|
|
66
|
+
|
|
67
|
+
[View all available icons in Storybook →](https://ldls.vercel.app/?path=/docs/symbols-interface-icons--docs)
|
|
68
|
+
|
|
69
|
+
- Always import icons from `/symbols` entry point
|
|
70
|
+
- Import: `import { ArrowRight, CheckCircle } from '@ledgerhq/lumen-ui-rnative/symbols'`
|
|
71
|
+
- Use as components: `<ArrowRight size={20} />`
|
|
72
|
+
- Pass as props: `<Button icon={ArrowRight}>Label</Button>`
|
|
73
|
+
- Available sizes: 12, 16, 20, 24, 32, 40, 48, 56
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## React Native Style System
|
|
78
|
+
|
|
79
|
+
Lumen React Native uses a custom style system called `lx` that provides type-safe access to design tokens. Explore the style system documentation:
|
|
80
|
+
|
|
81
|
+
- [Colors](https://ldls.vercel.app/?path=/docs/style-system-theme-colors--docs) - Semantic color tokens for background, text, and borders
|
|
82
|
+
- [Spacings](https://ldls.vercel.app/?path=/docs/style-system-theme-spacings--docs) - Spacing scale for padding, margin, and gaps
|
|
83
|
+
- [Sizes](https://ldls.vercel.app/?path=/docs/style-system-theme-sizes--docs) - Size tokens for width and height
|
|
84
|
+
- [Shadows](https://ldls.vercel.app/?path=/docs/style-system-theme-shadows--docs) - Elevation shadow styles
|
|
85
|
+
- [Border Width](https://ldls.vercel.app/?path=/docs/style-system-theme-border-width--docs) - Border width tokens
|
|
86
|
+
- [Border Radius](https://ldls.vercel.app/?path=/docs/style-system-theme-border-radius--docs) - Border radius tokens
|
|
87
|
+
|
|
88
|
+
### Style System Usage
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { Box, Text } from '@ledgerhq/lumen-ui-rnative';
|
|
92
|
+
|
|
93
|
+
// Using lx prop for type-safe styling
|
|
94
|
+
<Box
|
|
95
|
+
lx={{
|
|
96
|
+
backgroundColor: 'base',
|
|
97
|
+
padding: 16,
|
|
98
|
+
borderRadius: 'md',
|
|
99
|
+
borderWidth: 1,
|
|
100
|
+
borderColor: 'muted',
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
<Text lx={{ color: 'base', fontSize: 'body-2' }}>Styled with design tokens</Text>
|
|
104
|
+
</Box>;
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Design Tokens
|
|
110
|
+
|
|
111
|
+
### Colors
|
|
112
|
+
|
|
113
|
+
Use Lumen design tokens -- do not use default React Native color values.
|
|
114
|
+
|
|
115
|
+
#### Available Background Colors
|
|
116
|
+
|
|
117
|
+
- **Canvas**: `canvas`, `canvas-muted`, `canvas-sheet`, `canvas-overlay`
|
|
118
|
+
- **Base**: `base`, `base-hover`, `base-pressed`
|
|
119
|
+
- **Base Transparent**: `base-transparent`, `base-transparent-hover`, `base-transparent-pressed`
|
|
120
|
+
- **Muted**: `muted`, `muted-hover`, `muted-pressed`
|
|
121
|
+
- **Muted Transparent**: `muted-transparent`, `muted-transparent-hover`, `muted-transparent-pressed`, `muted-transparent-disabled`
|
|
122
|
+
- **Muted Strong**: `muted-strong`, `muted-strong-hover`, `muted-strong-pressed`
|
|
123
|
+
- **Accent**: `accent`, `accent-hover`, `accent-pressed`
|
|
124
|
+
- **Interactive**: `interactive`, `interactive-hover`, `interactive-pressed`
|
|
125
|
+
- **Status**: `error`, `error-strong`, `error-transparent`, `warning`, `warning-strong`, `success`, `success-strong`, `success-transparent`
|
|
126
|
+
- **Active**: `active`, `active-hover`, `active-pressed`, `active-subtle`, `active-subtle-hover`, `active-subtle-pressed`
|
|
127
|
+
- **Surface**: `surface`, `surface-hover`, `surface-pressed`
|
|
128
|
+
- **Utility**: `white`, `black`, `disabled`, `disabled-strong`
|
|
129
|
+
|
|
130
|
+
#### Available Text Colors
|
|
131
|
+
|
|
132
|
+
- **Base**: `base`, `base-hover`, `base-pressed`
|
|
133
|
+
- **Muted**: `muted`, `muted-hover`, `muted-pressed`, `muted-subtle`
|
|
134
|
+
- **Interactive**: `interactive`, `interactive-hover`, `interactive-pressed`
|
|
135
|
+
- **Status**: `error`, `warning`, `success`
|
|
136
|
+
- **On Colors**: `on-accent`, `on-interactive`, `on-error-strong`, `on-warning`, `on-success-strong`
|
|
137
|
+
- **Utility**: `white`, `black`, `grey`, `disabled`, `active`
|
|
138
|
+
|
|
139
|
+
#### Available Border Colors
|
|
140
|
+
|
|
141
|
+
- **Base**: `base`, `base-hover`, `base-pressed`
|
|
142
|
+
- **Muted**: `muted`, `muted-hover`, `muted-pressed`, `muted-subtle`
|
|
143
|
+
- **Status**: `error`, `warning`, `success`
|
|
144
|
+
- **Interactive**: `focus`, `active`
|
|
145
|
+
- **Utility**: `black`, `white`, `disabled`
|
|
146
|
+
|
|
147
|
+
### Dark Mode
|
|
148
|
+
|
|
149
|
+
- Lumen components support dark mode automatically via the theme provider
|
|
150
|
+
- No component-level changes needed
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/lumen-ui-rnative",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.68",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react-native",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@types/react": "^19.0.0",
|
|
39
39
|
"@gorhom/bottom-sheet": "^5.0.0",
|
|
40
|
-
"@ledgerhq/lumen-design-core": "0.0.
|
|
40
|
+
"@ledgerhq/lumen-design-core": "0.0.49",
|
|
41
41
|
"react": "19.0.0",
|
|
42
42
|
"react-native": "~0.79.7",
|
|
43
43
|
"react-native-reanimated": "^3.0.0",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AvatarProps } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* A circular avatar component that displays a user image or fallback icon.
|
|
4
|
+
*
|
|
5
|
+
* When the image fails to load or no src is provided, displays a User icon fallback.
|
|
6
|
+
* Supports an optional notification indicator.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://lumen-ldls.vercel.app/?path=/docs/react-native_communication-avatar--docs Storybook}
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* import { Avatar } from '@ledgerhq/lumen-ui-react';
|
|
12
|
+
*
|
|
13
|
+
* <Avatar src="https://example.com/photo.jpg" size="md" />
|
|
14
|
+
*
|
|
15
|
+
* // With notification indicator
|
|
16
|
+
* <Avatar src="https://example.com/photo.jpg" showNotification />
|
|
17
|
+
*/
|
|
18
|
+
export declare const Avatar: ({ lx, style, src, alt, size, showNotification, ref, ...props }: AvatarProps) => import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=Avatar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Avatar.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Avatar/Avatar.tsx"],"names":[],"mappings":"AAMA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAuDtC;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,MAAM,mEAShB,WAAW,4CA6Cb,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { StyleSheet, Image, View } from 'react-native';
|
|
4
|
+
import { useCommonTranslation } from '../../../i18n';
|
|
5
|
+
import { useStyleSheet } from '../../../styles';
|
|
6
|
+
import { User } from '../../Symbols';
|
|
7
|
+
import { Box } from '../Utility';
|
|
8
|
+
const fallbackSizes = {
|
|
9
|
+
sm: 16,
|
|
10
|
+
md: 24,
|
|
11
|
+
};
|
|
12
|
+
const useStyles = ({ size }) => {
|
|
13
|
+
return useStyleSheet((t) => {
|
|
14
|
+
const sizeMap = {
|
|
15
|
+
sm: { size: t.sizes.s40, padding: t.spacings.s4 },
|
|
16
|
+
md: { size: t.sizes.s48, padding: t.spacings.s4 },
|
|
17
|
+
};
|
|
18
|
+
const notificationsMap = {
|
|
19
|
+
sm: t.sizes.s10,
|
|
20
|
+
md: t.sizes.s12,
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
root: {
|
|
24
|
+
position: 'relative',
|
|
25
|
+
width: sizeMap[size].size,
|
|
26
|
+
height: sizeMap[size].size,
|
|
27
|
+
borderRadius: 9999,
|
|
28
|
+
backgroundColor: t.colors.bg.muted,
|
|
29
|
+
alignItems: 'center',
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
padding: sizeMap[size].padding,
|
|
32
|
+
},
|
|
33
|
+
notification: {
|
|
34
|
+
position: 'absolute',
|
|
35
|
+
top: 0,
|
|
36
|
+
right: 0,
|
|
37
|
+
width: notificationsMap[size],
|
|
38
|
+
height: notificationsMap[size],
|
|
39
|
+
borderRadius: 9999,
|
|
40
|
+
backgroundColor: t.colors.bg.errorStrong,
|
|
41
|
+
zIndex: 1,
|
|
42
|
+
},
|
|
43
|
+
image: {
|
|
44
|
+
width: '100%',
|
|
45
|
+
height: '100%',
|
|
46
|
+
overflow: 'hidden',
|
|
47
|
+
borderRadius: 9999,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
}, [size]);
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* A circular avatar component that displays a user image or fallback icon.
|
|
54
|
+
*
|
|
55
|
+
* When the image fails to load or no src is provided, displays a User icon fallback.
|
|
56
|
+
* Supports an optional notification indicator.
|
|
57
|
+
*
|
|
58
|
+
* @see {@link https://lumen-ldls.vercel.app/?path=/docs/react-native_communication-avatar--docs Storybook}
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* import { Avatar } from '@ledgerhq/lumen-ui-react';
|
|
62
|
+
*
|
|
63
|
+
* <Avatar src="https://example.com/photo.jpg" size="md" />
|
|
64
|
+
*
|
|
65
|
+
* // With notification indicator
|
|
66
|
+
* <Avatar src="https://example.com/photo.jpg" showNotification />
|
|
67
|
+
*/
|
|
68
|
+
export const Avatar = ({ lx, style, src, alt = 'avatar', size = 'md', showNotification = false, ref, ...props }) => {
|
|
69
|
+
const { t } = useCommonTranslation();
|
|
70
|
+
const [error, setError] = useState(false);
|
|
71
|
+
const shouldFallback = !src || error;
|
|
72
|
+
const styles = useStyles({ size });
|
|
73
|
+
const resolvedAlt = alt || t('components.avatar.defaultAlt');
|
|
74
|
+
const accessibilityLabel = showNotification
|
|
75
|
+
? `${resolvedAlt}, ${t('components.avatar.notificationAriaLabel')}`
|
|
76
|
+
: resolvedAlt;
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
setError(false);
|
|
79
|
+
}, [src]);
|
|
80
|
+
return (_jsxs(Box, { ref: ref, lx: lx, style: StyleSheet.flatten([styles.root, style]), accessibilityRole: 'image', accessibilityLabel: accessibilityLabel, ...props, children: [showNotification && (_jsx(View, { style: styles.notification, accessible: false })), shouldFallback ? (_jsx(User, { size: fallbackSizes[size], accessible: false, testID: 'avatar-fallback-icon' })) : (_jsx(Image, { source: { uri: src }, style: styles.image, accessible: false, onError: () => setError(true), testID: 'avatar-image' }))] }));
|
|
81
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StoryObj } from '@storybook/react-native-web-vite';
|
|
2
|
+
declare const meta: {
|
|
3
|
+
component: ({ lx, style, src, alt, size, showNotification, ref, ...props }: import("./types").AvatarProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
title: string;
|
|
5
|
+
parameters: {
|
|
6
|
+
docs: {
|
|
7
|
+
source: {
|
|
8
|
+
language: string;
|
|
9
|
+
format: boolean;
|
|
10
|
+
type: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default meta;
|
|
16
|
+
type Story = StoryObj<typeof meta>;
|
|
17
|
+
export declare const Base: Story;
|
|
18
|
+
export declare const SizeShowcase: Story;
|
|
19
|
+
export declare const FallbackShowcase: Story;
|
|
20
|
+
export declare const NotificationShowcase: Story;
|
|
21
|
+
export declare const InteractiveShowcase: Story;
|
|
22
|
+
//# sourceMappingURL=Avatar.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Avatar.stories.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Avatar/Avatar.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,kCAAkC,CAAC;AAMlE,QAAA,MAAM,IAAI;;;;;;;;;;;;CAYqB,CAAC;AAEhC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAKnC,eAAO,MAAM,IAAI,EAAE,KAelB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KA6B1B,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,KAe9B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAiBlC,CAAC;AAKF,eAAO,MAAM,mBAAmB,EAAE,KAajC,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { View, Text, Pressable, Linking } from 'react-native';
|
|
3
|
+
import { Box } from '../Utility';
|
|
4
|
+
import { Avatar } from './Avatar';
|
|
5
|
+
const meta = {
|
|
6
|
+
component: Avatar,
|
|
7
|
+
title: 'Communication/Avatar',
|
|
8
|
+
parameters: {
|
|
9
|
+
docs: {
|
|
10
|
+
source: {
|
|
11
|
+
language: 'tsx',
|
|
12
|
+
format: true,
|
|
13
|
+
type: 'code',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
export default meta;
|
|
19
|
+
const exampleSrc = 'https://plus.unsplash.com/premium_photo-1689551670902-19b441a6afde?q=80&w=774&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D';
|
|
20
|
+
export const Base = {
|
|
21
|
+
args: {
|
|
22
|
+
src: exampleSrc,
|
|
23
|
+
alt: 'avatar',
|
|
24
|
+
size: 'md',
|
|
25
|
+
showNotification: false,
|
|
26
|
+
},
|
|
27
|
+
render: (args) => _jsx(Avatar, { ...args }),
|
|
28
|
+
parameters: {
|
|
29
|
+
docs: {
|
|
30
|
+
source: {
|
|
31
|
+
code: `<Avatar src="https://example.com" size="md" alt="avatar" showNotification={false} />`,
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
export const SizeShowcase = {
|
|
37
|
+
render: () => (_jsxs(Box, { lx: {
|
|
38
|
+
alignItems: 'stretch',
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
gap: 's16',
|
|
41
|
+
}, children: [_jsxs(View, { style: { alignItems: 'center', justifyContent: 'flex-end' }, children: [_jsx(Avatar, { src: exampleSrc, alt: 'avatar', size: 'sm', showNotification: false }), _jsx(Text, { style: { marginTop: 4 }, children: "sm" })] }), _jsxs(View, { style: { alignItems: 'center', justifyContent: 'flex-end' }, children: [_jsx(Avatar, { src: exampleSrc, alt: 'avatar', size: 'md', showNotification: false }), _jsx(Text, { style: { marginTop: 4 }, children: "md" })] })] })),
|
|
42
|
+
};
|
|
43
|
+
export const FallbackShowcase = {
|
|
44
|
+
args: {
|
|
45
|
+
src: 'https://brokenLink.random',
|
|
46
|
+
size: 'md',
|
|
47
|
+
alt: 'Fallback example',
|
|
48
|
+
showNotification: false,
|
|
49
|
+
},
|
|
50
|
+
render: (args) => _jsx(Avatar, { ...args }),
|
|
51
|
+
parameters: {
|
|
52
|
+
docs: {
|
|
53
|
+
source: {
|
|
54
|
+
code: `<Avatar src="https://brokenLink.random" size="md" alt="Fallback example" showNotification={false} />`,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
export const NotificationShowcase = {
|
|
60
|
+
render: () => (_jsxs(Box, { lx: {
|
|
61
|
+
flexDirection: 'row',
|
|
62
|
+
gap: 's16',
|
|
63
|
+
}, children: [_jsx(Avatar, { src: exampleSrc, alt: 'avatar', size: 'md', showNotification: false }), _jsx(Avatar, { src: exampleSrc, alt: 'avatar', size: 'md', showNotification: true })] })),
|
|
64
|
+
};
|
|
65
|
+
const onPressRedirect = () => Linking.openURL('https://shop.ledger.com/pages/ledger-nano-gen5');
|
|
66
|
+
export const InteractiveShowcase = {
|
|
67
|
+
render: () => (_jsx(Pressable, { onPress: onPressRedirect, style: ({ pressed }) => ({
|
|
68
|
+
borderRadius: 9999,
|
|
69
|
+
opacity: pressed ? 0.7 : 1,
|
|
70
|
+
backgroundColor: pressed ? 'rgba(0, 0, 0, 0.05)' : 'transparent',
|
|
71
|
+
}), children: _jsx(Avatar, { src: exampleSrc, size: 'md', showNotification: true }) })),
|
|
72
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/Components/Avatar/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { StyledViewProps } from '../../../styles';
|
|
2
|
+
export type AvatarProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Image source URL. When undefined or on load error, displays a fallback icon.
|
|
5
|
+
* @optional
|
|
6
|
+
*/
|
|
7
|
+
src?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Alternative text for the image.
|
|
10
|
+
* @optional
|
|
11
|
+
*/
|
|
12
|
+
alt?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The size variant of the avatar.
|
|
15
|
+
* @optional
|
|
16
|
+
* @default md
|
|
17
|
+
*/
|
|
18
|
+
size?: 'sm' | 'md';
|
|
19
|
+
/**
|
|
20
|
+
* Whether to show the notifications indicator.
|
|
21
|
+
* @optional
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
showNotification?: boolean;
|
|
25
|
+
} & Omit<StyledViewProps, 'children'>;
|
|
26
|
+
//# sourceMappingURL=types.d.ts.map
|