-
Notifications
You must be signed in to change notification settings - Fork 309
Refactor Button component. #10824
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
base: develop
Are you sure you want to change the base?
Refactor Button component. #10824
Conversation
Build files for d06317f are ready:
|
Size Change: +3.55 kB (+0.17%) Total Size: 2.13 MB ℹ️ View Unchanged
|
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.
Brilliant work here, thank you @ankitrox!
I've left a few minor comments for your consideration. Please let me if you have any questions or concerns, thank you!
assets/js/googlesitekit/components-gm2/Button/MaybeTooltip.test.js
Outdated
Show resolved
Hide resolved
assets/js/googlesitekit/components-gm2/Button/SemanticButton.test.js
Outdated
Show resolved
Hide resolved
assets/js/googlesitekit/components-gm2/Button/SemanticButton.test.js
Outdated
Show resolved
Hide resolved
Thank you @nfmohit for reviewing the PR and adding your valuable suggestions. I've addressed the feedback and sending it your way to review those. Thanks again! |
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.
Thank you for addressing my feedback, @ankitrox!
I've left a few last-minute comments for your consideration. Please let me know if you have any questions or concerns, thank you!
MaybeTooltip.defaultProps = { | ||
disabled: false, | ||
tooltip: false, | ||
tooltipTitle: null, | ||
hasIconOnly: false, | ||
tooltipEnterDelayInMS: 100, | ||
}; |
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.
Let's use default parameters in the exported function, as defaultProps
on functional components will eventually be deprecated (see RFC).
With that said, as we're already refactoring, we should apply this refactor to the parent component too, if capacity permits, thank you!
} | ||
); | ||
|
||
SemanticButton.displayName = 'SemanticButton'; |
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.
Sorry for not flagging this earlier, but I don't think the displayName
property is necessary here, as it should ideally only be used when the component should be labelled differently than the exported function.
This should also be removed from the parent component, IMO.
SemanticButton.propTypes = { | ||
children: PropTypes.node, | ||
href: PropTypes.string, | ||
text: PropTypes.bool, | ||
className: PropTypes.string, | ||
danger: PropTypes.bool, | ||
disabled: PropTypes.bool, | ||
target: PropTypes.string, | ||
icon: PropTypes.element, | ||
trailingIcon: PropTypes.element, | ||
'aria-label': PropTypes.string, | ||
inverse: PropTypes.bool, | ||
tertiary: PropTypes.bool, | ||
callout: PropTypes.bool, | ||
calloutStyle: PropTypes.oneOf( [ 'primary', 'warning', 'error' ] ), | ||
title: PropTypes.string, | ||
customizedTooltip: PropTypes.element, | ||
tooltip: PropTypes.bool, | ||
hideTooltipTitle: PropTypes.bool, | ||
tooltipEnterDelayInMS: PropTypes.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.
I don't think icon
, trailingIcon
, title
, customizedTooltip
, tooltip
, hideTooltipTitle
, and tooltipEnterDelayInMS
are valid props for this component.
SemanticButton.propTypes = { | |
children: PropTypes.node, | |
href: PropTypes.string, | |
text: PropTypes.bool, | |
className: PropTypes.string, | |
danger: PropTypes.bool, | |
disabled: PropTypes.bool, | |
target: PropTypes.string, | |
icon: PropTypes.element, | |
trailingIcon: PropTypes.element, | |
'aria-label': PropTypes.string, | |
inverse: PropTypes.bool, | |
tertiary: PropTypes.bool, | |
callout: PropTypes.bool, | |
calloutStyle: PropTypes.oneOf( [ 'primary', 'warning', 'error' ] ), | |
title: PropTypes.string, | |
customizedTooltip: PropTypes.element, | |
tooltip: PropTypes.bool, | |
hideTooltipTitle: PropTypes.bool, | |
tooltipEnterDelayInMS: PropTypes.number, | |
}; | |
SemanticButton.propTypes = { | |
children: PropTypes.node, | |
href: PropTypes.string, | |
text: PropTypes.bool, | |
className: PropTypes.string, | |
danger: PropTypes.bool, | |
disabled: PropTypes.bool, | |
target: PropTypes.string, | |
'aria-label': PropTypes.string, | |
inverse: PropTypes.bool, | |
tertiary: PropTypes.bool, | |
callout: PropTypes.bool, | |
calloutStyle: PropTypes.oneOf( [ 'primary', 'warning', 'error' ] ), | |
}; |
Thanks @nfmohit, I have made the changes suggested above. Assigning this to you for another review. |
Summary
Addresses issue:
assets/js/googlesitekit/components-gm2/Button.js
#10357Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist