@jobber/hooks 2.7.1 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -48,23 +48,17 @@ function cleanup() {
|
|
|
48
48
|
window.innerWidth = defaultInnerWidth;
|
|
49
49
|
}
|
|
50
50
|
function isQueryMatching(query) {
|
|
51
|
-
const match = query.match(/(
|
|
51
|
+
const match = query.match(/(min-width|max-width):\s*(\d+)/);
|
|
52
52
|
if (!match)
|
|
53
53
|
return false;
|
|
54
54
|
const { innerWidth } = window;
|
|
55
|
-
const [,
|
|
55
|
+
const [, operator, value] = match;
|
|
56
56
|
const breakpoint = parseInt(value, 10);
|
|
57
57
|
switch (operator) {
|
|
58
|
-
case "
|
|
59
|
-
return innerWidth < breakpoint;
|
|
60
|
-
case "<=":
|
|
58
|
+
case "max-width":
|
|
61
59
|
return innerWidth <= breakpoint;
|
|
62
|
-
case "
|
|
63
|
-
return innerWidth > breakpoint;
|
|
64
|
-
case ">=":
|
|
60
|
+
case "min-width":
|
|
65
61
|
return innerWidth >= breakpoint;
|
|
66
|
-
case "=":
|
|
67
|
-
return innerWidth === breakpoint;
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
64
|
exports.isQueryMatching = isQueryMatching;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const mockViewportWidth_1 = require("./mockViewportWidth");
|
|
4
4
|
describe("isQueryMatching", () => {
|
|
5
|
-
it
|
|
6
|
-
const result = (0, mockViewportWidth_1.isQueryMatching)(`width ${
|
|
5
|
+
it("should return false on max-width", () => {
|
|
6
|
+
const result = (0, mockViewportWidth_1.isQueryMatching)(`max-width: ${window.innerWidth - 1}`);
|
|
7
7
|
expect(result).toBe(false);
|
|
8
8
|
});
|
|
9
|
-
it
|
|
10
|
-
const result = (0, mockViewportWidth_1.isQueryMatching)(`width ${
|
|
9
|
+
it("should return true on min-width", () => {
|
|
10
|
+
const result = (0, mockViewportWidth_1.isQueryMatching)(`min-width: ${window.innerWidth}`);
|
|
11
11
|
expect(result).toBe(true);
|
|
12
12
|
});
|
|
13
13
|
it("should return false when the width is not a number", () => {
|
|
@@ -8,11 +8,12 @@ exports.BREAKPOINT_SIZES = { sm: 490, md: 768, lg: 1080, xl: 1440 };
|
|
|
8
8
|
* [supported breakpoints](https://atlantis.getjobber.com/?path=/docs/design-breakpoints--page).
|
|
9
9
|
*/
|
|
10
10
|
function useBreakpoints() {
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
11
|
+
const { sm, md, lg, xl } = exports.BREAKPOINT_SIZES;
|
|
12
|
+
const extraSmallOnly = (0, useMediaQuery_1.useMediaQuery)(`(max-width: ${sm - 1}px)`);
|
|
13
|
+
const smallAndUp = (0, useMediaQuery_1.useMediaQuery)(`(min-width: ${sm}px)`);
|
|
14
|
+
const mediumAndUp = (0, useMediaQuery_1.useMediaQuery)(`(min-width: ${md}px)`);
|
|
15
|
+
const largeAndUp = (0, useMediaQuery_1.useMediaQuery)(`(min-width: ${lg}px)`);
|
|
16
|
+
const extraLargeAndUp = (0, useMediaQuery_1.useMediaQuery)(`(min-width: ${xl}px)`);
|
|
16
17
|
return {
|
|
17
18
|
smallAndUp,
|
|
18
19
|
mediumAndUp,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/hooks",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.js",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@apollo/client": "^3.0.0",
|
|
45
45
|
"react": "^18"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "e925163219d4d3c15d78318cfff03f6240c19ef3"
|
|
48
48
|
}
|