size.js.flow 559 B

1234567891011121314151617181920212223242526272829
  1. // @flow
  2. import type { Styles } from '../types/style'
  3. /**
  4. * Shorthand to set the height and width properties in a single statement.
  5. * @example
  6. * // Styles as object usage
  7. * const styles = {
  8. * ...size('300px', '250px')
  9. * }
  10. *
  11. * // styled-components usage
  12. * const div = styled.div`
  13. * ${size('300px', '250px')}
  14. * `
  15. *
  16. * // CSS as JS Output
  17. *
  18. * div {
  19. * 'height': '300px',
  20. * 'width': '250px',
  21. * }
  22. */
  23. export default function size(height: string | number, width?: string | number = height): Styles {
  24. return {
  25. height,
  26. width,
  27. }
  28. }