lightning-browser-extension icon indicating copy to clipboard operation
lightning-browser-extension copied to clipboard

Add unit switching within the "Amount" input

Open stackingsaunter opened this issue 2 years ago • 14 comments

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

  • creating invoiced priced in fiat currency
  • being able to see/use units in BTC not sats

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

stackingsaunter avatar Jun 24 '23 20:06 stackingsaunter

I would like to work on this for Hacktoberfest.

abhiShandy avatar Sep 29 '23 16:09 abhiShandy

@abhiShandy I assigned you

stackingsaunter avatar Sep 30 '23 12:09 stackingsaunter

First phase

  • [ ] Add trailing "sats"
  • [ ] Make trailing "sats" clickable to switch to "BTC" and vice versa
  • [ ] Fix the text color in dark mode #2784
  • [ ] Add hover states to units
  • [ ] ~Show three letter fiat code after the fiat amount~

Second phase

  • [ ] Switch from fiat to bitcoin and vice-versa

abhiShandy avatar Sep 30 '23 13:09 abhiShandy

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

abhiShandy avatar Sep 30 '23 14:09 abhiShandy

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

image

stackingsaunter avatar Sep 30 '23 14:09 stackingsaunter

@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?

abhiShandy avatar Oct 01 '23 12:10 abhiShandy

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.

bumi avatar Oct 02 '23 08:10 bumi

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 avatar Oct 02 '23 22:10 abhiShandy

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

abhiShandy avatar Oct 05 '23 13:10 abhiShandy

@abhiShandy hey are you still working on this?

stackingsaunter avatar Nov 16 '23 12:11 stackingsaunter

@abhiShandy hey are you still working on this?

No. I'm not working on this.

abhiShandy avatar Nov 16 '23 14:11 abhiShandy

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

bumi avatar Jan 08 '24 19:01 bumi

@bumi you mean add a button somewhere?

stackingsaunter avatar Jan 18 '24 11:01 stackingsaunter

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.

ffrediani avatar Aug 20 '24 13:08 ffrediani