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

dApp: Deposit/Withdrawal form improvements - visuals #687

Merged
merged 31 commits into from
Aug 21, 2024

Conversation

kpyszkowski
Copy link
Contributor

@kpyszkowski kpyszkowski commented Aug 1, 2024

Closes: #629
Closes: #652
Closes: #637
Closes: #570
Closes: #630

Changes:

  • Adjusted styles: spacings, button styles, input
  • Form input is automatically focused as the form appears
  • Added stake form input placeholder
  • Added withdrawal form input placeholder
  • Disabled submit button when amount is invalid
  • Removed fiat-converted amount displayed below the input
  • Displayed validation errors as Alert component
  • Adjusted validation strategy
  • Updated input displayed value formatting function to use bigIntToUserAmount instead of fixedPointNumberToString:
    • The fixedPointNumberToString aggressively trims trailing zero values conflicting with the way NumericFormat component does it. The bigIntToUserAmount seems to fit better here
  • Updated copies
  • Conditionally styled balance amount for invalid state
  • Added suffix currency symbol value
Screen.Recording.2024-08-19.at.21.57.03.mov

@kpyszkowski kpyszkowski added the 🎨 dApp dApp label Aug 1, 2024
@kpyszkowski kpyszkowski self-assigned this Aug 1, 2024
Copy link

netlify bot commented Aug 1, 2024

Deploy Preview for acre-dapp ready!

Name Link
🔨 Latest commit 880bbd9
🔍 Latest deploy log https://app.netlify.com/sites/acre-dapp/deploys/66c5aab43276770008807ac6
😎 Deploy Preview https://deploy-preview-687--acre-dapp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Aug 1, 2024

Deploy Preview for acre-dapp-testnet ready!

Name Link
🔨 Latest commit 880bbd9
🔍 Latest deploy log https://app.netlify.com/sites/acre-dapp-testnet/deploys/66c5aab4e8e75d0008b993c5
😎 Deploy Preview https://deploy-preview-687--acre-dapp-testnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@kpyszkowski kpyszkowski marked this pull request as draft August 5, 2024 10:37
@kpyszkowski kpyszkowski changed the title dApp: Make amount input focus on mount dApp: Deposit/Withdrawal form improvements Aug 5, 2024
@kpyszkowski kpyszkowski marked this pull request as ready for review August 5, 2024 15:31
Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

Overall it looks good, I just left some comments. I haven't tested it yet, but I noticed one bug.

Solution:
Screenshot 2024-08-07 at 11 09 36

Design:

Screenshot 2024-08-07 at 11 53 03

dapp/src/components/shared/TokenAmountForm/index.tsx Outdated Show resolved Hide resolved
dapp/src/components/shared/TokenBalanceInput/index.tsx Outdated Show resolved Hide resolved
dapp/src/components/shared/TokenBalanceInput/index.tsx Outdated Show resolved Hide resolved
dapp/src/components/shared/TokenBalanceInput/index.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

I left some comments. But I also noticed that build and format Github actions failed.

Screenshot 2024-08-13 at 10 54 20 Screenshot 2024-08-13 at 10 54 25

dapp/src/utils/forms.ts Outdated Show resolved Hide resolved
dapp/src/utils/numbers.ts Outdated Show resolved Hide resolved
kkosiorowska
kkosiorowska previously approved these changes Aug 14, 2024
Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

LGTM, ready for testing 🚀

@michalinacienciala
Copy link
Contributor

On the Withdraw form the Wallet balance label should be replaced by Acre balance, as per this comment.

@michalinacienciala
Copy link
Contributor

The input field should show a grey 'BTC' text after the amount entered by the user.

Design:
image

Actual:
image

@michalinacienciala

This comment was marked as resolved.

@michalinacienciala

This comment was marked as resolved.

@michalinacienciala
Copy link
Contributor

michalinacienciala commented Aug 16, 2024

As per this doc and this Discord discussion, we shouldn't show errors relating to the values entered in the amount input until user clicks Deposit/Withdraw. Right now we're validating the amount dynamically.
Also, the Deposit/Withdraw button should be disabled only freshly after user clicked on it and the validation failed. Afer that any change to the amount field should enable the button.

@michalinacienciala
Copy link
Contributor

Also, just making sure - the handling of the insufficient balance to handle fee is not in scope of this PR, right?

@kpyszkowski
Copy link
Contributor Author

kpyszkowski commented Aug 19, 2024

@michalinacienciala

The input field should show a grey 'BTC' text after the amount entered by the user.

In designs to looks like the value is mapped over placeholders. It requires the entire component to be rebuilt because we don't have such functionality and it's not how native inputs work. I suppose it would be too much time consuming for us. I'd suggest to skip it.

It is possible to add suffix to the value. Unfortunately it's impossible to style it so it will be the same color as the value.
image

Ref commit: 8e1f875

The amount in the input field should not change the color to red when there's a failure of the validation.

Ref commit: 07b172e

The value inside the input field should be 0.015 BTC, not 0.0150 BTC (and for withdrawal: 0.01 BTC instead of 0.0100 BTC)

Ref commit: a599749

As per this doc and this Discord discussion, we shouldn't show errors relating to the values entered in the amount input until user clicks Deposit/Withdraw. Right now we're validating the amount dynamically.
Also, the Deposit/Withdraw button should be disabled only freshly after user clicked on it and the validation failed. Afer that any change to the amount field should enable the button.

Functionalities you describe are impossible to implement with Formik - the library we use. It's impossible to track the state before first submit. About the form behavior that's all we can do.

Sorry, I misunderstood the requirements. I reviewed possibilities and applied requested changes basing on Coda write up.

  • The value is validated only on submit button click
  • The error state is reset on the change event triggered on input
  • The insufficient balance to cover network fee case is not covered since it requires to somehow estimate network fee values. It will be covered in separate PR to prevent blocking this PR

Ref commit: a72361a

Added video presentation in the PR description.

@michalinacienciala
Copy link
Contributor

Also, just making sure - the handling of the insufficient balance to handle fee is not in scope of this PR, right?

@kpyszkowski I think you missed this one

@michalinacienciala
Copy link
Contributor

Regarding the two items deemed as impossible / hard to implement - I asked @SorinQ about the approach we should take here. Anyway, we can probably close this PR without those changes and handle them in separate tasks (as soon as we resolve all other issues in the current PR).

Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

Overall it looks good. I left a few small questions. Let me know what you think.

Additionally, I will wait for the merge until tomorrow in case Michalina finds a moment to test. If not, we will do the merge tomorrow.

dapp/src/components/shared/Form/FormTokenBalanceInput.tsx Outdated Show resolved Hide resolved
dapp/src/components/shared/Form/FormTokenBalanceInput.tsx Outdated Show resolved Hide resolved
dapp/src/components/shared/TokenBalanceInput/index.tsx Outdated Show resolved Hide resolved
kkosiorowska
kkosiorowska previously approved these changes Aug 20, 2024
Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

🚀🚀🚀

Copy link
Contributor

@kkosiorowska kkosiorowska left a comment

Choose a reason for hiding this comment

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

Confirmed works great! 🚀

Screenshot 2024-08-21 at 11 00 28

@kkosiorowska kkosiorowska merged commit 183e193 into main Aug 21, 2024
28 checks passed
@kkosiorowska kkosiorowska deleted the amount-form-input-focus branch August 21, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment