You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
728 B

  1. import { Motion, spring } from 'react-motion';
  2. const Collapsable = ({ fullHeight, isVisible, children }) => (
  3. <Motion defaultStyle={{ opacity: !isVisible ? 0 : 100, height: isVisible ? fullHeight : 0 }} style={{ opacity: spring(!isVisible ? 0 : 100), height: spring(!isVisible ? 0 : fullHeight) }}>
  4. {({ opacity, height }) =>
  5. <div style={{ height: `${height}px`, overflow: 'hidden', opacity: opacity / 100, display: Math.floor(opacity) === 0 ? 'none' : 'block' }}>
  6. {children}
  7. </div>
  8. }
  9. </Motion>
  10. );
  11. Collapsable.propTypes = {
  12. fullHeight: React.PropTypes.number.isRequired,
  13. isVisible: React.PropTypes.bool.isRequired,
  14. children: React.PropTypes.node.isRequired
  15. };
  16. export default Collapsable;