@graphcommerce/next-ui 3.18.2 → 3.20.1

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.
Files changed (97) hide show
  1. package/AppShell/AppShellSticky/index.tsx +3 -19
  2. package/AppShell/DesktopNavActions.tsx +3 -4
  3. package/AppShell/DesktopNavBar.tsx +4 -4
  4. package/AppShell/FixedFab.tsx +1 -6
  5. package/AppShell/GlobalHead.tsx +36 -0
  6. package/AppShell/Logo.tsx +11 -20
  7. package/AppShell/MenuFab.tsx +19 -7
  8. package/AppShell/MenuFabSecondaryItem.tsx +3 -3
  9. package/AppShell/PlaceholderFab/index.tsx +8 -27
  10. package/AppShell/index.tsx +19 -0
  11. package/AppShell/useFabAnimation.tsx +3 -2
  12. package/AppShell/useFixedFabAnimation.tsx +3 -2
  13. package/Blog/BlogAuthor/index.tsx +10 -6
  14. package/Blog/BlogHeader/index.tsx +7 -3
  15. package/Blog/BlogList/index.tsx +1 -1
  16. package/Blog/BlogListItem/index.tsx +2 -1
  17. package/Blog/BlogTitle/index.tsx +5 -5
  18. package/Button/index.tsx +26 -21
  19. package/ButtonLink/index.tsx +1 -1
  20. package/CHANGELOG.md +76 -0
  21. package/ChipMenu/index.tsx +2 -2
  22. package/FlagAvatar/index.tsx +3 -3
  23. package/{AppShell/Footer/index.tsx → Footer/Footer.tsx} +4 -4
  24. package/{AppShell/Footer → Footer}/SocialIcon.tsx +3 -3
  25. package/Footer/index.ts +2 -0
  26. package/Form/InputCheckmark.tsx +3 -3
  27. package/Form/index.tsx +8 -3
  28. package/FramerScroller/components/SidebarGallery.tsx +25 -21
  29. package/FramerScroller/components/SidebarSlider.tsx +1 -3
  30. package/FullPageMessage/index.tsx +1 -1
  31. package/IconHeader/index.tsx +2 -15
  32. package/Layout/components/LayoutHeader.tsx +151 -0
  33. package/Layout/components/LayoutHeaderBack.tsx +50 -0
  34. package/Layout/components/LayoutHeaderClose.tsx +27 -0
  35. package/Layout/components/LayoutHeaderContent.tsx +182 -0
  36. package/Layout/components/LayoutHeadertypes.ts +10 -0
  37. package/Layout/components/LayoutProvider.tsx +17 -0
  38. package/{Title/index.tsx → Layout/components/LayoutTitle.tsx} +24 -15
  39. package/Layout/context/layoutContext.tsx +7 -0
  40. package/Layout/hooks/useScrollY.tsx +6 -0
  41. package/Layout/index.ts +5 -0
  42. package/Layout/types.ts +5 -0
  43. package/LayoutDefault/components/LayoutDefault.tsx +90 -0
  44. package/LayoutDefault/index.ts +1 -0
  45. package/LayoutOverlay/components/LayoutOverlay.tsx +25 -0
  46. package/LayoutOverlay/components/LayoutOverlayBase.tsx +352 -0
  47. package/LayoutOverlay/components/LayoutOverlayHeader.tsx +5 -0
  48. package/LayoutOverlay/hooks/useOverlayPosition.ts +70 -0
  49. package/LayoutOverlay/index.ts +2 -0
  50. package/Page/App.tsx +2 -0
  51. package/PageMeta/index.tsx +3 -0
  52. package/Pagination/index.tsx +0 -1
  53. package/Row/ButtonLinkList/index.tsx +1 -1
  54. package/Row/ColumnOneBoxed/index.tsx +1 -1
  55. package/Row/ColumnTwoWithTop/index.tsx +3 -3
  56. package/Row/ContentLinks/index.tsx +3 -3
  57. package/Row/HeroBanner/index.tsx +28 -21
  58. package/Row/IconBlocks/index.tsx +1 -1
  59. package/Row/ImageText/index.tsx +12 -5
  60. package/Row/ImageTextBoxed/index.tsx +3 -1
  61. package/Row/ParagraphWithSidebarSlide/index.tsx +2 -0
  62. package/Row/SpecialBanner/index.tsx +11 -7
  63. package/Row/index.tsx +1 -1
  64. package/Snackbar/MessageSnackbarImpl.tsx +1 -1
  65. package/StarRatingField/index.tsx +3 -4
  66. package/Stepper/Stepper.tsx +1 -1
  67. package/Styles/breakpointVal.tsx +22 -0
  68. package/Styles/classesPicker.ts +41 -0
  69. package/Styles/responsiveVal.tsx +1 -1
  70. package/SvgImage/SvgImageSimple.tsx +14 -11
  71. package/SvgImage/index.tsx +9 -11
  72. package/TextInputNumber/index.tsx +3 -4
  73. package/Theme/types.ts +14 -12
  74. package/ToggleButton/index.tsx +3 -8
  75. package/UspList/UspListItem.tsx +4 -2
  76. package/icons/index.tsx +2 -0
  77. package/index.ts +9 -42
  78. package/package.json +8 -9
  79. package/AppShell/AppShellHeader/appShellHeaderContext.tsx +0 -11
  80. package/AppShell/AppShellHeader/index.tsx +0 -438
  81. package/AppShell/AppShellHeader/useAppShellHeaderContext.tsx +0 -6
  82. package/AppShell/AppShellProvider/index.tsx +0 -18
  83. package/AppShell/AppShellTitle/index.tsx +0 -45
  84. package/AppShell/ForwardButton.tsx +0 -53
  85. package/AppShell/FullPageShellBase.tsx +0 -82
  86. package/AppShell/MinimalPageShellBase.tsx +0 -22
  87. package/AppShell/PageShellHeader/index.tsx +0 -14
  88. package/AppShell/SheetShellBase/index.tsx +0 -114
  89. package/AppShell/SheetShellBase/useSheetStyles.ts +0 -18
  90. package/AppShell/SheetShellDragIndicator/index.tsx +0 -55
  91. package/AppShell/SheetShellHeader/index.tsx +0 -28
  92. package/AppShell/ShellBase.tsx +0 -45
  93. package/Debug/DebugSpacer.tsx +0 -51
  94. package/FramerNextPagesSlider/Slide.tsx +0 -71
  95. package/FramerNextPagesSlider/Slider.tsx +0 -39
  96. package/FramerNextPagesSlider/index.ts +0 -1
  97. package/FramerNextPagesSlider/types.ts +0 -3
