-
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.
feat: hide asset list unsupported tokens in accordion, closes #16
- Loading branch information
1 parent
8f83bcc
commit f37bb1b
Showing
9 changed files
with
295 additions
and
29 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
10 changes: 7 additions & 3 deletions
10
src/app/features/asset-list/components/stacks-fungible-token-asset-list.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,11 +1,15 @@ | ||
import { useStacksFungibleTokenAssetBalancesWithMetadata } from '@app/query/stacks/balance/stacks-ft-balances.hooks'; | ||
import { useFilteredStacksFungibleTokenList } from '@app/query/stacks/balance/stacks-ft-balances.hooks'; | ||
|
||
import { StacksFungibleTokenAssetListLayout } from './stacks-fungible-token-asset-list.layout'; | ||
|
||
interface StacksFungibleTokenAssetListProps { | ||
address: string; | ||
} | ||
export function StacksFungibleTokenAssetList({ address }: StacksFungibleTokenAssetListProps) { | ||
const stacksFtAssetBalances = useStacksFungibleTokenAssetBalancesWithMetadata(address); | ||
return <StacksFungibleTokenAssetListLayout assetBalances={stacksFtAssetBalances} />; | ||
const stacksFilteredFtAssetBalances = useFilteredStacksFungibleTokenList({ | ||
address, | ||
filter: 'supported', | ||
}); | ||
|
||
return <StacksFungibleTokenAssetListLayout assetBalances={stacksFilteredFtAssetBalances} />; | ||
} |
39 changes: 39 additions & 0 deletions
39
src/app/features/asset-list/components/stacks-unsupported-token-asset-list.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,39 @@ | ||
import { useState } from 'react'; | ||
|
||
import { styled } from 'leather-styles/jsx'; | ||
|
||
import { useFilteredStacksFungibleTokenList } from '@app/query/stacks/balance/stacks-ft-balances.hooks'; | ||
import { Accordion } from '@app/ui/components/accordion/accordion'; | ||
|
||
import { StacksFungibleTokenAssetListLayout } from './stacks-fungible-token-asset-list.layout'; | ||
|
||
const accordionValue = 'accordion-unsupported-token-asset-list'; | ||
|
||
export function StacksUnsupportedTokenAssetList({ address }: { address: string }) { | ||
const stacksFilteredFtAssetBalances = useFilteredStacksFungibleTokenList({ | ||
address, | ||
filter: 'unsupported', | ||
}); | ||
|
||
const [isOpen, setIsOpen] = useState(false); | ||
function onValueChange(value: string) { | ||
setIsOpen(value === accordionValue); | ||
} | ||
|
||
if (stacksFilteredFtAssetBalances.length === 0) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Accordion.Root onValueChange={onValueChange} type="single" collapsible> | ||
<Accordion.Item title="Stacks Fungible Tokens" value={accordionValue}> | ||
<Accordion.Trigger> | ||
<styled.span>View {isOpen ? 'fewer' : 'more'}</styled.span> | ||
</Accordion.Trigger> | ||
<Accordion.Content> | ||
<StacksFungibleTokenAssetListLayout assetBalances={stacksFilteredFtAssetBalances} /> | ||
</Accordion.Content> | ||
</Accordion.Item> | ||
</Accordion.Root> | ||
); | ||
} |
Oops, something went wrong.