@graphcommerce/next-ui 3.11.4 → 3.11.5
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/AppShell/AppShellHeader/index.tsx +28 -21
- package/AppShell/FullPageShellBase.tsx +0 -2
- package/CHANGELOG.md +16 -0
- package/Page/types.ts +3 -2
- package/package.json +3 -3
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
useHistoryLink,
|
|
3
|
+
usePageContext,
|
|
4
|
+
usePageRouter,
|
|
5
|
+
usePrevUp,
|
|
6
|
+
useUp,
|
|
7
|
+
} from '@graphcommerce/framer-next-pages'
|
|
2
8
|
import { Fab, makeStyles, Theme } from '@material-ui/core'
|
|
3
9
|
import clsx from 'clsx'
|
|
4
10
|
import { m, MotionValue, useMotionValue, useTransform } from 'framer-motion'
|
|
@@ -6,7 +12,6 @@ import PageLink from 'next/link'
|
|
|
6
12
|
import React, { useCallback, useEffect } from 'react'
|
|
7
13
|
import Button from '../../Button'
|
|
8
14
|
import { UseStyles } from '../../Styles'
|
|
9
|
-
import SvgImage from '../../SvgImage'
|
|
10
15
|
import SvgImageSimple from '../../SvgImage/SvgImageSimple'
|
|
11
16
|
import { iconChevronLeft, iconClose } from '../../icons'
|
|
12
17
|
import useAppShellHeaderContext from './useAppShellHeaderContext'
|
|
@@ -23,8 +28,6 @@ export type AppShellHeaderProps = {
|
|
|
23
28
|
scrolled?: boolean
|
|
24
29
|
dragIndicator?: React.ReactNode
|
|
25
30
|
additional?: React.ReactNode
|
|
26
|
-
backFallbackHref?: string | null
|
|
27
|
-
backFallbackTitle?: string | null
|
|
28
31
|
fill?: 'both' | 'mobile-only'
|
|
29
32
|
sheet?: boolean
|
|
30
33
|
} & UseStyles<typeof useStyles>
|
|
@@ -222,15 +225,15 @@ export default function AppShellHeader(props: AppShellHeaderProps) {
|
|
|
222
225
|
additional,
|
|
223
226
|
dragIndicator,
|
|
224
227
|
scrolled,
|
|
225
|
-
backFallbackHref,
|
|
226
|
-
backFallbackTitle,
|
|
227
228
|
fill = 'both',
|
|
228
229
|
sheet,
|
|
229
230
|
} = props
|
|
231
|
+
|
|
230
232
|
const router = usePageRouter()
|
|
231
233
|
const { closeSteps, backSteps } = usePageContext()
|
|
232
234
|
const classes = useStyles(props)
|
|
233
|
-
|
|
235
|
+
const up = useUp()
|
|
236
|
+
const prevUp = usePrevUp()
|
|
234
237
|
const { titleRef, contentHeaderRef } = useAppShellHeaderContext()
|
|
235
238
|
|
|
236
239
|
const noChildren = typeof children === 'undefined' || !children
|
|
@@ -242,7 +245,7 @@ export default function AppShellHeader(props: AppShellHeaderProps) {
|
|
|
242
245
|
const titleHeight = useMotionValue<number>(100)
|
|
243
246
|
|
|
244
247
|
const { href: historyHref, onClick: historyOnClick } = useHistoryLink({
|
|
245
|
-
href:
|
|
248
|
+
href: up?.href ?? '',
|
|
246
249
|
})
|
|
247
250
|
|
|
248
251
|
const setOffset = useCallback(
|
|
@@ -289,7 +292,7 @@ export default function AppShellHeader(props: AppShellHeaderProps) {
|
|
|
289
292
|
}, [contentHeaderRef, sheetHeaderHeight])
|
|
290
293
|
|
|
291
294
|
const opacityTitle = useTransform(
|
|
292
|
-
[scrollY, sheetHeaderHeight, titleOffset, titleHeight] as MotionValue[],
|
|
295
|
+
[scrollY, sheetHeaderHeight, titleOffset, titleHeight] as MotionValue<number | string>[],
|
|
293
296
|
([scrollYV, sheetHeaderHeightV, titleOffsetV, titleHeigthV]: number[]) =>
|
|
294
297
|
Math.min(
|
|
295
298
|
Math.max(
|
|
@@ -326,21 +329,25 @@ export default function AppShellHeader(props: AppShellHeaderProps) {
|
|
|
326
329
|
))
|
|
327
330
|
|
|
328
331
|
const backIcon = <SvgImageSimple src={iconChevronLeft} />
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
332
|
+
|
|
333
|
+
const canClickBack = backSteps > 0 && router.asPath !== prevUp?.href
|
|
334
|
+
let back = canClickBack && (
|
|
335
|
+
<PageLink href={historyHref} passHref>
|
|
336
|
+
<Button
|
|
337
|
+
onClick={historyOnClick}
|
|
338
|
+
variant='pill-link'
|
|
339
|
+
className={classes.backButton}
|
|
340
|
+
startIcon={backIcon}
|
|
341
|
+
>
|
|
342
|
+
{historyOnClick ? up?.title : 'Back'}
|
|
343
|
+
</Button>
|
|
344
|
+
</PageLink>
|
|
338
345
|
)
|
|
339
|
-
if (!
|
|
346
|
+
if (!canClickBack && up?.href) {
|
|
340
347
|
back = (
|
|
341
|
-
<PageLink href={
|
|
348
|
+
<PageLink href={up?.href} passHref>
|
|
342
349
|
<Button variant='pill-link' className={classes.backButton} startIcon={backIcon}>
|
|
343
|
-
{
|
|
350
|
+
{up?.title ?? 'Back'}
|
|
344
351
|
</Button>
|
|
345
352
|
</PageLink>
|
|
346
353
|
)
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [3.11.5](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.11.4...@graphcommerce/next-ui@3.11.5) (2021-11-02)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* back button loop ([4d901e6](https://github.com/ho-nl/m2-pwa/commit/4d901e662579d1cfb97c823d581e60d687908b1a))
|
|
12
|
+
* break back button loop ([be2e5ae](https://github.com/ho-nl/m2-pwa/commit/be2e5aefa1e409a97c1ebf94173f4da7ea25386b))
|
|
13
|
+
* **framer-next-pages:** prevent back button loop when previous page is the up page of the previous page ([ec829c8](https://github.com/ho-nl/m2-pwa/commit/ec829c8eee2a3744747a7572b32299879c780d45))
|
|
14
|
+
* **framer-next-pages:** prevent back button loop when previous page is the up page of the previous page ([cbdde83](https://github.com/ho-nl/m2-pwa/commit/cbdde83790337bdf4c5f03c907ca6e6e02792e70))
|
|
15
|
+
* **types:** apollo state props ‘up’ can be null ([9377d7f](https://github.com/ho-nl/m2-pwa/commit/9377d7fd9a080a8a2b8c7127961d64dc66a5729a))
|
|
16
|
+
* **types:** make apollo up state optional ([eba9683](https://github.com/ho-nl/m2-pwa/commit/eba96832e372adaeaa2ed71622c88f9dc95071c5))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [3.11.3](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.11.2...@graphcommerce/next-ui@3.11.3) (2021-11-01)
|
|
7
23
|
|
|
8
24
|
|
package/Page/types.ts
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { ParsedUrlQuery } from 'querystring'
|
|
2
2
|
import { NormalizedCacheObject } from '@apollo/client'
|
|
3
|
+
import { UpPage } from '@graphcommerce/framer-next-pages/types'
|
|
3
4
|
import { GetStaticProps as GetStaticPropsNext } from 'next'
|
|
4
5
|
import { AppProps as NextAppProps } from 'next/app'
|
|
5
6
|
|
|
6
7
|
type AnyObj = Record<string, unknown>
|
|
7
8
|
|
|
8
|
-
type ApolloStateProps = { apolloState: NormalizedCacheObject }
|
|
9
|
+
type ApolloStateProps = { apolloState: NormalizedCacheObject; up?: UpPage | null }
|
|
9
10
|
|
|
10
11
|
export type GetStaticProps<
|
|
11
12
|
PL extends AnyObj,
|
|
12
13
|
P extends AnyObj = AnyObj,
|
|
13
|
-
Q extends ParsedUrlQuery = ParsedUrlQuery
|
|
14
|
+
Q extends ParsedUrlQuery = ParsedUrlQuery,
|
|
14
15
|
> = GetStaticPropsNext<P & Omit<PL, 'children'> & ApolloStateProps, Q>
|
|
15
16
|
|
|
16
17
|
/** Used by _app */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphcommerce/next-ui",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.5",
|
|
4
4
|
"author": "",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@apollo/client": "^3.4.16",
|
|
13
|
-
"@graphcommerce/framer-next-pages": "^2.107.
|
|
13
|
+
"@graphcommerce/framer-next-pages": "^2.107.3",
|
|
14
14
|
"@graphcommerce/framer-scroller": "^0.4.3",
|
|
15
15
|
"@graphcommerce/framer-sheet": "^2.105.15",
|
|
16
16
|
"@graphcommerce/framer-utils": "^2.103.13",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"project": "./tsconfig.json"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "62ee387abaaf2dbd3b9af99597d3d4592c30ab64"
|
|
57
57
|
}
|