margin.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = margin;
  4. var _directionalProperty = _interopRequireDefault(require("../helpers/directionalProperty"));
  5. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  6. /**
  7. * Shorthand that accepts up to four values, including null to skip a value, and maps them to their respective directions.
  8. * @example
  9. * // Styles as object usage
  10. * const styles = {
  11. * ...margin('12px', '24px', '36px', '48px')
  12. * }
  13. *
  14. * // styled-components usage
  15. * const div = styled.div`
  16. * ${margin('12px', '24px', '36px', '48px')}
  17. * `
  18. *
  19. * // CSS as JS Output
  20. *
  21. * div {
  22. * 'marginTop': '12px',
  23. * 'marginRight': '24px',
  24. * 'marginBottom': '36px',
  25. * 'marginLeft': '48px'
  26. * }
  27. */
  28. function margin() {
  29. for (var _len = arguments.length, values = new Array(_len), _key = 0; _key < _len; _key++) {
  30. values[_key] = arguments[_key];
  31. }
  32. return _directionalProperty["default"].apply(void 0, ['margin'].concat(values));
  33. }
  34. module.exports = exports.default;