@graphcommerce/framer-utils 3.0.5 → 3.1.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1399](https://github.com/graphcommerce-org/graphcommerce/pull/1399) [`da0ae7d02`](https://github.com/graphcommerce-org/graphcommerce/commit/da0ae7d0236e4908ba0bf0fa16656be516e841d4) Thanks [@paales](https://github.com/paales)! - Updated dependencies
8
+
9
+ ## 3.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1369](https://github.com/graphcommerce-org/graphcommerce/pull/1369) [`ae6449502`](https://github.com/graphcommerce-org/graphcommerce/commit/ae64495024a455bbe5188588604368c1542840c9) Thanks [@paales](https://github.com/paales)! - Upgraded dependencies
14
+
15
+ ## 3.1.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#1360](https://github.com/graphcommerce-org/graphcommerce/pull/1360) [`829b8690b`](https://github.com/graphcommerce-org/graphcommerce/commit/829b8690bc5d0a46e596299e4120e9837a9f179c) Thanks [@paales](https://github.com/paales)! - Add a clientSizeCssVar that will change when the viewport changes size, as a better alternative for 100vh and in preparation for 100dvh
20
+
3
21
  ## 3.0.5
4
22
 
5
23
  ### Patch Changes
@@ -2,10 +2,40 @@ import { motionValue, MotionValue } from 'framer-motion'
2
2
  import { useEffect } from 'react'
3
3
  import { clientSize } from '../utils/clientSize'
4
4
  import { useConstant } from './useConstant'
5
+ import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
5
6
 
6
7
  export type UseClientSizeReturn = { x: MotionValue<string>; y: MotionValue<string> }
7
8
  export type UseClientSizeOptions = { x?: string; y?: string }
8
9
 
10
+ export const clientSizeCssVar = {
11
+ y: `var(--client-size-y, 100vh)`,
12
+ x: `var(--client-size-x, 100vh)`,
13
+ }
14
+
15
+ let watching = false
16
+
17
+ export function useClientSizeCssVar() {
18
+ useIsomorphicLayoutEffect(() => {
19
+ if (watching === true) return () => {}
20
+
21
+ const recalc = () => {
22
+ if (typeof window !== 'undefined') {
23
+ const { x, y } = clientSize
24
+ document.body.style.setProperty('--client-size-x', `${x.get()}px`)
25
+ document.body.style.setProperty('--client-size-y', `${y.get()}px`)
26
+ }
27
+ }
28
+ recalc()
29
+ watching = true
30
+ const reset = clientSize.y.onChange(recalc)
31
+
32
+ return () => {
33
+ watching = false
34
+ reset()
35
+ }
36
+ }, [])
37
+ }
38
+
9
39
  /**
10
40
  * Get the clientSize x|y as a motionValue
11
41
  *
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": "3.0.5",
5
+ "version": "3.1.2",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"
@@ -15,10 +15,10 @@
15
15
  }
16
16
  },
17
17
  "devDependencies": {
18
- "@graphcommerce/eslint-config-pwa": "^4.0.5",
19
- "@graphcommerce/prettier-config-pwa": "^4.0.3",
18
+ "@graphcommerce/eslint-config-pwa": "^4.1.5",
19
+ "@graphcommerce/prettier-config-pwa": "^4.0.6",
20
20
  "@graphcommerce/typescript-config-pwa": "^4.0.2",
21
- "@playwright/test": "^1.19.2"
21
+ "@playwright/test": "^1.21.1"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "framer-motion": "^6.2.4",