Skip to content

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

Merged
merged 1 commit into from
Feb 11, 2017

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Feb 5, 2017

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 and onConfirm, now it handled inside Confirm component.

@levithomason I think we need to mark this change as breaking. Before data was Button's props while after this PR it will Confirms props.

@codecov-io
Copy link

codecov-io commented Feb 5, 2017

Codecov Report

Merging #1282 into master will increase coverage by -3.83%.

@@            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
Impacted Files Coverage Δ
src/modules/Modal/ModalContent.js 100% <100%> (ø)
src/addons/Confirm/Confirm.js 100% <100%> (ø)
src/modules/Modal/ModalHeader.js 100% <100%> (ø)
src/views/Card/CardDescription.js 100% <ø> (ø)
src/views/Card/CardContent.js 100% <ø> (ø)
src/views/Card/CardGroup.js 100% <ø> (ø)
src/views/Card/Card.js 100% <ø> (ø)
src/views/Card/CardMeta.js 100% <ø> (ø)
src/views/Card/CardHeader.js 100% <ø> (ø)
...ections/Menu/Types/MenuExampleVerticalSecondary.js 66.66% <ø> (ø)
... and 742 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 070178e...44bf621. Read the comment docs.

type: META.TYPES.ADDON,
}
/** The OK button text. */
confirmButton: PropTypes.string,
Copy link
Member Author

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,

Copy link
Member

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. 👍

Copy link
Member Author

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 😄

Copy link
Member

@levithomason levithomason left a 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.

type: META.TYPES.ADDON,
}
/** The OK button text. */
confirmButton: PropTypes.string,
Copy link
Member

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. 👍

return (
<Modal {...rest} {...openProp} size='small' onClose={this.handleCancel}>
{createShorthand(Modal.Header, val => ({ children: val }), header)}
{createShorthand(Modal.Content, val => ({ children: val }), content)}
Copy link
Member

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.

/** The OK button text */
confirmButton: PropTypes.string,
/**
* Called when the Cancel button is clicked.
Copy link
Member

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.

header?: any;

/**
* Called when the Cancel button is clicked.
Copy link
Member

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.

@levithomason
Copy link
Member

Warning. This PR updates behavior of onCancel and onConfirm, now it handled inside Confirm component.

@levithomason I think we need to mark this change as breaking. Before data was Button's props while after this PR it will Confirms props.

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 data parameter, so it was not a supported feature.

@layershifter
Copy link
Member Author

@levithomason I've updated PR, take a look 😄

@levithomason levithomason merged commit 5321032 into master Feb 11, 2017
@levithomason levithomason deleted the style/confirm branch February 11, 2017 06:04
@levithomason
Copy link
Member

Released in [email protected].

harel pushed a commit to harel/Semantic-UI-React that referenced this pull request Feb 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants