1 | "use strict";
|
2 |
|
3 | var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", {
|
6 | value: true
|
7 | });
|
8 | exports.default = createBreakpoints;
|
9 | exports.keys = void 0;
|
10 |
|
11 | var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
12 |
|
13 | var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
14 |
|
15 |
|
16 |
|
17 | var keys = ['xs', 'sm', 'md', 'lg', 'xl'];
|
18 |
|
19 | exports.keys = keys;
|
20 |
|
21 | function createBreakpoints(breakpoints) {
|
22 | var _breakpoints$values = breakpoints.values,
|
23 | values = _breakpoints$values === void 0 ? {
|
24 | xs: 0,
|
25 | sm: 600,
|
26 | md: 960,
|
27 | lg: 1280,
|
28 | xl: 1920
|
29 | } : _breakpoints$values,
|
30 | _breakpoints$unit = breakpoints.unit,
|
31 | unit = _breakpoints$unit === void 0 ? 'px' : _breakpoints$unit,
|
32 | _breakpoints$step = breakpoints.step,
|
33 | step = _breakpoints$step === void 0 ? 5 : _breakpoints$step,
|
34 | other = (0, _objectWithoutProperties2.default)(breakpoints, ["values", "unit", "step"]);
|
35 |
|
36 | function up(key) {
|
37 | var value = typeof values[key] === 'number' ? values[key] : key;
|
38 | return "@media (min-width:".concat(value).concat(unit, ")");
|
39 | }
|
40 |
|
41 | function down(key) {
|
42 | var endIndex = keys.indexOf(key) + 1;
|
43 | var upperbound = values[keys[endIndex]];
|
44 |
|
45 | if (endIndex === keys.length) {
|
46 |
|
47 | return up('xs');
|
48 | }
|
49 |
|
50 | var value = typeof upperbound === 'number' && endIndex > 0 ? upperbound : key;
|
51 | return "@media (max-width:".concat(value - step / 100).concat(unit, ")");
|
52 | }
|
53 |
|
54 | function between(start, end) {
|
55 | var endIndex = keys.indexOf(end);
|
56 |
|
57 | if (endIndex === keys.length - 1) {
|
58 | return up(start);
|
59 | }
|
60 |
|
61 | return "@media (min-width:".concat(typeof values[start] === 'number' ? values[start] : start).concat(unit, ") and ") + "(max-width:".concat((endIndex !== -1 && typeof values[keys[endIndex + 1]] === 'number' ? values[keys[endIndex + 1]] : end) - step / 100).concat(unit, ")");
|
62 | }
|
63 |
|
64 | function only(key) {
|
65 | return between(key, key);
|
66 | }
|
67 |
|
68 | var warnedOnce = false;
|
69 |
|
70 | function width(key) {
|
71 | if (process.env.NODE_ENV !== 'production') {
|
72 | if (!warnedOnce) {
|
73 | warnedOnce = true;
|
74 | console.warn(["Material-UI: The `theme.breakpoints.width` utility is deprecated because it's redundant.", 'Use the `theme.breakpoints.values` instead.'].join('\n'));
|
75 | }
|
76 | }
|
77 |
|
78 | return values[key];
|
79 | }
|
80 |
|
81 | return (0, _extends2.default)({
|
82 | keys: keys,
|
83 | values: values,
|
84 | up: up,
|
85 | down: down,
|
86 | between: between,
|
87 | only: only,
|
88 | width: width
|
89 | }, other);
|
90 | } |
\ | No newline at end of file |