@graphcommerce/next-ui 4.23.1 → 4.25.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.25.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1641](https://github.com/graphcommerce-org/graphcommerce/pull/1641) [`dc6237644`](https://github.com/graphcommerce-org/graphcommerce/commit/dc6237644ac349debb728059e4c937cec25bf4fd) Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Fix overlay content stretch bug on hover while animating
8
+
9
+ * [#1643](https://github.com/graphcommerce-org/graphcommerce/pull/1643) [`48273bccd`](https://github.com/graphcommerce-org/graphcommerce/commit/48273bccd2e471ce4bc024a600e693da791f1cde) Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Show current navigation title on item interaction
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies []:
14
+ - @graphcommerce/framer-scroller@2.1.37
15
+
16
+ ## 4.24.0
17
+
18
+ ### Minor Changes
19
+
20
+ - [#1638](https://github.com/graphcommerce-org/graphcommerce/pull/1638) [`104103bc2`](https://github.com/graphcommerce-org/graphcommerce/commit/104103bc2a0fbaa510af2e26b6b00ddc63e8495b) Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Fix navigation overlay visibility bug
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies []:
25
+ - @graphcommerce/framer-scroller@2.1.36
26
+
3
27
  ## 4.23.1
4
28
 
5
29
  ### Patch Changes
@@ -1,6 +1,14 @@
1
1
  /* eslint-disable @typescript-eslint/no-use-before-define */
2
2
  import { useMotionValueValue } from '@graphcommerce/framer-utils'
3
- import { Box, ListItemButton, styled, Theme, useEventCallback, useMediaQuery } from '@mui/material'
3
+ import {
4
+ Box,
5
+ ListItemButton,
6
+ styled,
7
+ Theme,
8
+ useEventCallback,
9
+ useMediaQuery,
10
+ alpha,
11
+ } from '@mui/material'
4
12
  import PageLink from 'next/link'
5
13
  import React from 'react'
6
14
  import { IconSvg } from '../../IconSvg'
@@ -92,7 +100,7 @@ export const NavigationItem = React.memo<NavigationItemProps>((props) => {
92
100
  display: hideItem ? 'none' : 'flex',
93
101
  '&.Mui-disabled': {
94
102
  opacity: 1,
95
- background: theme.palette.action.hover,
103
+ background: alpha(theme.palette.action.hover, 0.025),
96
104
  },
97
105
  }),
98
106
  mouseEvent === 'hover'
@@ -1,8 +1,7 @@
1
1
  import styled from '@emotion/styled'
2
2
  import { useMotionValueValue, useMotionSelector } from '@graphcommerce/framer-utils'
3
3
  import { i18n } from '@lingui/core'
4
- import { Trans } from '@lingui/react'
5
- import { Box, Fab, SxProps, Theme, useEventCallback, useMediaQuery } from '@mui/material'
4
+ import { Box, Fab, SxProps, Theme, useEventCallback, useTheme } from '@mui/material'
6
5
  import { m } from 'framer-motion'
7
6
  import React, { useEffect } from 'react'
8
7
  import type { LiteralUnion } from 'type-fest'
@@ -13,17 +12,10 @@ import { Overlay } from '../../Overlay/components/Overlay'
13
12
  import { extendableComponent } from '../../Styles/extendableComponent'
14
13
  import { useFabSize } from '../../Theme'
15
14
  import { iconClose, iconChevronLeft } from '../../icons'
16
- import {
17
- isNavigationButton,
18
- isNavigationComponent,
19
- NavigationContextType,
20
- NavigationNodeButton,
21
- NavigationNodeHref,
22
- NavigationPath,
23
- useNavigation,
24
- } from '../hooks/useNavigation'
15
+ import { useNavigation } from '../hooks/useNavigation'
25
16
  import { mouseEventPref } from './NavigationItem'
26
17
  import { NavigationList } from './NavigationList'
18
+ import { NavigationTitle } from './NavigationTitle'
27
19
 
28
20
  type LayoutOverlayVariant = 'left' | 'bottom' | 'right'
29
21
  type LayoutOverlaySize = 'floating' | 'minimal' | 'full'
@@ -44,28 +36,6 @@ type NavigationOverlayProps = {
44
36
  itemPadding?: ItemPadding
45
37
  } & mouseEventPref
46
38
 
47
- function findCurrent(
48
- items: NavigationContextType['items'],
49
- selected: NavigationPath | false,
50
- ): NavigationNodeHref | NavigationNodeButton | undefined {
51
- if (selected === false) return undefined
52
- const lastItem = selected.slice(-1)[0]
53
-
54
- if (!lastItem) return undefined
55
-
56
- for (const item of items) {
57
- // eslint-disable-next-line no-continue
58
- if (isNavigationComponent(item)) continue
59
-
60
- // If the item is the current one, return it
61
- if (item.id === lastItem) return item
62
-
63
- // Recursively find item
64
- if (isNavigationButton(item)) return findCurrent(item.childItems, selected)
65
- }
66
- return undefined
67
- }
68
-
69
39
  const MotionDiv = styled(m.div)()
70
40
 
71
41
  const componentName = 'Navigation'
@@ -92,9 +62,9 @@ export const NavigationOverlay = React.memo<NavigationOverlayProps>((props) => {
92
62
  const fabSize = useFabSize('responsive')
93
63
  const svgSize = useIconSvgSize('large')
94
64
 
95
- const isMobile = useMediaQuery<Theme>((theme) => theme.breakpoints.down('md'))
65
+ const theme2 = useTheme()
96
66
  const handleOnBack = useEventCallback(() => {
97
- if (isMobile) {
67
+ if (window.matchMedia(`(max-width: ${theme2.breakpoints.values.md}px)`).matches) {
98
68
  const current = selection.get()
99
69
  selection.set(current !== false ? current.slice(0, -1) : false)
100
70
  } else selection.set([])
@@ -106,7 +76,7 @@ export const NavigationOverlay = React.memo<NavigationOverlayProps>((props) => {
106
76
  )
107
77
 
108
78
  useEffect(() => {
109
- animating.set(false)
79
+ animating.set(true)
110
80
  }, [activeAndNotClosing, animating])
111
81
 
112
82
  const afterClose = useEventCallback(() => {
@@ -199,7 +169,7 @@ export const NavigationOverlay = React.memo<NavigationOverlayProps>((props) => {
199
169
  }
200
170
  >
201
171
  <LayoutTitle size='small' component='span'>
202
- {findCurrent(items, selection.get())?.name ?? <Trans id='Menu' />}
172
+ <NavigationTitle />
203
173
  </LayoutTitle>
204
174
  </LayoutHeaderContent>
205
175
  </Box>
@@ -207,44 +177,50 @@ export const NavigationOverlay = React.memo<NavigationOverlayProps>((props) => {
207
177
 
208
178
  <MotionDiv layout='position' style={{ display: 'grid' }}>
209
179
  <Box
210
- sx={(theme) => ({
211
- display: 'grid',
212
- alignItems: !stretchColumns ? 'start' : undefined,
213
- '& .NavigationItem-item': {
214
- // eslint-disable-next-line no-nested-ternary
215
- width: itemWidthMd
216
- ? selectedLevel >= 1
217
- ? `calc(${itemWidthMd} + 1px)`
218
- : itemWidthMd
219
- : 'stretch',
220
- },
221
- [theme.breakpoints.down('md')]: {
222
- width:
223
- sizeSm !== 'floating'
224
- ? `calc(${itemWidthSm || '100vw'} + ${selectedLevel}px)`
225
- : `calc(${itemWidthSm || '100vw'} - ${theme.page.horizontal} - ${
226
- theme.page.horizontal
227
- })`,
228
- minWidth: 200,
229
- overflow: 'hidden',
230
- scrollSnapType: 'x mandatory',
180
+ sx={[
181
+ (theme) => ({
182
+ display: 'grid',
183
+ alignItems: !stretchColumns ? 'start' : undefined,
231
184
  '& .NavigationItem-item': {
232
- width:
233
- sizeSm !== 'floating'
234
- ? `calc(${itemWidthSm || '100vw'} - ${
235
- theme.spacings[itemPadding] ?? itemPadding
236
- } - ${theme.spacings[itemPadding] ?? itemPadding} + ${selectedLevel}px)`
237
- : `calc(${itemWidthSm || '100vw'} - ${
238
- theme.spacings[itemPadding] ?? itemPadding
239
- } - ${theme.spacings[itemPadding] ?? itemPadding} - ${
240
- theme.page.horizontal
241
- } - ${theme.page.horizontal})`,
242
- minWidth: `calc(${200}px - ${theme.spacings[itemPadding] ?? itemPadding} - ${
243
- theme.spacings[itemPadding] ?? itemPadding
244
- })`,
185
+ // eslint-disable-next-line no-nested-ternary
186
+ width: itemWidthMd
187
+ ? selectedLevel >= 1
188
+ ? `calc(${itemWidthMd} + 1px)`
189
+ : itemWidthMd
190
+ : 'stretch',
245
191
  },
246
- },
247
- })}
192
+ }),
193
+ activeAndNotClosing
194
+ ? (theme) => ({
195
+ [theme.breakpoints.down('md')]: {
196
+ width:
197
+ sizeSm !== 'floating'
198
+ ? `calc(${itemWidthSm || '100vw'} + ${selectedLevel}px)`
199
+ : `calc(${itemWidthSm || '100vw'} - ${theme.page.horizontal} - ${
200
+ theme.page.horizontal
201
+ })`,
202
+ minWidth: 200,
203
+ overflow: 'hidden',
204
+ scrollSnapType: 'x mandatory',
205
+ '& .NavigationItem-item': {
206
+ width:
207
+ sizeSm !== 'floating'
208
+ ? `calc(${itemWidthSm || '100vw'} - ${
209
+ theme.spacings[itemPadding] ?? itemPadding
210
+ } - ${theme.spacings[itemPadding] ?? itemPadding} + ${selectedLevel}px)`
211
+ : `calc(${itemWidthSm || '100vw'} - ${
212
+ theme.spacings[itemPadding] ?? itemPadding
213
+ } - ${theme.spacings[itemPadding] ?? itemPadding} - ${
214
+ theme.page.horizontal
215
+ } - ${theme.page.horizontal})`,
216
+ minWidth: `calc(${200}px - ${theme.spacings[itemPadding] ?? itemPadding} - ${
217
+ theme.spacings[itemPadding] ?? itemPadding
218
+ })`,
219
+ },
220
+ },
221
+ })
222
+ : {},
223
+ ]}
248
224
  >
249
225
  <Box
250
226
  className={classes.navigation}
@@ -24,7 +24,7 @@ export const NavigationProvider = React.memo<NavigationProviderProps>((props) =>
24
24
  items,
25
25
  hideRootOnNavigate = true,
26
26
  closeAfterNavigate = false,
27
- animationDuration = 0.275,
27
+ animationDuration = 0.225,
28
28
  children,
29
29
  selection,
30
30
  } = props
@@ -0,0 +1,40 @@
1
+ import { useMotionValueValue } from '@graphcommerce/framer-utils'
2
+ import { Trans } from '@lingui/react'
3
+ import {
4
+ NavigationPath,
5
+ NavigationNodeHref,
6
+ NavigationNodeButton,
7
+ useNavigation,
8
+ } from '../hooks/useNavigation'
9
+
10
+ function findCurrent(
11
+ items,
12
+ selected: NavigationPath | false,
13
+ ): NavigationNodeHref | NavigationNodeButton | undefined {
14
+ if (selected === false) return undefined
15
+ const lastItem = selected.slice(-1)[0]
16
+
17
+ if (!lastItem) return undefined
18
+
19
+ let result
20
+ for (const item of items) {
21
+ if (item.id === lastItem) {
22
+ result = item
23
+ break
24
+ }
25
+ if (item.childItems) {
26
+ result = findCurrent(item.childItems, selected)
27
+ if (result) {
28
+ break
29
+ }
30
+ }
31
+ }
32
+ return result
33
+ }
34
+
35
+ export const NavigationTitle = () => {
36
+ const { selection, items } = useNavigation()
37
+ return (
38
+ <>{useMotionValueValue(selection, (v) => findCurrent(items, v))?.name ?? <Trans id='Menu' />}</>
39
+ )
40
+ }
@@ -241,7 +241,7 @@ export function OverlayBase(incommingProps: LayoutOverlayBaseProps) {
241
241
  bottom: 0,
242
242
  top: 0,
243
243
  left: 0,
244
- backgroundColor: 'rgba(0, 0, 0, 0.5)',
244
+ backgroundColor: 'rgba(0, 0, 0, 0.3)',
245
245
  WebkitTapHighlightColor: 'transparent',
246
246
  willChange: 'opacity',
247
247
  },
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-ui",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.23.1",
5
+ "version": "4.25.0",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "sideEffects": false,
@@ -20,7 +20,7 @@
20
20
  "@emotion/server": "^11.4.0",
21
21
  "@emotion/styled": "^11.9.3",
22
22
  "@graphcommerce/framer-next-pages": "3.3.0",
23
- "@graphcommerce/framer-scroller": "2.1.35",
23
+ "@graphcommerce/framer-scroller": "2.1.37",
24
24
  "@graphcommerce/framer-utils": "3.2.0",
25
25
  "@graphcommerce/image": "3.1.9",
26
26
  "cookie": "^0.5.0",