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

Update NumberBadge to show hundreds in full, show thousands with k #38605

Merged
merged 3 commits into from Nov 17, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -207,7 +207,15 @@ export class ActivityActionItem extends BaseActionItem {
// Number
if (badge instanceof NumberBadge) {
if (badge.number) {
this.$badgeContent.text(badge.number > 99 ? '99+' : badge.number.toString());
let number;
if (badge.number > 9999) {
number = '10k+';
} else if (badge.number > 999) {
number = (badge.number / 1000).toFixed(1).replace(/\.0$/, '') + 'k';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO this just seems like too complex of a logic.
Can we use something like

badge.number.toString()[0] + 'k'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes! Because we know the number is < 10,000, we can do that 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to use .charAt(0) as it's more readable.

} else {
number = badge.number.toString();
}
this.$badgeContent.text(number);
this.$badge.show();
}
}
Expand Down