safe-global / safe-wallet-web

Safe{Wallet} – multisig EVM wallet
https://app.safe.global
GNU General Public License v3.0
344 stars 409 forks source link

Feat: better fiat and token amount formatting #3807

Closed katspaugh closed 3 months ago

katspaugh commented 4 months ago

What it solves

A revised fiat and token amount formatting rules as outlined here.

How this PR fixes it

This PR simplifies the formatting logic quite a lot, and relies on browser's default formatting plus some tweaks.

Additionally, it right-aligns fiat values in Asset tables.

Screenshot 2024-06-06 at 14 49 21
github-actions[bot] commented 4 months ago

Branch preview

✅ Deploy successful!

Website: https://format--walletweb.review.5afe.dev/home?safe=eth:0xA77DE01e157f9f57C7c4A326eeE9C4874D0598b6

Storybook: https://format--walletweb.review.5afe.dev/storybook/

github-actions[bot] commented 4 months ago

ESLint Summary View Full Report

Annotations are provided inline on the Files Changed tab. You can also see all annotations that were generated on the annotations page.

Type Occurrences Fixable
Errors 0 0
Warnings 0 0
Ignored 0 N/A

Report generated by eslint-plus-action

github-actions[bot] commented 4 months ago

📦 Next.js Bundle Analysis for safe-wallet-web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

🎉 Global Bundle Size Decreased

Page Size (compressed)
global 950.07 KB (🟢 -292 B)
Details

The global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

If you want further insight into what is behind the changes, give @next/bundle-analyzer a try!

Four Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load
/address-book 26.1 KB (🟡 +13 B) 976.16 KB
/balances 29.43 KB (🟡 +25 B) 979.49 KB
/home 58.69 KB (🟡 +17 B) 1008.76 KB
/settings/setup 35.96 KB (🟡 +13 B) 986.02 KB
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this.

github-actions[bot] commented 4 months ago

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟡 Statements
79.39% (-0.11% 🔻)
11443/14413
🔴 Branches
58.41% (-0.19% 🔻)
2748/4705
🟡 Functions
66.61% (-0.2% 🔻)
1837/2758
🟢 Lines
80.73% (-0.12% 🔻)
10313/12774
Show files with reduced coverage 🔻
|
St.:grey_question:
| File | Statements | Branches | Functions | Lines | | :-: | :- | :- | :- | :- | :- | | 🟢 |
`...` / index.tsx
|
82.35% (-8.82% 🔻)
|
66.67% (-16.67% 🔻)
|
50% (-12.5% 🔻)
|
83.87% (-9.68% 🔻)
|

Test suite run success

1433 tests passing in 199 suites.

Report generated by 🧪jest coverage report action from eb0c6a5b61fdc71575ca38ecebece90af4d8f94b

francovenica commented 3 months ago

There are concerns about numbers "dancing" given the different space that numbers take, so a $11 will take much less space than a $88, so the numbers look "not aligned" even when they are https://format--walletweb.review.5afe.dev/balances?safe=eth:0x8675B754342754A30A2AeF474D114d8460bca19b

image

francovenica commented 3 months ago

It was agreed that the "dancing" will be addressed in the future: https://5afe.slack.com/archives/C03DAGWJCR5/p1718031746930849?thread_ts=1718025802.019199&cid=C03DAGWJCR5

LGTM