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(frontend): Hide Send button for zero balance #3250

Merged

Conversation

AntonioVentilii-DFINITY
Copy link
Contributor

@AntonioVentilii-DFINITY AntonioVentilii-DFINITY commented Oct 31, 2024

Motivation

We want to hide the Send button in the Hero when the user has no tokens, and display a different message. That is ONLY for the main page, and not the transactions page.

Note that we are talking about token balance and not USD balance, since for some tokens we don't have an exchange rate.

Changes

  • Create util (and tests) to find any possible non-zero balance in the balancesStore.
  • Create derived to find any non-zero balance, using the util created.
  • Adjust Actions component to show Send button in the main page ONLY when there are at least some non-zero-balance tokens.
  • Adjust ExchangeBalance to show a difference sentence if there are no tokens.

Tests

For the derived, I decided to create a specific util and test that one. I think I covered all possible scenarios, but any input welcome.

For the results, here it is (no changes for users with non-zero balances):

Screenshot 2024-10-31 at 09 12 02
Screenshot 2024-10-31 at 09 12 11
Screenshot 2024-10-31 at 09 12 28
Screenshot 2024-10-31 at 09 13 09
Screenshot 2024-10-31 at 09 13 18
Screenshot 2024-10-31 at 09 17 20

Transition

I tried to add a fade transition for the Send button when suddenly some token arrives, however, it messes up the layout, and since the Button layout is quite nested, I am not sure how to tackle this.

{#if sendAction}
	<div in:fade>
		<Send {isTransactionsPage} />
	</div>
{/if}

Screenshot 2024-10-31 at 09 17 08

@AntonioVentilii-DFINITY
Copy link
Contributor Author

AntonioVentilii-DFINITY commented Oct 31, 2024

OISY-64

Copy link
Contributor

@DenysKarmazynDFINITY DenysKarmazynDFINITY left a comment

Choose a reason for hiding this comment

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

The code LGTM, thanks!

Re. the transition - IMO, not event element should have it. In your particular case, having an animation for a middle button would probably look more like a layout shift. Therefore, I would proceed without it.

Copy link
Member

@peterpeterparker peterpeterparker left a comment

Choose a reason for hiding this comment

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

Here maybe a max width to avoid displaying solely "it" on a second line - i.e. displaying more words on the second line?

image

@AntonioVentilii-DFINITY
Copy link
Contributor Author

AntonioVentilii-DFINITY commented Oct 31, 2024

@peterpeterparker

which one you think makes more sense? Or even less width?

Screenshot 2024-10-31 at 14 12 03
Screenshot 2024-10-31 at 14 12 18
Screenshot 2024-10-31 at 14 14 17

@peterpeterparker
Copy link
Member

I like this one because I firstly read "start using it!", that's a strong call to action.

image

@AntonioVentilii-DFINITY AntonioVentilii-DFINITY merged commit 598a2ed into main Oct 31, 2024
11 checks passed
@AntonioVentilii-DFINITY AntonioVentilii-DFINITY deleted the feat(frontend)/Hide-Send-button-for-zero-balance branch October 31, 2024 17:14
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.

4 participants