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
Tag percentages with certain format #2759
Conversation
🦋 Changeset detectedLatest commit: 24079c2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
2 Ignored Deployments
|
Apply Sweep Rules to your PR?
|
], | ||
}); | ||
}; | ||
|
||
export const library = [ | ||
makeUnitFn("n", "nano", 1e-9), | ||
makeUnitFn("m", "mili", 1e-3), | ||
makeUnitFn("%", "percent", 1e-2), | ||
makeUnitFn("%", "percent", 1e-2, ".2%"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.2~p
seems slightly better; it rounds larger numbers too much but doesn't lose heading significant digits in small numbers:
> format('.2~p')(3456789)
'350000000%'
> format('.2~p')(34.56789)
'3500%'
> format('.2~p')(0.3456789)
'35%'
> format('.2~p')(0.003456789)
'0.35%'
> format('.2~p')(0.00003456789)
'0.0035%'
Compared to .2%
:
> format('.2%')(3456789)
'345678900.00%'
> format('.2%')(34.56789)
'3456.79%'
> format('.2%')(0.3456789)
'34.57%'
> format('.2%')(0.003456789)
'0.35%'
> format('.2%')(0.00003456789)
'0.00%'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that's neat, happy to change.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2759 +/- ##
==========================================
+ Coverage 71.56% 71.61% +0.04%
==========================================
Files 118 118
Lines 6465 6469 +4
Branches 1318 1322 +4
==========================================
+ Hits 4627 4633 +6
+ Misses 1830 1828 -2
Partials 8 8 ☔ View full report in Codecov by Sentry. |
Pretty straightforward. I'm a bit nervous that this will have trouble for huge or tiny percentages, but as I think about it, that doesn't seem like a huge concern - I think we can deal with it later on, as needed.