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
[Badge] Give Badge dynamic width and other improvements #14121
Conversation
1753645
to
ed6f737
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.
The animation of the Show Badge
label in the documentation doesn't longer work.
There is some small breaking change here, depends on how we see it. I would say we should release it in a minor rather than a patch.
one possible fix for the show/hide animation:
|
23698bd
to
e8a1d87
Compare
6f273c6
to
ed19cf5
Compare
ed19cf5
to
d03a42d
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.
Currently, it's a breaking change due to showZero but we can always invert this and call it hideZero and potentially revert back after v4
Shouldn't this be targeted at next
then?
I would call it a bug fix. What's the use case for showing a badge when it's zero? |
If there isn't one, do we really need the showZero prop? |
let displayValue = ''; | ||
|
||
if (variant !== 'dot') { | ||
displayValue = badgeContent > max ? `${max}+` : badgeContent; |
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.
So now badgeContent
is not a node as specified by the TypeScript/PropTypes definitions, but must be a number?
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.
@kLabz Do you have a specific issue using a node? 'hello' > 99 = false
, ({}) > 99 = false
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.
Not really, but this feels really weird. If other node types are still considered supported, it's fine for me 👍
(Context: I am writing type definitions for a statically typed language so if the type changed I would have updated to the equivalent of number
)
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.
It's true that we don't have any test with a react node. I think that we should add one.
@@ -95,7 +120,7 @@ Badge.propTypes = { | |||
/** | |||
* The content rendered within the badge. | |||
*/ | |||
badgeContent: PropTypes.node.isRequired, | |||
badgeContent: PropTypes.node, |
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.
TS should be updated too if this prop is not mandatory any 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.
@kLabz Yes, it should. Do you want to take care of it? Well spotted.
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.
Done (#14186, I hope I was supposed to target next
)
Closes #14105
Demo: https://deploy-preview-14121--material-ui.netlify.com/demos/badges/
Currently, it's a breaking change due to showZero but we can always invert this and call it hideZero and potentially revert back after v4
Added properties:
To Do