logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

collapsable.js (834B)


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