-
Notifications
You must be signed in to change notification settings - Fork 4.1k
style(Confirm): refactor, update typings and propTypes usage #1282
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
Conversation
Codecov Report@@ Coverage Diff @@
## master #1282 +/- ##
==========================================
- Coverage 99.74% 95.92% -3.83%
==========================================
Files 140 883 +743
Lines 2394 4929 +2535
==========================================
+ Hits 2388 4728 +2340
- Misses 6 201 +195
Continue to review full report at Codecov.
|
b90d5ec
to
1986efb
Compare
src/addons/Confirm/Confirm.js
Outdated
type: META.TYPES.ADDON, | ||
} | ||
/** The OK button text. */ | ||
confirmButton: PropTypes.string, |
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'm also thinking about shorthand there too.
-confirmButton: PropTypes.string,
+confirm: customPropTypes.itemShorthand,
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.
That would be great if you'd like to implement it. 👍
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.
Okay, I'll make it today 😄
1986efb
to
7a138f0
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.
Couple changes related to shorthand. If you'd like to do these in a separate PR, we can do that as well. LMK.
src/addons/Confirm/Confirm.js
Outdated
type: META.TYPES.ADDON, | ||
} | ||
/** The OK button text. */ | ||
confirmButton: PropTypes.string, |
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.
That would be great if you'd like to implement it. 👍
src/addons/Confirm/Confirm.js
Outdated
return ( | ||
<Modal {...rest} {...openProp} size='small' onClose={this.handleCancel}> | ||
{createShorthand(Modal.Header, val => ({ children: val }), header)} | ||
{createShorthand(Modal.Content, val => ({ children: val }), content)} |
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'm slowing trying to remove use of createShorthand
in favor of adding create()
methods to the component when needed. We do plan to have shorthand for the Modal, which we currently don't, so having the create()
methods for ModalHeader and ModalContent would be helpful.
Let's remove createShorthand
and add the create()
method for these components instead.
src/addons/Confirm/Confirm.js
Outdated
/** The OK button text */ | ||
confirmButton: PropTypes.string, | ||
/** | ||
* Called when the Cancel button is clicked. |
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 correct this, "Called when the Modal is closed without clicking confirm." Since, it is called on Escape and click outside as well.
src/addons/Confirm/index.d.ts
Outdated
header?: any; | ||
|
||
/** | ||
* Called when the Cancel button is clicked. |
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.
See my comment for the onClick
propType.
Thanks, this is how it should've been written initially. I don't think we'll need to make this one breaking since the previous behavior was a bug and this fixes it. Also, the callback did not advertise a second |
7a138f0
to
44bf621
Compare
@levithomason I've updated PR, take a look 😄 |
Released in |
This PR is part of work for removing propTypes in production bundle (#524, #731).
Also, cleanups and updates typings for #1072.
Fixes #1290.
Warning. This PR updates behavior of
onCancel
andonConfirm
, now it handled insideConfirm
component.@levithomason I think we need to mark this change as breaking. Before
data
wasButton
's props while after this PR it willConfirm
s props.