@graphcommerce/framer-utils 3.0.3 → 3.1.0

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,58 +1,60 @@
1
1
  # Change Log
2
2
 
3
+ ## 3.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#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
8
+
9
+ ## 3.0.5
10
+
11
+ ### Patch Changes
12
+
13
+ - [#1322](https://github.com/graphcommerce-org/graphcommerce/pull/1322) [`bec88d0d7`](https://github.com/graphcommerce-org/graphcommerce/commit/bec88d0d70b679e15150917df89986ecee5b39a6) Thanks [@paales](https://github.com/paales)! - ScrollerButton is rendered while it shouldn’t because there is a rounding error in scroll and offset values
14
+
15
+ ## 3.0.4
16
+
17
+ ### Patch Changes
18
+
19
+ - [#1307](https://github.com/ho-nl/m2-pwa/pull/1307) [`bd10506d3`](https://github.com/ho-nl/m2-pwa/commit/bd10506d32fdbc91d01dadc29a12ebd1e0943655) Thanks [@paales](https://github.com/paales)! - All default exports are now named exports internally and all `index.tsx` are renamed to the component name.
20
+
21
+ * [#1307](https://github.com/ho-nl/m2-pwa/pull/1307) [`27cb1f2d8`](https://github.com/ho-nl/m2-pwa/commit/27cb1f2d8dbfb8f1b301ce56fb6a2b6c1fc6a5ef) Thanks [@paales](https://github.com/paales)! - upgrade dependencies
22
+
3
23
  ## 3.0.3
4
24
 
5
25
  ### Patch Changes
6
26
 
7
- - [`973ff8645`](https://github.com/ho-nl/m2-pwa/commit/973ff86452a70ade9f4db13fdda6e963d7220e96)
8
- Thanks [@paales](https://github.com/paales)! - made packages public
27
+ - [`973ff8645`](https://github.com/ho-nl/m2-pwa/commit/973ff86452a70ade9f4db13fdda6e963d7220e96) Thanks [@paales](https://github.com/paales)! - made packages public
9
28
 
10
29
  ## 3.0.2
11
30
 
12
31
  ### Patch Changes
13
32
 
14
- - [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
15
- [`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2)
16
- Thanks [@paales](https://github.com/paales)! - We've moved lots of internal packages from
17
- `dependencies` to `peerDependencies`. The result of this is that there will be significantly less
18
- duplicate packages in the node_modules folders.
33
+ - [#1276](https://github.com/ho-nl/m2-pwa/pull/1276) [`ce09388e0`](https://github.com/ho-nl/m2-pwa/commit/ce09388e0d7ef33aee660612340f6fbae15ceec2) Thanks [@paales](https://github.com/paales)! - We've moved lots of internal packages from `dependencies` to `peerDependencies`. The result of this is that there will be significantly less duplicate packages in the node_modules folders.
19
34
 
20
- * [#1276](https://github.com/ho-nl/m2-pwa/pull/1276)
21
- [`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d)
22
- Thanks [@paales](https://github.com/paales)! - Upgraded to
23
- [NextJS 12.1](https://nextjs.org/blog/next-12-1)! This is just for compatibility, but we'll be
24
- implementing
25
- [On-demand Incremental Static Regeneration](https://nextjs.org/blog/next-12-1#on-demand-incremental-static-regeneration-beta)
26
- soon.
35
+ * [#1276](https://github.com/ho-nl/m2-pwa/pull/1276) [`52a45bba4`](https://github.com/ho-nl/m2-pwa/commit/52a45bba4dc6dd6df3c81f5023df7d23ed8a534d) Thanks [@paales](https://github.com/paales)! - Upgraded to [NextJS 12.1](https://nextjs.org/blog/next-12-1)! This is just for compatibility, but we'll be implementing [On-demand Incremental Static Regeneration](https://nextjs.org/blog/next-12-1#on-demand-incremental-static-regeneration-beta) soon.
27
36
 
28
- This will greatly reduce the requirement to rebuid stuff and we'll add a management UI on the
29
- frontend to be able to revalidate pages manually.
37
+ This will greatly reduce the requirement to rebuid stuff and we'll add a management UI on the frontend to be able to revalidate pages manually.
30
38
 
31
39
  ## 3.0.1
32
40
 
33
41
  ### Patch Changes
34
42
 
35
- - [`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514)
36
- Thanks [@paales](https://github.com/paales)! - Added homepage and repository package.json files,
37
- so that the packages link to back to the website and repository
43
+ - [`0cbaa878b`](https://github.com/ho-nl/m2-pwa/commit/0cbaa878b8a844d5abbeb1797b625a33130e6514) Thanks [@paales](https://github.com/paales)! - Added homepage and repository package.json files, so that the packages link to back to the website and repository
38
44
 
39
45
  ## 3.0.0
40
46
 
41
47
  ### Major Changes
42
48
 
43
- - [#1258](https://github.com/ho-nl/m2-pwa/pull/1258)
44
- [`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05)
45
- Thanks [@paales](https://github.com/paales)! - Upgraded to Material UI 5
49
+ - [#1258](https://github.com/ho-nl/m2-pwa/pull/1258) [`ad36382a4`](https://github.com/ho-nl/m2-pwa/commit/ad36382a4d55d83d9e47b7eb6a02671a2a631a05) Thanks [@paales](https://github.com/paales)! - Upgraded to Material UI 5
46
50
 
47
- All notable changes to this project will be documented in this file. See
48
- [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
51
+ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
49
52
 
50
53
  ## [2.103.6](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-utils@2.103.5...@graphcommerce/framer-utils@2.103.6) (2021-10-09)
51
54
 
52
55
  ### Bug Fixes
53
56
 
54
- - clientSize.x was incorrect
55
- ([39d12c4](https://github.com/ho-nl/m2-pwa/commit/39d12c4b583b7806f943dbd08c31b2dd940cc74b))
57
+ - clientSize.x was incorrect ([39d12c4](https://github.com/ho-nl/m2-pwa/commit/39d12c4b583b7806f943dbd08c31b2dd940cc74b))
56
58
 
57
59
  ## [2.103.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-utils@2.103.0...@graphcommerce/framer-utils@2.103.1) (2021-09-27)
58
60
 
@@ -62,67 +64,48 @@ All notable changes to this project will be documented in this file. See
62
64
 
63
65
  ### Bug Fixes
64
66
 
65
- - bottom sheet is not properly sized when scrolled
66
- ([93a1dc4](https://github.com/ho-nl/m2-pwa/commit/93a1dc40c37de74a8223657add77c51d51a24d92))
67
- - **framer-sheet:** bottom sheet does not resize properly
68
- ([2ae89db](https://github.com/ho-nl/m2-pwa/commit/2ae89dbd651acba10f40ac68956213dd744e2247))
69
- - **framer-utils:** reading of values didn't happen at the right moment, causing unnessary layout
70
- reflows
71
- ([b119262](https://github.com/ho-nl/m2-pwa/commit/b119262ffb2907a215f9f37f12ef6cf6f62fadcd))
72
- - **framer-utils:** state wasn't directly set when initializing useMotionValueValue
73
- ([3560456](https://github.com/ho-nl/m2-pwa/commit/35604562a4a39fef3b5dc4c0305ce0753608d9e8))
74
- - ignore md files from triggering version updates
75
- ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
67
+ - bottom sheet is not properly sized when scrolled ([93a1dc4](https://github.com/ho-nl/m2-pwa/commit/93a1dc40c37de74a8223657add77c51d51a24d92))
68
+ - **framer-sheet:** bottom sheet does not resize properly ([2ae89db](https://github.com/ho-nl/m2-pwa/commit/2ae89dbd651acba10f40ac68956213dd744e2247))
69
+ - **framer-utils:** reading of values didn't happen at the right moment, causing unnessary layout reflows ([b119262](https://github.com/ho-nl/m2-pwa/commit/b119262ffb2907a215f9f37f12ef6cf6f62fadcd))
70
+ - **framer-utils:** state wasn't directly set when initializing useMotionValueValue ([3560456](https://github.com/ho-nl/m2-pwa/commit/35604562a4a39fef3b5dc4c0305ce0753608d9e8))
71
+ - ignore md files from triggering version updates ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
76
72
 
77
73
  ### Features
78
74
 
79
- - **content-header:** text buttons on mobile - pill buttons on desktop
80
- ([1438838](https://github.com/ho-nl/m2-pwa/commit/1438838fbd2aac1e3510368f2a657314ebd05d2d))
81
- - **framer-utils:** created framer-utils and implemented for framer-sheet and framer-next-pages
82
- ([788bf28](https://github.com/ho-nl/m2-pwa/commit/788bf282d4a38ec5e78ab7244065c540dfc132a1))
83
- - **playwright:** added new playwright package to enable browser testing
84
- ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
85
- - renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of
86
- [@reachdigital](https://github.com/reachdigital)
87
- ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
75
+ - **content-header:** text buttons on mobile - pill buttons on desktop ([1438838](https://github.com/ho-nl/m2-pwa/commit/1438838fbd2aac1e3510368f2a657314ebd05d2d))
76
+ - **framer-utils:** created framer-utils and implemented for framer-sheet and framer-next-pages ([788bf28](https://github.com/ho-nl/m2-pwa/commit/788bf282d4a38ec5e78ab7244065c540dfc132a1))
77
+ - **playwright:** added new playwright package to enable browser testing ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
78
+ - renamed all packages to use [@graphcommerce](https://github.com/graphcommerce) instead of [@reachdigital](https://github.com/reachdigital) ([491e4ce](https://github.com/ho-nl/m2-pwa/commit/491e4cec9a2686472dac36b79f999257c0811ffe))
88
79
 
89
80
  # Change Log
90
81
 
91
- All notable changes to this project will be documented in this file. See
92
- [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
82
+ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
93
83
 
94
84
  ## [2.102.5](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-utils@2.102.4...@graphcommerce/framer-utils@2.102.5) (2021-09-01)
95
85
 
96
86
  ### Bug Fixes
97
87
 
98
- - **framer-utils:** reading of values didn't happen at the right moment, causing unnessary layout
99
- reflows
100
- ([b119262](https://github.com/ho-nl/m2-pwa/commit/b119262ffb2907a215f9f37f12ef6cf6f62fadcd))
101
- - **framer-utils:** state wasn't directly set when initializing useMotionValueValue
102
- ([3560456](https://github.com/ho-nl/m2-pwa/commit/35604562a4a39fef3b5dc4c0305ce0753608d9e8))
88
+ - **framer-utils:** reading of values didn't happen at the right moment, causing unnessary layout reflows ([b119262](https://github.com/ho-nl/m2-pwa/commit/b119262ffb2907a215f9f37f12ef6cf6f62fadcd))
89
+ - **framer-utils:** state wasn't directly set when initializing useMotionValueValue ([3560456](https://github.com/ho-nl/m2-pwa/commit/35604562a4a39fef3b5dc4c0305ce0753608d9e8))
103
90
 
104
91
  ## [2.102.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-utils@2.102.1...@graphcommerce/framer-utils@2.102.2) (2021-08-04)
105
92
 
106
93
  ### Bug Fixes
107
94
 
108
- - bottom sheet is not properly sized when scrolled
109
- ([93a1dc4](https://github.com/ho-nl/m2-pwa/commit/93a1dc40c37de74a8223657add77c51d51a24d92))
95
+ - bottom sheet is not properly sized when scrolled ([93a1dc4](https://github.com/ho-nl/m2-pwa/commit/93a1dc40c37de74a8223657add77c51d51a24d92))
110
96
 
111
97
  # [2.102.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-utils@2.101.1...@graphcommerce/framer-utils@2.102.0) (2021-07-26)
112
98
 
113
99
  ### Features
114
100
 
115
- - **playwright:** added new playwright package to enable browser testing
116
- ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
101
+ - **playwright:** added new playwright package to enable browser testing ([6f49ec7](https://github.com/ho-nl/m2-pwa/commit/6f49ec7595563775b96ebf21c27e39da1282e8d9))
117
102
 
118
103
  # [2.101.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/framer-utils@2.100.10...@graphcommerce/framer-utils@2.101.0) (2021-07-20)
119
104
 
120
105
  ### Bug Fixes
121
106
 
122
- - ignore md files from triggering version updates
123
- ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
107
+ - ignore md files from triggering version updates ([4f98392](https://github.com/ho-nl/m2-pwa/commit/4f9839250b3a32d3070da5290e5efcc5e2243fba))
124
108
 
125
109
  ### Features
126
110
 
127
- - **content-header:** text buttons on mobile - pill buttons on desktop
128
- ([1438838](https://github.com/ho-nl/m2-pwa/commit/1438838fbd2aac1e3510368f2a657314ebd05d2d))
111
+ - **content-header:** text buttons on mobile - pill buttons on desktop ([1438838](https://github.com/ho-nl/m2-pwa/commit/1438838fbd2aac1e3510368f2a657314ebd05d2d))
@@ -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
  *
@@ -30,23 +30,22 @@ export function useElementScroll(
30
30
  const element = ref?.current
31
31
  if (!element) return () => {}
32
32
 
33
- const setProgress = (offset: number, maxOffset: number, value: MotionValue) => {
34
- value.set(!offset && !maxOffset ? noScroll : offset / maxOffset)
35
- }
36
-
37
33
  const updater = () => {
38
34
  sync.read(() => {
39
35
  const { scrollLeft, scrollTop, scrollWidth, scrollHeight, offsetWidth, offsetHeight } =
40
36
  element
41
37
 
38
+ const xMax = Math.max(0, scrollWidth - offsetWidth)
39
+ const yMax = Math.max(0, scrollHeight - offsetHeight)
40
+
42
41
  values.x.set(scrollLeft)
43
42
  values.y.set(scrollTop)
44
- values.xMax.set(scrollWidth - offsetWidth)
45
- values.yMax.set(scrollHeight - offsetHeight)
43
+ values.xMax.set(xMax)
44
+ values.yMax.set(yMax)
46
45
 
47
46
  // Set 0-1 progress
48
- setProgress(scrollLeft, scrollWidth - offsetWidth, values.xProgress)
49
- setProgress(scrollTop, scrollHeight - offsetHeight, values.yProgress)
47
+ values.xProgress.set(!scrollLeft && !xMax ? noScroll : scrollLeft / xMax)
48
+ values.yProgress.set(!scrollTop && !yMax ? noScroll : scrollTop / yMax)
50
49
  })
51
50
  }
52
51
 
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.3",
5
+ "version": "3.1.0",
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.3",
19
- "@graphcommerce/prettier-config-pwa": "^4.0.2",
18
+ "@graphcommerce/eslint-config-pwa": "^4.1.2",
19
+ "@graphcommerce/prettier-config-pwa": "^4.0.3",
20
20
  "@graphcommerce/typescript-config-pwa": "^4.0.2",
21
- "@playwright/test": "^1.19.1"
21
+ "@playwright/test": "^1.19.2"
22
22
  },
23
23
  "peerDependencies": {
24
24
  "framer-motion": "^6.2.4",