-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b73d0b9
commit 90ba3ab
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
53 changes: 53 additions & 0 deletions
53
packages/ui/src/components/address-displayer/address-displayer.native.stories.tsx
This file contains 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,53 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { BtcAvatarIcon } from '../avatar/btc-avatar-icon.native'; | ||
import { StxAvatarIcon } from '../avatar/stx-avatar-icon.native'; | ||
import { Box } from '../box/box.native'; | ||
import { Flag } from '../flag/flag.native'; | ||
import { AddressDisplayer as Component } from './address-displayer.native'; | ||
|
||
const meta: Meta<typeof Component> = { | ||
component: Component, | ||
title: 'AddressDisplayer', | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Component>; | ||
|
||
export const Bitcoin: Story = { | ||
args: { | ||
address: 'bc1pmzfrwwndsqmk5yh69yjr5lfgfg4ev8c0tsc06e', | ||
}, | ||
}; | ||
|
||
export const Stacks: Story = { | ||
args: { | ||
address: 'SP3XKZE32KZ925AAAGWPG1W66YP5BM2RD73T6AJHS', | ||
}, | ||
}; | ||
|
||
export const WithBTCIcon: Story = { | ||
args: { | ||
address: 'bc1pmzfrwwndsqmk5yh69yjr5lfgfg4ev8c0tsc06e', | ||
}, | ||
render: args => ( | ||
<Flag img={<BtcAvatarIcon />}> | ||
<Box flexDirection="row" flexWrap="wrap"> | ||
<Component address={args.address} /> | ||
</Box> | ||
</Flag> | ||
), | ||
}; | ||
|
||
export const WithSTXIcon: Story = { | ||
args: { | ||
address: 'SP3XKZE32KZ925AAAGWPG1W66YP5BM2RD73T6AJHS', | ||
}, | ||
render: args => ( | ||
<Flag img={<StxAvatarIcon />}> | ||
<Box flexDirection="row" flexWrap="wrap"> | ||
<Component address={args.address} /> | ||
</Box> | ||
</Flag> | ||
), | ||
}; |
25 changes: 25 additions & 0 deletions
25
packages/ui/src/components/address-displayer/address-displayer.native.tsx
This file contains 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,25 @@ | ||
import { isEven } from '@leather.io/utils'; | ||
|
||
import { Box, BoxProps } from '../box/box.native'; | ||
import { Text } from '../text/text.native'; | ||
import { AddressDisplayerBaseProps } from './address-displayer.types.shared'; | ||
import { groupByFour } from './address-displayer.utils.shared'; | ||
|
||
type AddressDisplayerProps = AddressDisplayerBaseProps & BoxProps; | ||
|
||
export function AddressDisplayer({ address, ...props }: AddressDisplayerProps) { | ||
return ( | ||
<Box flexDirection="row" columnGap="2" flexWrap="wrap"> | ||
{groupByFour(address).map((letterGroup, index) => ( | ||
<Text | ||
key={index} | ||
variant="address" | ||
color={isEven(index) ? 'ink.text-primary' : 'ink.text-subdued'} | ||
{...props} | ||
> | ||
{letterGroup} | ||
</Text> | ||
))} | ||
</Box> | ||
); | ||
} |
This file contains 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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { createBox } from '@shopify/restyle'; | ||
import { BoxProps as RestyleBoxProps, createBox } from '@shopify/restyle'; | ||
|
||
import { type Theme } from '../../theme-native'; | ||
|
||
export const Box = createBox<Theme>(); | ||
export type BoxProps = RestyleBoxProps<Theme>; |