-
Notifications
You must be signed in to change notification settings - Fork 3
feat(ui-react/ui-rnative): add Trend component #678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aquelemiguel
wants to merge
23
commits into
main
Choose a base branch
from
dls-670
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
52cd966
feat: add initial files
aquelemiguel 900352e
feat: add to sandbox app + organize imports
aquelemiguel dea35d9
feat: add some conditional styling based on trend variant + add trian…
aquelemiguel b46378d
feat: add neutral trend value
aquelemiguel 63ce16b
feat: add tofixed(2) for value percent
aquelemiguel 3927a76
feat: add disabled context
aquelemiguel e80e8c3
docs: add stories + mdx
aquelemiguel 7bae019
test: add simple tests for trend
aquelemiguel bac00fc
feat: add positive/negative/neutral accessibility aria label
aquelemiguel 8d41430
chore: add translations for other langs
aquelemiguel 09c41df
chore: use formatted value directly on text
aquelemiguel 5582d17
fix: add missing deps on styles, making text dynamic
aquelemiguel 4cf15aa
docs: remove emoji
aquelemiguel d491b15
chore: add release plan
aquelemiguel f6090d7
fix: solve wrapped into act issue in tests
aquelemiguel 0abac8b
test: fix formatted value
aquelemiguel c6bf18f
chore: run lint
aquelemiguel 3f47446
refactor: move variant compute into its own func instead of ternary
aquelemiguel 27afee9
chore: removed trend translations to fallback to en, until localisati…
aquelemiguel 80bb8d4
fix: fix style prop override via props spread
aquelemiguel a3acc4b
chore: migrate to react lib
aquelemiguel a335205
chore: add release plans
aquelemiguel 8f48dcf
chore: add code connect
aquelemiguel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@ledgerhq/lumen-ui-rnative': patch | ||
| --- | ||
|
|
||
| feat(ui-rnative): add Trend component |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import { Box, Trend } from '@ledgerhq/lumen-ui-rnative'; | ||
|
|
||
| export function Trends() { | ||
| return ( | ||
| <Box lx={{ gap: 's24' }}> | ||
| <Box lx={{ gap: 's16', flexDirection: 'row' }}> | ||
| <Trend value={0.24} size='sm' /> | ||
| <Trend value={0.24} size='md' /> | ||
| </Box> | ||
| <Box lx={{ gap: 's16', flexDirection: 'row' }}> | ||
| <Trend value={-1.33} size='sm' /> | ||
| <Trend value={-1.33} size='md' /> | ||
| </Box> | ||
| <Box lx={{ gap: 's16', flexDirection: 'row' }}> | ||
| <Trend value={0} size='sm' /> | ||
| <Trend value={0} size='md' /> | ||
| </Box> | ||
| <Box lx={{ gap: 's16', flexDirection: 'row' }}> | ||
| <Trend value={6.1} size='sm' disabled /> | ||
| <Trend value={6.1} size='md' disabled /> | ||
| </Box> | ||
| </Box> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| import { Meta, Canvas, Controls } from '@storybook/addon-docs/blocks'; | ||
| import * as TrendStories from './Trend.stories'; | ||
| import { CustomTabs, Tab } from '../../../../.storybook/components'; | ||
| import { DoVsDontRow, DoBlockItem, DontBlockItem } from '../../../../.storybook/components/DoVsDont'; | ||
| import CommonRulesDoAndDont from '../../../../.storybook/components/DoVsDont/CommonRulesDoAndDont.mdx'; | ||
|
|
||
| <Meta title='Communication/Trend' of={TrendStories} /> | ||
|
|
||
| # Trend | ||
|
|
||
| <CustomTabs> | ||
| <Tab label="Overview"> | ||
|
|
||
| ## Introduction | ||
|
|
||
| A compact indicator used to communicate directional change in a numeric value, typically a percentage. It combines an icon and a formatted label to convey whether a value has gone up, down, or stayed flat. | ||
|
|
||
| > View in [Figma](https://www.figma.com/design/JxaLVMTWirCpU0rsbZ30k7/2.-Components-Library?node-id=892-5393). | ||
|
|
||
| ## Anatomy | ||
|
|
||
| - **Icon:** A directional triangle (up or down) or a minus symbol that visually reinforces the direction of change at a glance. | ||
| - **Value:** The numeric percentage formatted to exactly two decimal places, ensuring consistent alignment across lists and tables. | ||
|
|
||
| ## Properties | ||
|
|
||
| ### Overview | ||
|
|
||
| <Canvas of={TrendStories.Base} /> | ||
| <Controls of={TrendStories.Base} /> | ||
|
|
||
| ### Variants | ||
|
|
||
| The variant is derived automatically from the `value` prop. No manual selection needed! This ensures the color and icon always stay in sync with the actual data. | ||
|
|
||
| - **Positive** - value greater than 0: green color, triangle up icon | ||
| - **Negative** - value less than 0: red color, triangle down icon | ||
| - **Neutral** - value equal to 0: muted color, minus icon | ||
|
|
||
| <Canvas of={TrendStories.VariantShowcase} /> | ||
|
|
||
| --- | ||
|
|
||
| ### Size | ||
|
|
||
| Two sizes are available to accommodate different layout densities. Use `md` in most contexts and `sm` when space is constrained, such as inside a table cell or a compact list item. | ||
|
|
||
| - **md** (default) - standard body text and icon sizes | ||
| - **sm** - smaller text and icon, suitable for dense UIs | ||
|
|
||
| <Canvas of={TrendStories.SizeShowcase} /> | ||
|
|
||
| --- | ||
|
|
||
| ### Disabled | ||
|
|
||
| When `disabled` is `true`, the icon and text both render in a muted, non-interactive style regardless of the underlying value. Use this when the data is unavailable, loading, or the surrounding context is non-interactive. | ||
|
|
||
| <Canvas of={TrendStories.DisabledShowcase} /> | ||
|
|
||
| </Tab> | ||
| <Tab label="Implementation"> | ||
|
|
||
| ## Setup | ||
|
|
||
| Install and set up the library with our [Setup Guide →](?path=/docs/getting-started-setup--docs). | ||
|
|
||
| ### Basic Usage | ||
|
|
||
| Pass any numeric value - the component handles color, icon, and formatting automatically. | ||
|
|
||
| ```tsx | ||
| import { Trend } from '@ledgerhq/lumen-ui-rnative'; | ||
|
|
||
| function MyComponent() { | ||
| return <Trend value={5.25} />; | ||
| } | ||
| ``` | ||
|
|
||
| ### Sizes | ||
|
|
||
| Choose `sm` for dense layouts like tables or compact list rows, and `md` for standard content areas. | ||
|
|
||
| ```tsx | ||
| <Trend value={3.14} size='md' /> | ||
| <Trend value={3.14} size='sm' /> | ||
| ``` | ||
|
|
||
| ### Disabled State | ||
|
|
||
| Wrap or pass `disabled` when the value is unavailable or the parent context is non-interactive. The component style updates automatically - no extra styling needed. | ||
|
|
||
| ```tsx | ||
| <Trend value={5.25} disabled /> | ||
| ``` | ||
|
|
||
| ### Layout Adjustments | ||
|
|
||
| Use `lx` for layout only - not for overriding colors or typography. The component's visual appearance is controlled exclusively via props. | ||
|
|
||
| ```tsx | ||
| <Trend value={-1.5} lx={{ marginTop: 's4' }} /> | ||
| ``` | ||
|
|
||
| </Tab> | ||
| </CustomTabs> |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.