@graphcommerce/framer-utils 9.0.0-canary.114 → 9.0.0-canary.116
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/CHANGELOG.md
CHANGED
|
@@ -1,20 +1,10 @@
|
|
|
1
1
|
import type { MotionValue } from 'framer-motion'
|
|
2
|
-
import { motionValue } from 'framer-motion'
|
|
3
2
|
import sync from 'framesync'
|
|
4
|
-
import { useEffect } from 'react'
|
|
5
|
-
import { clientSize } from '../utils/clientSize'
|
|
6
|
-
import { useConstant } from './useConstant'
|
|
7
3
|
import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
|
|
8
4
|
|
|
9
5
|
export type UseClientSizeReturn = { x: MotionValue<string>; y: MotionValue<string> }
|
|
10
6
|
export type UseClientSizeOptions = { x?: string; y?: string }
|
|
11
7
|
|
|
12
|
-
/** @deprecated Please use dvh() or dvw() instead */
|
|
13
|
-
export const clientSizeCssVar = {
|
|
14
|
-
y: 'var(--client-size-y)',
|
|
15
|
-
x: 'var(--client-size-x)',
|
|
16
|
-
}
|
|
17
|
-
|
|
18
8
|
export const dvh = (p = 100) => {
|
|
19
9
|
if (p === 100) return 'var(--client-size-y)'
|
|
20
10
|
return `calc(var(--client-size-y) * ${p / 100})`
|
|
@@ -55,36 +45,3 @@ export function useMeasureDynamicViewportSize() {
|
|
|
55
45
|
}
|
|
56
46
|
}, [])
|
|
57
47
|
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Get the clientSize x|y as a motionValue
|
|
61
|
-
*
|
|
62
|
-
* ```tsx
|
|
63
|
-
* function MyComponent() {
|
|
64
|
-
* const { y } = useClientSize({ y: '100vh' })
|
|
65
|
-
* return <motion.div style={{ height: y }}>bla</motion.div>
|
|
66
|
-
* }
|
|
67
|
-
* ```
|
|
68
|
-
*
|
|
69
|
-
* @deprecated Use `var(--client-size-y)` or `var(--client-size-x)` instead
|
|
70
|
-
*/
|
|
71
|
-
export function useClientSize(options?: UseClientSizeOptions): UseClientSizeReturn {
|
|
72
|
-
const ret = useConstant<UseClientSizeReturn>(() => ({
|
|
73
|
-
x: motionValue(options?.x ?? '0px'),
|
|
74
|
-
y: motionValue(options?.y ?? '0px'),
|
|
75
|
-
}))
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
setTimeout(() => ret.x.set(`${clientSize.x.get()}px`), 1000)
|
|
79
|
-
const cX = clientSize.x.on('change', (xv) => ret.x.set(`${xv}px`))
|
|
80
|
-
return () => cX()
|
|
81
|
-
}, [ret.x])
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
setTimeout(() => ret.y.set(`${clientSize.y.get()}px`), 1000)
|
|
85
|
-
const cY = clientSize.y.on('change', (yv) => ret.y.set(`${yv}px`))
|
|
86
|
-
return () => cY()
|
|
87
|
-
}, [ret.y])
|
|
88
|
-
|
|
89
|
-
return ret
|
|
90
|
-
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/framer-utils",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.0.0-canary.
|
|
5
|
+
"version": "9.0.0-canary.116",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"dev": "tsc -W"
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.
|
|
19
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.
|
|
20
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.
|
|
18
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.116",
|
|
19
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.116",
|
|
20
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.116",
|
|
21
21
|
"framer-motion": "^11.0.0",
|
|
22
22
|
"react": "^18.2.0",
|
|
23
23
|
"react-dom": "^18.2.0"
|