Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: hide asset list unsupported tokens in accordion, closes #16 #5344

Merged
merged 1 commit into from
May 6, 2024

Conversation

alter-eggo
Copy link
Contributor

@alter-eggo alter-eggo commented May 3, 2024

Try out Leather build bb66cb7Extension build, Test report, Storybook, Chromatic

This pr puts unsupported list of tokens in accordion, also adds Accordion ui component

Screen.Recording.2024-05-03.at.17.56.08.mov

@alter-eggo alter-eggo force-pushed the feat/filter-token-list branch from 6e2ccc6 to 5befee1 Compare May 3, 2024 14:00
@markmhendrickson
Copy link
Collaborator

@fabric-8 curious how we want to handle left and right padding here on hover? Or better no hover background effect?

image

@alter-eggo alter-eggo force-pushed the feat/filter-token-list branch from 5befee1 to d6484fa Compare May 3, 2024 16:38
@alter-eggo
Copy link
Contributor Author

@@ -8,6 +8,14 @@ export const keyframes: CssKeyframes = {
from: { opacity: 1, transform: 'translateY(0)' },
to: { opacity: 0, transform: 'translateY(4px)' },
},
slideDown: {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have a slideUpAndFade and slideDownAndFade being used in other UI components (dropdown, select, and tooltip) ...wondering about naming here bc specific to this feature with the maxHeight?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm, how do you think better to name? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary to change, but thought maybe just adding the maxHeight to the ones we already have might work? Not critical to address.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changing maxHeight there will break animation, dropdown's menu height will go from 0 to the actual height, I believe we don't expect it there

Copy link
Contributor

@fbwoolf fbwoolf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @alter-eggo, just some naming suggestions.

@alter-eggo alter-eggo force-pushed the feat/filter-token-list branch from d6484fa to 3fe305d Compare May 3, 2024 19:05
@fabric-8
Copy link
Contributor

fabric-8 commented May 3, 2024

Amazing to see this coming to life already!

Realizing that the way it's set up in the design doesn't match the current implementation because the token list items are built differently (They don't have any padding inside and all the padding is given via the outer container).

In design we're using token list item "future versions" which have a built-in padding that would align with a button like used here. The hack you used is nifty, however given the current situation and the container getting really close to the left/right boundaries I'd also propose to not use a full background hover effect but instead do something simpler and just rely on a change of text color on hover (action-primary-hover) without changing the background, similar to what we do for the account switcher.

CleanShot 2024-05-03 at 23 47 09@2x

Apologies this is on me, should have checked how the current token list items are constructed instead of relying on the future-to-be-design-ones and made that suggestion from the start.

Comment on lines 106 to 140
export function useFilteredStacksFungibleTokenList({
address,
filter = 'all',
}: useFilteredStacksFungibleTokenListArgs) {
const stacksFtAssetBalances = useStacksFungibleTokenAssetBalancesWithMetadata(address);
const { data: swapAssets = [] } = useAlexSwappableAssets();

return useMemo(() => {
if (filter === 'supported') {
return stacksFtAssetBalances.filter(assetBalance =>
swapAssets.some(swapAsset =>
swapAsset.principal.includes(assetBalance.asset.contractAddress)
)
);
}

if (filter === 'unsupported') {
return stacksFtAssetBalances.filter(
assetBalance =>
!swapAssets.some(swapAsset =>
swapAsset.principal.includes(assetBalance.asset.contractAddress)
)
);
}

return stacksFtAssetBalances;
}, [stacksFtAssetBalances, swapAssets, filter]);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we break apart the filtering from the hook that binds it to the state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

separated it

Comment on lines 30 to 31
left: '-2%',
right: '-2%',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we use negative spacing units, rather than percentage here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder also if we can reuse any styles from <Pressable />, which does the same thing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed it, due to @fabric-8 comment above

@alter-eggo alter-eggo force-pushed the feat/filter-token-list branch from 3fe305d to a3a1236 Compare May 6, 2024 12:41
/**
* @see https://github.com/leather-wallet/issues/issues/16
*/
type StacksFtTokensFilter = 'all' | 'supported' | 'unsupported';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think this is a smart API choice 👍🏼

@alter-eggo alter-eggo force-pushed the feat/filter-token-list branch from a3a1236 to bb66cb7 Compare May 6, 2024 13:05
@alter-eggo alter-eggo added this pull request to the merge queue May 6, 2024
Merged via the queue into dev with commit f37bb1b May 6, 2024
28 checks passed
@alter-eggo alter-eggo deleted the feat/filter-token-list branch May 6, 2024 13:16
@@ -108,6 +109,9 @@ export function AssetsList() {
)}
</BitcoinNativeSegwitAccountLoader>

<CurrentStacksAccountLoader fallback={<AddStacksLedgerKeysItem />}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alter-eggo - can you please check this as it's causing a double display of the Connect Stacks button on Ledger if you only have a BTC account:
DoubleStacks_Ledger

@alter-eggo
Copy link
Contributor Author

thanks @pete-watters
fixed here #5352

@markmhendrickson
Copy link
Collaborator

Nice work, @alter-eggo 💪 Does the UI remember the user's preference in terms of hiding or showing? E.g. if the user shows the tokens and refreshes, are they still shown or hidden again?

If the UI doesn't remember, let's create a separate issue to track that as an enhancement.

@alter-eggo
Copy link
Contributor Author

@markmhendrickson always hidden, will you create a task?

@markmhendrickson
Copy link
Collaborator

I've created it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants