@graphcommerce/next-ui 6.0.0-canary.20 → 6.0.0-canary.21
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 +8 -0
- package/Navigation/components/NavigationItem.tsx +1 -1
- package/Navigation/components/NavigationOverlay.tsx +8 -10
- package/Navigation/components/NavigationProvider.tsx +10 -1
- package/Navigation/hooks/useNavigation.ts +1 -0
- package/Overlay/components/OverlayBase.tsx +6 -4
- package/Overlay/hooks/useOverlayPosition.ts +16 -6
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 6.0.0-canary.21
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#1806](https://github.com/graphcommerce-org/graphcommerce/pull/1806) [`597396766`](https://github.com/graphcommerce-org/graphcommerce/commit/597396766940de8c4ab5d8c84a0c6637ed72dba2) - - Put navigation HTML permanently in the DOM
|
|
8
|
+
- Fix issue where Navigation can't be reopened after closing, dragging or navigating
|
|
9
|
+
- Fix overlay visibility when browser is resized, or exactly 864px width ([@ErwinOtten](https://github.com/ErwinOtten))
|
|
10
|
+
|
|
3
11
|
## 6.0.0-canary.20
|
|
4
12
|
|
|
5
13
|
## 5.2.0-canary.19
|
|
@@ -113,7 +113,7 @@ export const NavigationItem = React.memo<NavigationItemProps>((props) => {
|
|
|
113
113
|
tabIndex={tabIndex}
|
|
114
114
|
onClick={(e) => {
|
|
115
115
|
e.preventDefault()
|
|
116
|
-
if (!isSelected
|
|
116
|
+
if (!isSelected) {
|
|
117
117
|
selection.set(itemPath)
|
|
118
118
|
}
|
|
119
119
|
}}
|
|
@@ -57,7 +57,8 @@ export const NavigationOverlay = React.memo((props: NavigationOverlayProps) => {
|
|
|
57
57
|
mouseEvent,
|
|
58
58
|
itemPadding = 'md',
|
|
59
59
|
} = props
|
|
60
|
-
const { selection, items, animating, closing, serverRenderDepth } =
|
|
60
|
+
const { selection, items, animating, closing, serverRenderDepth, animationDuration } =
|
|
61
|
+
useNavigation()
|
|
61
62
|
|
|
62
63
|
const fabMarginY = `calc((${useFabSize('responsive')} - ${useIconSvgSize('large')}) * -0.5)`
|
|
63
64
|
const itemPad = useTheme().spacings[itemPadding] ?? itemPadding
|
|
@@ -81,7 +82,9 @@ export const NavigationOverlay = React.memo((props: NavigationOverlayProps) => {
|
|
|
81
82
|
|
|
82
83
|
const afterClose = useEventCallback(() => {
|
|
83
84
|
if (!closing.get()) return
|
|
84
|
-
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
closing.set(false)
|
|
87
|
+
}, animationDuration * 1000)
|
|
85
88
|
selection.set(false)
|
|
86
89
|
})
|
|
87
90
|
|
|
@@ -179,7 +182,7 @@ export const NavigationOverlay = React.memo((props: NavigationOverlayProps) => {
|
|
|
179
182
|
[theme.breakpoints.down('md')]: {
|
|
180
183
|
width:
|
|
181
184
|
sizeSm !== 'floating'
|
|
182
|
-
?
|
|
185
|
+
? itemWidthSm
|
|
183
186
|
: `calc(${itemWidthSm} - (${theme.page.horizontal} * 2))`,
|
|
184
187
|
minWidth: 200,
|
|
185
188
|
overflow: 'hidden',
|
|
@@ -187,19 +190,14 @@ export const NavigationOverlay = React.memo((props: NavigationOverlayProps) => {
|
|
|
187
190
|
'& .NavigationItem-item': {
|
|
188
191
|
width:
|
|
189
192
|
sizeSm !== 'floating'
|
|
190
|
-
? `calc(${itemWidthSm} - (${itemPad} * 2)
|
|
193
|
+
? `calc(${itemWidthSm} - (${itemPad} * 2))`
|
|
191
194
|
: `calc(${itemWidthSm} - (${itemPad} * 2) - (${theme.page.horizontal} * 2))`,
|
|
192
195
|
minWidth: `calc(200px - (${itemPad} * 2))`,
|
|
193
196
|
},
|
|
194
197
|
},
|
|
195
198
|
[theme.breakpoints.up('md')]: {
|
|
196
199
|
'& .NavigationItem-item': {
|
|
197
|
-
|
|
198
|
-
width: itemWidthMd
|
|
199
|
-
? selectedLevel >= 1
|
|
200
|
-
? `calc(${itemWidthMd} + 1px)`
|
|
201
|
-
: itemWidthMd
|
|
202
|
-
: 'stretch',
|
|
200
|
+
width: itemWidthMd || 'stretch',
|
|
203
201
|
},
|
|
204
202
|
},
|
|
205
203
|
}),
|
|
@@ -54,8 +54,17 @@ export const NavigationProvider = React.memo<NavigationProviderProps>((props) =>
|
|
|
54
54
|
)
|
|
55
55
|
.filter(nonNullable),
|
|
56
56
|
serverRenderDepth,
|
|
57
|
+
animationDuration,
|
|
57
58
|
}),
|
|
58
|
-
[
|
|
59
|
+
[
|
|
60
|
+
hideRootOnNavigate,
|
|
61
|
+
selection,
|
|
62
|
+
animating,
|
|
63
|
+
closing,
|
|
64
|
+
items,
|
|
65
|
+
serverRenderDepth,
|
|
66
|
+
animationDuration,
|
|
67
|
+
],
|
|
59
68
|
)
|
|
60
69
|
|
|
61
70
|
return (
|
|
@@ -6,6 +6,7 @@ import React, { useCallback, useEffect, useRef } from 'react'
|
|
|
6
6
|
import { LayoutProvider } from '../../Layout/components/LayoutProvider'
|
|
7
7
|
import { ExtendableComponent, extendableComponent } from '../../Styles'
|
|
8
8
|
import { useOverlayPosition } from '../hooks/useOverlayPosition'
|
|
9
|
+
import framesync from 'framesync'
|
|
9
10
|
|
|
10
11
|
export type LayoutOverlayVariant = 'left' | 'bottom' | 'right'
|
|
11
12
|
export type LayoutOverlaySize = 'floating' | 'minimal' | 'full'
|
|
@@ -158,9 +159,10 @@ export function OverlayBase(incomingProps: LayoutOverlayBaseProps) {
|
|
|
158
159
|
scroller.scrollTop = positions.open.y.get()
|
|
159
160
|
}
|
|
160
161
|
}
|
|
162
|
+
const resizeTimed = () => framesync.read(resize)
|
|
161
163
|
|
|
162
|
-
window.addEventListener('resize',
|
|
163
|
-
return () => window.removeEventListener('resize',
|
|
164
|
+
window.addEventListener('resize', resizeTimed)
|
|
165
|
+
return () => window.removeEventListener('resize', resizeTimed)
|
|
164
166
|
}, [position, positions, scrollerRef])
|
|
165
167
|
|
|
166
168
|
// When the overlay is closed by navigating away, we're closing the overlay.
|
|
@@ -341,7 +343,7 @@ export function OverlayBase(incomingProps: LayoutOverlayBaseProps) {
|
|
|
341
343
|
|
|
342
344
|
[theme.breakpoints.down('md')]: {
|
|
343
345
|
'&.variantSmLeft, &.variantSmRight': {
|
|
344
|
-
width:
|
|
346
|
+
width: dvw(100),
|
|
345
347
|
},
|
|
346
348
|
'&.variantSmBottom': {
|
|
347
349
|
height: dvh(100),
|
|
@@ -469,7 +471,7 @@ export function OverlayBase(incomingProps: LayoutOverlayBaseProps) {
|
|
|
469
471
|
})}
|
|
470
472
|
>
|
|
471
473
|
<LayoutProvider scroll={scrollYOffset}>
|
|
472
|
-
{
|
|
474
|
+
{typeof children === 'function' ? active && children() : children}
|
|
473
475
|
</LayoutProvider>
|
|
474
476
|
</MotionDiv>
|
|
475
477
|
</Box>
|
|
@@ -3,6 +3,7 @@ import { useConstant, useIsomorphicLayoutEffect } from '@graphcommerce/framer-ut
|
|
|
3
3
|
import { motionValue } from 'framer-motion'
|
|
4
4
|
import { useCallback, useEffect } from 'react'
|
|
5
5
|
import { useMatchMedia } from '../../hooks'
|
|
6
|
+
import framesync from 'framesync'
|
|
6
7
|
|
|
7
8
|
const clampRound = (value: number) => Math.round(Math.max(0, Math.min(1, value)) * 100) / 100
|
|
8
9
|
|
|
@@ -34,27 +35,34 @@ export function useOverlayPosition(
|
|
|
34
35
|
|
|
35
36
|
const measure = () => {
|
|
36
37
|
const positions = getScrollSnapPositions()
|
|
38
|
+
const x = positions.x[positions.x.length - 1]
|
|
39
|
+
const y = positions.y[positions.y.length - 1]
|
|
37
40
|
|
|
38
41
|
if (variant() === 'left') {
|
|
42
|
+
state.closed.x.set(x)
|
|
39
43
|
state.open.x.set(0)
|
|
40
|
-
state.closed.x.set(positions.x[positions.x.length - 1] ?? 0)
|
|
41
44
|
}
|
|
42
45
|
if (variant() === 'right') {
|
|
43
|
-
state.open.x.set(
|
|
46
|
+
state.open.x.set(x)
|
|
44
47
|
state.closed.x.set(0)
|
|
45
48
|
}
|
|
46
49
|
if (variant() === 'bottom') {
|
|
47
|
-
state.open.y.set(
|
|
50
|
+
state.open.y.set(y)
|
|
48
51
|
state.closed.y.set(0)
|
|
49
52
|
}
|
|
50
53
|
}
|
|
54
|
+
const measureTimed = () => framesync.read(measure)
|
|
51
55
|
measure()
|
|
52
56
|
|
|
53
|
-
const ro = new ResizeObserver(
|
|
57
|
+
const ro = new ResizeObserver(measureTimed)
|
|
54
58
|
ro.observe(scrollerRef.current)
|
|
55
59
|
;[...scrollerRef.current.children].forEach((child) => ro.observe(child))
|
|
56
60
|
|
|
57
|
-
|
|
61
|
+
window.addEventListener('resize', measureTimed)
|
|
62
|
+
return () => {
|
|
63
|
+
window.removeEventListener('resize', measureTimed)
|
|
64
|
+
ro.disconnect()
|
|
65
|
+
}
|
|
58
66
|
}, [getScrollSnapPositions, scrollerRef, state, variant])
|
|
59
67
|
|
|
60
68
|
// sets a float between 0 and 1 for the visibility of the overlay
|
|
@@ -82,9 +90,11 @@ export function useOverlayPosition(
|
|
|
82
90
|
|
|
83
91
|
const cancelY = scroll.y.onChange(calc)
|
|
84
92
|
const cancelX = scroll.x.onChange(calc)
|
|
93
|
+
|
|
94
|
+
const calcTimed = () => framesync.read(calc)
|
|
85
95
|
calc()
|
|
86
96
|
|
|
87
|
-
const ro = new ResizeObserver(
|
|
97
|
+
const ro = new ResizeObserver(calcTimed)
|
|
88
98
|
ro.observe(scrollerRef.current)
|
|
89
99
|
;[...scrollerRef.current.children].forEach((child) => ro.observe(child))
|
|
90
100
|
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/next-ui",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "6.0.0-canary.
|
|
5
|
+
"version": "6.0.0-canary.21",
|
|
6
6
|
"author": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"sideEffects": false,
|
|
@@ -18,18 +18,18 @@
|
|
|
18
18
|
"@emotion/react": "^11.10.5",
|
|
19
19
|
"@emotion/server": "^11.4.0",
|
|
20
20
|
"@emotion/styled": "^11.10.5",
|
|
21
|
-
"@graphcommerce/framer-next-pages": "6.0.0-canary.
|
|
22
|
-
"@graphcommerce/framer-scroller": "6.0.0-canary.
|
|
23
|
-
"@graphcommerce/framer-utils": "6.0.0-canary.
|
|
24
|
-
"@graphcommerce/image": "6.0.0-canary.
|
|
21
|
+
"@graphcommerce/framer-next-pages": "6.0.0-canary.21",
|
|
22
|
+
"@graphcommerce/framer-scroller": "6.0.0-canary.21",
|
|
23
|
+
"@graphcommerce/framer-utils": "6.0.0-canary.21",
|
|
24
|
+
"@graphcommerce/image": "6.0.0-canary.21",
|
|
25
25
|
"cookie": "^0.5.0",
|
|
26
26
|
"react-is": "^18.2.0",
|
|
27
27
|
"schema-dts": "^1.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@graphcommerce/eslint-config-pwa": "6.0.0-canary.
|
|
31
|
-
"@graphcommerce/prettier-config-pwa": "6.0.0-canary.
|
|
32
|
-
"@graphcommerce/typescript-config-pwa": "6.0.0-canary.
|
|
30
|
+
"@graphcommerce/eslint-config-pwa": "6.0.0-canary.21",
|
|
31
|
+
"@graphcommerce/prettier-config-pwa": "6.0.0-canary.21",
|
|
32
|
+
"@graphcommerce/typescript-config-pwa": "6.0.0-canary.21",
|
|
33
33
|
"@types/cookie": "^0.5.1",
|
|
34
34
|
"@types/react-is": "^17.0.3",
|
|
35
35
|
"typescript": "4.9.4"
|