@graphcommerce/next-ui 4.1.2 → 4.1.5

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,46 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.1.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1290](https://github.com/ho-nl/m2-pwa/pull/1290)
8
+ [`47ae012c1`](https://github.com/ho-nl/m2-pwa/commit/47ae012c10f5762f99019ec38409177632377a98)
9
+ Thanks [@paales](https://github.com/paales)! - `withTheme` didn’t apply styles correcty
10
+
11
+ * [#1290](https://github.com/ho-nl/m2-pwa/pull/1290)
12
+ [`39e28a4cd`](https://github.com/ho-nl/m2-pwa/commit/39e28a4cd6cdfaa4fc6dc4500ae86c14f7069150)
13
+ Thanks [@paales](https://github.com/paales)! - Allow background color on header
14
+
15
+ - [#1289](https://github.com/ho-nl/m2-pwa/pull/1289)
16
+ [`ec8026cc5`](https://github.com/ho-nl/m2-pwa/commit/ec8026cc5a5be8d97a6e5dbf208808154fa1d618)
17
+ Thanks [@LaurensFranken](https://github.com/LaurensFranken)! - add sx prop to UspsList component
18
+
19
+ * [#1290](https://github.com/ho-nl/m2-pwa/pull/1290)
20
+ [`35672d8e8`](https://github.com/ho-nl/m2-pwa/commit/35672d8e87011bf4eb049f449e86e851fc91a525)
21
+ Thanks [@paales](https://github.com/paales)! - Footer didn't accept sx prop
22
+
23
+ ## 4.1.4
24
+
25
+ ### Patch Changes
26
+
27
+ - [#1287](https://github.com/ho-nl/m2-pwa/pull/1287)
28
+ [`d17f97d3a`](https://github.com/ho-nl/m2-pwa/commit/d17f97d3a786c33a99a10e4e949251c52fdbbdac)
29
+ Thanks [@paales](https://github.com/paales)! - Allow passing sx prop to SidebarGallery and
30
+ ContentLinks
31
+
32
+ ## 4.1.3
33
+
34
+ ### Patch Changes
35
+
36
+ - [#1285](https://github.com/ho-nl/m2-pwa/pull/1285)
37
+ [`c85294ba6`](https://github.com/ho-nl/m2-pwa/commit/c85294ba6d742ce78c074559a1e95409b25a5017)
38
+ Thanks [@paales](https://github.com/paales)! - upgraded dependencies
39
+
40
+ - Updated dependencies
41
+ [[`16d77b280`](https://github.com/ho-nl/m2-pwa/commit/16d77b2806e49e376d06bc0d578d38eb724b0c17)]:
42
+ - @graphcommerce/framer-scroller@2.0.4
43
+
3
44
  ## 4.1.2
4
45
 
5
46
  ### Patch Changes
package/Footer/Footer.tsx CHANGED
@@ -18,39 +18,49 @@ const { classes, selectors } = extendableComponent('Footer', [
18
18
  ] as const)
19
19
 
20
20
  export function Footer(props: FooterProps) {
21
- const { socialLinks, storeSwitcher, customerService, copyright, ...containerProps } = props
21
+ const {
22
+ socialLinks,
23
+ storeSwitcher,
24
+ customerService,
25
+ copyright,
26
+ sx = [],
27
+ ...containerProps
28
+ } = props
22
29
 
23
30
  return (
24
31
  <Container
25
- sx={(theme) => ({
26
- gridTemplateColumns: '5fr 3fr',
27
- borderTop: `1px solid ${theme.palette.divider}`,
28
- display: 'grid',
29
- alignItems: 'center',
32
+ sx={[
33
+ (theme) => ({
34
+ gridTemplateColumns: '5fr 3fr',
35
+ borderTop: `1px solid ${theme.palette.divider}`,
36
+ display: 'grid',
37
+ alignItems: 'center',
30
38
 
31
- padding: `${theme.spacings.lg} ${theme.page.horizontal} ${theme.page.vertical}`,
32
- justifyItems: 'center',
33
- gridTemplateAreas: `
39
+ padding: `${theme.spacings.lg} ${theme.page.horizontal} ${theme.page.vertical}`,
40
+ justifyItems: 'center',
41
+ gridTemplateAreas: `
34
42
  'switcher switcher'
35
43
  'support support'
36
44
  'social social'
37
45
  'links links'
38
46
  `,
39
- gap: theme.spacings.md,
40
- '& > *': { maxWidth: 'max-content' },
47
+ gap: theme.spacings.md,
48
+ '& > *': { maxWidth: 'max-content' },
41
49
 
42
- [theme.breakpoints.up('sm')]: {
43
- gridTemplateAreas: `
50
+ [theme.breakpoints.up('sm')]: {
51
+ gridTemplateAreas: `
44
52
  'social switcher'
45
53
  'links support'
46
54
  `,
47
- justifyItems: 'start',
48
- padding: `${theme.page.vertical} ${theme.page.horizontal}`,
49
- gridTemplateColumns: 'auto auto',
50
- gridTemplateRows: 'auto',
51
- justifyContent: 'space-between',
52
- },
53
- })}
55
+ justifyItems: 'start',
56
+ padding: `${theme.page.vertical} ${theme.page.horizontal}`,
57
+ gridTemplateColumns: 'auto auto',
58
+ gridTemplateRows: 'auto',
59
+ justifyContent: 'space-between',
60
+ },
61
+ }),
62
+ ...(Array.isArray(sx) ? sx : [sx]),
63
+ ]}
54
64
  maxWidth={false}
55
65
  className={classes.root}
56
66
  {...containerProps}
@@ -8,7 +8,7 @@ import {
8
8
  ScrollerProvider,
9
9
  } from '@graphcommerce/framer-scroller'
10
10
  import { clientSize, useMotionValueValue } from '@graphcommerce/framer-utils'
11
- import { Fab, useTheme, alpha, Box, styled } from '@mui/material'
11
+ import { Fab, useTheme, alpha, Box, styled, SxProps, Theme } from '@mui/material'
12
12
  import { m, useDomEvent, useMotionValue } from 'framer-motion'
13
13
  import { useRouter } from 'next/router'
14
14
  import React, { useEffect, useRef } from 'react'
@@ -47,10 +47,17 @@ export type SidebarGalleryProps = {
47
47
  images: MotionImageAspectProps[]
48
48
  aspectRatio?: [number, number]
49
49
  routeHash?: string
50
+ sx?: SxProps<Theme>
50
51
  }
51
52
 
52
53
  export function SidebarGallery(props: SidebarGalleryProps) {
53
- const { sidebar, images, aspectRatio: [width, height] = [1, 1], routeHash = 'gallery' } = props
54
+ const {
55
+ sidebar,
56
+ images,
57
+ aspectRatio: [width, height] = [1, 1],
58
+ sx,
59
+ routeHash = 'gallery',
60
+ } = props
54
61
 
55
62
  const router = useRouter()
56
63
  const prevRoute = usePrevPageRouter()
@@ -109,7 +116,7 @@ export function SidebarGallery(props: SidebarGalleryProps) {
109
116
 
110
117
  return (
111
118
  <ScrollerProvider scrollSnapAlign='center'>
112
- <Row maxWidth={false} disableGutters className={classes.row}>
119
+ <Row maxWidth={false} disableGutters className={classes.row} sx={sx}>
113
120
  <MotionBox
114
121
  layout
115
122
  className={classes.root}
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  Scroller,
3
3
  ScrollerButton,
4
+ ScrollerButtonProps as ScrollerButtonPropsType,
4
5
  ScrollerPageCounter,
5
6
  ScrollerProvider,
6
7
  } from '@graphcommerce/framer-scroller'
@@ -23,10 +24,15 @@ const { classes, selectors } = extendableComponent('SidebarSlider', [
23
24
  'centerRight',
24
25
  ] as const)
25
26
 
26
- export type SidebarSliderProps = { children: ReactNode; sidebar: ReactNode; sx?: SxProps<Theme> }
27
+ export type SidebarSliderProps = {
28
+ children: ReactNode
29
+ sidebar: ReactNode
30
+ sx?: SxProps<Theme>
31
+ buttonSize?: ScrollerButtonPropsType['size']
32
+ }
27
33
 
28
34
  export function SidebarSlider(props: SidebarSliderProps) {
29
- const { children, sidebar, sx } = props
35
+ const { children, sidebar, sx, buttonSize } = props
30
36
 
31
37
  return (
32
38
  <Row maxWidth={false} disableGutters className={classes.root} sx={sx}>
@@ -79,6 +85,7 @@ export function SidebarSlider(props: SidebarSliderProps) {
79
85
  direction='left'
80
86
  className={classes.sliderButtons}
81
87
  sx={{ display: { xs: 'none', md: 'flex' } }}
88
+ size={buttonSize}
82
89
  >
83
90
  <SvgIcon src={iconChevronLeft} />
84
91
  </ScrollerButton>
@@ -93,7 +100,12 @@ export function SidebarSlider(props: SidebarSliderProps) {
93
100
  top: `calc(50% - 28px)`,
94
101
  })}
95
102
  >
96
- <ScrollerButton direction='right' className={classes.sliderButtons}>
103
+ <ScrollerButton
104
+ direction='right'
105
+ className={classes.sliderButtons}
106
+ sx={{ display: { xs: 'none', md: 'flex' } }}
107
+ size={buttonSize}
108
+ >
97
109
  <SvgIcon src={iconChevronRight} />
98
110
  </ScrollerButton>
99
111
  </Box>
@@ -92,7 +92,7 @@ export function LayoutDefault(props: LayoutDefaultProps) {
92
92
  justifyContent: 'space-between',
93
93
  width: '100%',
94
94
  height: 0,
95
- zIndex: 2,
95
+ zIndex: 'drawer',
96
96
  [theme.breakpoints.up('sm')]: {
97
97
  padding: `0 ${theme.page.horizontal}`,
98
98
  position: 'sticky',
@@ -13,7 +13,7 @@ const ButtonItem = styled(Button)(({ theme }) => ({
13
13
  borderBottom: `1px solid ${theme.palette.divider}`,
14
14
  borderRadius: 0,
15
15
  justifyContent: 'space-between',
16
- ...theme.typography.body1,
16
+ typography: 'body1',
17
17
  }))
18
18
 
19
19
  export function ButtonLinkListItem(props: ButtonLinkProps) {
@@ -14,13 +14,18 @@ const parts = ['root', 'scroller', 'title'] as const
14
14
  const { classes } = extendableComponent(compName, parts)
15
15
 
16
16
  export function ContentLinks(props: ContentLinksProps) {
17
- const { title, children } = props
17
+ const { title, children, sx = [] } = props
18
18
 
19
19
  return (
20
20
  <Container
21
21
  className={classes.root}
22
22
  maxWidth={false}
23
- sx={(theme) => ({ marginBottom: `${theme.spacings.md}` })}
23
+ sx={[
24
+ (theme) => ({
25
+ marginBottom: `${theme.spacings.md}`,
26
+ }),
27
+ ...(Array.isArray(sx) ? sx : [sx]),
28
+ ]}
24
29
  >
25
30
  <ScrollerProvider scrollSnapAlign='none'>
26
31
  <Scroller
@@ -1,4 +1,7 @@
1
- import { css, Theme, ThemeProvider } from '@mui/material'
1
+ import { SxProps, Theme, ThemeProvider } from '@mui/material'
2
+ import React from 'react'
3
+
4
+ type WithSx = { sx?: SxProps<Theme> }
2
5
 
3
6
  /**
4
7
  * It will provide a theme for the underlying tree and will set the color/font and backgroundColor
@@ -21,22 +24,37 @@ import { css, Theme, ThemeProvider } from '@mui/material'
21
24
  * const MyPage = () => {
22
25
  * return <div>Your regular page content, but now in darkMode</div>
23
26
  * }
24
- *
25
27
  * export default withTheme(MyPage, darkTheme)
26
28
  * ```
29
+ *
30
+ * If you are trying to theme a complete page:
31
+ *
32
+ * ```tsx
33
+ * MyPage.pageOptions = {
34
+ * Layout: withTheme(LayoutFull, darkTheme),
35
+ * } as PageOptions
36
+ * ```
27
37
  */
28
- export function withTheme(Component: React.FC<{ className?: string }>, theme: Theme) {
29
- return (props: Record<string, unknown>) => (
30
- <ThemeProvider theme={theme}>
31
- <Component
32
- {...props}
33
- // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
34
- css={css({
35
- color: theme.palette.text.primary,
36
- backgroundColor: theme.palette.background.default,
37
- ...(theme.typography.body1 as any),
38
- })}
39
- />
40
- </ThemeProvider>
41
- )
38
+ export function withTheme<T>(
39
+ Component: (value: T & WithSx) => React.ReactElement<any, any> | null,
40
+ theme: Theme,
41
+ ): React.FC<T & WithSx> {
42
+ return (data: T & WithSx) => {
43
+ const sx = data.sx ?? []
44
+ return (
45
+ <ThemeProvider theme={theme}>
46
+ <Component
47
+ {...data}
48
+ sx={[
49
+ {
50
+ typography: 'body1',
51
+ color: theme.palette.text.primary,
52
+ backgroundColor: theme.palette.background.default,
53
+ },
54
+ ...(Array.isArray(sx) ? sx : [sx]),
55
+ ]}
56
+ />
57
+ </ThemeProvider>
58
+ )
59
+ }
42
60
  }
package/UspList/index.tsx CHANGED
@@ -1,8 +1,9 @@
1
- import { Box } from '@mui/material'
1
+ import { Box, SxProps, Theme } from '@mui/material'
2
2
  import { extendableComponent } from '../Styles'
3
3
 
4
4
  export type UspListProps = OwnerState & {
5
5
  children: React.ReactNode
6
+ sx?: SxProps<Theme>
6
7
  }
7
8
 
8
9
  type OwnerState = { size?: 'small' | 'medium' }
@@ -11,24 +12,27 @@ const parts = ['root'] as const
11
12
  const { withState } = extendableComponent<OwnerState, typeof name, typeof parts>(name, parts)
12
13
 
13
14
  export function UspList(props: UspListProps) {
14
- const { children, size } = props
15
+ const { children, size, sx = [] } = props
15
16
  const classes = withState({ size })
16
17
 
17
18
  return (
18
19
  <Box
19
20
  component='ul'
20
21
  className={classes.root}
21
- sx={(theme) => ({
22
- listStyleType: 'none',
23
- padding: 0,
24
- margin: 0,
25
- display: 'grid',
26
- alignContent: 'start',
27
- rowGap: theme.spacings.xs,
28
- '&.sizeSmall': {
29
- rowGap: '3px',
30
- },
31
- })}
22
+ sx={[
23
+ (theme) => ({
24
+ listStyleType: 'none',
25
+ padding: 0,
26
+ margin: 0,
27
+ display: 'grid',
28
+ alignContent: 'start',
29
+ rowGap: theme.spacings.xs,
30
+ '&.sizeSmall': {
31
+ rowGap: '3px',
32
+ },
33
+ }),
34
+ ...(Array.isArray(sx) ? sx : [sx]),
35
+ ]}
32
36
  >
33
37
  {children}
34
38
  </Box>
package/icons/index.tsx CHANGED
@@ -38,3 +38,4 @@ export { default as iconEmailOutline } from './envelope-alt.svg'
38
38
  export { default as icon404 } from './explore.svg'
39
39
  export { default as iconSun } from './sun.svg'
40
40
  export { default as iconMoon } from './moon.svg'
41
+ export { default as iconPlay } from './play.svg'
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.1.2",
5
+ "version": "4.1.5",
6
6
  "author": "",
7
7
  "license": "MIT",
8
8
  "sideEffects": false,
@@ -20,12 +20,12 @@
20
20
  "@emotion/server": "^11.4.0",
21
21
  "@emotion/styled": "^11.6.0",
22
22
  "@graphcommerce/framer-next-pages": "^3.1.0",
23
- "@graphcommerce/framer-scroller": "^2.0.3",
23
+ "@graphcommerce/framer-scroller": "^2.0.4",
24
24
  "@graphcommerce/framer-utils": "^3.0.3",
25
25
  "@graphcommerce/image": "^3.1.0",
26
26
  "react-is": "^17.0.2",
27
27
  "react-schemaorg": "^2.0.0",
28
- "schema-dts": "^1.0.0",
28
+ "schema-dts": "^1.1.0",
29
29
  "type-fest": "^2.12.0"
30
30
  },
31
31
  "peerDependencies": {
@@ -39,7 +39,7 @@
39
39
  "react-dom": "^17.0.2"
40
40
  },
41
41
  "devDependencies": {
42
- "@graphcommerce/eslint-config-pwa": "^4.0.3",
42
+ "@graphcommerce/eslint-config-pwa": "^4.0.4",
43
43
  "@graphcommerce/prettier-config-pwa": "^4.0.2",
44
44
  "@graphcommerce/typescript-config-pwa": "^4.0.2",
45
45
  "@playwright/test": "^1.19.1",