PopinFixed.jsx 1.2KB

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