Skip to content

Commit

Permalink
fix(llm): improve readability of supply info in the market
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasWerey committed May 13, 2024
1 parent 3f6db5b commit 867e781
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/many-cobras-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": patch
---

Improve readability of the supply info for coin inside market
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export default function MarketStats({
atlDate: _atlDate,
price,
priceChangePercentage,
ticker,
} = currency || {};

const athDate = _athDate ? new Date(_athDate) : null;
Expand Down Expand Up @@ -158,6 +159,7 @@ export default function MarketStats({
{counterValueFormatter({
value: circulatingSupply,
locale,
ticker,
t,
})}
</StyledTextLabel>
Expand All @@ -167,6 +169,7 @@ export default function MarketStats({
{counterValueFormatter({
value: totalSupply,
locale,
ticker,
t,
})}
</StyledTextLabel>
Expand All @@ -176,6 +179,7 @@ export default function MarketStats({
{counterValueFormatter({
value: maxSupply,
locale,
ticker,
t,
})}
</StyledTextLabel>
Expand Down
18 changes: 14 additions & 4 deletions apps/ledger-live-mobile/src/newArch/features/Market/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@ export const counterValueFormatter = ({
locale,
t,
allowZeroValue = false,
ticker = "",
}: {
currency?: string;
value: number;
shorten?: boolean;
locale: string;
t?: TFunction;
allowZeroValue?: boolean;
ticker?: string;
}): string => {
if (isNaN(value) || (!value && !allowZeroValue)) {
return "-";
Expand All @@ -72,7 +74,11 @@ export const counterValueFormatter = ({
});
}

const formatter = currency ? formatters[locale][currency] : undefined;
const formatter = currency
? formatters[locale][currency]
: ticker
? new Intl.NumberFormat(locale)
: undefined;

if (shorten && t && formatter) {
const sign = value > 0 ? "" : "-";
Expand All @@ -92,9 +98,13 @@ export const counterValueFormatter = ({
return formattedNumber;
}

// FIXME: HOW DID THIS WORK WHEN CURRENCY IS EMTPY
// PLEASE FIX
return formatter ? formatter.format(value) : value + "";
if (formatter) {
const formattedValue = formatter.format(value);
const upperCaseTicker = ticker?.trim()?.toLocaleUpperCase();
return `${formattedValue} ${upperCaseTicker}`.trim();
}

return String(value);
};

export function getAnalyticsProperties<P extends object>(
Expand Down

0 comments on commit 867e781

Please sign in to comment.