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

add Collapse component #79 #201

Merged
merged 24 commits into from
Nov 1, 2016
Merged

add Collapse component #79 #201

merged 24 commits into from
Nov 1, 2016

Conversation

LiJinyao
Copy link
Contributor

No description provided.

this.element.style.height = `${this.getHeight()}px`;
});
this.transitionTag = setTimeout(() => {
this.setState({ collapse: SHOWN });
Copy link
Member

Choose a reason for hiding this comment

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

I believe the bootstrap js removes the height inline style after it has been shown. This would likely prevent any issues when added content and then collapsing the content again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your review! The height inline style will be removed after setState called. Because there is no style declaration in the render function, so the inline height will be removed after rerender.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh Sorry! I found the problem. I'll fix it.

import Collapse from '../Collapse';

describe('Collapse', () => {
it('should render children', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Test coverage went down. Could you setup jasmine.clock here since you're using setTimeout.

  beforeEach(() => {
    jasmine.clock().install();
  });

  afterEach(() => {
    jasmine.clock().uninstall();
  });

After prop changes, I believe you'll need to then use, jasmine.clock().tick(400); to move the virtual clock forward and test for the changes.

@@ -35,6 +35,7 @@ var paths = [
'/components/tabs/',
'/components/jumbotron/',
'/components/alerts/',
'/components/collapse',
Copy link
Member

Choose a reason for hiding this comment

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

can you add a trailing / to generate the correct route path. I noticed a console warning regarding the active class applied to the nav .

expect(wrapper.instance().props.isOpen).toEqual(false);
});

it('should render with calss "collapse"', () => {
Copy link
Member

Choose a reason for hiding this comment

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

couple of typos here, calss -> class

// will open
this.setState({ collapse: SHOW }, () => {
// start transition
this.element.style.height = `${this.getHeight()}px`;
Copy link
Member

@eddywashere eddywashere Oct 29, 2016

Choose a reason for hiding this comment

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

What are your thoughts on moving these dom attribute changes over to react via setState? Would it still work or would the timing be off? I know some components break outside the react way of doing things but I'd like to only do that when absolutely necessary. This change doesn't have to happen in this PR either.

// apply via setState
setState({height: `${this.getHeight()}px`})

// in render
<div
        {...attributes}
        style={...attributes.style, height: this.state.height}
        className={classes}
        ref={(c) => { this.element = c; }}
      />

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought the timing will be off at first, now I am trying to move these dom attribute changes to react. Let's see if it will work fine.

collapseClass
);
return (
<div
Copy link
Member

Choose a reason for hiding this comment

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

Could you update this to use the Tag (tag) prop pattern that other components use?

super(props);
this.state = {
collapse: props.isOpen ? SHOWN : HIDDEN,
height: 0,
Copy link
Member

Choose a reason for hiding this comment

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

Should height be set to null isOpen is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ops, Yes it is. Thanks for your patient review!

@eddywashere eddywashere merged commit ddbf0dd into reactstrap:master Nov 1, 2016
eddywashere pushed a commit that referenced this pull request Nov 2, 2016
#216)

* add NavbarToggler example

* feat(Collapse): add Collapse component #79 (#201)

* init collapse

* add collapse animation

* add margin between toggle button and collapse

* disable lint on force refresh DOM line.

* add test to Collapse

* remove height after shown

* Revert "remove height after shown"

This reverts commit eff9353.

* remove height after shown.

* add more test

* use setState() to set inline height style

* remove custom tag in doc

* add inline style test

* remove comment

* set height to null when isOpen is true

* add initial state test

* chore(release): adding 3.8.0 (#217)

* chore(release): adding 3.8.0

* feat(Collapse): add cssModule support

* feat(refs): add getRef to focusable components (#218)

* chore(release): adding 3.8.1 (#219)

* add NavbarToggler example

* update example to use Collapse component
@LiJinyao LiJinyao deleted the collapse branch December 10, 2016 04:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants