@graphcommerce/next-ui 3.19.1 → 3.20.3
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/AppShellSticky/index.tsx +3 -19
- package/AppShell/DesktopNavActions.tsx +3 -4
- package/AppShell/DesktopNavBar.tsx +2 -3
- package/AppShell/FixedFab.tsx +1 -6
- package/AppShell/GlobalHead.tsx +36 -0
- package/AppShell/Logo.tsx +11 -20
- package/AppShell/MenuFab.tsx +5 -3
- package/AppShell/MenuFabSecondaryItem.tsx +3 -3
- package/AppShell/PlaceholderFab/index.tsx +8 -27
- package/AppShell/index.tsx +19 -0
- package/AppShell/useFabAnimation.tsx +3 -2
- package/AppShell/useFixedFabAnimation.tsx +3 -2
- package/Blog/BlogAuthor/index.tsx +1 -1
- package/Blog/BlogHeader/index.tsx +2 -3
- package/Blog/BlogList/index.tsx +1 -1
- package/Blog/BlogListItem/index.tsx +1 -1
- package/Blog/BlogTitle/index.tsx +5 -5
- package/Button/index.tsx +26 -21
- package/CHANGELOG.md +56 -0
- package/ChipMenu/index.tsx +2 -2
- package/FlagAvatar/index.tsx +3 -3
- package/{AppShell/Footer/index.tsx → Footer/Footer.tsx} +3 -3
- package/{AppShell/Footer → Footer}/SocialIcon.tsx +3 -3
- package/Footer/index.ts +2 -0
- package/Form/InputCheckmark.tsx +3 -3
- package/Form/index.tsx +1 -1
- package/FramerScroller/components/SidebarGallery.tsx +24 -20
- package/FramerScroller/components/SidebarSlider.tsx +1 -3
- package/FullPageMessage/index.tsx +1 -1
- package/IconHeader/index.tsx +2 -15
- package/Layout/components/LayoutHeader.tsx +151 -0
- package/Layout/components/LayoutHeaderBack.tsx +58 -0
- package/Layout/components/LayoutHeaderClose.tsx +27 -0
- package/Layout/components/LayoutHeaderContent.tsx +178 -0
- package/Layout/components/LayoutHeadertypes.ts +10 -0
- package/Layout/components/LayoutProvider.tsx +17 -0
- package/{Title/index.tsx → Layout/components/LayoutTitle.tsx} +24 -15
- package/Layout/context/layoutContext.tsx +7 -0
- package/Layout/hooks/useScrollY.tsx +6 -0
- package/Layout/index.ts +5 -0
- package/Layout/types.ts +5 -0
- package/LayoutDefault/components/LayoutDefault.tsx +90 -0
- package/LayoutDefault/index.ts +1 -0
- package/LayoutOverlay/components/LayoutOverlay.tsx +25 -0
- package/LayoutOverlay/components/LayoutOverlayBase.tsx +362 -0
- package/LayoutOverlay/components/LayoutOverlayHeader.tsx +5 -0
- package/LayoutOverlay/hooks/useOverlayPosition.ts +70 -0
- package/LayoutOverlay/index.ts +2 -0
- package/Page/App.tsx +2 -0
- package/PageMeta/index.tsx +3 -0
- package/Pagination/index.tsx +0 -1
- package/Row/ButtonLinkList/index.tsx +1 -1
- package/Row/ColumnOneBoxed/index.tsx +1 -1
- package/Row/ColumnTwoWithTop/index.tsx +3 -3
- package/Row/ContentLinks/index.tsx +3 -3
- package/Row/HeroBanner/index.tsx +7 -11
- package/Row/IconBlocks/index.tsx +1 -1
- package/Row/ImageText/index.tsx +1 -1
- package/Row/ImageTextBoxed/index.tsx +1 -1
- package/Row/ParagraphWithSidebarSlide/index.tsx +1 -1
- package/Row/SpecialBanner/index.tsx +4 -3
- package/Row/index.tsx +1 -1
- package/Snackbar/MessageSnackbarImpl.tsx +1 -1
- package/StarRatingField/index.tsx +3 -4
- package/Stepper/Stepper.tsx +1 -1
- package/Styles/breakpointVal.tsx +2 -2
- package/Styles/classesPicker.ts +41 -0
- package/Styles/responsiveVal.tsx +1 -1
- package/SvgImage/SvgImageSimple.tsx +9 -8
- package/SvgImage/index.tsx +9 -11
- package/TextInputNumber/index.tsx +3 -4
- package/Theme/types.ts +14 -12
- package/ToggleButton/index.tsx +2 -4
- package/UspList/UspListItem.tsx +1 -1
- package/index.ts +9 -43
- package/package.json +8 -9
- package/AppShell/AppShellHeader/appShellHeaderContext.tsx +0 -11
- package/AppShell/AppShellHeader/index.tsx +0 -439
- package/AppShell/AppShellHeader/useAppShellHeaderContext.tsx +0 -6
- package/AppShell/AppShellProvider/index.tsx +0 -18
- package/AppShell/AppShellTitle/index.tsx +0 -45
- package/AppShell/ForwardButton.tsx +0 -53
- package/AppShell/FullPageShellBase.tsx +0 -82
- package/AppShell/MinimalPageShellBase.tsx +0 -22
- package/AppShell/PageShellHeader/index.tsx +0 -14
- package/AppShell/SheetShellBase/index.tsx +0 -114
- package/AppShell/SheetShellBase/useSheetStyles.ts +0 -18
- package/AppShell/SheetShellDragIndicator/index.tsx +0 -55
- package/AppShell/SheetShellHeader/index.tsx +0 -28
- package/AppShell/ShellBase.tsx +0 -45
- package/Debug/DebugSpacer.tsx +0 -51
- package/FramerNextPagesSlider/Slide.tsx +0 -71
- package/FramerNextPagesSlider/Slider.tsx +0 -39
- package/FramerNextPagesSlider/index.ts +0 -1
- package/FramerNextPagesSlider/types.ts +0 -3
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { usePageContext, usePageRouter } from '@graphcommerce/framer-next-pages'
|
|
2
|
-
import {
|
|
3
|
-
ClassKeys,
|
|
4
|
-
Sheet,
|
|
5
|
-
SheetBackdrop,
|
|
6
|
-
SheetContainer,
|
|
7
|
-
SheetPanel,
|
|
8
|
-
SheetProps,
|
|
9
|
-
SnapPoint,
|
|
10
|
-
styles as sheetStyles,
|
|
11
|
-
} from '@graphcommerce/framer-sheet'
|
|
12
|
-
import { makeStyles, StyleRules, Theme } from '@material-ui/core'
|
|
13
|
-
import { useDomEvent } from 'framer-motion'
|
|
14
|
-
import { useRouter } from 'next/router'
|
|
15
|
-
import React, { useEffect, useRef, useState } from 'react'
|
|
16
|
-
import responsiveVal from '../../Styles/responsiveVal'
|
|
17
|
-
import AppShellProvider from '../AppShellProvider'
|
|
18
|
-
import ShellBase, { PageLayoutBaseProps } from '../ShellBase'
|
|
19
|
-
import useSheetStyles from './useSheetStyles'
|
|
20
|
-
|
|
21
|
-
export type SheetShellBaseProps = {
|
|
22
|
-
header?: React.ReactNode
|
|
23
|
-
children?: React.ReactNode
|
|
24
|
-
} & Pick<SheetProps, 'size' | 'variant'> &
|
|
25
|
-
PageLayoutBaseProps
|
|
26
|
-
|
|
27
|
-
const styles = sheetStyles as StyleRules<ClassKeys>
|
|
28
|
-
|
|
29
|
-
const useStyles = makeStyles(
|
|
30
|
-
(theme: Theme) => ({
|
|
31
|
-
container: {
|
|
32
|
-
...styles.container,
|
|
33
|
-
},
|
|
34
|
-
containertop: {
|
|
35
|
-
...styles.containertop,
|
|
36
|
-
},
|
|
37
|
-
containerbottom: {
|
|
38
|
-
...styles.containerbottom,
|
|
39
|
-
paddingTop: `calc(${theme.page.headerInnerHeight.md} * 0.55)`,
|
|
40
|
-
[theme.breakpoints.up('md')]: {
|
|
41
|
-
// offset top is x% of the header height, so it slightly overlaps the logo
|
|
42
|
-
paddingTop: `calc(${theme.page.headerInnerHeight.md} * 0.85)`,
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
containerleft: {
|
|
46
|
-
...styles.containerleft,
|
|
47
|
-
paddingRight: responsiveVal(26, 48),
|
|
48
|
-
},
|
|
49
|
-
containerright: {
|
|
50
|
-
...styles.containerright,
|
|
51
|
-
paddingLeft: responsiveVal(26, 48),
|
|
52
|
-
},
|
|
53
|
-
}),
|
|
54
|
-
{ name: 'SheetShellBase' },
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
function SheetShellBase(props: SheetShellBaseProps) {
|
|
58
|
-
const { children, variant, size, name } = props
|
|
59
|
-
const sheetContainerClasses = useStyles()
|
|
60
|
-
const sheetClasses = useSheetStyles(props)
|
|
61
|
-
const router = useRouter()
|
|
62
|
-
const pageRouter = usePageRouter()
|
|
63
|
-
const { depth, closeSteps, active, direction } = usePageContext()
|
|
64
|
-
const open = depth < 0 || router.asPath === pageRouter.asPath
|
|
65
|
-
const initialLocale = useRef(router.locale)
|
|
66
|
-
const [isNavigating, setIsNavigating] = useState<boolean>(false)
|
|
67
|
-
|
|
68
|
-
function handleClose() {
|
|
69
|
-
if (!isNavigating) {
|
|
70
|
-
setIsNavigating(true)
|
|
71
|
-
return initialLocale.current !== router.locale
|
|
72
|
-
? pageRouter.push('/')
|
|
73
|
-
: pageRouter.go(closeSteps * -1)
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function handleSnap(snapPoint: SnapPoint) {
|
|
78
|
-
if (snapPoint !== 'closed') return
|
|
79
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
80
|
-
handleClose()
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const windowRef = useRef(typeof window !== 'undefined' ? window : null)
|
|
84
|
-
|
|
85
|
-
function handleEscapeKey(e: KeyboardEvent | Event) {
|
|
86
|
-
if (active) {
|
|
87
|
-
if ((e as KeyboardEvent)?.key === 'Escape') {
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
89
|
-
handleClose()
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
useDomEvent(windowRef, 'keyup', handleEscapeKey, { passive: true })
|
|
95
|
-
|
|
96
|
-
return (
|
|
97
|
-
<AppShellProvider>
|
|
98
|
-
<ShellBase name={name}>
|
|
99
|
-
<Sheet open={open} onSnap={handleSnap} variant={variant} size={size}>
|
|
100
|
-
<SheetBackdrop onTap={handleClose} classes={sheetClasses} />
|
|
101
|
-
<SheetContainer classes={sheetContainerClasses}>
|
|
102
|
-
<SheetPanel initial={direction === -1 ? 'snapPoint1' : 'closed'} classes={sheetClasses}>
|
|
103
|
-
{/* <FocusLock returnFocus={{ preventScroll: true }} disabled={!isActive}> */}
|
|
104
|
-
{children}
|
|
105
|
-
{/* </FocusLock> */}
|
|
106
|
-
</SheetPanel>
|
|
107
|
-
</SheetContainer>
|
|
108
|
-
</Sheet>
|
|
109
|
-
</ShellBase>
|
|
110
|
-
</AppShellProvider>
|
|
111
|
-
)
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export default SheetShellBase
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import styles, { ClassKeys } from '@graphcommerce/framer-sheet/styles'
|
|
2
|
-
import { makeStyles, StyleRules, Theme } from '@material-ui/core'
|
|
3
|
-
import { ClassNameMap } from '@material-ui/styles'
|
|
4
|
-
|
|
5
|
-
type UseSheetStylesReturn = (props?: Record<string, unknown>) => ClassNameMap<ClassKeys>
|
|
6
|
-
|
|
7
|
-
const useSheetStyles = makeStyles<Theme, never, ClassKeys>(
|
|
8
|
-
(theme: Theme) => ({
|
|
9
|
-
...(styles as StyleRules<ClassKeys>),
|
|
10
|
-
content: {
|
|
11
|
-
...styles.content,
|
|
12
|
-
backgroundColor: theme.palette.background.default,
|
|
13
|
-
},
|
|
14
|
-
}),
|
|
15
|
-
{ name: 'Sheet' },
|
|
16
|
-
) as UseSheetStylesReturn
|
|
17
|
-
|
|
18
|
-
export default useSheetStyles
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SheetDragIndicator,
|
|
3
|
-
SheetDragIndicatorProps,
|
|
4
|
-
styles as sheetStyles,
|
|
5
|
-
ClassKeys,
|
|
6
|
-
} from '@graphcommerce/framer-sheet'
|
|
7
|
-
import { makeStyles, StyleRules } from '@material-ui/core'
|
|
8
|
-
import React from 'react'
|
|
9
|
-
import responsiveVal from '../../Styles/responsiveVal'
|
|
10
|
-
|
|
11
|
-
const styles = sheetStyles as StyleRules<ClassKeys>
|
|
12
|
-
|
|
13
|
-
const useStyles = makeStyles(
|
|
14
|
-
() => ({
|
|
15
|
-
indicatorRoot: {
|
|
16
|
-
...styles.indicatorRoot,
|
|
17
|
-
position: 'absolute',
|
|
18
|
-
left: 0,
|
|
19
|
-
right: 0,
|
|
20
|
-
top: 0,
|
|
21
|
-
},
|
|
22
|
-
indicatorRoottop: {
|
|
23
|
-
...styles.indicatorRoottop,
|
|
24
|
-
padding: `${responsiveVal(4, 8)} 4px 4px 4px`,
|
|
25
|
-
},
|
|
26
|
-
indicatorRootbottom: {
|
|
27
|
-
...styles.indicatorRootbottom,
|
|
28
|
-
padding: `${responsiveVal(4, 8)} 4px 4px 4px`,
|
|
29
|
-
},
|
|
30
|
-
indicatorRootleft: {
|
|
31
|
-
...styles.indicatorRootleft,
|
|
32
|
-
},
|
|
33
|
-
indicatorRootright: {
|
|
34
|
-
...styles.indicatorRootright,
|
|
35
|
-
},
|
|
36
|
-
indicator: {
|
|
37
|
-
...styles.indicator,
|
|
38
|
-
borderRadius: 99,
|
|
39
|
-
backgroundColor: '#ddd',
|
|
40
|
-
},
|
|
41
|
-
indicatortop: { ...styles.indicatortop, width: responsiveVal(12, 40), height: 4 },
|
|
42
|
-
indicatorbottom: { ...styles.indicatorbottom, width: responsiveVal(12, 40), height: 4 },
|
|
43
|
-
indicatorleft: { ...styles.indicatorleft, width: 4, height: responsiveVal(12, 40) },
|
|
44
|
-
indicatorright: { ...styles.indicatorright, width: 4, height: responsiveVal(12, 40) },
|
|
45
|
-
}),
|
|
46
|
-
{ name: 'SheetShellDragIndicator' },
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
type SheetShellDragIndicatorProps = SheetDragIndicatorProps
|
|
50
|
-
|
|
51
|
-
export default function SheetShellDragIndicator(props: SheetShellDragIndicatorProps) {
|
|
52
|
-
const classes = useStyles()
|
|
53
|
-
|
|
54
|
-
return <SheetDragIndicator {...props} classes={classes} />
|
|
55
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import useSheetContext from '@graphcommerce/framer-sheet/hooks/useSheetContext'
|
|
2
|
-
import { useElementScroll } from '@graphcommerce/framer-utils'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import AppShellHeader, { AppShellHeaderProps } from '../AppShellHeader'
|
|
5
|
-
import useSheetStyles from '../SheetShellBase/useSheetStyles'
|
|
6
|
-
import SheetShellDragIndicator from '../SheetShellDragIndicator'
|
|
7
|
-
|
|
8
|
-
type SheetShellHeaderProps = {
|
|
9
|
-
hideDragIndicator?: boolean
|
|
10
|
-
} & Omit<AppShellHeaderProps, 'scrollY'>
|
|
11
|
-
|
|
12
|
-
export default function SheetShellHeader(props: SheetShellHeaderProps) {
|
|
13
|
-
const { hideDragIndicator } = props
|
|
14
|
-
const { contentRef } = useSheetContext()
|
|
15
|
-
const { y } = useElementScroll(contentRef)
|
|
16
|
-
const sheetClasses = useSheetStyles()
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<AppShellHeader
|
|
20
|
-
{...props}
|
|
21
|
-
scrollY={y}
|
|
22
|
-
dragIndicator={
|
|
23
|
-
hideDragIndicator ? undefined : <SheetShellDragIndicator classes={sheetClasses} />
|
|
24
|
-
}
|
|
25
|
-
sheet
|
|
26
|
-
/>
|
|
27
|
-
)
|
|
28
|
-
}
|
package/AppShell/ShellBase.tsx
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { useTheme } from '@material-ui/core'
|
|
2
|
-
import Head from 'next/head'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import PageLoadIndicator from '../PageLoadIndicator'
|
|
5
|
-
|
|
6
|
-
export type PageLayoutBaseProps = { name: string; children?: React.ReactNode }
|
|
7
|
-
|
|
8
|
-
const ShellBase = (props: { name: string; children?: React.ReactNode }) => {
|
|
9
|
-
const { children, name } = props
|
|
10
|
-
const theme = useTheme()
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<>
|
|
14
|
-
<PageLoadIndicator />
|
|
15
|
-
<Head>
|
|
16
|
-
<meta name='theme-color' content={theme.palette.background.default} key='theme-color' />
|
|
17
|
-
<meta
|
|
18
|
-
name='viewport'
|
|
19
|
-
content='minimum-scale=1, initial-scale=1, width=device-width'
|
|
20
|
-
key='viewport'
|
|
21
|
-
/>
|
|
22
|
-
<meta name='application-name' content={name} key='application-name' />
|
|
23
|
-
<meta
|
|
24
|
-
name='apple-mobile-web-app-capable'
|
|
25
|
-
content='yes'
|
|
26
|
-
key='apple-mobile-web-app-capable'
|
|
27
|
-
/>
|
|
28
|
-
<meta
|
|
29
|
-
name='apple-mobile-web-app-status-bar-style'
|
|
30
|
-
content='default'
|
|
31
|
-
key='apple-mobile-web-app-status-bar-style'
|
|
32
|
-
/>
|
|
33
|
-
<meta name='apple-mobile-web-app-title' content={name} key='apple-mobile-web-app-title' />
|
|
34
|
-
<meta name='format-detection' content='telephone=no' key='format-detection' />
|
|
35
|
-
<meta name='mobile-web-app-capable' content='yes' key='mobile-web-app-capable' />
|
|
36
|
-
<link rel='apple-touch-icon' href='/manifest/icon-512-512.png' key='apple-touch-icon' />
|
|
37
|
-
<link rel='manifest' href='/manifest.webmanifest' key='manifest' />
|
|
38
|
-
<link rel='shortcut icon' href='/manifest/favicon.ico' key='shortcut icon' />
|
|
39
|
-
</Head>
|
|
40
|
-
{children}
|
|
41
|
-
</>
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export default ShellBase
|
package/Debug/DebugSpacer.tsx
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from '@material-ui/core'
|
|
2
|
-
import { CSSProperties } from '@material-ui/styles'
|
|
3
|
-
import { AnimatePresence, HTMLMotionProps, m } from 'framer-motion'
|
|
4
|
-
|
|
5
|
-
export type DebugSpacerProps = {
|
|
6
|
-
height?: number
|
|
7
|
-
color?: CSSProperties['color']
|
|
8
|
-
} & HTMLMotionProps<'div'>
|
|
9
|
-
|
|
10
|
-
const useStyles = makeStyles(() => ({
|
|
11
|
-
root: {
|
|
12
|
-
background: `repeating-linear-gradient(-45deg, transparent, transparent 20px, #f6f6f6 20px, #f6f6f6 40px) top left`,
|
|
13
|
-
boxShadow: `#eee 0px 0px 0px 3px inset`,
|
|
14
|
-
overflow: 'hidden',
|
|
15
|
-
},
|
|
16
|
-
div: {
|
|
17
|
-
color: `rgba(0,0,0,0.1)`,
|
|
18
|
-
overflow: 'hidden',
|
|
19
|
-
width: '100%',
|
|
20
|
-
textAlign: 'center',
|
|
21
|
-
fontSize: 20,
|
|
22
|
-
display: 'grid',
|
|
23
|
-
alignItems: 'center',
|
|
24
|
-
},
|
|
25
|
-
}))
|
|
26
|
-
export default function DebugSpacer({ height = 250, ...divProps }: DebugSpacerProps) {
|
|
27
|
-
const classes = useStyles()
|
|
28
|
-
let increment = 0
|
|
29
|
-
// eslint-disable-next-line no-return-assign
|
|
30
|
-
const rows = new Array(Math.ceil(height / 100)).fill(0).map(() => {
|
|
31
|
-
increment += 100
|
|
32
|
-
return Math.min(increment, height)
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<m.div className={classes.root} {...divProps} animate={{ height }}>
|
|
37
|
-
<AnimatePresence>
|
|
38
|
-
{rows.map((nr) => (
|
|
39
|
-
<div
|
|
40
|
-
data-key={`debug-row-${nr}`}
|
|
41
|
-
className={classes.div}
|
|
42
|
-
style={{ height: nr % 100 || 100, borderTop: `3px solid #efefef` }}
|
|
43
|
-
key={`debug-row-${nr}`}
|
|
44
|
-
>
|
|
45
|
-
{nr}
|
|
46
|
-
</div>
|
|
47
|
-
))}
|
|
48
|
-
</AnimatePresence>
|
|
49
|
-
</m.div>
|
|
50
|
-
)
|
|
51
|
-
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { usePageContext, usePageRouter } from '@graphcommerce/framer-next-pages'
|
|
2
|
-
import { SPRING_ANIM } from '@graphcommerce/framer-sheet'
|
|
3
|
-
import { makeStyles } from '@material-ui/core'
|
|
4
|
-
import { m, motionValue, useElementScroll } from 'framer-motion'
|
|
5
|
-
import React, { useEffect, useRef } from 'react'
|
|
6
|
-
import { ScrollPositions } from './types'
|
|
7
|
-
|
|
8
|
-
const useStyles = makeStyles(
|
|
9
|
-
() => ({
|
|
10
|
-
slide: {
|
|
11
|
-
position: 'absolute',
|
|
12
|
-
left: 0,
|
|
13
|
-
top: 0,
|
|
14
|
-
right: 0,
|
|
15
|
-
height: '100%',
|
|
16
|
-
overflowY: 'auto',
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
{ name: 'FramerNextPagesSlider' },
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
type Custom = {
|
|
23
|
-
depth: number
|
|
24
|
-
direction: 1 | -1
|
|
25
|
-
exiting: boolean
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export type RouterSlideProps = {
|
|
29
|
-
children?: React.ReactNode
|
|
30
|
-
scrollPositions: React.MutableRefObject<ScrollPositions>
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export default function RouterSlide({ children, scrollPositions }: RouterSlideProps) {
|
|
34
|
-
const classes = useStyles()
|
|
35
|
-
const ref = useRef<HTMLDivElement>(null)
|
|
36
|
-
const { scrollY } = useElementScroll(ref)
|
|
37
|
-
const { direction, depth } = usePageContext()
|
|
38
|
-
const router = usePageRouter()
|
|
39
|
-
|
|
40
|
-
useEffect(() => {
|
|
41
|
-
scrollPositions.current[router.asPath] ??= motionValue(0)
|
|
42
|
-
scrollY.onChange((v) => scrollPositions.current[router.asPath].set(v))
|
|
43
|
-
}, [router.asPath, scrollPositions, scrollY])
|
|
44
|
-
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
const scroll = scrollPositions.current[router.asPath].get()
|
|
47
|
-
if (ref.current && scroll) ref.current.scrollTop = scroll
|
|
48
|
-
}, [router.asPath, scrollPositions])
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<m.div
|
|
52
|
-
className={classes.slide}
|
|
53
|
-
ref={ref}
|
|
54
|
-
custom={{ depth, direction, exiting: false }}
|
|
55
|
-
initial='initial'
|
|
56
|
-
animate={{ x: 0 }}
|
|
57
|
-
exit='exit'
|
|
58
|
-
variants={{
|
|
59
|
-
initial: (c: Custom) => (c.direction === 1 ? { x: '100%' } : { x: '-100%' }),
|
|
60
|
-
exit: (c: Custom) => {
|
|
61
|
-
if (!c.depth && c.exiting && c.direction === 1) return { x: '-100%' }
|
|
62
|
-
if (!c.depth && c.exiting && c.direction === -1) return { x: '100%' }
|
|
63
|
-
return { x: 0 }
|
|
64
|
-
},
|
|
65
|
-
}}
|
|
66
|
-
transition={{ ...SPRING_ANIM, restDelta: 0.01, damping: 20 }}
|
|
67
|
-
>
|
|
68
|
-
{children}
|
|
69
|
-
</m.div>
|
|
70
|
-
)
|
|
71
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { usePageContext, usePageRouter } from '@graphcommerce/framer-next-pages'
|
|
2
|
-
import { makeStyles } from '@material-ui/core'
|
|
3
|
-
import { AnimatePresence } from 'framer-motion'
|
|
4
|
-
import React, { useRef } from 'react'
|
|
5
|
-
import RouterSlide from './Slide'
|
|
6
|
-
import { ScrollPositions } from './types'
|
|
7
|
-
|
|
8
|
-
const useStyles = makeStyles(
|
|
9
|
-
{
|
|
10
|
-
slider: {
|
|
11
|
-
position: 'relative',
|
|
12
|
-
width: '100%',
|
|
13
|
-
height: '100%',
|
|
14
|
-
},
|
|
15
|
-
},
|
|
16
|
-
{ name: 'FramerNextPagesSlider' },
|
|
17
|
-
)
|
|
18
|
-
|
|
19
|
-
export type SliderRouteProps = { children?: React.ReactNode }
|
|
20
|
-
|
|
21
|
-
/** RouteSlider provides an iOS settings style navigation */
|
|
22
|
-
export default function Slider(props: SliderRouteProps) {
|
|
23
|
-
const classes = useStyles()
|
|
24
|
-
const { children } = props
|
|
25
|
-
const { depth, direction } = usePageContext()
|
|
26
|
-
const router = usePageRouter()
|
|
27
|
-
|
|
28
|
-
const scrollPositions = useRef<ScrollPositions>({})
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className={classes.slider}>
|
|
32
|
-
<AnimatePresence initial={false} custom={{ depth, direction, exiting: true }}>
|
|
33
|
-
<RouterSlide key={router.asPath} scrollPositions={scrollPositions}>
|
|
34
|
-
{children}
|
|
35
|
-
</RouterSlide>
|
|
36
|
-
</AnimatePresence>
|
|
37
|
-
</div>
|
|
38
|
-
)
|
|
39
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from './Slider'
|