@@ -0,0 +1,352 @@
1
+ import { usePageContext, usePageRouter, useScrollOffset } from '@graphcommerce/framer-next-pages'
2
+ import { Scroller, useScrollerContext, useScrollTo } from '@graphcommerce/framer-scroller'
3
+ import { useElementScroll, useIsomorphicLayoutEffect } from '@graphcommerce/framer-utils'
4
+ import { makeStyles, Theme } from '@material-ui/core'
5
+ import {
6
+ m,
7
+ MotionValue,
8
+ useDomEvent,
9
+ useMotionValue,
10
+ usePresence,
11
+ useTransform,
12
+ } from 'framer-motion'
13
+ import React, { useCallback, useEffect, useRef } from 'react'
14
+ import LayoutProvider from '../../Layout/components/LayoutProvider'
15
+ import { UseStyles } from '../../Styles'
16
+ import { classesPicker } from '../../Styles/classesPicker'
17
+ import { useOverlayPosition } from '../hooks/useOverlayPosition'
18
+
19
+ const useStyles = makeStyles(
20
+ (theme: Theme) => ({
21
+ root: {
22
+ display: 'grid',
23
+ cursor: 'default',
24
+ overflow: 'auto',
25
+ height: '100vh',
26
+ '@supports (-webkit-touch-callout: none)': {
27
+ height: '-webkit-fill-available',
28
+ },
29
+ },
30
+ rootVariantSmLeft: {
31
+ [theme.breakpoints.down('sm')]: {
32
+ gridTemplate: `
33
+ "overlay beforeOverlay"
34
+ "afterOverlay afterOverlay"
35
+ `,
36
+ },
37
+ },
38
+ rootVariantMdLeft: {
39
+ [theme.breakpoints.up('md')]: {
40
+ gridTemplate: `
41
+ "overlay beforeOverlay"
42
+ "afterOverlay afterOverlay"
43
+ `,
44
+ },
45
+ },
46
+ rootVariantSmRight: {
47
+ [theme.breakpoints.down('sm')]: {
48
+ gridTemplate: `
49
+ "beforeOverlay overlay"
50
+ "afterOverlay afterOverlay"
51
+ `,
52
+ },
53
+ },
54
+ rootVariantMdRight: {
55
+ [theme.breakpoints.up('md')]: {
56
+ gridTemplate: `
57
+ "beforeOverlay overlay"
58
+ "afterOverlay afterOverlay"
59
+ `,
60
+ },
61
+ },
62
+ rootVariantSmBottom: {
63
+ [theme.breakpoints.down('sm')]: {
64
+ gridTemplate: `"beforeOverlay" "overlay" "afterOverlay"`,
65
+ height: '100vh',
66
+ '@supports (-webkit-touch-callout: none)': {
67
+ height: '-webkit-fill-available',
68
+ },
69
+ },
70
+ },
71
+ rootVariantMdBottom: {
72
+ [theme.breakpoints.up('md')]: {
73
+ gridTemplate: `"beforeOverlay" "overlay" "afterOverlay"`,
74
+ height: '100vh',
75
+ },
76
+ },
77
+ beforeOverlay: {
78
+ gridArea: 'beforeOverlay',
79
+ scrollSnapAlign: 'start',
80
+ scrollSnapStop: 'always',
81
+ display: 'grid',
82
+ alignContent: 'end',
83
+ },
84
+ beforeOverlayVariantSmRight: {
85
+ [theme.breakpoints.down('sm')]: {
86
+ width: '100vw',
87
+ },
88
+ },
89
+ beforeOverlayVariantMdRight: {
90
+ [theme.breakpoints.up('md')]: {
91
+ width: '100vw',
92
+ },
93
+ },
94
+
95
+ beforeOverlayVariantSmLeft: {
96
+ [theme.breakpoints.down('sm')]: {
97
+ width: '100vw',
98
+ },
99
+ },
100
+ beforeOverlayVariantMdLeft: {
101
+ [theme.breakpoints.up('md')]: {
102
+ width: '100vw',
103
+ },
104
+ },
105
+
106
+ beforeOverlayVariantMdBottom: {
107
+ [theme.breakpoints.up('md')]: {
108
+ height: '100vh',
109
+ },
110
+ },
111
+ beforeOverlayVariantSmBottom: {
112
+ [theme.breakpoints.down('sm')]: {
113
+ height: '100vh',
114
+ '@supports (-webkit-touch-callout: none)': {
115
+ height: '-webkit-fill-available',
116
+ },
117
+ },
118
+ },
119
+ overlay: {
120
+ pointerEvents: 'none',
121
+ gridArea: 'overlay',
122
+ scrollSnapAlign: 'start',
123
+ width: 'min-content',
124
+ minHeight: '100vh',
125
+ '@supports (-webkit-touch-callout: none)': {
126
+ minHeight: '-webkit-fill-available',
127
+ },
128
+ },
129
+ overlayVariantSmBottom: {
130
+ [theme.breakpoints.down('sm')]: {
131
+ marginTop: `calc(${theme.appShell.headerHeightSm} * 0.5 * -1)`,
132
+ paddingTop: `calc(${theme.appShell.headerHeightSm} * 0.5)`,
133
+ scrollSnapStop: 'always',
134
+ display: 'grid',
135
+ },
136
+ },
137
+ overlayVariantMdBottom: {
138
+ [theme.breakpoints.up('md')]: {
139
+ marginTop: `calc(${theme.appShell.headerHeightMd} + (${theme.appShell.appBarHeightMd} - ${theme.appShell.appBarInnerHeightMd}) * 0.5)`,
140
+ paddingTop: `calc(${theme.appShell.headerHeightMd} + (${theme.appShell.appBarHeightMd} - ${theme.appShell.appBarInnerHeightMd}) * -0.5)`,
141
+ scrollSnapAlign: 'start',
142
+ scrollSnapStop: 'always',
143
+ display: 'grid',
144
+ },
145
+ },
146
+ overlayPane: {
147
+ pointerEvents: 'all',
148
+ backgroundColor: theme.palette.background.paper,
149
+ boxShadow: theme.shadows[24],
150
+ minWidth: 'min(800px, 90vw)',
151
+ },
152
+ overlayPaneVariantSmBottom: {
153
+ [theme.breakpoints.down('sm')]: {
154
+ width: '100vw',
155
+ borderRadius: 10,
156
+ },
157
+ },
158
+ overlayPaneVariantMdBottom: {
159
+ [theme.breakpoints.up('md')]: {
160
+ width: '100vw',
161
+ borderRadius: 10,
162
+ },
163
+ },
164
+ overlayPaneVariantSmLeft: {
165
+ [theme.breakpoints.down('sm')]: {
166
+ paddingBottom: 1,
167
+ minHeight: '100vh',
168
+ '@supports (-webkit-touch-callout: none)': {
169
+ minHeight: '-webkit-fill-available',
170
+ },
171
+ },
172
+ },
173
+ overlayPaneVariantMdLeft: {
174
+ [theme.breakpoints.up('md')]: {
175
+ paddingBottom: 1,
176
+ minHeight: '100vh',
177
+ '@supports (-webkit-touch-callout: none)': {
178
+ minHeight: '-webkit-fill-available',
179
+ },
180
+ },
181
+ },
182
+ overlayPaneVariantSmRight: {
183
+ [theme.breakpoints.down('sm')]: {
184
+ paddingBottom: 1,
185
+ minHeight: '100vh',
186
+ '@supports (-webkit-touch-callout: none)': {
187
+ minHeight: '-webkit-fill-available',
188
+ },
189
+ },
190
+ },
191
+ overlayPaneVariantMdRight: {
192
+ [theme.breakpoints.up('md')]: {
193
+ paddingBottom: 1,
194
+ minHeight: '100vh',
195
+ '@supports (-webkit-touch-callout: none)': {
196
+ minHeight: '-webkit-fill-available',
197
+ },
198
+ },
199
+ },
200
+ afterOverlay: {
201
+ gridArea: 'afterOverlay',
202
+ scrollSnapAlign: 'start',
203
+ },
204
+ backdrop: {
205
+ zIndex: -1,
206
+ position: 'fixed',
207
+ display: 'flex',
208
+ alignItems: 'center',
209
+ justifyContent: 'center',
210
+ right: 0,
211
+ bottom: 0,
212
+ top: 0,
213
+ left: 0,
214
+ backgroundColor: 'rgba(0, 0, 0, 0.5)',
215
+ WebkitTapHighlightColor: 'transparent',
216
+ },
217
+ }),
218
+ { name: 'Overlay' },
219
+ )
220
+
221
+ export type LayoutOverlayVariant = 'left' | 'bottom' | 'right'
222
+
223
+ export type LayoutOverlayBaseProps = {
224
+ children?: React.ReactNode
225
+ variantSm: LayoutOverlayVariant
226
+ variantMd: LayoutOverlayVariant
227
+ } & UseStyles<typeof useStyles>
228
+
229
+ export enum OverlayPosition {
230
+ UNOPENED = -1,
231
+ OPENED = 1,
232
+ CLOSED = 0,
233
+ }
234
+
235
+ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
236
+ const { children, variantSm, variantMd } = props
237
+ const { scrollerRef } = useScrollerContext()
238
+ const positions = useOverlayPosition()
239
+ const scrollTo = useScrollTo()
240
+ const [isPresent, safeToRemove] = usePresence()
241
+
242
+ const { closeSteps, active, direction } = usePageContext()
243
+ const pageRouter = usePageRouter()
244
+
245
+ const position = useMotionValue<OverlayPosition>(OverlayPosition.UNOPENED)
246
+
247
+ const classes = useStyles(props)
248
+ const className = classesPicker(classes, { variantSm, variantMd })
249
+
250
+ const overlayRef = useRef<HTMLDivElement>(null)
251
+
252
+ const scroll = useElementScroll(scrollerRef)
253
+
254
+ useIsomorphicLayoutEffect(() => {
255
+ const scroller = scrollerRef.current
256
+ if (!scroller || !isPresent) return
257
+
258
+ const open = { x: positions.open.x.get(), y: positions.open.y.get() }
259
+
260
+ if (direction === 1 && position.get() !== OverlayPosition.OPENED) {
261
+ scroller.scrollLeft = positions.closed.x.get()
262
+ scroller.scrollTop = positions.closed.y.get()
263
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
264
+ scrollTo(open).then(() => {
265
+ scroller.scrollLeft = positions.open.x.get()
266
+ scroller.scrollTop = positions.open.y.get()
267
+ position.set(OverlayPosition.OPENED)
268
+ })
269
+ } else {
270
+ scroller.scrollLeft = open.x
271
+ scroller.scrollTop = open.y
272
+ }
273
+ }, [direction, isPresent, position, positions, scrollTo, scrollerRef])
274
+
275
+ // Make sure the overlay stays open when resizing the window.
276
+ useEffect(() => {
277
+ const scroller = scrollerRef.current
278
+ if (!scroller) return () => {}
279
+
280
+ const resize = () => {
281
+ if (positions.open.visible.get() !== 1) return
282
+ scroller.scrollLeft = positions.open.x.get()
283
+ scroller.scrollTop = positions.open.y.get()
284
+ }
285
+
286
+ window.addEventListener('resize', resize)
287
+ return () => window.removeEventListener('resize', resize)
288
+ // We're not checking for all deps, because that will cause rerenders.
289
+ // The scroller context shouldn't be changing, but at the moment it is.
290
+ }, [positions, scrollerRef])
291
+
292
+ useEffect(() => {
293
+ if (isPresent) return
294
+
295
+ position.set(OverlayPosition.CLOSED)
296
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
297
+ scrollTo({
298
+ x: positions.closed.x.get(),
299
+ y: positions.closed.y.get(),
300
+ }).then(() => safeToRemove?.())
301
+ }, [isPresent, position, positions, safeToRemove, scrollTo])
302
+
303
+ // Only go back to a previous page if the overlay isn't closed.
304
+ const closeOverlay = useCallback(() => {
305
+ if (position.get() !== OverlayPosition.OPENED) return
306
+ position.set(OverlayPosition.CLOSED)
307
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
308
+ pageRouter.go(closeSteps * -1)
309
+ }, [closeSteps, pageRouter, position])
310
+
311
+ // Handle escape key
312
+ const windowRef = useRef(typeof window !== 'undefined' ? window : null)
313
+ const handleEscape = (e: KeyboardEvent | Event) => {
314
+ if (active && (e as KeyboardEvent)?.key === 'Escape') closeOverlay()
315
+ }
316
+ useDomEvent(windowRef, 'keyup', handleEscape, { passive: true })
317
+
318
+ // When the overlay isn't visible anymore, we navigate back.
319
+ useEffect(() => positions.open.visible.onChange((o) => o === 0 && closeOverlay()))
320
+
321
+ // Measure the offset of the overlay in the scroller.
322
+
323
+ const offsetY = useMotionValue(0)
324
+ useEffect(() => {
325
+ if (!overlayRef.current) return () => {}
326
+ const ro = new ResizeObserver(([entry]) => offsetY.set(entry.contentRect.top))
327
+ ro.observe(overlayRef.current)
328
+ return () => ro.disconnect()
329
+ }, [offsetY])
330
+
331
+ // Create the exact position for the LayoutProvider which offsets the top of the overlay
332
+ const offsetPageY = useScrollOffset().y
333
+ const scrollWithoffset = useTransform(
334
+ [scroll.y, positions.open.y, offsetY] as MotionValue<number | string>[],
335
+ ([y, openY, offsetYv]: number[]) => Math.max(0, y - openY - offsetYv + offsetPageY),
336
+ )
337
+
338
+ return (
339
+ <>
340
+ <m.div {...className('backdrop')} style={{ opacity: positions.open.visible }} />
341
+ <Scroller {...className('root')} grid={false} hideScrollbar>
342
+ <div {...className('beforeOverlay')} onClick={closeOverlay} />
343
+ <div {...className('overlay')} ref={overlayRef}>
344
+ <div {...className('overlayPane')}>
345
+ <LayoutProvider scroll={scrollWithoffset}>{children}</LayoutProvider>
346
+ </div>
347
+ </div>
348
+ <div {...className('afterOverlay')} />
349
+ </Scroller>
350
+ </>
351
+ )
352
+ }
@@ -0,0 +1,5 @@
1
+ import { LayoutHeaderProps, LayoutHeader } from '../../Layout'
2
+
3
+ export function LayoutOverlayHeader(props: LayoutHeaderProps) {
4
+ return <LayoutHeader {...props} noAlign />
5
+ }
@@ -0,0 +1,70 @@
1
+ import { useScrollerContext } from '@graphcommerce/framer-scroller'
2
+ import {
3
+ useConstant,
4
+ useElementScroll,
5
+ useIsomorphicLayoutEffect,
6
+ } from '@graphcommerce/framer-utils'
7
+ import { motionValue } from 'framer-motion'
8
+ import { useEffect } from 'react'
9
+
10
+ export function useOverlayPosition() {
11
+ const { getScrollSnapPositions, scrollerRef } = useScrollerContext()
12
+
13
+ const state = useConstant(() => ({
14
+ open: {
15
+ x: motionValue(0),
16
+ y: motionValue(0),
17
+ visible: motionValue(0),
18
+ },
19
+ closed: { x: motionValue(0), y: motionValue(0) },
20
+ }))
21
+
22
+ const scroll = useElementScroll(scrollerRef)
23
+
24
+ useIsomorphicLayoutEffect(() => {
25
+ if (!scrollerRef.current) return () => {}
26
+
27
+ const measure = () => {
28
+ const positions = getScrollSnapPositions()
29
+ state.open.x.set(positions.x[1] ?? 0)
30
+ state.closed.x.set(positions.x[0])
31
+ state.open.y.set(positions.y[1] ?? 0)
32
+ state.closed.y.set(positions.y[0])
33
+ }
34
+ const ro = new ResizeObserver(measure)
35
+ measure()
36
+
37
+ ro.observe(scrollerRef.current)
38
+ return () => ro.disconnect()
39
+ })
40
+
41
+ // sets a float between 0 and 1 for the visibility of the overlay
42
+ useEffect(() => {
43
+ const calc = () => {
44
+ const x = scroll.x.get()
45
+ const y = scroll.y.get()
46
+
47
+ const yC = state.closed.y.get()
48
+ const yO = state.open.y.get()
49
+ const visY = yC === yO ? 1 : Math.max(0, Math.min(1, (y - yC) / (yO - yC)))
50
+
51
+ const xC = state.closed.x.get()
52
+ const xO = state.open.x.get()
53
+ const visX = xO === xC ? 1 : Math.max(0, Math.min(1, (x - xC) / (xO - xC)))
54
+
55
+ // todo: visibility sometimes flickers
56
+ state.open.visible.set(visY * visX)
57
+ }
58
+
59
+ const cancelY = scroll.y.onChange(calc)
60
+ const cancelX = scroll.x.onChange(calc)
61
+ calc()
62
+
63
+ return () => {
64
+ cancelY()
65
+ cancelX()
66
+ }
67
+ }, [state, scroll])
68
+
69
+ return state
70
+ }
@@ -0,0 +1,2 @@
1
+ export * from './components/LayoutOverlay'
2
+ export * from './components/LayoutOverlayHeader'
package/Page/App.tsx CHANGED
@@ -2,6 +2,7 @@ import { FramerNextPages } from '@graphcommerce/framer-next-pages'
2
2
  import { LazyMotion } from 'framer-motion'
