-
Notifications
You must be signed in to change notification settings - Fork 90
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
feat(NcCounterBubble): add count prop for humanized count display #5863
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.
Very nice! :)
Is it possible to have this be default and not a choice/prop? That is, if a counter bubble is used anywhere, it should never go up further than 1000.
What about using 1K+ instead of 999+?
I'd prefer 999+ as that's more universally localized and a bit clearer that it's "a ton".
The limit is Changing the behavior of the current custom content rendering would be more breaking and also dirty implementation-wise. |
It is 999 by default, which in most cases makes sense, but sometime even 99 would be ok, so we should not hard code this but just have a meaningful default, no? |
157de2a
to
7ce91df
Compare
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.
Rest is good!
7ce91df
to
bb5e2be
Compare
bb5e2be
to
ba97433
Compare
I would like to stress that numbers well above 1000 are a regular occurence. I would like to keep support for strings to allow consumers to pass things like "12.5k" if they so choose |
As far as I can see, you can still use the slot for custom strings. It was only deprecated for now. Removing it is a breaking change and implies a major bump. |
@marcelklehr do you have an example, where |
I use it in the bookmarks app to show bookmarks counts for folders and menu items |
Ok, then let’s do it as you suggested (and also as e.g. Twitter does for favs and retweets):
Then it fulfills multiple requirements:
Sounds good @ShGKme @marcelklehr @susnux? |
Sounds good for me :) (While I personally would prefer a small |
@susnux small "k" and capital "M" sounds good to me too, it seems like the standard. Not sure what the specific reason to Twitter using a capital K is. |
Before I polish it, @susnux What do you think about this solution? |
4906065
to
2f5a0a9
Compare
|
@jancborchardt Updated, see screenshots |
2f5a0a9
to
fe8eb1f
Compare
|
||
Note, if you pass a plain number to the default slot, without raw prop it will be humanized like via `count` prop. This feature is **deprecated** and will be removed in the future. Prefer using `count` prop for numbers with humanization. |
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.
Shall we deprecate the whole default slot?
As the counter function is done by the prop, using the slot without the counter handling feels like you want to use NcChip or NcUserBubble.
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.
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.
BTW just for my reasoning:
From my point of view it makes no sense that we have so many components supporting the same use case.
This one is specialized for counting / showing a count, so we should stick with that behavior.
If there are complains about this, we still could add a unit
prop where you can put n('row', 'rows')
and the result would be 1 row
, 99 rows
, 1k rows
. But lets see if this is needed.
/backport to next |
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.
Awesome @ShGKme, sorry for the tears :D
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.
Looks good code-wise now!
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.
Super cool!
Maybe it makes sense to provide humanizeCount
as part of @nextcloud/l10n
?
(just needs to be squashed (fixup commit)) |
I'm not sure. It's basically a browser feature, just a default compact format + getting locale from |
Signed-off-by: Grigorii K. Shartsev <me@shgk.me>
00f3adb
to
a756430
Compare
Rebased onto |
Maybe makes sense to make it easier for developers |
☑️ Resolves
Currently, the maximal number is limited via ... ellipsis. It doesn't make sense for numbers. And it is broken on Nextcloud 30 styles.
In general, having a slot doesn't make much sense for me. As the component is supposed to show a count, it is better to work with it as a number, not any content.
Instead, add an explicit
count
humanize output using:count
prop for the valuecount
orNcChip
raw
prop to disable this behavior🖼️ Screenshots
With new
count
propWith old slot
Docs for styling
🏁 Checklist
next
requested with a Vue 3 upgrade