-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/storybook-init
- Loading branch information
Showing
106 changed files
with
1,717 additions
and
760 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
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Flex, Grid, GridItem, Text } from "@chakra-ui/react"; | ||
|
||
import { ViewMore } from "../table"; | ||
import type { Option, TokenWithValue, USD } from "lib/types"; | ||
|
||
import { SupportedAssetSectionContent } from "./SupportedAssetSectionContent"; | ||
import { SupportedAssetTitle } from "./SupportedAssetTitle"; | ||
import { UnsupportedAssetSectionContent } from "./UnsupportedAssetSectionContent"; | ||
import { UnsupportedAssetTitle } from "./UnsupportedAssetTitle"; | ||
|
||
const MAX_SUPPORTED_ASSETS_SHOW = 6; | ||
const MAX_UNSUPPORTED_ASSETS_SHOW = 3; | ||
|
||
interface AssetSectionOverviewProps { | ||
isAccount: boolean; | ||
supportedAssets: TokenWithValue[]; | ||
totalSupportedAssetsValue: Option<USD<Big>>; | ||
unsupportedAssets: TokenWithValue[]; | ||
onViewMore: () => void; | ||
} | ||
|
||
export const AssetSectionOverview = ({ | ||
isAccount, | ||
supportedAssets, | ||
totalSupportedAssetsValue, | ||
unsupportedAssets, | ||
onViewMore, | ||
}: AssetSectionOverviewProps) => { | ||
if (!supportedAssets.length && !unsupportedAssets.length) | ||
return ( | ||
<Text variant="body2" color="text.dark"> | ||
This {isAccount ? "address" : "contract"} does not hold any assets | ||
</Text> | ||
); | ||
|
||
return ( | ||
<Grid gridTemplateColumns={{ base: "1fr", xl: "2fr 1fr" }} gridGap={4}> | ||
<GridItem border="1px solid" borderColor="gray.700" borderRadius="8px"> | ||
<Flex direction="column" justifyContent="space-between" h="full"> | ||
<Flex direction="column"> | ||
<SupportedAssetTitle | ||
supportedAssets={supportedAssets} | ||
totalSupportedAssetsValue={totalSupportedAssetsValue} | ||
/> | ||
<SupportedAssetSectionContent | ||
isAccount={isAccount} | ||
supportedAssets={supportedAssets.slice( | ||
0, | ||
MAX_SUPPORTED_ASSETS_SHOW | ||
)} | ||
onViewMore={onViewMore} | ||
/> | ||
</Flex> | ||
{onViewMore && supportedAssets.length > MAX_SUPPORTED_ASSETS_SHOW && ( | ||
<ViewMore | ||
onClick={onViewMore} | ||
borderRadius="0px 0px 8px 8px" | ||
minH="48px" | ||
/> | ||
)} | ||
</Flex> | ||
</GridItem> | ||
<GridItem border="1px solid" borderColor="gray.700" borderRadius="8px"> | ||
<UnsupportedAssetTitle unsupportedAssets={unsupportedAssets} /> | ||
<UnsupportedAssetSectionContent | ||
isAccount={isAccount} | ||
unsupportedAssets={unsupportedAssets.slice( | ||
0, | ||
MAX_UNSUPPORTED_ASSETS_SHOW | ||
)} | ||
onViewMore={onViewMore} | ||
/> | ||
{onViewMore && | ||
unsupportedAssets.length > MAX_UNSUPPORTED_ASSETS_SHOW && ( | ||
<ViewMore | ||
onClick={onViewMore} | ||
borderRadius="0px 0px 8px 8px" | ||
minH="48px" | ||
/> | ||
)} | ||
</GridItem> | ||
</Grid> | ||
); | ||
}; |
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,47 @@ | ||
import { Flex, Grid, Text } from "@chakra-ui/react"; | ||
|
||
import { TokenCard } from "lib/components/token"; | ||
import type { TokenWithValue } from "lib/types"; | ||
|
||
interface SupportedAssetSectionContentProps { | ||
supportedAssets: TokenWithValue[]; | ||
isAccount?: boolean; | ||
onViewMore?: () => void; | ||
} | ||
|
||
export const SupportedAssetSectionContent = ({ | ||
supportedAssets, | ||
isAccount = false, | ||
onViewMore, | ||
}: SupportedAssetSectionContentProps) => { | ||
if (!supportedAssets.length) | ||
return ( | ||
<Flex | ||
w="full" | ||
alignItems="center" | ||
justifyContent="center" | ||
h="calc(100% - 45px)" | ||
minH={20} | ||
> | ||
<Text variant="body2" color="text.dark"> | ||
This {isAccount ? "address" : "contract"} does not hold any supported | ||
assets | ||
</Text> | ||
</Flex> | ||
); | ||
|
||
return ( | ||
<Grid | ||
p={4} | ||
gridGap={4} | ||
gridTemplateColumns={{ | ||
base: "1 fr", | ||
md: onViewMore ? "repeat(3, 1fr)" : "repeat(4, 1fr)", | ||
}} | ||
> | ||
{supportedAssets.map((asset) => ( | ||
<TokenCard key={asset.denom} token={asset} minW="full" /> | ||
))} | ||
</Grid> | ||
); | ||
}; |
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,49 @@ | ||
import { Flex, Heading } from "@chakra-ui/react"; | ||
|
||
import { TableTitle } from "../table"; | ||
import { useMobile } from "lib/app-provider"; | ||
import type { Option, TokenWithValue, USD } from "lib/types"; | ||
import { formatPrice } from "lib/utils"; | ||
|
||
interface SupportedAssetTitleProps { | ||
supportedAssets: TokenWithValue[]; | ||
totalSupportedAssetsValue: Option<USD<Big>>; | ||
} | ||
|
||
export const SupportedAssetTitle = ({ | ||
supportedAssets, | ||
totalSupportedAssetsValue, | ||
}: SupportedAssetTitleProps) => { | ||
const isMobile = useMobile(); | ||
const isZeroValue = | ||
!totalSupportedAssetsValue || totalSupportedAssetsValue.eq(0); | ||
|
||
return ( | ||
<Flex | ||
w="full" | ||
bg="gray.900" | ||
py={2} | ||
px={4} | ||
borderRadius="8px 8px 0px 0px" | ||
justifyContent="space-between" | ||
> | ||
<TableTitle | ||
title="Supported Assets" | ||
count={supportedAssets.length} | ||
mb={0} | ||
/> | ||
{!isMobile && ( | ||
<Heading | ||
mt={1} | ||
as="h6" | ||
variant="h6" | ||
color={isZeroValue ? "text.dark" : "text.main"} | ||
> | ||
{totalSupportedAssetsValue | ||
? formatPrice(totalSupportedAssetsValue) | ||
: "N/A"} | ||
</Heading> | ||
)} | ||
</Flex> | ||
); | ||
}; |
48 changes: 48 additions & 0 deletions
48
src/lib/components/asset/UnsupportedAssetSectionContent.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,48 @@ | ||
import { Flex, Grid, Text } from "@chakra-ui/react"; | ||
|
||
import { UnsupportedToken } from "../token"; | ||
import type { TokenWithValue } from "lib/types"; | ||
|
||
interface UnsupportedAssetSectionContentProps { | ||
unsupportedAssets: TokenWithValue[]; | ||
isAccount?: boolean; | ||
onViewMore?: () => void; | ||
} | ||
|
||
export const UnsupportedAssetSectionContent = ({ | ||
unsupportedAssets, | ||
onViewMore, | ||
isAccount = false, | ||
}: UnsupportedAssetSectionContentProps) => { | ||
if (!unsupportedAssets.length) | ||
return ( | ||
<Flex | ||
w="full" | ||
alignItems="center" | ||
justifyContent="center" | ||
h="calc(100% - 45px)" | ||
minH={20} | ||
> | ||
<Text variant="body2" color="text.dark"> | ||
This {isAccount ? "address" : "contract"} does not hold any | ||
unsupported assets | ||
</Text> | ||
</Flex> | ||
); | ||
|
||
return ( | ||
<Flex direction="column" gap={5} p={4}> | ||
<Grid | ||
gridGap={4} | ||
gridTemplateColumns={{ | ||
base: "1 fr", | ||
md: onViewMore ? "1fr" : "repeat(2, 1fr)", | ||
}} | ||
> | ||
{unsupportedAssets.map((asset) => ( | ||
<UnsupportedToken key={asset.denom} token={asset} /> | ||
))} | ||
</Grid> | ||
</Flex> | ||
); | ||
}; |
Oops, something went wrong.