@graphcommerce/next-ui 3.1.6 → 3.2.2

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.
@@ -91,6 +91,11 @@ export default function MenuFab(props: MenuFabProps) {
91
91
  onClose={() => setOpenEl(null)}
92
92
  classes={{ paper: classes.menu }}
93
93
  disableScrollLock
94
+ transitionDuration={{
95
+ appear: 175,
96
+ enter: 175,
97
+ exit: 175,
98
+ }}
94
99
  >
95
100
  {search && (
96
101
  <List>
package/Button/index.tsx CHANGED
@@ -56,7 +56,7 @@ const useStyles = makeStyles<
56
56
  [theme.breakpoints.up('md')]: {
57
57
  background: theme.palette.secondary.main,
58
58
  color: theme.palette.secondary.contrastText,
59
- boxShadow: theme.shadows[2],
59
+ boxShadow: theme.shadows[6],
60
60
  borderRadius: 25,
61
61
  padding: '6px 16px',
62
62
  fontWeight: theme.typography.fontWeightBold,
package/CHANGELOG.md CHANGED
@@ -3,6 +3,63 @@
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.2.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.2.1...@graphcommerce/next-ui@3.2.2) (2021-10-11)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **menu-fab:** animation duration ([5b9ece2](https://github.com/ho-nl/m2-pwa/commit/5b9ece293fb7e12663386f9f9cbc99bc4e22aaa9))
12
+
13
+
14
+
15
+
16
+
17
+ ## [3.2.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.2.0...@graphcommerce/next-ui@3.2.1) (2021-10-11)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **framer-scroller:** dots should have a background ([8f2e1a1](https://github.com/ho-nl/m2-pwa/commit/8f2e1a1ffc9de3369938fe2f9e9f25f592739d8d))
23
+
24
+
25
+
26
+
27
+
28
+ # [3.2.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.1.7...@graphcommerce/next-ui@3.2.0) (2021-10-09)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **framer-scroller:** pan snap does not work on mobile ([660f242](https://github.com/ho-nl/m2-pwa/commit/660f242a38558669fa896a74e14cafdd85069d57))
34
+ * **framer-slider:** route changes ([4cadbea](https://github.com/ho-nl/m2-pwa/commit/4cadbea3e494326377e74e2fa9370ab80f8d8c35))
35
+ * make sure the gallery never gets higher than 100% ([1eae8c7](https://github.com/ho-nl/m2-pwa/commit/1eae8c7cfb2a9e67f03f1e4e4db5c95213d2dbe0))
36
+ * poistioning on mobile ([bec497f](https://github.com/ho-nl/m2-pwa/commit/bec497fca426346b80b453a3871b9c66521a2161))
37
+ * **sidebar-gallery:** differentiate drag from click ([acd408e](https://github.com/ho-nl/m2-pwa/commit/acd408e400f8285e2b3a9105b4694d5fd839dd99))
38
+ * **sidebar-gallery:** push gallery to history one time ([2c45b64](https://github.com/ho-nl/m2-pwa/commit/2c45b64e171577f7b584662d56416eeae4a22554))
39
+ * **sidebar-gallery:** route handling ([1c3b8b1](https://github.com/ho-nl/m2-pwa/commit/1c3b8b1687b0bf637da6c88d2d9b30a734b98d11))
40
+ * **sidebar-gallery:** use fullscreen and fullscreen exit icons ([1328d22](https://github.com/ho-nl/m2-pwa/commit/1328d220030f766be2d4046abd87d45175e4fe38))
41
+ * use better URL handling and remove drag temporarily ([0b99387](https://github.com/ho-nl/m2-pwa/commit/0b993876280270320eef5301130c5cc3eb339ea9))
42
+
43
+
44
+ ### Features
45
+
46
+ * **sidebar-gallery:** toggle with browser back buttons ([a2f804b](https://github.com/ho-nl/m2-pwa/commit/a2f804b0cedb98df8f6a7b197aeeeeda43c6b1ba))
47
+
48
+
49
+
50
+
51
+
52
+ ## [3.1.7](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.1.6...@graphcommerce/next-ui@3.1.7) (2021-10-08)
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * SvgImageSimple should pass the layout prop ([a0b5c81](https://github.com/ho-nl/m2-pwa/commit/a0b5c818f93ba24a34c6ce8aa21f8af50bd05dd2))
58
+
59
+
60
+
61
+
62
+
6
63
  ## [3.1.6](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.1.5...@graphcommerce/next-ui@3.1.6) (2021-10-07)
7
64
 
8
65
 
@@ -1,3 +1,4 @@
1
+ import { usePrevPageRouter } from '@graphcommerce/framer-next-pages/hooks/usePrevPageRouter'
1
2
  import {
2
3
  CenterSlide,
3
4
  MotionImageAspect,
@@ -8,24 +9,21 @@ import {
8
9
  ScrollerProvider,
9
10
  } from '@graphcommerce/framer-scroller'
10
11
  import { clientSize, useMotionValueValue } from '@graphcommerce/framer-utils'
11
- import { Fab, makeStyles, Theme, useTheme } from '@material-ui/core'
12
+ import { Fab, makeStyles, Theme, useTheme, alpha } from '@material-ui/core'
12
13
  import clsx from 'clsx'
13
- import { m, useDomEvent } from 'framer-motion'
14
- import React, { useRef, useState } from 'react'
14
+ import { m, useDomEvent, useMotionValue } from 'framer-motion'
15
+ import { useRouter } from 'next/router'
16
+ import React, { useEffect, useRef } from 'react'
15
17
  import { UseStyles } from '../../Styles'
16
18
  import responsiveVal from '../../Styles/responsiveVal'
17
19
  import SvgImage from '../../SvgImage'
18
20
  import SvgImageSimple from '../../SvgImage/SvgImageSimple'
19
- import {
20
- iconChevronLeft,
21
- iconChevronRight,
22
- iconCollapseVertical,
23
- iconExpandVertical,
24
- } from '../../icons'
21
+ import { iconChevronLeft, iconChevronRight, iconFullscreen, iconFullscreenExit } from '../../icons'
25
22
 
26
23
  type StyleProps = {
27
24
  aspectRatio: [number, number]
28
25
  clientHeight: number
26
+ classes?: Record<string, unknown>
29
27
  }
30
28
 
31
29
  const useStyles = makeStyles(
@@ -42,7 +40,7 @@ const useStyles = makeStyles(
42
40
  rootZoomed: {
43
41
  position: 'relative',
44
42
  zIndex: theme.zIndex.modal,
45
- marginTop: 0,
43
+ marginTop: `calc(${theme.page.headerInnerHeight.sm} * -1)`,
46
44
  [theme.breakpoints.up('md')]: {
47
45
  marginTop: `calc(${theme.page.headerInnerHeight.md} * -1 - ${theme.spacings.sm})`,
48
46
  },
@@ -79,8 +77,12 @@ const useStyles = makeStyles(
79
77
  gridAutoFlow: `column`,
80
78
  gridTemplateColumns: `repeat(100, 100%)`,
81
79
  gridTemplateRows: `100%`,
80
+ cursor: 'zoom-in',
82
81
  },
83
-
82
+ scrollerZoomed: ({ clientHeight }: StyleProps) => ({
83
+ height: clientHeight,
84
+ cursor: 'inherit',
85
+ }),
84
86
  sidebarWrapper: {
85
87
  boxSizing: 'content-box',
86
88
  display: 'grid',
@@ -130,7 +132,7 @@ const useStyles = makeStyles(
130
132
  },
131
133
  },
132
134
  toggleIcon: {
133
- boxShadow: theme.shadows[2],
135
+ boxShadow: theme.shadows[6],
134
136
  },
135
137
  topRight: {
136
138
  display: 'grid',
@@ -155,6 +157,9 @@ const useStyles = makeStyles(
155
157
  right: theme.spacings.sm,
156
158
  top: `calc(50% - 28px)`,
157
159
  },
160
+ dots: {
161
+ background: alpha(theme.palette.background.highlight, 0.7),
162
+ },
158
163
  }),
159
164
  { name: 'SidebarGallery' },
160
165
  )
@@ -163,27 +168,41 @@ export type SidebarGalleryProps = {
163
168
  sidebar: React.ReactNode
164
169
  images: MotionImageAspectProps[]
165
170
  aspectRatio?: [number, number]
171
+ routeHash?: string
166
172
  } & UseStyles<typeof useStyles>
167
173
 
168
174
  export default function SidebarGallery(props: SidebarGalleryProps) {
169
- const { sidebar, images, aspectRatio = [1, 1] } = props
170
- const [zoomed, setZoomed] = useState(false)
171
-
175
+ const { sidebar, images, aspectRatio = [1, 1], routeHash = 'gallery' } = props
176
+ const router = useRouter()
177
+ const prevRoute = usePrevPageRouter()
172
178
  const clientHeight = useMotionValueValue(clientSize.y, (y) => y)
173
- const classes = useStyles({ clientHeight, aspectRatio })
179
+ const classes = useStyles({ clientHeight, aspectRatio, classes: props.classes })
180
+
181
+ const route = `#${routeHash}`
182
+ // We're using the URL to manage the state of the gallery.
183
+ const zoomed = router.asPath.endsWith(route)
184
+
185
+ // cleanup if someone enters the page with #gallery
186
+ useEffect(() => {
187
+ if (!prevRoute?.pathname && zoomed) {
188
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
189
+ router.replace(router.asPath.replace(route, ''))
190
+ }
191
+ }, [prevRoute?.pathname, route, router, zoomed])
174
192
 
175
193
  const toggle = () => {
176
- setZoomed(!zoomed)
177
194
  if (!zoomed) {
195
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
196
+ router.push(route, undefined, { shallow: true })
178
197
  document.body.style.overflow = 'hidden'
179
198
  window.scrollTo({ top: 0, behavior: 'smooth' })
199
+ } else {
200
+ router.back()
180
201
  }
181
202
  }
182
203
 
183
204
  const clsxZoom = (key: string) => clsx(classes?.[key], zoomed && classes?.[`${key}Zoomed`])
184
-
185
205
  const theme = useTheme()
186
-
187
206
  const windowRef = useRef(typeof window !== 'undefined' ? window : null)
188
207
 
189
208
  const handleEscapeKey = (e: KeyboardEvent | Event) => {
@@ -194,6 +213,16 @@ export default function SidebarGallery(props: SidebarGalleryProps) {
194
213
  }
195
214
  }
196
215
 
216
+ const dragStart = useMotionValue<number>(0)
217
+ const onMouseDownScroller: React.MouseEventHandler<HTMLDivElement> = (e) => {
218
+ if (dragStart.get() === e.clientX) return
219
+ dragStart.set(e.clientX)
220
+ }
221
+ const onMouseUpScroller: React.MouseEventHandler<HTMLDivElement> = (e) => {
222
+ const currentDragLoc = e.clientX
223
+ if (Math.abs(currentDragLoc - dragStart.get()) < 8) toggle()
224
+ }
225
+
197
226
  useDomEvent(windowRef, 'keyup', handleEscapeKey, { passive: true })
198
227
 
199
228
  return (
@@ -206,7 +235,12 @@ export default function SidebarGallery(props: SidebarGalleryProps) {
206
235
  if (!zoomed) document.body.style.overflow = ''
207
236
  }}
208
237
  >
209
- <Scroller className={clsxZoom('scroller')} hideScrollbar>
238
+ <Scroller
239
+ className={clsxZoom('scroller')}
240
+ hideScrollbar
241
+ onMouseDown={onMouseDownScroller}
242
+ onMouseUp={onMouseUpScroller}
243
+ >
210
244
  {images.map((image, idx) => (
211
245
  <CenterSlide key={typeof image.src === 'string' ? image.src : idx}>
212
246
  <MotionImageAspect
@@ -225,11 +259,11 @@ export default function SidebarGallery(props: SidebarGalleryProps) {
225
259
  ))}
226
260
  </Scroller>
227
261
  <m.div layout className={classes.topRight}>
228
- <Fab color='inherit' size='small' className={classes.toggleIcon} onClick={toggle}>
262
+ <Fab color='inherit' size='small' className={classes.toggleIcon} onMouseUp={toggle}>
229
263
  {!zoomed ? (
230
- <SvgImage src={iconExpandVertical} alt='Zoom in' loading='eager' />
264
+ <SvgImage src={iconFullscreen} alt='Zoom in' loading='eager' size='small' />
231
265
  ) : (
232
- <SvgImage src={iconCollapseVertical} alt='Zoom out' loading='eager' />
266
+ <SvgImage src={iconFullscreenExit} alt='Zoom out' loading='eager' size='small' />
233
267
  )}
234
268
  </Fab>
235
269
  </m.div>
@@ -245,9 +279,10 @@ export default function SidebarGallery(props: SidebarGalleryProps) {
245
279
  </div>
246
280
 
247
281
  <div className={classes.bottomCenter}>
248
- <ScrollerDots layout />
282
+ <ScrollerDots layout classes={{ dots: classes.dots }} />
249
283
  </div>
250
284
  </m.div>
285
+
251
286
  <div className={clsxZoom('sidebarWrapper')}>
252
287
  <m.div layout className={clsxZoom('sidebar')}>
253
288
  {sidebar}
@@ -1,4 +1,3 @@
1
- import { relative } from 'path/posix'
2
1
  import {
3
2
  Scroller,
4
3
  ScrollerButton,
@@ -8,9 +7,10 @@ import {
8
7
  import { Theme } from '@material-ui/core'
9
8
  import { makeStyles } from '@material-ui/styles'
10
9
  import React, { ReactNode } from 'react'
11
- import { SvgImageSimple, iconChevronLeft, iconChevronRight } from '../..'
12
10
  import { UseStyles } from '../../Styles'
13
11
  import responsiveVal from '../../Styles/responsiveVal'
12
+ import SvgImageSimple from '../../SvgImage/SvgImageSimple'
13
+ import { iconChevronLeft, iconChevronRight } from '../../icons'
14
14
 
15
15
  const useStyles = makeStyles(
16
16
  (theme: Theme) => ({
@@ -37,7 +37,6 @@ const useStyles = makeStyles(
37
37
  gridRowGap: theme.spacings.lg,
38
38
  alignContent: 'space-around',
39
39
  paddingRight: theme.page.horizontal,
40
-
41
40
  '& > *': {
42
41
  minWidth: responsiveVal(200, 400),
43
42
  },
@@ -11,6 +11,11 @@ const useStyles = makeStyles(
11
11
  marginTop: theme.spacings.md,
12
12
  marginBottom: theme.spacings.md,
13
13
  },
14
+ innerContainer: {
15
+ display: 'grid',
16
+ alignItems: 'center',
17
+ justifyItems: 'center',
18
+ },
14
19
  rootMargin: {
15
20
  marginTop: responsiveVal(50, 250),
16
21
  },
@@ -18,21 +23,18 @@ const useStyles = makeStyles(
18
23
  textAlign: 'center',
19
24
  marginTop: theme.spacings.sm,
20
25
  },
21
- innerContainer: {
22
- display: 'grid',
23
- alignItems: 'center',
24
- justifyItems: 'center',
25
- },
26
+
26
27
  button: {
27
28
  marginTop: theme.spacings.sm,
28
29
  },
29
30
  altButton: {
30
31
  marginTop: 6,
31
32
  },
33
+ icon: {
34
+ height: responsiveVal(120, 180),
35
+ },
32
36
  }),
33
- {
34
- name: 'FullPageMessage',
35
- },
37
+ { name: 'FullPageMessage' },
36
38
  )
37
39
 
38
40
  export type FullPageMessageProps = {
@@ -51,7 +53,7 @@ export default function FullPageMessage(props: FullPageMessageProps) {
51
53
  return (
52
54
  <div className={clsx(classes.root, disableMargin || classes.rootMargin)}>
53
55
  <Container maxWidth='md' className={classes.innerContainer}>
54
- {icon}
56
+ <div className={classes.icon}>{icon}</div>
55
57
 
56
58
  <div className={classes.subject}>
57
59
  <Typography variant='h3' gutterBottom>
@@ -42,14 +42,14 @@ type SvgImageSimpleProps = Omit<ImageProps, 'fixed'> & {
42
42
  }
43
43
 
44
44
  const SvgImageSimple = forwardRef<HTMLImageElement, SvgImageSimpleProps>((props, ref) => {
45
- const { className, size = 'medium', muted, inverted, ...imageProps } = props
45
+ const { className, size = 'medium', muted, inverted, layout = 'fixed', ...imageProps } = props
46
46
  const classes = useStyles()
47
47
 
48
48
  return (
49
49
  <Image
50
50
  {...imageProps}
51
51
  ref={ref}
52
- layout='fixed'
52
+ layout={layout}
53
53
  className={clsx(
54
54
  className,
55
55
  classes.image,
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z"/></svg>
package/icons/index.tsx CHANGED
@@ -12,11 +12,9 @@ export { default as iconChevronRight } from './icon_chevron_right.svg'
12
12
  export { default as iconChevronUp } from './icon_chevron_up.svg'
13
13
  export { default as iconClose } from './icon_close.svg'
14
14
  export { default as iconCloseCircle } from './icon_close_circle.svg'
15
- export { default as iconCollapseVertical } from './icon_collapse_vertical.svg'
16
15
  export { default as iconCustomerService } from './icon_customer_service.svg'
17
16
  export { default as iconEmail } from './icon_email.svg'
18
17
  export { default as iconEmailOutline } from './icon_email_outline.svg'
19
- export { default as iconExpandVertical } from './icon_expand_vertical.svg'
20
18
  export { default as iconHeart } from './icon_heart.svg'
21
19
  export { default as iconHome } from './icon_home.svg'
22
20
  export { default as iconId } from './icon_id.svg'
@@ -40,3 +38,5 @@ export { default as iconStar } from './icon_star.svg'
40
38
  export { default as iconStarFilledMuted } from './icon_star_filled_muted.svg'
41
39
  export { default as iconStarYellow } from './icon_star_yellow.svg'
42
40
  export { default as iconParty } from './icon_party.svg'
41
+ export { default as iconFullscreenExit } from './icon_fullscreen_exit.svg'
42
+ export { default as iconFullscreen } from './icon_fullscreen.svg'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/next-ui",
3
- "version": "3.1.6",
3
+ "version": "3.2.2",
4
4
  "author": "",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -10,12 +10,12 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@apollo/client": "^3.4.16",
13
- "@graphcommerce/framer-next-pages": "^2.106.6",
14
- "@graphcommerce/framer-scroller": "^0.2.7",
15
- "@graphcommerce/framer-sheet": "^2.105.5",
16
- "@graphcommerce/framer-utils": "^2.103.5",
13
+ "@graphcommerce/framer-next-pages": "^2.106.7",
14
+ "@graphcommerce/framer-scroller": "^0.2.9",
15
+ "@graphcommerce/framer-sheet": "^2.105.7",
16
+ "@graphcommerce/framer-utils": "^2.103.6",
17
17
  "@graphcommerce/graphql": "^2.103.5",
18
- "@graphcommerce/image": "^2.104.6",
18
+ "@graphcommerce/image": "^2.104.8",
19
19
  "@graphql-typed-document-node/core": "^3.1.0",
20
20
  "@material-ui/core": "^4.12.3",
21
21
  "@material-ui/lab": "^4.0.0-alpha.60",
@@ -55,5 +55,5 @@
55
55
  "project": "./tsconfig.json"
56
56
  }
57
57
  },
58
- "gitHead": "717bd3c1658e421c247c1f8b210935cdb7780197"
58
+ "gitHead": "be6fb6e501c76d846b06935bf61e949f82f0c50f"
59
59
  }
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
4
- <g id="arrow-bar-right" transform="translate(16.000000, 16.000000) scale(-1, 1) translate(-16.000000, -16.000000) translate(8.000000, 8.000000)" stroke="#000000" stroke-width="1.5">
5
- <line x1="16" y1="8" x2="6" y2="8" id="Path"></line>
6
- <line x1="16" y1="8" x2="12" y2="12" id="Path"></line>
7
- <line x1="16" y1="8" x2="12" y2="4" id="Path"></line>
8
- <line x1="1" y1="0" x2="1" y2="16" id="Path"></line>
9
- </g>
10
- </g>
11
- </svg>
@@ -1,11 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg width="32px" height="32px" viewBox="0 0 32 32" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round">
4
- <g id="arrow-bar-right" transform="translate(8.000000, 8.000000)" stroke="#000000" stroke-width="1.5">
5
- <line x1="16" y1="8" x2="6" y2="8" id="Path"></line>
6
- <line x1="16" y1="8" x2="12" y2="12" id="Path"></line>
7
- <line x1="16" y1="8" x2="12" y2="4" id="Path"></line>
8
- <line x1="1" y1="0" x2="1" y2="16" id="Path"></line>
9
- </g>
10
- </g>
11
- </svg>