-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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(Confirm): allow custom sizes #2409
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.
Thanks for PR, I've left some comments 👍
import React, { Component } from 'react' | ||
import { Button, Confirm } from 'semantic-ui-react' | ||
|
||
class ConfirmExampleSize extends Component { |
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 a in definition export, i.e. export default class ConfirmExampleSize
class ConfirmExampleSize extends Component { | ||
state = { open: false } | ||
|
||
show = () => this.setState({ open: true }) |
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 add more sense to handler's name: show
=> handleButtonClick
size="large" | ||
header='This is a large confirm' | ||
onCancel={this.handleCancel} | ||
onConfirm={this.handleConfirm} |
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 sort props in alphabetical order
src/addons/Confirm/Confirm.d.ts
Outdated
@@ -39,6 +39,9 @@ export interface ConfirmProps extends ModalProps { | |||
|
|||
/** Whether or not the modal is visible. */ | |||
open?: boolean; | |||
|
|||
/** A modal can vary in size. */ |
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.
Typo: confirm can vary in size
src/addons/Confirm/Confirm.js
Outdated
@@ -46,6 +46,9 @@ class Confirm extends Component { | |||
|
|||
/** Whether or not the modal is visible. */ | |||
open: PropTypes.bool, | |||
|
|||
/** A modal can vary in size */ | |||
size: PropTypes.oneOf(['fullscreen', 'large', 'mini', 'small', 'tiny']), |
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.
Let's also add a small
as value to defaultProps
@@ -40,13 +40,13 @@ describe('Confirm', () => { | |||
mapValueToProps: content => ({ content }), | |||
}) | |||
|
|||
it('renders a small Modal', () => { | |||
wrapperShallow(<Confirm />) | |||
it('renders a large Modal', () => { |
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 update this test:
describe('children', () => {
it('renders a Modal', () => {
shallow(<Confirm />)
.type()
.should.equal(Modal)
})
})
describe('size', () => {
it('has "small" size by default', () => {
shallow(<Confirm />)
.should.have.prop('size', 'small')
})
_.forEach(['fullscreen', 'large', 'mini', 'small', 'tiny'], size => {
it(`applies "${size}" size', () => {
shallow(<Confirm size={size} />)
.should.have.prop('size', size)
})
})
})
@aabustamante yes, it's a known problem, rerun tests and everything should be fine. There are also lint issues: Run |
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.
Hi, @layershifter. I am a little bit confused. I think maybe my name was not the one you wanted to mention, anyway I added some comments.
<Button onClick={this.show}>Show Large</Button> | ||
<Confirm | ||
open={this.state.open} | ||
size="large" |
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 keep consistency with single quotes.
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.
Hi, @layershifter. I noticed that there is another file in this same path called ConfirmExampleButtons
updated a year ago. This file I mention also mixes single quotes and double quotes, I remember that there are some lint tests for this, could this be indicating that these files are not in the coverage of the lint test? or maybe I'm wrong and there is no test for this, if that's the case I think we should create one, what do you think?.
Codecov Report
@@ Coverage Diff @@
## master #2409 +/- ##
==========================================
- Coverage 99.73% 99.73% -0.01%
==========================================
Files 152 152
Lines 2672 2664 -8
==========================================
- Hits 2665 2657 -8
Misses 7 7
Continue to review full report at Codecov.
|
src/addons/Confirm/Confirm.js
Outdated
@@ -46,12 +46,16 @@ class Confirm extends Component { | |||
|
|||
/** Whether or not the modal is visible. */ | |||
open: PropTypes.bool, | |||
|
|||
/** A modal can vary in size */ |
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.
This should say Confirm
and have a period:
- /** A modal can vary in size */
+ /** A Confirm can vary in size. */
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.
Note, I tried to update this but it is on @ashurbeyli's master
branch which I cannot push to.
Although we can add this here, all extra Confirm props are passed to the underlying Modal automatically. If we hoist one, we should technically hoist them all. There is an issue for that in #1169. Again, we can merge this one for now once comments are addressed. |
Cool, was just about to make a release. I'll wait for this to pass. |
Thank you! |
Released in |
fixes: #2405