-
Notifications
You must be signed in to change notification settings - Fork 87
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
49ffae5
commit ed78ba0
Showing
7 changed files
with
118 additions
and
146 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/app/src/systems/Asset/components/AssetItem/AssetItem.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,36 @@ | ||
import { VStack } from '@fuels/ui'; | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { AssetItem } from './AssetItem'; | ||
|
||
const meta: Meta<typeof AssetItem> = { | ||
title: 'Asset/AssetItem', | ||
component: AssetItem, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof AssetItem>; | ||
|
||
export const Usage: Story = { | ||
render: () => ( | ||
<VStack> | ||
<AssetItem assetId="0x0000000000000000000000000000000000000000000000000000000000000000" /> | ||
<AssetItem assetId="0x00000000000000000000000000000000000000000000000000" /> | ||
</VStack> | ||
), | ||
}; | ||
|
||
export const WithPrefix: Story = { | ||
render: () => ( | ||
<VStack> | ||
<AssetItem | ||
prefix="Input:" | ||
assetId="0x0000000000000000000000000000000000000000000000000000000000000000" | ||
/> | ||
<AssetItem | ||
prefix="Input:" | ||
assetId="0x00000000000000000000000000000000000000000000000000" | ||
/> | ||
</VStack> | ||
), | ||
}; |
58 changes: 58 additions & 0 deletions
58
packages/app/src/systems/Asset/components/AssetItem/AssetItem.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,58 @@ | ||
import type { HStackProps } from '@fuels/ui'; | ||
import { HStack, Text, shortAddress, Copyable, Tooltip, Box } from '@fuels/ui'; | ||
import Image from 'next/image'; | ||
import { TxIcon } from '~/systems/Transaction/component/TxIcon/TxIcon'; | ||
|
||
import { useAsset } from '../../hooks/useAsset'; | ||
|
||
const ICON_SIZE = 38; | ||
|
||
type AssetItemProps = HStackProps & { | ||
assetId: string; | ||
prefix?: string; | ||
}; | ||
|
||
export function AssetItem({ | ||
prefix, | ||
assetId, | ||
children, | ||
...props | ||
}: AssetItemProps) { | ||
const asset = useAsset(assetId); | ||
return ( | ||
<HStack {...props} align="center"> | ||
{asset?.icon ? ( | ||
<Image | ||
src={asset.icon as string} | ||
width={ICON_SIZE} | ||
height={ICON_SIZE} | ||
alt={asset.name} | ||
/> | ||
) : ( | ||
<TxIcon type="Mint" status="Submitted" /> | ||
)} | ||
<Box> | ||
<HStack gap="2"> | ||
{prefix && <Text className="font-medium">{prefix}</Text>} | ||
{asset?.symbol ? ( | ||
<Tooltip content={assetId}> | ||
<Copyable value={assetId}> | ||
<Text className="flex items-center gap-2 text-md"> | ||
{asset?.name} | ||
<Text className="mt-px text-muted">{asset.symbol}</Text> | ||
</Text> | ||
</Copyable> | ||
</Tooltip> | ||
) : ( | ||
<Tooltip content={assetId}> | ||
<Copyable value={assetId} className="text-gray-11"> | ||
{shortAddress(assetId)} | ||
</Copyable> | ||
</Tooltip> | ||
)} | ||
</HStack> | ||
{children} | ||
</Box> | ||
</HStack> | ||
); | ||
} |
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
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
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
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
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