flexFlow.js 781 B

12345678910111213141516171819202122232425262728293031323334
  1. 'use strict';
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = normalizeFlexFlow;
  6. // flex-flow: <flex-direction> || <flex-wrap>
  7. const flexDirection = ['row', 'row-reverse', 'column', 'column-reverse'];
  8. const flexWrap = ['nowrap', 'wrap', 'wrap-reverse'];
  9. function normalizeFlexFlow(flexFlow) {
  10. let order = {
  11. direction: '',
  12. wrap: ''
  13. };
  14. flexFlow.walk(({ value }) => {
  15. if (~flexDirection.indexOf(value.toLowerCase())) {
  16. order.direction = value;
  17. return;
  18. }
  19. if (~flexWrap.indexOf(value.toLowerCase())) {
  20. order.wrap = value;
  21. return;
  22. }
  23. });
  24. return `${order.direction} ${order.wrap}`.trim();
  25. };
  26. module.exports = exports['default'];