npm-pkg-hook 1.8.4 → 1.8.5
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.
- package/package.json +5 -4
- package/src/hooks/useMobile/index.js +9 -40
package/package.json
CHANGED
|
@@ -6,10 +6,11 @@
|
|
|
6
6
|
"js-cookie": "3.0.1",
|
|
7
7
|
"lodash": "^4.17.21",
|
|
8
8
|
"md5": "2.3.0",
|
|
9
|
-
"moment": "^2.29.4",
|
|
9
|
+
"moment": "^2.29.4",
|
|
10
10
|
"react": "18.1.0",
|
|
11
11
|
"react-dom": "18.1.0",
|
|
12
|
-
"react-query": "^3.39.2"
|
|
12
|
+
"react-query": "^3.39.2",
|
|
13
|
+
"react-responsive": "^10.0.0"
|
|
13
14
|
},
|
|
14
15
|
"description": "description-pkg-hook",
|
|
15
16
|
"devDependencies": {
|
|
@@ -30,7 +31,7 @@
|
|
|
30
31
|
},
|
|
31
32
|
"license": "ISC",
|
|
32
33
|
"main": "/src/index.jsx",
|
|
33
|
-
"name": "npm-pkg-hook",
|
|
34
|
+
"name": "npm-pkg-hook",
|
|
34
35
|
"publishConfig": {
|
|
35
36
|
"registry": "https://registry.npmjs.org/"
|
|
36
37
|
},
|
|
@@ -44,5 +45,5 @@
|
|
|
44
45
|
"rm": "rm -rf node_modules package-lock.json && npm i",
|
|
45
46
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
46
47
|
},
|
|
47
|
-
"version": "1.8.
|
|
48
|
+
"version": "1.8.5"
|
|
48
49
|
}
|
|
@@ -1,47 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMediaQuery } from 'react-responsive'
|
|
2
2
|
|
|
3
|
-
export const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const [innerHeight, setInnerHeight] = useState(0)
|
|
8
|
-
const [innerWidth, setInnerWidth] = useState(0)
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
const handleResize = () => {
|
|
12
|
-
// Verificar si window está disponible (es decir, estamos en el lado del cliente)
|
|
13
|
-
if (typeof window !== 'undefined') {
|
|
14
|
-
const width = window.innerWidth
|
|
15
|
-
const height = window.innerHeight
|
|
16
|
-
setInnerWidth(width)
|
|
17
|
-
setInnerHeight(height)
|
|
18
|
-
callBack()
|
|
19
|
-
|
|
20
|
-
// Determinar el tipo de dispositivo
|
|
21
|
-
if (width <= 768) {
|
|
22
|
-
setIsTablet(true)
|
|
23
|
-
} else if (width <= 960) {
|
|
24
|
-
setIsMobile(true)
|
|
25
|
-
} else {
|
|
26
|
-
setIsMobile(false)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Ejecutar handleResize al cargar y al cambiar el tamaño de la pantalla
|
|
32
|
-
handleResize()
|
|
33
|
-
window.addEventListener('resize', handleResize)
|
|
3
|
+
export const MEDIA_QUERY = {
|
|
4
|
+
MOBILE: '768px',
|
|
5
|
+
TABLED: '960px'
|
|
6
|
+
}
|
|
34
7
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
}, [callBack])
|
|
8
|
+
export const useMobile = () => {
|
|
9
|
+
const isMobile = useMediaQuery({ query: `(max-width: ${MEDIA_QUERY.MOBILE})` })
|
|
10
|
+
const isTablet = useMediaQuery({ query: `(max-width: ${MEDIA_QUERY.TABLED}})` })
|
|
40
11
|
|
|
41
12
|
return {
|
|
42
13
|
isMobile,
|
|
43
|
-
isTablet
|
|
44
|
-
innerHeight,
|
|
45
|
-
innerWidth
|
|
14
|
+
isTablet
|
|
46
15
|
}
|
|
47
16
|
}
|