@graphcommerce/next-ui 3.18.1 → 3.20.0

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 -8
  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 +5 -5
  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 +27 -22
  19. package/ButtonLink/index.tsx +1 -1
  20. package/CHANGELOG.md +73 -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 +2 -6
  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 +173 -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 +354 -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 +2 -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 +6 -13
  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
package/CHANGELOG.md CHANGED
@@ -3,6 +3,79 @@
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.20.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.19.1...@graphcommerce/next-ui@3.20.0) (2021-12-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * classesPicker would sometimes return 'undefined' as a class ([baa51f1](https://github.com/ho-nl/m2-pwa/commit/baa51f1ac6d47460bfc713bd2c10ae14f1f6ecbf))
12
+ * close button should always be present ([32d4173](https://github.com/ho-nl/m2-pwa/commit/32d4173e44c6e77815cf483590c1f703d48a386b))
13
+ * horizontal scroll on page ([d025a16](https://github.com/ho-nl/m2-pwa/commit/d025a16a02b43756fc58b0b764faa404eb06da6c))
14
+ * make sure elements that use scroll positioning are using the right hook ([80ee33f](https://github.com/ho-nl/m2-pwa/commit/80ee33f68ecc223147d63fc37e5b9ba94df4564e))
15
+ * make sure galleries are scrollable properly ([8653316](https://github.com/ho-nl/m2-pwa/commit/86533167891f0ae197fdf096b84fdda8e89a0f6e))
16
+ * make sure it doesn't error when trying to override root ([99a69a3](https://github.com/ho-nl/m2-pwa/commit/99a69a36579b4c934f3b1be187130983bdf133bf))
17
+ * make sure that pill link buttons get the right background color etc. ([c142b31](https://github.com/ho-nl/m2-pwa/commit/c142b31552417d2296341785994e2f7b35462793))
18
+ * make sure the overlay becomes visible, even if the overlay is scrolled ([1738c98](https://github.com/ho-nl/m2-pwa/commit/1738c982ea84ec2b93daa824c4b8c86ab2a3f5ed))
19
+ * make the headerHeight properly configurable ([c39c942](https://github.com/ho-nl/m2-pwa/commit/c39c942a62a9bb9687ea553be28e37fb49a6b065))
20
+ * minHeight of page on iOS is sometimes less high than expected ([8a0bc23](https://github.com/ho-nl/m2-pwa/commit/8a0bc234d153d974ac415369483ddabfb5e7fb0c))
21
+ * missing CssBaseline ([d2a7126](https://github.com/ho-nl/m2-pwa/commit/d2a7126295b99b0446dc31b0cf7c60671a18f976))
22
+ * only apply page meta when the current page is active ([f099a51](https://github.com/ho-nl/m2-pwa/commit/f099a519d169dcc9e2653db8353ce93d7b0a138e))
23
+ * spacing of LayoutTItle ([7afcd31](https://github.com/ho-nl/m2-pwa/commit/7afcd3163d16e902cf2ff7917f56ee6a8798f55b))
24
+
25
+
26
+ ### Features
27
+
28
+ * **framer-scroller-sheet:** created package replacing the framer-sheet package ([f9f2e91](https://github.com/ho-nl/m2-pwa/commit/f9f2e9101191f5cb5c4514ceb9534ddeb2476763))
29
+ * **framer-scroller:** split the grid functionality from the scroller ([81307ea](https://github.com/ho-nl/m2-pwa/commit/81307ea2652bf31a1f94e8db72af4ee161bdca2e))
30
+ * refactor page shell ([594bdb3](https://github.com/ho-nl/m2-pwa/commit/594bdb32927b797208b2a295bc0db9f9ceb94676))
31
+
32
+
33
+
34
+
35
+
36
+ # [3.19.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.18.2...@graphcommerce/next-ui@3.19.0) (2021-12-01)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * borderRadius ([0999901](https://github.com/ho-nl/m2-pwa/commit/0999901f6a3265f40fef18e72702d80158d8c4a9))
42
+ * borderRadius ([b9cffcc](https://github.com/ho-nl/m2-pwa/commit/b9cffccf444cb2ff8d6257ef3a64c0ea18e30477))
43
+ * borderRadius toggleButton ([4a97800](https://github.com/ho-nl/m2-pwa/commit/4a97800150bbfe03692a66d7fbde5705a32b9cd7))
44
+ * build ([ba97378](https://github.com/ho-nl/m2-pwa/commit/ba97378d40d70b3f47c4c252600c669a53568c27))
45
+ * build ([b6cb704](https://github.com/ho-nl/m2-pwa/commit/b6cb7048c1208648687621000ab0d6789032d480))
46
+ * finetune svg stroke width ([d788d72](https://github.com/ho-nl/m2-pwa/commit/d788d72c88d5b924a14e9fdde1a52f62be7c274c))
47
+ * flicker on menu icon ([04d9633](https://github.com/ho-nl/m2-pwa/commit/04d96331cfdd4678a56a4eb9170141800c03a6a1))
48
+ * hero text spacing ([79dd6aa](https://github.com/ho-nl/m2-pwa/commit/79dd6aa2fe576104ebbbdd092f6b415d319dec48))
49
+ * icon OrderBefore ([25a2390](https://github.com/ho-nl/m2-pwa/commit/25a2390321c7047c5191a15a9352020b8161ff7a))
50
+ * icons ([c561e20](https://github.com/ho-nl/m2-pwa/commit/c561e20a247fef5ea33ac10dbecf55d1e5500dec))
51
+ * prevent scaling of video on mobile ([168b5b9](https://github.com/ho-nl/m2-pwa/commit/168b5b9451dbe373703ebc76c44516d1c0eb316f))
52
+ * Tap targets are not sized appropriately ([b3b3339](https://github.com/ho-nl/m2-pwa/commit/b3b33398c26cfe775f2e9fc4dacd8eaad2e02725))
53
+
54
+
55
+ ### Features
56
+
57
+ * borderRadius based on theme.shape.borderRadius ([7c34937](https://github.com/ho-nl/m2-pwa/commit/7c349376cd41a131c628324c299106fdb7e60484))
58
+ * breakpointVal ([0294503](https://github.com/ho-nl/m2-pwa/commit/029450343051cf6995babad9f9b42c7e6ad1094e))
59
+ * closeable menu ([5f94bb5](https://github.com/ho-nl/m2-pwa/commit/5f94bb5644ce1058ec705a8acced71ba2ba95e04))
60
+ * icon for 404 ([ff32915](https://github.com/ho-nl/m2-pwa/commit/ff3291578719cb7105d1045d68a78952b27da7fe))
61
+ * introduce borderRadius ([183afbc](https://github.com/ho-nl/m2-pwa/commit/183afbc8ee269f6694c372b06afdf41302f86c09))
62
+ * responsiveTyp ([6108b61](https://github.com/ho-nl/m2-pwa/commit/6108b6148e76ddbbe2db1614f10aaf88423db5ca))
63
+
64
+
65
+
66
+
67
+
68
+ ## [3.18.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.18.1...@graphcommerce/next-ui@3.18.2) (2021-11-27)
69
+
70
+
71
+ ### Bug Fixes
72
+
73
+ * shadow snackbar with elevation ([8d7d011](https://github.com/ho-nl/m2-pwa/commit/8d7d0119357325f5c838def4ae8dc4ae19a43a6f))
74
+
75
+
76
+
77
+
78
+
6
79
  ## [3.18.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.18.0...@graphcommerce/next-ui@3.18.1) (2021-11-22)
7
80
 
8
81
 
@@ -1,8 +1,8 @@
1
- import { Chip, ChipProps, lighten, makeStyles, Menu, Theme } from '@material-ui/core'
1
+ import { Chip, ChipProps, makeStyles, Menu, Theme } from '@material-ui/core'
2
2
  import clsx from 'clsx'
3
3
  import React, { PropsWithChildren, useState } from 'react'
4
4
  import SectionHeader from '../SectionHeader'
5
- import responsiveVal from '../Styles/responsiveVal'
5
+ import { responsiveVal } from '../Styles/responsiveVal'
6
6
  import SvgImageSimple from '../SvgImage/SvgImageSimple'
7
7
  import { iconChevronDown, iconChevronUp, iconCancelAlt } from '../icons'
8
8
 
@@ -1,10 +1,10 @@
1
- import { makeStyles, Theme, Avatar, AvatarProps } from '@material-ui/core'
1
+ import { makeStyles, Avatar, AvatarProps } from '@material-ui/core'
2
2
  import React from 'react'
3
3
 
4
4
  const useStyles = makeStyles(
5
- (theme: Theme) => ({
5
+ {
6
6
  root: {},
7
- }),
7
+ },
8
8
  { name: 'FlagAvatar' },
9
9
  )
10
10
 
@@ -1,6 +1,6 @@
1
1
  import { ContainerProps, Theme, makeStyles, Container } from '@material-ui/core'
2
2
  import React from 'react'
3
- import { UseStyles } from '../../Styles'
3
+ import { UseStyles } from '../Styles'
4
4
 
5
5
  const useStyles = makeStyles(
6
6
  (theme: Theme) => ({
@@ -46,7 +46,7 @@ const useStyles = makeStyles(
46
46
  [theme.breakpoints.down('xs')]: {
47
47
  gridAutoFlow: 'row',
48
48
  textAlign: 'center',
49
- gap: 4,
49
+ gap: 8,
50
50
  },
51
51
  },
52
52
  support: {
@@ -80,14 +80,14 @@ const useStyles = makeStyles(
80
80
  { name: 'Footer' },
81
81
  )
82
82
 
83
- type FooterProps = UseStyles<typeof useStyles> & {
83
+ export type FooterProps = UseStyles<typeof useStyles> & {
84
84
  storeSwitcher?: React.ReactNode
85
85
  socialLinks?: React.ReactElement
86
86
  customerService?: React.ReactNode
87
87
  copyright?: React.ReactElement
88
88
  } & Omit<ContainerProps, 'children'>
89
89
 
90
- export default function Footer(props: FooterProps) {
90
+ export function Footer(props: FooterProps) {
91
91
  const { socialLinks, storeSwitcher, customerService, copyright, ...containerProps } = props
92
92
  const classes = useStyles(props)
93
93
 
@@ -1,7 +1,7 @@
1
1
  import { makeStyles, Theme } from '@material-ui/core'
2
2
  import React from 'react'
3
- import { UseStyles } from '../../Styles'
4
- import SvgImage, { SvgImageProps } from '../../SvgImage'
3
+ import { UseStyles } from '../Styles'
4
+ import SvgImage, { SvgImageProps } from '../SvgImage'
5
5
 
6
6
  const useStyles = makeStyles(
7
7
  (theme: Theme) => ({
@@ -16,7 +16,7 @@ const useStyles = makeStyles(
16
16
 
17
17
  type SocialIconProps = UseStyles<typeof useStyles> & SvgImageProps
18
18
 
19
- export default function SocialIcon(props: SocialIconProps) {
19
+ export function SocialIcon(props: SocialIconProps) {
20
20
  const classes = useStyles(props)
21
21
 
22
22
  return <SvgImage {...props} className={classes.root} />
@@ -0,0 +1,2 @@
1
+ export * from './Footer'
2
+ export * from './SocialIcon'
@@ -1,4 +1,4 @@
1
- import { makeStyles, Theme } from '@material-ui/core'
1
+ import { makeStyles } from '@material-ui/core'
2
2
  import clsx from 'clsx'
3
3
  import React, { PropsWithChildren } from 'react'
4
4
  import SvgImageSimple from '../SvgImage/SvgImageSimple'
@@ -6,14 +6,14 @@ import { iconCheckmark } from '../icons'
6
6
 
7
7
  export type InputCheckmarkProps = PropsWithChildren<{ show?: boolean; select?: boolean }>
8
8
  const useStyles = makeStyles(
9
- (theme: Theme) => ({
9
+ {
10
10
  iconCheckmark: {
11
11
  stroke: '#01D26A',
12
12
  },
13
13
  select: {
14
14
  marginRight: 15,
15
15
  },
16
- }),
16
+ },
17
17
  { name: 'InputCheckmark' },
18
18
  )
19
19
 
package/Form/index.tsx CHANGED
@@ -1,7 +1,8 @@
1
- import { darken, makeStyles, Theme } from '@material-ui/core'
1
+ import { darken, lighten, makeStyles, Theme } from '@material-ui/core'
2
2
  import clsx from 'clsx'
3
3
  import React from 'react'
4
4
  import { UseStyles } from '../Styles'
5
+ import { responsiveVal } from '../Styles/responsiveVal'
5
6
 
6
7
  const useStyles = makeStyles(
7
8
  (theme: Theme) => ({
@@ -14,12 +15,16 @@ const useStyles = makeStyles(
14
15
  background: theme.palette.secondary.light,
15
16
  },
16
17
  default: {
17
- background: darken(theme.palette.background.paper, 0.02),
18
+ background:
19
+ theme.palette.type === 'light'
20
+ ? darken(theme.palette.background.default, 0.03)
21
+ : lighten(theme.palette.background.default, 0.2),
18
22
  },
19
23
  contained: {
20
24
  padding: theme.spacings.sm,
25
+ // paddingTop: theme.spacings.md,
21
26
  overflow: 'hidden',
22
- borderRadius: 6,
27
+ borderRadius: responsiveVal(theme.shape.borderRadius * 3, theme.shape.borderRadius * 4),
23
28
  },
24
29
  }),
25
30
  { name: 'Form' },
@@ -1,3 +1,4 @@
1
+ import { usePageRouter } from '@graphcommerce/framer-next-pages'
1
2
  import { usePrevPageRouter } from '@graphcommerce/framer-next-pages/hooks/usePrevPageRouter'
2
3
  import {
3
4
  CenterSlide,
@@ -12,11 +13,11 @@ import { clientSize, useMotionValueValue } from '@graphcommerce/framer-utils'
12
13
  import { Fab, makeStyles, Theme, useTheme, alpha } from '@material-ui/core'
13
14
  import clsx from 'clsx'
14
15
  import { m, useDomEvent, useMotionValue } from 'framer-motion'
15
- import { useRouter } from 'next/router'
16
16
  import React, { useEffect, useRef } from 'react'
17
- import { Row } from '../..'
17
+ import { classesPicker } from '../..'
18
+ import Row from '../../Row'
18
19
  import { UseStyles } from '../../Styles'
19
- import responsiveVal from '../../Styles/responsiveVal'
20
+ import { responsiveVal } from '../../Styles/responsiveVal'
20
21
  import SvgImageSimple from '../../SvgImage/SvgImageSimple'
21
22
  import { iconChevronLeft, iconChevronRight, iconFullscreen, iconFullscreenExit } from '../../icons'
22
23
 
@@ -42,14 +43,14 @@ const useStyles = makeStyles(
42
43
  rootZoomed: {
43
44
  position: 'relative',
44
45
  zIndex: theme.zIndex.modal,
45
- marginTop: `calc(${theme.page.headerInnerHeight.sm} * -1)`,
46
+ marginTop: `calc(${theme.appShell.headerHeightSm} * -1)`,
46
47
  [theme.breakpoints.up('md')]: {
47
- marginTop: `calc(${theme.page.headerInnerHeight.md} * -1 - ${theme.spacings.sm})`,
48
+ marginTop: `calc(${theme.appShell.headerHeightMd} * -1 - ${theme.spacings.lg})`,
48
49
  },
49
50
  paddingRight: 0,
50
51
  },
51
52
  scrollerContainer: ({ aspectRatio: [width, height] }: StyleProps) => {
52
- const headerHeight = `${theme.page.headerInnerHeight.sm} - ${theme.spacings.sm} * 2`
53
+ const headerHeight = `${theme.appShell.headerHeightSm} - ${theme.spacings.sm} * 2`
53
54
  const galleryMargin = theme.spacings.lg
54
55
  const extraSpacing = theme.spacings.md
55
56
 
@@ -108,7 +109,7 @@ const useStyles = makeStyles(
108
109
  sidebar: {
109
110
  boxSizing: 'border-box',
110
111
  width: '100%',
111
- padding: `${theme.spacings.md} ${theme.page.horizontal}`,
112
+ padding: `${theme.spacings.lg} ${theme.page.horizontal}`,
112
113
  [theme.breakpoints.up('md')]: {
113
114
  paddingLeft: theme.spacings.lg,
114
115
  },
@@ -172,11 +173,18 @@ export type SidebarGalleryProps = {
172
173
  } & UseStyles<typeof useStyles>
173
174
 
174
175
  export default function SidebarGallery(props: SidebarGalleryProps) {
175
- const { sidebar, images, aspectRatio = [1, 1], routeHash = 'gallery' } = props
176
- const router = useRouter()
176
+ const {
177
+ sidebar,
178
+ images,
179
+ aspectRatio = [1, 1],
180
+ routeHash = 'gallery',
181
+ classes: classesBase,
182
+ } = props
183
+
184
+ const router = usePageRouter()
177
185
  const prevRoute = usePrevPageRouter()
178
186
  const clientHeight = useMotionValueValue(clientSize.y, (y) => y)
179
- const classes = useStyles({ clientHeight, aspectRatio, classes: props.classes })
187
+ const classes = useStyles({ clientHeight, aspectRatio, classes: classesBase })
180
188
 
181
189
  const route = `#${routeHash}`
182
190
  // We're using the URL to manage the state of the gallery.
@@ -201,16 +209,12 @@ export default function SidebarGallery(props: SidebarGalleryProps) {
201
209
  }
202
210
  }
203
211
 
204
- const clsxZoom = (key: string) => clsx(classes?.[key], zoomed && classes?.[`${key}Zoomed`])
212
+ const className = classesPicker(classes, { zoomed })
205
213
  const theme = useTheme()
206
214
  const windowRef = useRef(typeof window !== 'undefined' ? window : null)
207
215
 
208
216
  const handleEscapeKey = (e: KeyboardEvent | Event) => {
209
- if (zoomed) {
210
- if ((e as KeyboardEvent)?.key === 'Escape') {
211
- toggle()
212
- }
213
- }
217
+ if (zoomed && (e as KeyboardEvent)?.key === 'Escape') toggle()
214
218
  }
215
219
 
216
220
  const dragStart = useMotionValue<number>(0)
@@ -228,16 +232,16 @@ export default function SidebarGallery(props: SidebarGalleryProps) {
228
232
  return (
229
233
  <ScrollerProvider scrollSnapAlign='center'>
230
234
  <Row maxWidth={false} disableGutters>
231
- <m.div layout className={clsxZoom('root')}>
235
+ <m.div layout {...className('root')}>
232
236
  <m.div
233
237
  layout
234
- className={clsxZoom('scrollerContainer')}
238
+ {...className('scrollerContainer')}
235
239
  onLayoutAnimationComplete={() => {
236
240
  if (!zoomed) document.body.style.overflow = ''
237
241
  }}
238
242
  >
239
243
  <Scroller
240
- className={clsxZoom('scroller')}
244
+ {...className('scroller')}
241
245
  hideScrollbar
242
246
  onMouseDown={onMouseDownScroller}
243
247
  onMouseUp={onMouseUpScroller}
@@ -299,8 +303,8 @@ export default function SidebarGallery(props: SidebarGalleryProps) {
299
303
  </div>
300
304
  </m.div>
301
305
 
302
- <div className={clsxZoom('sidebarWrapper')}>
303
- <m.div layout className={clsxZoom('sidebar')}>
306
+ <div {...className('sidebarWrapper')}>
307
+ <m.div layout {...className('sidebar')}>
304
308
  {sidebar}
305
309
  </m.div>
306
310
  </div>
@@ -8,7 +8,7 @@ import { Theme, makeStyles } from '@material-ui/core'
8
8
  import React, { ReactNode } from 'react'
9
9
  import Row from '../../Row'
10
10
  import { UseStyles } from '../../Styles'
11
- import responsiveVal from '../../Styles/responsiveVal'
11
+ import { responsiveVal } from '../../Styles/responsiveVal'
12
12
  import SvgImageSimple from '../../SvgImage/SvgImageSimple'
13
13
  import { iconChevronLeft, iconChevronRight } from '../../icons'
14
14
 
@@ -29,10 +29,8 @@ const useStyles = makeStyles(
29
29
  minWidth: 1,
30
30
  },
31
31
  scroller: {
32
- width: '100%',
33
32
  gridColumnGap: theme.spacings.md,
34
33
  gridRowGap: theme.spacings.lg,
35
- alignContent: 'space-around',
36
34
  paddingRight: theme.page.horizontal,
37
35
  gridAutoColumns: responsiveVal(200, 400),
38
36
  },
@@ -78,9 +76,7 @@ export default function SidebarSlider(props: SidebarSliderProps) {
78
76
  </div>
79
77
 
80
78
  <div className={classes.scrollerContainer}>
81
- <Scroller className={classes.scroller} hideScrollbar>
82
- {children}
83
- </Scroller>
79
+ <Scroller className={classes.scroller}>{children}</Scroller>
84
80
  <div className={classes.centerLeft}>
85
81
  <ScrollerButton layout direction='left' className={classes.sliderButtons}>
86
82
  <SvgImageSimple src={iconChevronLeft} />
@@ -2,7 +2,7 @@ import { Container, Theme, Typography } from '@material-ui/core'
2
2
  import { makeStyles } from '@material-ui/styles'
3
3
  import clsx from 'clsx'
4
4
  import React from 'react'
5
- import responsiveVal from '../Styles/responsiveVal'
5
+ import { responsiveVal } from '../Styles/responsiveVal'
6
6
 
7
7
  const useStyles = makeStyles(
8
8
  (theme: Theme) => ({
@@ -1,9 +1,8 @@
1
1
  import { makeStyles, Theme, Typography } from '@material-ui/core'
2
2
  import clsx from 'clsx'
3
3
  import React from 'react'
4
- import { SvgImageSimple } from '..'
5
- import responsiveVal from '../Styles/responsiveVal'
6
- import SvgImage, { SvgImageProps } from '../SvgImage'
4
+ import { SvgImageProps } from '../SvgImage'
5
+ import SvgImageSimple from '../SvgImage/SvgImageSimple'
7
6
 
8
7
  // TODO: remove all occurrences. deprecated component
9
8
 
@@ -73,18 +72,6 @@ export default function IconHeader(props: IconHeaderProps) {
73
72
  large: 'h2',
74
73
  }
75
74
 
76
- const iconSizes = {
77
- small: 32,
78
- medium: 48,
79
- large: 64,
80
- }
81
-
82
- const iconMobileSizes = {
83
- small: 24,
84
- medium: 32,
85
- large: 40,
86
- }
87
-
88
75
  return (
89
76
  <div className={clsx(classes.container, !noMargin && classes.margin)}>
90
77
  <div className={clsx(classes.innerContainer, !stayInline && classes.breakColumnsDesktop)}>
@@ -0,0 +1,151 @@
1
+ import { usePageContext } from '@graphcommerce/framer-next-pages'
2
+ import { makeStyles, Theme } from '@material-ui/core'
3
+ import React from 'react'
4
+ import { classesPicker } from '../../Styles/classesPicker'
5
+ import LayoutHeaderBack, { useShowBack } from './LayoutHeaderBack'
6
+ import LayoutHeaderClose, { useShowClose } from './LayoutHeaderClose'
7
+ import LayoutHeaderContent, { ContentProps } from './LayoutHeaderContent'
8
+ import { FloatingProps } from './LayoutHeadertypes'
9
+
10
+ export type LayoutHeaderProps = FloatingProps &
11
+ Omit<ContentProps, 'leftAction' | 'rightAction'> & {
12
+ /**
13
+ * Button to display on the left side of the title
14
+ *
15
+ * - Assumes it can float on desktop
16
+ * - Assumes it can not float on mobile
17
+ */
18
+ primary?: React.ReactNode
19
+ /**
20
+ * Button to display on the right side of the title
21
+ *
22
+ * - Assumes it can float on desktop
23
+ * - Assumes it can not float on mobile
24
+ */
25
+ secondary?: React.ReactNode
26
+
27
+ additional?: React.ReactNode
28
+
29
+ noAlign?: boolean
30
+ }
31
+
32
+ const useStyles = makeStyles(
33
+ (theme: Theme) => ({
34
+ sticky: {
35
+ zIndex: theme.zIndex.appBar,
36
+ position: 'sticky',
37
+ pointerEvents: 'none',
38
+
39
+ [theme.breakpoints.up('md')]: {
40
+ top: 0,
41
+ height: theme.appShell.appBarHeightMd,
42
+ marginTop: `calc((${theme.appShell.appBarHeightMd} - ${theme.appShell.appBarInnerHeightMd}) * -0.5)`,
43
+ marginBottom: `calc(${theme.appShell.appBarHeightMd} * -1 - calc((${theme.appShell.appBarHeightMd} - ${theme.appShell.appBarInnerHeightMd}) * -0.5))`,
44
+ },
45
+ },
46
+ stickyNoChildren: {
47
+ zIndex: theme.zIndex.appBar - 2,
48
+ },
49
+ stickyVisibleSm: {
50
+ [theme.breakpoints.down('sm')]: {
51
+ top: 0,
52
+ marginTop: `calc(${theme.appShell.headerHeightSm} * -1)`,
53
+ height: theme.appShell.headerHeightSm,
54
+ },
55
+ },
56
+ stickyFloatingSm: {
57
+ [theme.breakpoints.down('sm')]: {
58
+ top: 0,
59
+ marginTop: `calc(${theme.appShell.headerHeightSm} * -1)`,
60
+ height: theme.appShell.headerHeightSm,
61
+ },
62
+ },
63
+ stickyFloatingMd: {
64
+ [theme.breakpoints.up('md')]: {
65
+ top: `calc(${theme.appShell.headerHeightMd} + calc((${theme.appShell.appBarHeightMd} - ${theme.appShell.appBarInnerHeightMd}) * -0.5))`,
66
+ },
67
+ },
68
+ stickyNoAlign: {
69
+ [theme.breakpoints.down('sm')]: {
70
+ position: 'sticky',
71
+ left: 0,
72
+ right: 0,
73
+ top: 0,
74
+ marginTop: 0,
75
+ height: theme.appShell.headerHeightSm,
76
+ marginBottom: `calc(${theme.appShell.headerHeightSm} * -1)`,
77
+ },
78
+ [theme.breakpoints.up('md')]: {
79
+ position: 'sticky',
80
+ left: 0,
81
+ right: 0,
82
+ top: 0,
83
+ marginTop: 0,
84
+ height: theme.appShell.appBarHeightMd,
85
+ marginBottom: `calc(${theme.appShell.appBarHeightMd} * -1)`,
86
+ },
87
+ },
88
+ stickyDivider: {
89
+ [theme.breakpoints.down('sm')]: {
90
+ marginBottom: 0,
91
+ },
92
+ [theme.breakpoints.up('md')]: {
93
+ marginBottom: 0,
94
+ },
95
+ },
96
+ }),
97
+ { name: 'LayoutHeader' },
98
+ )
99
+
100
+ export function LayoutHeader(props: LayoutHeaderProps) {
101
+ const { children, additional, divider, primary, secondary, noAlign } = props
102
+ const classes = useStyles(props)
103
+ const showBack = useShowBack()
104
+ const showClose = useShowClose()
105
+
106
+ const floatFallback = !children
107
+ let { floatingSm = false, floatingMd = floatFallback } = props
108
+
109
+ if (divider) floatingMd = false
110
+
111
+ // When the primary or secondary is set, the header can't float on mobile even if the prop is passed.
112
+ if (divider || primary || secondary) floatingSm = false
113
+
114
+ const close = showClose && <LayoutHeaderClose />
115
+ const back = showBack && <LayoutHeaderBack variant={floatingSm ? 'pill' : 'pill-link'} />
116
+
117
+ let left = secondary
118
+ let right = primary
119
+
120
+ if (back) left = back
121
+
122
+ if (!left) left = close
123
+ else if (!right) right = close
124
+
125
+ if (!left && !right && !children) return null
126
+
127
+ const className = classesPicker(classes, {
128
+ floatingSm,
129
+ floatingMd,
130
+ visibleSm: !floatingSm,
131
+ visibleMd: !floatingMd,
132
+ noChildren: !children,
133
+ noAlign,
134
+ divider: !!divider,
135
+ })
136
+
137
+ return (
138
+ <div {...className('sticky')}>
139
+ <LayoutHeaderContent
140
+ left={left}
141
+ right={right}
142
+ divider={divider}
143
+ floatingMd={floatingMd}
144
+ floatingSm={floatingSm}
145
+ >
146
+ {children}
147
+ {additional}
148
+ </LayoutHeaderContent>
149
+ </div>
150
+ )
151
+ }
@@ -0,0 +1,50 @@
1
+ import { usePageRouter, useUp, usePrevUp, usePageContext } from '@graphcommerce/framer-next-pages'
2
+ import { Trans } from '@lingui/macro'
3
+ import PageLink from 'next/link'
4
+ import React from 'react'
5
+ import Button, { ButtonProps } from '../../Button'
6
+ import SvgImageSimple from '../../SvgImage/SvgImageSimple'
7
+ import { iconChevronLeft } from '../../icons'
8
+
9
+ export type BackProps = Omit<ButtonProps, 'onClick' | 'children'>
10
+
11
+ export function useShowBack() {
12
+ const router = usePageRouter()
13
+ const up = useUp()
14
+ const prevUp = usePrevUp()
15
+ const { backSteps } = usePageContext()
16
+
17
+ const canClickBack = backSteps > 0 && router.asPath !== prevUp?.href
18
+
19
+ if (canClickBack) return true
20
+ if (up?.href && up.href !== router.asPath) return true
21
+ return false
22
+ }
23
+
24
+ export default function LayoutHeaderBack(props: BackProps) {
25
+ const router = usePageRouter()
26
+ const up = useUp()
27
+ const prevUp = usePrevUp()
28
+ const { backSteps } = usePageContext()
29
+
30
+ const backIcon = <SvgImageSimple src={iconChevronLeft} />
31
+ const canClickBack = backSteps > 0 && router.asPath !== prevUp?.href
32
+
33
+ if (canClickBack)
34
+ return (
35
+ <Button onClick={() => router.back()} variant='pill-link' startIcon={backIcon} {...props}>
36
+ {up?.href === router.asPath ? up.title : <Trans>Back</Trans>}
37
+ </Button>
38
+ )
39
+
40
+ if (up?.href && up.href !== router.asPath)
41
+ return (
42
+ <PageLink href={up.href} passHref>
43
+ <Button variant='pill-link' startIcon={backIcon} {...props}>
44
+ {up.title}
45
+ </Button>
46
+ </PageLink>
47
+ )
48
+
49
+ return null
50
+ }
@@ -0,0 +1,27 @@
1
+ import { usePageRouter, usePageContext } from '@graphcommerce/framer-next-pages'
2
+ import React from 'react'
3
+ import Button from '../../Button'
4
+ import SvgImageSimple from '../../SvgImage/SvgImageSimple'
5
+ import { iconClose } from '../../icons'
6
+
7
+ export function useShowClose() {
8
+ const { overlayGroup } = usePageContext()
9
+ return !!overlayGroup
10
+ }
11
+
12
+ export default function LayoutHeaderClose() {
13
+ const router = usePageRouter()
14
+ const { closeSteps } = usePageContext()
15
+
16
+ return (
17
+ <Button
18
+ type='button'
19
+ onClick={() => router.go(closeSteps * -1)}
20
+ aria-label='Close'
21
+ variant='pill-link'
22
+ startIcon={<SvgImageSimple src={iconClose} />}
23
+ >
24
+ Close
25
+ </Button>
26
+ )
27
+ }