Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. import PropTypes from 'prop-types';
  2. import styled, { css } from 'styled-components';
  3.  
  4. const FlexBox = styled.div`
  5. align-content: ${({ alignContent }) => alignContent};
  6. align-items: ${({ alignItems }) => alignItems};
  7. display: ${({ display }) => display};
  8.  
  9. ${({ flexFlow }) => !flexFlow && css`
  10. flex-direction: ${({ flexDirection }) => flexDirection};
  11. flex-wrap: ${({ flexWrap }) => flexWrap};
  12. `}
  13.  
  14. ${({ flexFlow }) => flexFlow && css`
  15. flex-flow: ${flexFlow};
  16. `}
  17.  
  18. justify-content: ${({ justifyContent }) => justifyContent};
  19. width: ${({ width }) => width};
  20. `;
  21.  
  22. FlexBox.propTypes = {
  23. alignContent: PropTypes.oneOf([
  24. 'flex-start', 'flex-end', 'center',
  25. 'space-between', 'space-around', 'stretch',
  26. ]),
  27. alignItems: PropTypes.oneOf(['stretch', 'flex-start', 'flex-end', 'center', 'baseline']),
  28. display: PropTypes.oneOf(['inline-flex', 'flex']),
  29. flexDirection: PropTypes.oneOf(['row', 'row-reverse', 'column', 'column-reverse']),
  30. flexFlow: PropTypes.string,
  31. flexWrap: PropTypes.oneOf(['nowrap', 'wrap', 'wrap-reverse']),
  32. justifyContent: PropTypes.oneOf([
  33. 'flex-start', 'flex-end', 'center',
  34. 'space-between', 'space-around', 'space-evenly',
  35. ]),
  36. };
  37.  
  38. FlexBox.defaultProps = {
  39. alignContent: 'stretch',
  40. alignItems: 'stretch',
  41. display: 'flex',
  42. flexDirection: 'row',
  43. flexFlow: null,
  44. flexWrap: 'wrap',
  45. justifyContent: 'flex-start',
  46. width: 'auto',
  47. };
  48.  
  49. FlexBox.displayName = 'FlexBox';
  50.  
  51. export default Flexbox;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement