@graphcommerce/next-ui 4.24.0 → 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 +13 -0
- package/Navigation/components/NavigationItem.tsx +10 -2
- package/Navigation/components/NavigationOverlay.tsx +7 -37
- package/Navigation/components/NavigationProvider.tsx +1 -1
- package/Navigation/components/NavigationTitle.tsx +40 -0
- package/Overlay/components/OverlayBase.tsx +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
3
16
|
## 4.24.0
|
|
4
17
|
|
|
5
18
|
### Minor 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 {
|
|
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 {
|
|
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
|
|
65
|
+
const theme2 = useTheme()
|
|
96
66
|
const handleOnBack = useEventCallback(() => {
|
|
97
|
-
if (
|
|
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(
|
|
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
|
-
|
|
172
|
+
<NavigationTitle />
|
|
203
173
|
</LayoutTitle>
|
|
204
174
|
</LayoutHeaderContent>
|
|
205
175
|
</Box>
|
|
@@ -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.
|
|
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.
|
|
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.
|
|
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",
|