PopinFixed.jsx 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import React from 'react'
  2. import classnames from 'classnames'
  3. import PropTypes from 'prop-types'
  4. import PopinFixedHeader from './PopinFixedHeader.jsx'
  5. import PopinFixedOption from './PopinFixedOption.jsx'
  6. import PopinFixedContent from './PopinFixedContent.jsx'
  7. require('./PopinFixed.styl')
  8. const PopinFixed = props => {
  9. return (
  10. <div className={classnames('wsContentGeneric', props.customClass, {'visible': props.visible})} style={props.style}>
  11. {props.children}
  12. </div>
  13. )
  14. }
  15. export default PopinFixed
  16. PopinFixed.propTypes = {
  17. // from http://www.mattzabriskie.com/blog/react-validating-children
  18. children: PropTypes.arrayOf((children, key, componentName /* , location, propFullName */) => {
  19. if (
  20. children.length > 3 ||
  21. children[0].type !== PopinFixedHeader ||
  22. children[1].type !== PopinFixedOption ||
  23. children[2].type !== PopinFixedContent
  24. ) {
  25. return new Error(`PropType Error: childrens of ${componentName} must be: 1 PopinFixedHeader, 1 PopinFixedOption and 1 PopinFixedContent.`)
  26. }
  27. }).isRequired,
  28. customClass: PropTypes.string,
  29. visible: PropTypes.bool
  30. }
  31. PopinFixed.defaultProps = {
  32. customClass: '',
  33. visible: true
  34. }