-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Localise number formatting in quiz stats #10349
Conversation
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.
@minimalsm Left a few suggestions! If we use the after
pseudoelement with content of +
, the DOM will automatically render that inline and take direction into account (always placing it "after" by default). Should help simplify some logic here =)
@minimalsm I've done some updates to they way I calculate average, new variable is |
052122d
to
58b439a
Compare
Updated @nhsz 🫡 |
@minimalsm I'd suggest to parse integer numbers to avoid redundant decimals when float part is I was doing that with
logic should be probably adapted a bit for this solution |
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.
Nice @minimalsm
Nice to have: would recommend to isolate all this new logic into its own function.
// to have something like this
const { language } = useI18next()
...
const formattedStats = getFormattedStats(language, userAverageScores)
@nhsz the number formatter already does this for us (unless I misunderstand you). const percentFormatter = new Intl.NumberFormat("en-US", {
style: "percent",
minimumSignificantDigits: 2,
maximumSignificantDigits: 3,
})
console.log(percentFormatter.format(0.49)) // 49%
console.log(percentFormatter.format(0.4900000000)) //49%
console.log(percentFormatter.format(0.499)) //49.9%
console.log(percentFormatter.format(0.4999)) // 50% |
Good point! Done here 🫡 |
@minimalsm I tried completing a quiz with 50% score and it's displayed as |
@nhsz should be fixed in this commit: Can you confirm? |
LGTM now, thanks! I have moved |
Description
Added enhanced localization and formatting for numbers on the quiz stats component:
Related Issue
#10320