-
-
Notifications
You must be signed in to change notification settings - Fork 11
feat: [DSRN] Add TitleSubpage #1059
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
Merged
Merged
Changes from 21 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
22350b8
Added TitleStandard to DSRN
brianacnguyen ec63d5b
Fixed lint errors
brianacnguyen 0438865
Added TitleHub to DSRN
brianacnguyen 09c1bff
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 7e64aeb
Updated accessories to endAccessories for TitleHub
brianacnguyen b824c63
Added TitleSubpage to DSRN
brianacnguyen c5c7f7c
Updated stories and fixed lint errors
brianacnguyen 700cca4
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 4a76f25
Merge branch 'main' into dsrn/titlesubpage
brianacnguyen 50a9e15
Simplified titlesubpage
brianacnguyen fb0d6cc
Merge branch 'dsrn/titlesubpage' of github.com:MetaMask/metamask-desi…
brianacnguyen f0b5953
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 8291fa5
Updated based on suggestions
brianacnguyen 121dfb4
Fixed lint errors
brianacnguyen 683e4bf
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 0b600dd
Updated AvatarSlot to be contained in a 40px box
brianacnguyen 569526b
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen e548d32
fixed lint
brianacnguyen fd76d8d
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 7e581f6
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 1ec1d52
Removed storybook requires from merge
brianacnguyen bb22eda
Merge branch 'main' into dsrn/titlesubpage
brianacnguyen 5c75979
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 21983af
Removed wrapper around titleavatar
brianacnguyen 200f3cf
Merge branch 'dsrn/titlesubpage' of github.com:MetaMask/metamask-desi…
brianacnguyen 2c5a102
Merge branch 'main' of github.com:MetaMask/metamask-design-system int…
brianacnguyen 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
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
478 changes: 478 additions & 0 deletions
478
packages/design-system-react-native/src/components/TitleSubpage/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
238 changes: 238 additions & 0 deletions
238
packages/design-system-react-native/src/components/TitleSubpage/TitleSubpage.stories.tsx
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,238 @@ | ||
| import { | ||
| FontWeight, | ||
| TextColor, | ||
| TextVariant, | ||
| } from '@metamask/design-system-shared'; | ||
| import type { Meta, StoryObj } from '@storybook/react-native'; | ||
| import React from 'react'; | ||
|
|
||
| import UsdcSVG from '../../assets/token-icons/usdc.svg'; | ||
| import { AvatarToken, AvatarTokenSize } from '../AvatarToken'; | ||
| import { Box, BoxAlignItems, BoxFlexDirection } from '../Box'; | ||
| import { Icon, IconName, IconSize, IconColor } from '../Icon'; | ||
| import { Text } from '../Text'; | ||
|
|
||
| import { TitleSubpage } from './TitleSubpage'; | ||
| import type { TitleSubpageProps } from './TitleSubpage.types'; | ||
|
|
||
| /** | ||
| * Token avatar for stories using bundled USDC artwork. | ||
| * | ||
| * @returns The USDC `AvatarToken` for story defaults. | ||
| */ | ||
| const StoryTitleAvatar = () => ( | ||
| <AvatarToken src={UsdcSVG} size={AvatarTokenSize.Lg} name="USD Coin" /> | ||
| ); | ||
|
|
||
| const USDC_TITLE = 'USD Coin'; | ||
| const USDC_SUBTITLE = 'USDC'; | ||
| const USDC_AMOUNT = '$1.0001'; | ||
| const USDC_PRICE_CHANGE_BOTTOM_LABEL = '+$0.000126 (+0.01%)'; | ||
|
|
||
| const TodayBottomLabelEndAccessory = () => ( | ||
| <Text | ||
| variant={TextVariant.BodySm} | ||
| fontWeight={FontWeight.Medium} | ||
| color={TextColor.TextAlternative} | ||
| > | ||
| Today | ||
| </Text> | ||
| ); | ||
|
|
||
| /** | ||
| * Pill badge: dot + label (e.g. network), for `titleEndAccessory`. | ||
| * TODO: Temporary until a Tag component exists. | ||
| * | ||
| * @returns Story-only testnet badge UI. | ||
| */ | ||
| const TestnetBadge = () => ( | ||
| <Box | ||
| flexDirection={BoxFlexDirection.Row} | ||
| alignItems={BoxAlignItems.Center} | ||
| gap={1} | ||
| twClassName="rounded-full bg-warning-muted px-2 py-1" | ||
| > | ||
| <Box twClassName="h-2 w-2 shrink-0 rounded-full bg-warning-default" /> | ||
| <Text | ||
| variant={TextVariant.BodySm} | ||
| color={TextColor.WarningDefault} | ||
| fontWeight={FontWeight.Medium} | ||
| > | ||
| Testnet | ||
| </Text> | ||
| </Box> | ||
| ); | ||
|
|
||
| const meta: Meta<TitleSubpageProps> = { | ||
| title: 'Components/TitleSubpage', | ||
| component: TitleSubpage, | ||
| args: { | ||
| titleAvatar: <StoryTitleAvatar />, | ||
| title: USDC_TITLE, | ||
| subtitle: USDC_SUBTITLE, | ||
| amount: USDC_AMOUNT, | ||
| twClassName: '', | ||
| }, | ||
| argTypes: { | ||
| title: { | ||
| control: 'text', | ||
| }, | ||
| amount: { | ||
| control: 'text', | ||
| }, | ||
| subtitle: { | ||
| control: 'text', | ||
| }, | ||
| bottomLabel: { | ||
| control: 'text', | ||
| }, | ||
| twClassName: { control: 'text' }, | ||
| }, | ||
| decorators: [ | ||
| (Story) => ( | ||
| <Box twClassName="w-full"> | ||
| <Story /> | ||
| </Box> | ||
| ), | ||
| ], | ||
| }; | ||
|
|
||
| export default meta; | ||
|
|
||
| type Story = StoryObj<TitleSubpageProps>; | ||
|
|
||
| export const Default: Story = { | ||
| render: (args) => ( | ||
| <TitleSubpage | ||
| {...args} | ||
| bottomLabel={USDC_PRICE_CHANGE_BOTTOM_LABEL} | ||
| bottomLabelEndAccessory={<TodayBottomLabelEndAccessory />} | ||
| bottomLabelProps={{ color: TextColor.SuccessDefault }} | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| export const Amount: Story = { | ||
| render: () => ( | ||
| <TitleSubpage | ||
| titleAvatar={<StoryTitleAvatar />} | ||
| title={USDC_TITLE} | ||
| subtitle={USDC_SUBTITLE} | ||
| amount={USDC_AMOUNT} | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| export const AmountEndAccessory: Story = { | ||
| render: () => ( | ||
| <TitleSubpage | ||
| titleAvatar={<StoryTitleAvatar />} | ||
| title={USDC_TITLE} | ||
| subtitle={USDC_SUBTITLE} | ||
| amount={USDC_AMOUNT} | ||
| amountEndAccessory={ | ||
| <Icon | ||
| name={IconName.Info} | ||
| size={IconSize.Md} | ||
| color={IconColor.IconAlternative} | ||
| twClassName="ml-1" | ||
| /> | ||
| } | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| export const Title: Story = { | ||
| render: () => ( | ||
| <TitleSubpage titleAvatar={<StoryTitleAvatar />} title={USDC_TITLE} /> | ||
| ), | ||
| }; | ||
|
|
||
| export const TitleEndAccessory: Story = { | ||
| render: () => ( | ||
| <TitleSubpage | ||
| titleAvatar={<StoryTitleAvatar />} | ||
| title={USDC_TITLE} | ||
| titleEndAccessory={<TestnetBadge />} | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| export const Subtitle: Story = { | ||
| render: () => ( | ||
| <TitleSubpage | ||
| titleAvatar={<StoryTitleAvatar />} | ||
| title={USDC_TITLE} | ||
| subtitle={USDC_SUBTITLE} | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| export const SubtitleEndAccessory: Story = { | ||
| render: () => ( | ||
| <TitleSubpage | ||
| titleAvatar={<StoryTitleAvatar />} | ||
| title={USDC_TITLE} | ||
| subtitle={USDC_SUBTITLE} | ||
| subtitleEndAccessory={ | ||
| <Icon | ||
| name={IconName.Info} | ||
| size={IconSize.Xs} | ||
| color={IconColor.IconAlternative} | ||
| twClassName="ml-2" | ||
| /> | ||
| } | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| export const BottomLabel: Story = { | ||
| render: (args) => ( | ||
| <TitleSubpage | ||
| {...args} | ||
| title={USDC_TITLE} | ||
| subtitle={USDC_SUBTITLE} | ||
| amount={USDC_AMOUNT} | ||
| bottomLabel={USDC_PRICE_CHANGE_BOTTOM_LABEL} | ||
| bottomLabelProps={{ color: TextColor.SuccessDefault }} | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| export const BottomLabelEndAccessory: Story = { | ||
| render: () => ( | ||
| <TitleSubpage | ||
| titleAvatar={<StoryTitleAvatar />} | ||
| title={USDC_TITLE} | ||
| subtitle={USDC_SUBTITLE} | ||
| amount={USDC_AMOUNT} | ||
| bottomLabel={USDC_PRICE_CHANGE_BOTTOM_LABEL} | ||
| bottomLabelEndAccessory={<TodayBottomLabelEndAccessory />} | ||
| bottomLabelProps={{ color: TextColor.SuccessDefault }} | ||
| /> | ||
| ), | ||
| }; | ||
|
|
||
| export const BottomAccessory: Story = { | ||
| render: () => ( | ||
| <TitleSubpage | ||
| titleAvatar={<StoryTitleAvatar />} | ||
| title={USDC_TITLE} | ||
| subtitle={USDC_SUBTITLE} | ||
| amount={USDC_AMOUNT} | ||
| bottomAccessory={ | ||
| <Box | ||
| flexDirection={BoxFlexDirection.Row} | ||
| alignItems={BoxAlignItems.Center} | ||
| gap={1} | ||
| > | ||
| <Icon name={IconName.SecurityAlert} size={IconSize.Sm} /> | ||
| <Text variant={TextVariant.BodySm} color={TextColor.TextAlternative}> | ||
| Stablecoin prices can deviate from $1. Verify the asset and network | ||
| before you trade. | ||
| </Text> | ||
| </Box> | ||
| } | ||
| /> | ||
| ), | ||
| }; | ||
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.