3
3
  import { AppPropsType } from 'next/dist/shared/lib/utils'
4
4
  import React, { useEffect } from 'react'
5
+ import PageLoadIndicator from '../PageLoadIndicator'
5
6
  import { AppProps } from './types'
6
7
 
7
8
  export default function App(props: AppProps & AppPropsType) {
@@ -9,6 +10,7 @@ export default function App(props: AppProps & AppPropsType) {
9
10
 
10
11
  return (
11
12
  <LazyMotion features={async () => (await import('./framerFeatures')).default} strict>
13
+ <PageLoadIndicator />
12
14
  <FramerNextPages {...props} />
13
15
  </LazyMotion>
14
16
  )
@@ -1,3 +1,4 @@
1
+ import { usePageContext } from '@graphcommerce/framer-next-pages'
1
2
  import Head from 'next/head'
2
3
 
3
4
  // https://developers.google.com/search/docs/advanced/robots/robots_meta_tag#directives
@@ -22,11 +23,13 @@ export type PageMetaProps = {
22
23
  }
23
24
 
24
25
  export default function PageMeta(props: PageMetaProps) {
26
+ const { active } = usePageContext()
25
27
  const { title, canonical, metaDescription, metaRobots = ['all'] } = props
26
28
 
27
29
  if (!(canonical ?? 'http').startsWith('http'))
28
30
  throw new Error(`canonical must start with http:// or https://, '${canonical}' given`)
29
31
 
32
+ if (!active) return null
30
33
  return (
31
34
  <Head>
32
35
  <title>{title.trim()}</title>
@@ -1,6 +1,5 @@
1
1
  import { Fab, makeStyles, Theme, Typography } from '@material-ui/core'
2
2
  import { PaginationProps, usePagination } from '@material-ui/lab'
3
- import clsx from 'clsx'
4
3
  import React from 'react'
5
4
  import { UseStyles } from '../Styles'
6
5
  import SvgImageSimple from '../SvgImage/SvgImageSimple'
@@ -3,7 +3,7 @@ import React from 'react'
3
3
  import Row from '..'
4
4
  import SectionContainer from '../../SectionContainer'
5
5
  import { UseStyles } from '../../Styles'
6
- import responsiveVal from '../../Styles/responsiveVal'
6
+ import { responsiveVal } from '../../Styles/responsiveVal'
7
7
 
8
8
  const useStyles = makeStyles(
9
9
  (theme: Theme) => ({
@@ -1,4 +1,4 @@
1
- import { Container, ContainerProps, makeStyles, Theme } from '@material-ui/core'
1
+ import { ContainerProps, makeStyles, Theme } from '@material-ui/core'
2
2
  import React from 'react'
3
3
  import Row from '..'
4
4
 
@@ -1,5 +1,5 @@
1
- import { Container, makeStyles, Theme } from '@material-ui/core'
2
- import React, { PropsWithChildren } from 'react'
1
+ import { makeStyles, Theme } from '@material-ui/core'
2
+ import React from 'react'
3
3
  import Row from '..'
4
4
  import { UseStyles } from '../../Styles'
5
5
 
@@ -19,7 +19,7 @@ const useStyles = makeStyles(
19
19
  "left right"
20
20
  `,
21
21
  gridTemplateColumns: '1fr auto',
22
- gap: `${theme.spacings.sm} ${theme.spacings.xl}`,
22
+ gap: `${theme.spacings.sm} ${theme.spacings.xxl}`,
23
23
  },
24
24
  },
25
25
  top: {
@@ -5,12 +5,12 @@ import { UseStyles } from '../../Styles'
5
5
 
6
6
  const useStyles = makeStyles(
7
7
  (theme: Theme) => ({
8
- root: {},
9
- scroller: {
8
+ root: {
10
9
  marginBottom: `${theme.spacings.lg}`,
10
+ },
11
+ scroller: {
11
12
  justifyContent: 'start',
12
13
  gap: `${theme.spacings.md}`,
13
- alignContent: 'center',
14
14
  gridAutoColumns: `max-content`,
15
15
  },
16
16
  title: {
@@ -1,16 +1,13 @@
1
- import { ContainerProps, Theme, makeStyles } from '@material-ui/core'
2
- import { m, useTransform, useViewportScroll } from 'framer-motion'
1
+ import { ContainerProps, Theme, makeStyles, useTheme, useMediaQuery } from '@material-ui/core'
2
+ import { m, useTransform } from 'framer-motion'
3
3
  import React from 'react'
4
4
  import Row from '..'
5
+ import { useScrollY } from '../../Layout/hooks/useScrollY'
5
6
  import { UseStyles } from '../../Styles'
6
- import responsiveVal from '../../Styles/responsiveVal'
7
+ import { responsiveVal } from '../../Styles/responsiveVal'
7
8
 
8
9
  const useStyles = makeStyles(
9
10
  (theme: Theme) => ({
10
- container: {
11
- paddingLeft: 0,
12
- paddingRight: 0,
13
- },
14
11
  wrapper: {
15
12
  position: 'relative',
16
13
  },
@@ -22,22 +19,19 @@ const useStyles = makeStyles(
22
19
  justifyItems: 'center',
23
20
  alignContent: 'center',
24
21
  padding: `${theme.spacings.lg} ${theme.spacings.md}`,
25
- minHeight: `calc(100vh - ${theme.page.headerInnerHeight.sm})`,
22
+ paddingTop: `calc(${theme.spacings.lg} - ${theme.spacings.md})`,
23
+ minHeight: `calc(100vh - ${theme.appShell.headerHeightSm})`,
26
24
  '& > *': {
27
25
  zIndex: 1,
28
26
  maxWidth: 'max-content',
29
27
  },
30
- [theme.breakpoints.down('sm')]: {
31
- ['@supports (-webkit-touch-callout: none)']: {
32
- minHeight: '-webkit-fill-available',
33
- },
34
- },
35
28
  [theme.breakpoints.up('md')]: {
36
29
  width: '70%',
37
- minHeight: `calc(100vh - ${theme.page.headerInnerHeight.md})`,
30
+ minHeight: `calc(100vh - ${theme.appShell.headerHeightMd})`,
38
31
  },
39
32
  [theme.breakpoints.up('lg')]: {
40
33
  padding: `${theme.spacings.lg} ${theme.spacings.lg}`,
34
+ paddingTop: `calc(${theme.spacings.lg} - ${theme.spacings.md})`,
41
35
  width: '50%',
42
36
  },
43
37
  },
@@ -50,16 +44,23 @@ const useStyles = makeStyles(
50
44
  display: 'grid',
51
45
  justifyItems: 'center',
52
46
  overflow: 'hidden',
53
- paddingBottom: theme.spacings.md,
47
+ paddingBottom: theme.page.horizontal,
54
48
  '& video': {
55
49
  objectFit: 'cover',
56
50
  width: '100%',
57
51
  height: '100%',
52
+ [theme.breakpoints.down('sm')]: {
53
+ borderRadius: responsiveVal(theme.shape.borderRadius * 2, theme.shape.borderRadius * 3),
54
+ },
58
55
  },
59
56
  [theme.breakpoints.up('md')]: {
60
57
  height: '100%',
61
58
  },
62
59
  },
60
+ animated: {
61
+ borderRadius: responsiveVal(theme.shape.borderRadius * 2, theme.shape.borderRadius * 3),
62
+ overflow: 'hidden',
63
+ },
63
64
  }),
64
65
  { name: 'HeroBanner' },
65
66
  )
@@ -74,23 +75,29 @@ export type HeroBannerProps = UseStyles<typeof useStyles> &
74
75
  export default function HeroBanner(props: HeroBannerProps) {
75
76
  const { pageLinks, videoSrc, children, ...containerProps } = props
76
77
  const classes = useStyles(props)
77
-
78
- const { scrollY } = useViewportScroll()
79
- const actionsAnimWidth = useTransform(
78
+ const theme = useTheme()
79
+ const scrollY = useScrollY()
80
+ const width = useTransform(
81
+ scrollY,
82
+ [10, 150],
83
+ [`calc(100% - ${responsiveVal(20, 60)}))`, `calc(100% - ${responsiveVal(0, 0)})`],
84
+ )
85
+ const matches = useMediaQuery(theme.breakpoints.down('sm'))
86
+ const borderRadius = useTransform(
80
87
  scrollY,
81
88
  [10, 150],
82
- [`calc(100% - ${responsiveVal(30, 60)})`, `calc(100% - ${responsiveVal(0, 0)})`],
89
+ [`${responsiveVal(8, 12)}`, `${responsiveVal(0, 0)}`],
83
90
  )
84
91
 
85
92
  return (
86
- <Row maxWidth={false} {...containerProps} className={classes.container}>
93
+ <Row maxWidth={false} {...containerProps} disableGutters>
87
94
  <div className={classes.wrapper}>
88
95
  <div className={classes.copy}>
89
96
  {children}
90
97
  {pageLinks}
91
98
  </div>
92
99
  <div className={classes.asset}>
93
- <m.div style={{ width: actionsAnimWidth }}>
100
+ <m.div style={{ width: !matches ? width : 0, borderRadius }} className={classes.animated}>
94
101
  <video src={videoSrc} autoPlay muted loop playsInline disableRemotePlayback />
95
102
  </m.div>
96
103
  </div>
@@ -2,7 +2,7 @@ import { makeStyles, Theme, Typography } from '@material-ui/core'
2
2
  import React from 'react'
3
3
  import Row from '..'
4
4
  import { UseStyles } from '../../Styles'
5
- import responsiveVal from '../../Styles/responsiveVal'
5
+ import { responsiveVal } from '../../Styles/responsiveVal'
6
6
 
7
7
  const useStyles = makeStyles(
8
8
  (theme: Theme) => ({