diff options
| author | Adam Soltys <[email protected]> | 2026-02-03 21:46:49 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-11 15:34:18 -0800 |
| commit | 0a4c48eef92e45e5c12a7b8be321caf165fddb43 (patch) | |
| tree | eda11e154d1d9c2d7fc0fce6d30fc3445e124fbb /src/lib | |
| parent | a4c2b673ded38c31d869f93fdb8b0a656ff01c17 (diff) | |
| download | coinos-ui-0a4c48eef92e45e5c12a7b8be321caf165fddb43.tar.gz coinos-ui-0a4c48eef92e45e5c12a7b8be321caf165fddb43.zip | |
accounts redesign
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/utils.ts | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 33737b50..897b0f5a 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -334,16 +334,25 @@ export const f = ( locale = "en-US", minimumFractionDigits = 2, maximumFractionDigits = 2, -) => - new Intl.NumberFormat(locale, { +) => { + const l = typeof locale === "function" ? locale() : locale || "en-US"; + const cur = currency || "USD"; + const region = l.length >= 2 ? l.slice(-2) : ""; + const currencyDisplay = + region && cur.startsWith(region) ? "narrowSymbol" : "symbol"; + return new Intl.NumberFormat(l, { style: "currency", - currency: currency || "USD", + currency: cur, + currencyDisplay, minimumFractionDigits, maximumFractionDigits, }).format(s); +}; -export const s = (s: number, locale = "en-US"): string => - new Intl.NumberFormat(locale, { maximumFractionDigits: 0 }).format(s); +export const s = (s: number, locale = "en-US"): string => { + const l = typeof locale === "function" ? locale() : locale || "en-US"; + return new Intl.NumberFormat(l, { maximumFractionDigits: 0 }).format(s); +}; export const sat = (s: number): string => `${si(Math.abs(s)).toString()}`; |
