Skip to content

Commit

Permalink
ui(balance): use thin space char as delimiter in fractional part
Browse files Browse the repository at this point in the history
  • Loading branch information
theborakompanioni committed Nov 4, 2023
1 parent 514180b commit c0cdf91
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/format.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ const SATS_FORMATTER = new Intl.NumberFormat('en-US', {
})

const _decimalPoint = '\u002E'
const _nbHalfSpace = '\u202F'
const _thinSpace = '\u2009'

export type FormatBtcProps = {
deemphasize?: (char: string) => string | JSX.Element
}

const DEFAULT_FORMAT_BTC_PROPS = {
deemphasize: (char: string) => <span className="opacity-50">{char}</span>,
const DEFAULT_FORMAT_BTC_PROPS: FormatBtcProps = {
deemphasize: (char) => <span className="opacity-50">{char}</span>,
}

export const formatBtc = (
value: number,
{ deemphasize = DEFAULT_FORMAT_BTC_PROPS.deemphasize }: FormatBtcProps = DEFAULT_FORMAT_BTC_PROPS,
{ deemphasize = DEFAULT_FORMAT_BTC_PROPS.deemphasize! }: FormatBtcProps = DEFAULT_FORMAT_BTC_PROPS,
) => {
const numberString = BTC_FORMATTER.format(value)
const [integerPart, fractionalPart] = numberString.split(_decimalPoint)
Expand All @@ -39,7 +39,7 @@ export const formatBtc = (
.map((val, index) =>
index === 2 || index === 5 ? (
<>
{_nbHalfSpace}
{_thinSpace}
{val}
</>
) : (
Expand Down

0 comments on commit c0cdf91

Please sign in to comment.