@graphcommerce/next-ui 4.24.0 → 4.26.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.26.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#1651](https://github.com/graphcommerce-org/graphcommerce/pull/1651) [`42e7fac75`](https://github.com/graphcommerce-org/graphcommerce/commit/42e7fac75712f9bda7a6b919ede14b3c75d07771) Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Correct component usage in /service
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies []:
12
+ - @graphcommerce/framer-scroller@2.1.38
13
+
14
+ ## 4.25.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [#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
19
+
20
+ * [#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
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies []:
25
+ - @graphcommerce/framer-scroller@2.1.37
26
+
3
27
  ## 4.24.0
4
28
 
5
29
  ### 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 { 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>
@@ -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
  },
@@ -1,29 +1,36 @@
1
- import { Button, ButtonProps, styled } from '@mui/material'
1
+ import { ListItemButtonProps, ListItemButton, ListItemIcon, ListItemText } from '@mui/material'
2
2
  import PageLink from 'next/link'
3
3
  import React from 'react'
4
4
  import { IconSvg } from '../../IconSvg'
5
5
  import { iconChevronRight } from '../../icons'
6
6
 
7
- export type ButtonLinkListItemProps = { url: string; endIcon?: React.ReactNode } & ButtonProps
8
-
9
- const ButtonItem = styled(Button)(({ theme }) => ({
10
- color: theme.palette.text.primary,
11
- textDecoration: 'none',
12
- padding: `${theme.spacings.xs} 0`,
13
- borderBottom: `1px solid ${theme.palette.divider}`,
14
- borderRadius: 0,
15
- justifyContent: 'space-between',
16
- typography: 'body1',
17
- }))
7
+ export type ButtonLinkListItemProps = {
8
+ url: string
9
+ endIcon?: React.ReactNode
10
+ } & ListItemButtonProps
18
11
 
19
12
  export function ButtonLinkListItem(props: ButtonLinkListItemProps) {
20
- const { children, url, endIcon = <IconSvg src={iconChevronRight} />, ...buttonProps } = props
13
+ const {
14
+ children,
15
+ url,
16
+ endIcon = <IconSvg src={iconChevronRight} />,
17
+ ...ButtonLinkListItemProps
18
+ } = props
21
19
 
22
20
  return (
23
21
  <PageLink href={url} passHref>
24
- <ButtonItem {...buttonProps} endIcon={endIcon} LinkComponent='h3'>
25
- {children}
26
- </ButtonItem>
22
+ <ListItemButton
23
+ LinkComponent='a'
24
+ sx={(theme) => ({
25
+ padding: `${theme.spacings.xxs} 0`,
26
+ borderBottom: `1px solid ${theme.palette.divider}`,
27
+ justifyContent: 'space-between',
28
+ })}
29
+ {...ButtonLinkListItemProps}
30
+ >
31
+ <ListItemText>{children}</ListItemText>
32
+ <ListItemIcon>{endIcon}</ListItemIcon>
33
+ </ListItemButton>
27
34
  </PageLink>
28
35
  )
29
36
  }
@@ -1,4 +1,4 @@
1
- import { Typography, Button, SxProps, Theme, Box } from '@mui/material'
1
+ import { Typography, Button, SxProps, Theme, Box, ButtonProps } from '@mui/material'
2
2
  import React from 'react'
3
3
  import { extendableComponent } from '../../Styles'
4
4
 
@@ -8,65 +8,43 @@ export type IconBlockProps = {
8
8
  children: React.ReactNode
9
9
  href?: string
10
10
  sx?: SxProps<Theme>
11
- }
11
+ } & ButtonProps
12
12
 
13
13
  const name = 'IconBlock' as const
14
14
  const parts = ['block', 'link', 'title'] as const
15
15
  const { classes } = extendableComponent(name, parts)
16
16
 
17
17
  export const IconBlock = React.forwardRef<HTMLAnchorElement, IconBlockProps>((props, ref) => {
18
- const { title, children, icon, href, sx = [] } = props
19
-
20
- const content = (
21
- <>
22
- {icon}
23
- <Typography
24
- variant='subtitle1'
25
- className={classes.title}
26
- sx={(theme) => ({ fontWeight: theme.typography.fontWeightBold })}
27
- component='span'
28
- >
29
- {title}
30
- </Typography>
31
- {children}
32
- </>
33
- )
34
-
35
- const blockSx: SxProps<Theme> = [
36
- (theme) => ({
37
- border: `1px solid ${theme.palette.divider}`,
38
- padding: `${theme.spacings.sm}`,
39
- borderRadius: '6px',
40
- textAlign: 'center',
41
- color: theme.palette.text.primary,
42
- '& > *': {
43
- display: 'grid',
44
- gridAutoFlow: 'row',
45
- justifyItems: 'center',
46
- gap: `${theme.spacings.xxs}`,
47
- },
48
- }),
49
- ...(Array.isArray(sx) ? sx : [sx]),
50
- ]
51
-
52
- if (href) {
53
- return (
54
- <Button
55
- href={href}
56
- variant='text'
57
- color='primary'
58
- className={classes.block}
59
- ref={ref}
60
- sx={blockSx}
61
- >
62
- <div>{content}</div>
63
- </Button>
64
- )
65
- }
18
+ const { title, children, icon, href = '#', sx = [], ...buttonProps } = props
66
19
 
67
20
  return (
68
- <Box className={classes.block} sx={blockSx}>
69
- {content}
70
- </Box>
21
+ <Button
22
+ href={href}
23
+ variant='outlined'
24
+ color='primary'
25
+ className={classes.block}
26
+ {...buttonProps}
27
+ sx={[
28
+ (theme) => ({
29
+ padding: `${theme.spacings.sm}`,
30
+ textAlign: 'center',
31
+ '& > *': {
32
+ display: 'grid',
33
+ gridAutoFlow: 'row',
34
+ justifyItems: 'center',
35
+ gap: `${theme.spacings.xxs}`,
36
+ },
37
+ }),
38
+ ...(Array.isArray(sx) ? sx : [sx]),
39
+ ]}
40
+ >
41
+ <Box>
42
+ {icon}
43
+ <Typography variant='subtitle1' className={classes.title} component='span'>
44
+ {title}
45
+ </Typography>
46
+ {children}
47
+ </Box>
48
+ </Button>
71
49
  )
72
50
  })
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.24.0",
5
+ "version": "4.26.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.36",
23
+ "@graphcommerce/framer-scroller": "2.1.38",
24
24
  "@graphcommerce/framer-utils": "3.2.0",
25
25
  "@graphcommerce/image": "3.1.9",
26
26
  "cookie": "^0.5.0",