@graphcommerce/next-ui 11.0.0-canary.48 → 11.0.0-canary.49
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/FramerScroller/SidebarGallery.tsx +50 -8
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 11.0.0-canary.49
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2701](https://github.com/graphcommerce-org/graphcommerce/pull/2701) [`561f62d`](https://github.com/graphcommerce-org/graphcommerce/commit/561f62dd0072d3080dc18a01fa5fda66a96af410) - A page that opens with `#gallery`, for example after a reload of the zoomed gallery or after Back from another site, renders without zoom, the same as the server render, and removes `#gallery` without a "Cancel rendering route" error. Before, the gallery rendered zoomed in the browser and closed again, so the image moved on page load. ([@DivaniNL](https://github.com/DivaniNL))
|
|
8
|
+
|
|
9
|
+
- [#2701](https://github.com/graphcommerce-org/graphcommerce/pull/2701) [`7df196c`](https://github.com/graphcommerce-org/graphcommerce/commit/7df196c9115966de4b794c55d9d21f2e1dad007c) - The zoomed SidebarGallery fills the full screen height. It moves up by its measured distance to the top of the page instead of a fixed margin based on the header height. With the fixed margin, the zoomed gallery on desktop started 11px below the top of the screen and the bottom 11px was cut off. ([@DivaniNL](https://github.com/DivaniNL))
|
|
10
|
+
|
|
3
11
|
## 11.0.0-canary.48
|
|
4
12
|
|
|
5
13
|
### Minor Changes
|
|
@@ -16,7 +16,7 @@ import type { SxProps, Theme } from '@mui/material'
|
|
|
16
16
|
import { Box, Fab, styled, Unstable_TrapFocus as TrapFocus, useTheme } from '@mui/material'
|
|
17
17
|
import { m, useDomEvent, useMotionValue } from 'framer-motion'
|
|
18
18
|
import { useRouter } from 'next/router'
|
|
19
|
-
import React, { useEffect, useRef } from 'react'
|
|
19
|
+
import React, { useCallback, useEffect, useRef } from 'react'
|
|
20
20
|
import { iconChevronLeft, iconChevronRight, iconFullscreen, iconFullscreenExit } from '../icons'
|
|
21
21
|
import { IconSvg } from '../IconSvg'
|
|
22
22
|
import { Row } from '../Row/Row'
|
|
@@ -82,28 +82,67 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
82
82
|
afterScroller,
|
|
83
83
|
} = props
|
|
84
84
|
|
|
85
|
+
const rootRef = useRef<HTMLDivElement>(null)
|
|
86
|
+
const sidebarWrapperRef = useRef<HTMLDivElement>(null)
|
|
85
87
|
const router = useRouter()
|
|
86
88
|
const prevRoute = usePrevPageRouter()
|
|
87
89
|
// const classes = useMergedClasses(useStyles({ clientHeight, aspectRatio }).classes, props.classes)
|
|
88
90
|
|
|
89
91
|
const route = `#${routeHash}`
|
|
90
|
-
// We're using the URL to manage the state of the gallery.
|
|
91
|
-
|
|
92
|
+
// We're using the URL to manage the state of the gallery. A page that opens with #gallery has no
|
|
93
|
+
// previous page and renders without zoom, the same as the server render.
|
|
94
|
+
const zoomed = router.asPath.endsWith(route) && Boolean(prevRoute?.pathname)
|
|
92
95
|
usePreventScroll(zoomed)
|
|
93
96
|
|
|
94
97
|
// cleanup if someone enters the page with #gallery
|
|
95
98
|
useEffect(() => {
|
|
96
|
-
if (
|
|
97
|
-
|
|
98
|
-
|
|
99
|
+
if (prevRoute?.pathname || !router.asPath.endsWith(route)) return undefined
|
|
100
|
+
let active = true
|
|
101
|
+
const removeHash = async () => {
|
|
102
|
+
try {
|
|
103
|
+
await router.replace(router.asPath.replace(route, ''))
|
|
104
|
+
} catch (e) {
|
|
105
|
+
// The route change of Next.js after hydration can cancel this replace.
|
|
106
|
+
if (!(e as { cancelled?: boolean }).cancelled) throw e
|
|
107
|
+
if (active) await removeHash()
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
111
|
+
removeHash()
|
|
112
|
+
return () => {
|
|
113
|
+
active = false
|
|
99
114
|
}
|
|
100
115
|
}, [prevRoute?.pathname, route, router, zoomed])
|
|
101
116
|
|
|
117
|
+
// The zoomed gallery moves up by its layout distance to the top of the page, so it fills the full
|
|
118
|
+
// screen height. offsetTop ignores transforms, so the Framer layout animation and the translate
|
|
119
|
+
// do not change the measurement. The sidebar keeps its height from before the zoom, so its content
|
|
120
|
+
// does not move while it slides out.
|
|
121
|
+
const measureZoomOffsets = useCallback(() => {
|
|
122
|
+
const root = rootRef.current
|
|
123
|
+
if (!root || !sidebarWrapperRef.current) return
|
|
124
|
+
let top = 0
|
|
125
|
+
for (let el: HTMLElement | null = root; el; el = el.offsetParent as HTMLElement | null) {
|
|
126
|
+
top += el.offsetTop
|
|
127
|
+
}
|
|
128
|
+
root.style.setProperty('--zoom-offset', `${top}px`)
|
|
129
|
+
if (!zoomed) {
|
|
130
|
+
root.style.setProperty('--sidebar-height', `${sidebarWrapperRef.current.offsetHeight}px`)
|
|
131
|
+
}
|
|
132
|
+
}, [zoomed])
|
|
133
|
+
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
measureZoomOffsets()
|
|
136
|
+
window.addEventListener('resize', measureZoomOffsets)
|
|
137
|
+
return () => window.removeEventListener('resize', measureZoomOffsets)
|
|
138
|
+
}, [measureZoomOffsets])
|
|
139
|
+
|
|
102
140
|
const toggle = () => {
|
|
103
141
|
if (disableZoom) {
|
|
104
142
|
return
|
|
105
143
|
}
|
|
106
144
|
if (!zoomed) {
|
|
145
|
+
measureZoomOffsets()
|
|
107
146
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
108
147
|
router.push(route, undefined, { shallow: true })
|
|
109
148
|
window.scrollTo({ top: 0, behavior: 'smooth' })
|
|
@@ -160,6 +199,7 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
160
199
|
)}
|
|
161
200
|
>
|
|
162
201
|
<MotionBox
|
|
202
|
+
ref={rootRef}
|
|
163
203
|
layout
|
|
164
204
|
layoutDependency={zoomed}
|
|
165
205
|
className={classes.root}
|
|
@@ -175,9 +215,8 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
175
215
|
'&.zoomed': {
|
|
176
216
|
position: 'relative',
|
|
177
217
|
zIndex: theme.zIndex.modal,
|
|
178
|
-
|
|
218
|
+
translate: '0 calc(var(--zoom-offset) * -1)',
|
|
179
219
|
[theme.breakpoints.up('md')]: {
|
|
180
|
-
marginTop: `calc(${theme.appShell.headerHeightMd} * -1 - ${theme.spacings.lg})`,
|
|
181
220
|
gridTemplateColumns: '1fr auto',
|
|
182
221
|
},
|
|
183
222
|
px: 0,
|
|
@@ -367,6 +406,7 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
367
406
|
</MotionBox>
|
|
368
407
|
</TrapFocus>
|
|
369
408
|
<Box
|
|
409
|
+
ref={sidebarWrapperRef}
|
|
370
410
|
className={classes.sidebarWrapper}
|
|
371
411
|
sx={sxx(
|
|
372
412
|
{
|
|
@@ -386,6 +426,8 @@ export function SidebarGallery(props: SidebarGalleryProps) {
|
|
|
386
426
|
left: `calc(${responsiveVal(300, 500, undefined, theme.breakpoints.values.lg)} + ${
|
|
387
427
|
theme.page.horizontal
|
|
388
428
|
} * 2)`,
|
|
429
|
+
marginTop: 'var(--zoom-offset)',
|
|
430
|
+
height: 'var(--sidebar-height)',
|
|
389
431
|
},
|
|
390
432
|
},
|
|
391
433
|
)}
|
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": "11.0.0-canary.
|
|
5
|
+
"version": "11.0.0-canary.49",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@emotion/react": "^11.14.0",
|
|
44
44
|
"@emotion/server": "^11.11.0",
|
|
45
45
|
"@emotion/styled": "^11.14.1",
|
|
46
|
-
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.
|
|
47
|
-
"@graphcommerce/framer-next-pages": "^11.0.0-canary.
|
|
48
|
-
"@graphcommerce/framer-scroller": "^11.0.0-canary.
|
|
49
|
-
"@graphcommerce/framer-utils": "^11.0.0-canary.
|
|
50
|
-
"@graphcommerce/image": "^11.0.0-canary.
|
|
51
|
-
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.
|
|
52
|
-
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.
|
|
46
|
+
"@graphcommerce/eslint-config-pwa": "^11.0.0-canary.49",
|
|
47
|
+
"@graphcommerce/framer-next-pages": "^11.0.0-canary.49",
|
|
48
|
+
"@graphcommerce/framer-scroller": "^11.0.0-canary.49",
|
|
49
|
+
"@graphcommerce/framer-utils": "^11.0.0-canary.49",
|
|
50
|
+
"@graphcommerce/image": "^11.0.0-canary.49",
|
|
51
|
+
"@graphcommerce/prettier-config-pwa": "^11.0.0-canary.49",
|
|
52
|
+
"@graphcommerce/typescript-config-pwa": "^11.0.0-canary.49",
|
|
53
53
|
"@lingui/core": "^5",
|
|
54
54
|
"@lingui/macro": "^5",
|
|
55
55
|
"@lingui/react": "^5",
|