Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(llm): improve readability of supply info in the market #6842

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
Loading