-
Notifications
You must be signed in to change notification settings - Fork 142
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
Showing
59 changed files
with
765 additions
and
667 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { HStack } from 'leather-styles/jsx'; | ||
|
||
import { useViewportMinWidth } from '@app/common/hooks/use-media-query'; | ||
import { BulletSeparator } from '@app/ui/components/bullet-separator/bullet-separator'; | ||
import { Caption } from '@app/ui/components/typography/caption'; | ||
import { truncateMiddle } from '@app/ui/utils/truncate-middle'; | ||
|
||
import { StacksAccountLoader } from '../loaders/stacks-account-loader'; | ||
import { BitcoinNativeSegwitAccountLoader } from './bitcoin-account-loader'; | ||
|
||
interface AccountAddressesProps { | ||
index: number; | ||
} | ||
export function AcccountAddresses({ index }: AccountAddressesProps) { | ||
const isBreakpointSm = useViewportMinWidth('sm'); | ||
|
||
return ( | ||
<HStack alignItems="center" gap="space.02" whiteSpace="nowrap"> | ||
<BulletSeparator> | ||
<StacksAccountLoader index={index}> | ||
{account => <Caption>{truncateMiddle(account.address, isBreakpointSm ? 4 : 3)}</Caption>} | ||
</StacksAccountLoader> | ||
<BitcoinNativeSegwitAccountLoader index={index}> | ||
{signer => <Caption>{truncateMiddle(signer.address, 5)}</Caption>} | ||
</BitcoinNativeSegwitAccountLoader> | ||
</BulletSeparator> | ||
</HStack> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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 { ReactNode } from 'react'; | ||
|
||
import { SettingsSelectors } from '@tests/selectors/settings.selectors'; | ||
|
||
import { ItemInteractive } from '@app/ui/components/item/item-interactive'; | ||
import { ItemLayout } from '@app/ui/components/item/item.layout'; | ||
import { Spinner } from '@app/ui/components/spinner'; | ||
|
||
interface AccountListItemLayoutProps { | ||
accountAddresses: ReactNode; | ||
accountName: ReactNode; | ||
avatar: ReactNode; | ||
balanceLabel: ReactNode; | ||
index: number; | ||
isLoading: boolean; | ||
isSelected: boolean; | ||
onSelectAccount(): void; | ||
} | ||
export function AccountListItemLayout(props: AccountListItemLayoutProps) { | ||
const { | ||
accountAddresses, | ||
accountName, | ||
avatar, | ||
balanceLabel, | ||
index, | ||
isLoading, | ||
isSelected, | ||
onSelectAccount, | ||
} = props; | ||
|
||
return ( | ||
<ItemInteractive | ||
data-testid={SettingsSelectors.SwitchAccountItemIndex.replace('[index]', `${index}`)} | ||
key={`account-${index}`} | ||
onClick={onSelectAccount} | ||
> | ||
<ItemLayout | ||
isSelected={isSelected} | ||
flagImg={avatar} | ||
titleLeft={accountName} | ||
titleRight={ | ||
isLoading ? ( | ||
<Spinner | ||
color="accent.text-subdued" | ||
position="absolute" | ||
right={0} | ||
size="18px" | ||
top="calc(50% - 8px)" | ||
/> | ||
) : ( | ||
balanceLabel | ||
) | ||
} | ||
captionLeft={accountAddresses} | ||
/> | ||
</ItemInteractive> | ||
); | ||
} |
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
61 changes: 22 additions & 39 deletions
61
...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 { 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/ui/components/flag/flag'; | ||
import { Brc20Token } from '@app/query/bitcoin/ordinals/brc20/brc20-tokens.query'; | ||
import { Brc20TokenIcon } from '@app/ui/components/icons/brc20-token-icon'; | ||
import { ItemInteractive } from '@app/ui/components/item/item-interactive'; | ||
import { ItemLayout } from '@app/ui/components/item/item.layout'; | ||
import { BasicTooltip } from '@app/ui/components/tooltip/basic-tooltip'; | ||
|
||
interface Brc20TokenAssetItemLayoutProps extends BoxProps { | ||
balance: Money; | ||
caption: string; | ||
isPressable?: boolean; | ||
interface Brc20TokenAssetItemLayoutProps { | ||
token: Brc20Token; | ||
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} | ||
label="Not enough BTC in balance" | ||
side="top" | ||
label={'Not enough BTC in balance'} | ||
asChild | ||
> | ||
<Flex onClick={isPressable ? onClick : undefined} {...bind}> | ||
<Flag 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> | ||
<ItemInteractive onClick={onClick}> | ||
<ItemLayout | ||
flagImg={<Brc20TokenIcon />} | ||
titleLeft={token.tick} | ||
captionLeft="BRC-20" | ||
titleRight={ | ||
<BasicTooltip | ||
asChild | ||
label={formattedBalance.isAbbreviated ? balance.amount.toString() : undefined} | ||
side="left" | ||
> | ||
<styled.span data-testid={title} textStyle="label.01"> | ||
<styled.span data-testid={token.tick} fontWeight={500} textStyle="label.02"> | ||
{formattedBalance.value} | ||
</styled.span> | ||
</BasicTooltip> | ||
</HStack> | ||
<HStack alignItems="center" justifyContent="space-between" height="1.25rem" width="100%"> | ||
<AssetCaption caption={caption} /> | ||
</HStack> | ||
{component} | ||
</Flag> | ||
</Flex> | ||
} | ||
/> | ||
</ItemInteractive> | ||
</BasicTooltip> | ||
); | ||
} |
Oops, something went wrong.