-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
55 changed files
with
845 additions
and
612 deletions.
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
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
73 changes: 28 additions & 45 deletions
73
...crypto-assets/bitcoin/brc20-token-asset-list/components/brc20-token-asset-item.layout.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 |
---|---|---|
@@ -1,69 +1,52 @@ | ||
import { BoxProps, Flex, HStack, styled } from 'leather-styles/jsx'; | ||
|
||
import type { Money } from '@shared/models/money.model'; | ||
import { createMoney } from '@shared/models/money.model'; | ||
|
||
import { formatBalance } from '@app/common/format-balance'; | ||
import { AssetCaption } from '@app/components/crypto-assets/components/asset-caption'; | ||
import { usePressable } from '@app/components/item-hover'; | ||
import { Flag } from '@app/components/layout/flag'; | ||
import { Brc20Token } from '@app/query/bitcoin/ordinals/brc20/brc20-tokens.query'; | ||
import { Brc20TokenIcon } from '@app/ui/components/icons/brc20-token-icon'; | ||
import { Item } from '@app/ui/components/items/item'; | ||
import { ItemDefaultLayout } from '@app/ui/components/items/item-default.layout'; | ||
import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip'; | ||
|
||
interface Brc20TokenAssetItemLayoutProps extends BoxProps { | ||
balance: Money; | ||
caption: string; | ||
interface Brc20TokenAssetItemLayoutProps { | ||
token: Brc20Token; | ||
isPressable?: boolean; | ||
onClick?(): void; | ||
title: string; | ||
displayNotEnoughBalance?: boolean; | ||
} | ||
export function Brc20TokenAssetItemLayout({ | ||
balance, | ||
caption, | ||
isPressable, | ||
onClick, | ||
title, | ||
displayNotEnoughBalance, | ||
token, | ||
}: Brc20TokenAssetItemLayoutProps) { | ||
const [component, bind] = usePressable(isPressable); | ||
|
||
const balance = createMoney(Number(token.overall_balance), token.tick, 0); | ||
const formattedBalance = formatBalance(balance.amount.toString()); | ||
|
||
return ( | ||
<BasicTooltip | ||
asChild | ||
disabled={!displayNotEnoughBalance} | ||
side="top" | ||
label={'Not enough BTC in balance'} | ||
asChild | ||
side="top" | ||
> | ||
<Flex onClick={isPressable ? onClick : undefined} {...bind}> | ||
<Flag align="middle" img={<Brc20TokenIcon />} spacing="space.04" width="100%"> | ||
<HStack alignItems="center" justifyContent="space-between" width="100%"> | ||
<styled.span | ||
maxWidth="150px" | ||
overflow="hidden" | ||
textAlign="left" | ||
textOverflow="ellipsis" | ||
textStyle="label.01" | ||
whiteSpace="nowrap" | ||
> | ||
{title} | ||
</styled.span> | ||
<BasicTooltip | ||
label={formattedBalance.isAbbreviated ? balance.amount.toString() : undefined} | ||
side="left" | ||
> | ||
<styled.span data-testid={title} textStyle="label.01"> | ||
{formattedBalance.value} | ||
</styled.span> | ||
</BasicTooltip> | ||
</HStack> | ||
<HStack alignItems="center" justifyContent="space-between" height="1.25rem" width="100%"> | ||
<AssetCaption caption={caption} /> | ||
</HStack> | ||
{component} | ||
</Flag> | ||
</Flex> | ||
<Item.Root isPressable={isPressable} onClick={onClick}> | ||
<Item.Content> | ||
<ItemDefaultLayout | ||
isPressable={isPressable} | ||
flagImg={<Brc20TokenIcon />} | ||
contentLeftTop={<Item.Text>{token.tick}</Item.Text>} | ||
contentLeftBottom={<Item.Caption textStyle="caption.01">{'BRC-20'}</Item.Caption>} | ||
contentRightTop={ | ||
<BasicTooltip | ||
label={formattedBalance.isAbbreviated ? balance.amount.toString() : undefined} | ||
side="left" | ||
> | ||
<Item.Text data-testid={token.tick}>{formattedBalance.value}</Item.Text> | ||
</BasicTooltip> | ||
} | ||
/> | ||
</Item.Content> | ||
</Item.Root> | ||
</BasicTooltip> | ||
); | ||
} |
29 changes: 0 additions & 29 deletions
29
...onents/crypto-assets/bitcoin/brc20-token-asset-list/components/brc20-token-asset-item.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...crypto-assets/bitcoin/brc20-token-asset-list/components/brc20-token-asset-list.layout.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,10 @@ | ||
import { CryptoAssetSelectors } from '@tests/selectors/crypto-asset.selectors'; | ||
import { Stack, StackProps } from 'leather-styles/jsx'; | ||
|
||
export function Brc20AssetListLayout({ children }: StackProps) { | ||
return ( | ||
<Stack data-testid={CryptoAssetSelectors.CryptoAssetList} width="100%"> | ||
{children} | ||
</Stack> | ||
); | ||
} |
Oops, something went wrong.