PopinFixedContent.jsx 1.2KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import React from 'react'
  2. import classnames from 'classnames'
  3. import PropTypes from 'prop-types'
  4. const PopinFixedContent = props => {
  5. return props.children.length === 2
  6. ? (
  7. <div className={classnames('wsContentGeneric__content', `${props.customClass}__content`)}>
  8. <div className={classnames('wsContentGeneric__content__left', `${props.customClass}__content__left`)}>
  9. {props.children[0]}
  10. </div>
  11. <div className={classnames('wsContentGeneric__content__right', `${props.customClass}__content__right`)}>
  12. {props.children[1]}
  13. </div>
  14. </div>
  15. )
  16. : (
  17. <div className={classnames('wsContentGeneric__content', `${props.customClass}__content`)}>
  18. { props.children }
  19. </div>
  20. )
  21. }
  22. export default PopinFixedContent
  23. PopinFixedContent.propTypes = {
  24. customClass: PropTypes.string,
  25. children: (props, propName, componentName) => {
  26. if (Array.isArray(props) && props.length !== 2) {
  27. return new Error(`PropType Error: ${componentName} must have 1 or 2 children.`)
  28. } else if (typeof props !== 'object') {
  29. return new Error(`PropType Error: childrens of ${componentName} must have 1 or 2 children.`)
  30. }
  31. }
  32. }