buildMediaQuery.js 780 B

123456789101112131415161718192021222324252627
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. Object.defineProperty(exports, "default", {
  6. enumerable: true,
  7. get: function() {
  8. return buildMediaQuery;
  9. }
  10. });
  11. function buildMediaQuery(screens) {
  12. screens = Array.isArray(screens) ? screens : [
  13. screens
  14. ];
  15. return screens.map((screen)=>{
  16. let values = screen.values.map((screen)=>{
  17. if (screen.raw !== undefined) {
  18. return screen.raw;
  19. }
  20. return [
  21. screen.min && `(min-width: ${screen.min})`,
  22. screen.max && `(max-width: ${screen.max})`
  23. ].filter(Boolean).join(" and ");
  24. });
  25. return screen.not ? `not all and ${values}` : values;
  26. }).join(", ");
  27. }