diff --git a/packages/ui/native.ts b/packages/ui/native.ts index 3dc4310f6..3536d06c4 100644 --- a/packages/ui/native.ts +++ b/packages/ui/native.ts @@ -8,6 +8,7 @@ export { BlurView } from './src/components/blur-view/blur-view.native'; export { Chip } from './src/components/chip/chip.native'; export { HStack } from './src/components/box/hstack.native'; export { Stack } from './src/components/box/stack.native'; +export { AddressDisplayer } from './src/components/address-displayer/address-displayer.native'; export { AnimatedButton, Button, diff --git a/packages/ui/src/components/address-displayer/address-displayer.native.stories.tsx b/packages/ui/src/components/address-displayer/address-displayer.native.stories.tsx new file mode 100644 index 000000000..6e3027b80 --- /dev/null +++ b/packages/ui/src/components/address-displayer/address-displayer.native.stories.tsx @@ -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 = { + component: Component, + title: 'AddressDisplayer', +}; + +export default meta; +type Story = StoryObj; + +export const Bitcoin: Story = { + args: { + address: 'bc1pmzfrwwndsqmk5yh69yjr5lfgfg4ev8c0tsc06e', + }, +}; + +export const Stacks: Story = { + args: { + address: 'SP3XKZE32KZ925AAAGWPG1W66YP5BM2RD73T6AJHS', + }, +}; + +export const WithBTCIcon: Story = { + args: { + address: 'bc1pmzfrwwndsqmk5yh69yjr5lfgfg4ev8c0tsc06e', + }, + render: args => ( + }> + + + + + ), +}; + +export const WithSTXIcon: Story = { + args: { + address: 'SP3XKZE32KZ925AAAGWPG1W66YP5BM2RD73T6AJHS', + }, + render: args => ( + }> + + + + + ), +}; diff --git a/packages/ui/src/components/address-displayer/address-displayer.native.tsx b/packages/ui/src/components/address-displayer/address-displayer.native.tsx new file mode 100644 index 000000000..179d4ac89 --- /dev/null +++ b/packages/ui/src/components/address-displayer/address-displayer.native.tsx @@ -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 ( + + {groupByFour(address).map((letterGroup, index) => ( + + {letterGroup} + + ))} + + ); +} diff --git a/packages/ui/src/components/box/box.native.tsx b/packages/ui/src/components/box/box.native.tsx index bfa5e734b..de1a7513e 100644 --- a/packages/ui/src/components/box/box.native.tsx +++ b/packages/ui/src/components/box/box.native.tsx @@ -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(); +export type BoxProps = RestyleBoxProps;