Skip to content
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

Merged
merged 1 commit into from
Jan 10, 2018

Conversation

ashurbeyli
Copy link
Contributor

fixes: #2405

@ashurbeyli
Copy link
Contributor Author

There are 2 failed tests that is not related to this issue.

image

Copy link
Member

@layershifter layershifter left a 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 {
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 use a in definition export, i.e. export default class ConfirmExampleSize

class ConfirmExampleSize extends Component {
state = { open: false }

show = () => this.setState({ open: true })
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 add more sense to handler's name: show => handleButtonClick

size="large"
header='This is a large confirm'
onCancel={this.handleCancel}
onConfirm={this.handleConfirm}
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 sort props in alphabetical order

@@ -39,6 +39,9 @@ export interface ConfirmProps extends ModalProps {

/** Whether or not the modal is visible. */
open?: boolean;

/** A modal can vary in size. */
Copy link
Member

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

@@ -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']),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^

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 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', () => {
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 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)
    })
  })
})

@layershifter
Copy link
Member

@aabustamante yes, it's a known problem, rerun tests and everything should be fine. There are also lint issues:

image

Run yarn run lint:fix to fix them 👍

Copy link
Contributor

@aabustamante aabustamante left a 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"
Copy link
Contributor

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.

Copy link
Contributor

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 ConfirmExampleButtonsupdated 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-io
Copy link

codecov-io commented Jan 7, 2018

Codecov Report

Merging #2409 into master will decrease coverage by <.01%.
The diff coverage is n/a.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/addons/Confirm/Confirm.js 100% <ø> (ø) ⬆️
src/modules/Checkbox/Checkbox.js 100% <0%> (ø) ⬆️
src/modules/Progress/Progress.js 100% <0%> (ø) ⬆️

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 380cf90...339dd78. Read the comment docs.

@@ -46,12 +46,16 @@ class Confirm extends Component {

/** Whether or not the modal is visible. */
open: PropTypes.bool,

/** A modal can vary in size */
Copy link
Member

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. */

Copy link
Member

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.

@levithomason
Copy link
Member

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.

@levithomason
Copy link
Member

Cool, was just about to make a release. I'll wait for this to pass.

@levithomason
Copy link
Member

Thank you!

@levithomason
Copy link
Member

Released in semantic-ui-react@0.77.2

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.

Confirm: allow custom sizes
5 participants