getAlby / lightning-browser-extension

The Bitcoin Lightning Browser Extension that brings deep Lightning & Nostr integration to the web. Wallet interface to multiple lightning nodes and key signer for Nostr, Liquid and onchain use.
https://getalby.com/#extension
MIT License
540 stars 194 forks source link

Add unit switching within the "Amount" input #2511

Open stackingsaunter opened 1 year ago

stackingsaunter commented 1 year ago

Currently there are two important missing features while creating an invoice that are often used and requested:

Let's add both being able to set an input by user in fiat and also change sats to BTC. You can play how desired outcome should work in this prototype

You can see the behaviour flow and hanoff HERE.

Changes description:

  1. Add trailing users input "sats" or "BTC" unit: image

  2. Those units should be clickable and change to BTC (and vice versa) image

  3. Clicking on fiat unit should switch it's place with bitcoin units, thus making it possible for the user to create an invoice priced in fiat: image

  4. If fiat unit has a symbol, we show it in front of the number. If it uses 3 letters (USD, ARS, TRY, PLN etc) we should show it after the fiat amount: image

  5. All units have hover states I also found one colouring inconsistency. Amount input in dark mode uses "gray" instead of "neutral" like all the rest units, so we could upgrade it to "neutral" with PR related to this issue^ image Screenshot 2023-06-24 at 22 01 02

Handoff

image image image image

abhiShandy commented 1 year ago

I would like to work on this for Hacktoberfest.

stackingsaunter commented 1 year ago

@abhiShandy I assigned you

abhiShandy commented 1 year ago

First phase

Second phase

abhiShandy commented 1 year ago

The Intl.NumberFormat displays fiat in different formats when locale is changed. Check this example.

stackingsaunter commented 1 year ago

@abhiShandy I changed a bit colors in the inputs. Please refer to those colors:

image

abhiShandy commented 1 year ago

@stackingsaunter Adding a trailing unit in the user input is difficult with HTML and CSS. I'll try to find a JavaScript trick. Meanwhile, have you considered an alternative design?

bumi commented 1 year ago

I was wondering if an auto-growing input field maybe might work? - to have the unit not as part of the input but after the input. though avoiding JS would be nice.

abhiShandy commented 1 year ago

I was wondering if an auto-growing input field maybe might work? - to have the unit not as part of the input but after the input. though avoiding JS would be nice.

width: fit-content doesn't work on Chrome at least. Check this Tailwind Playground.

abhiShandy commented 1 year ago

This CSS trick uses <span contenteditable> instead of <input type="number"/>. Is that an acceptable solution?

stackingsaunter commented 12 months ago

@abhiShandy hey are you still working on this?

abhiShandy commented 12 months ago

@abhiShandy hey are you still working on this?

No. I'm not working on this.

bumi commented 10 months ago

maybe we start without 2 - and just do the fiat - sat switch first?

stackingsaunter commented 10 months ago

@bumi you mean add a button somewhere?

ffrediani commented 2 months ago

This is indeed very well missed feature. Being able to see the equivalent fiat amount when entering the amount of sats in a new invoice is very useful thing to have. Remember to add somewhere an option to choose the available fiat to be the default used.