@graphcommerce/framer-utils 6.0.0-canary.28 → 6.0.0-canary.30

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,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 6.0.0-canary.30
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1829](https://github.com/graphcommerce-org/graphcommerce/pull/1829) [`52ecfc2ad`](https://github.com/graphcommerce-org/graphcommerce/commit/52ecfc2ad25fc6ef92465862fb94c1829bdd7c52) - Dynamic viewport height when supported ([@bramvanderholst](https://github.com/bramvanderholst))
8
+
9
+ ## 6.0.0-canary.29
10
+
3
11
  ## 6.0.0-canary.28
4
12
 
5
13
  ### Patch Changes
@@ -2,6 +2,7 @@ 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 sync from 'framesync'
5
6
  import { useIsomorphicLayoutEffect } from './useIsomorphicLayoutEffect'
6
7
 
7
8
  export type UseClientSizeReturn = { x: MotionValue<string>; y: MotionValue<string> }
@@ -9,17 +10,17 @@ export type UseClientSizeOptions = { x?: string; y?: string }
9
10
 
10
11
  /** @deprecated Please use dvh() or dvw() instead */
11
12
  export const clientSizeCssVar = {
12
- y: `var(--client-size-y, 100vh)`,
13
- x: `var(--client-size-x, 100vw)`,
13
+ y: `var(--client-size-y)`,
14
+ x: `var(--client-size-x)`,
14
15
  }
15
16
 
16
17
  export const dvh = (p = 100) => {
17
- if (p === 100) return 'var(--client-size-y, 100vh)'
18
- return `calc(var(--client-size-y, 100vh) * ${p / 100})`
18
+ if (p === 100) return 'var(--client-size-y)'
19
+ return `calc(var(--client-size-y) * ${p / 100})`
19
20
  }
20
21
  export const dvw = (p = 100) => {
21
- if (p === 100) return 'var(--client-size-x, 100vw)'
22
- return `calc(var(--client-size-x, 100vw) * ${p / 100})`
22
+ if (p === 100) return 'var(--client-size-x)'
23
+ return `calc(var(--client-size-x) * ${p / 100})`
23
24
  }
24
25
 
25
26
  let watching = false
@@ -32,19 +33,24 @@ export function useMeasureDynamicViewportSize() {
32
33
  useIsomorphicLayoutEffect(() => {
33
34
  if (watching === true) return () => {}
34
35
 
36
+ const hasSupport = globalThis.CSS?.supports?.('height: 100dvh') ?? false
37
+
38
+ if (hasSupport) return () => {}
39
+
35
40
  const recalc = () => {
36
41
  document.body.style.setProperty('--client-size-x', `${global.window?.innerWidth ?? 0}px`)
37
42
  document.body.style.setProperty('--client-size-y', `${global.window?.innerHeight ?? 0}px`)
38
43
  }
44
+ const recalcSynced = () => sync.read(recalc)
39
45
 
40
- window.addEventListener('resize', recalc)
46
+ window.addEventListener('resize', recalcSynced)
41
47
 
42
- recalc()
48
+ recalcSynced()
43
49
  watching = true
44
50
 
45
51
  return () => {
46
52
  watching = false
47
- window.removeEventListener('resize', recalc)
53
+ window.removeEventListener('resize', recalcSynced)
48
54
  }
49
55
  }, [])
50
56
  }
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": "6.0.0-canary.28",
5
+ "version": "6.0.0-canary.30",
6
6
  "sideEffects": false,
7
7
  "scripts": {
8
8
  "dev": "tsc -W"
@@ -15,9 +15,9 @@
15
15
  }
16
16
  },
17
17
  "devDependencies": {
18
- "@graphcommerce/eslint-config-pwa": "6.0.0-canary.28",
19
- "@graphcommerce/prettier-config-pwa": "6.0.0-canary.28",
20
- "@graphcommerce/typescript-config-pwa": "6.0.0-canary.28"
18
+ "@graphcommerce/eslint-config-pwa": "6.0.0-canary.30",
19
+ "@graphcommerce/prettier-config-pwa": "6.0.0-canary.30",
20
+ "@graphcommerce/typescript-config-pwa": "6.0.0-canary.30"
21
21
  },
22
22
  "peerDependencies": {
23
23
  "framer-motion": "^7.0.0",