@graphcommerce/next-ui 3.3.3 → 3.7.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.
@@ -81,10 +81,15 @@ const useStyles = makeStyles(
81
81
  { name: 'DesktopNavBar' },
82
82
  )
83
83
 
84
- export type MenuTabsProps = MenuProps & UseStyles<typeof useStyles> & { LinkProps?: MuiLinkProps }
84
+ export type MenuTabsProps = MenuProps &
85
+ UseStyles<typeof useStyles> & {
86
+ LinkProps?: MuiLinkProps
87
+ iconScrollerBtnLeft?: React.ReactNode
88
+ iconScrollerBtnRight?: React.ReactNode
89
+ }
85
90
 
86
91
  export default function DesktopNavBar(props: MenuTabsProps) {
87
- const { menu, LinkProps } = props
92
+ const { menu, LinkProps, iconScrollerBtnLeft, iconScrollerBtnRight } = props
88
93
  const classes = useStyles(props)
89
94
  const router = useRouter()
90
95
 
@@ -117,7 +122,7 @@ export default function DesktopNavBar(props: MenuTabsProps) {
117
122
  size='small'
118
123
  classes={{ root: clsx(classes.prevNextBtn, classes.prevBtn) }}
119
124
  >
120
- <SvgImageSimple src={iconChevronLeft} />
125
+ {iconScrollerBtnLeft ?? <SvgImageSimple src={iconChevronLeft} />}
121
126
  </ScrollerButton>
122
127
  </m.div>
123
128
 
@@ -127,7 +132,7 @@ export default function DesktopNavBar(props: MenuTabsProps) {
127
132
  size='small'
128
133
  classes={{ root: clsx(classes.prevNextBtn, classes.nextBtn) }}
129
134
  >
130
- <SvgImageSimple src={iconChevronRight} />
135
+ {iconScrollerBtnRight ?? <SvgImageSimple src={iconChevronRight} />}
131
136
  </ScrollerButton>
132
137
  </m.div>
133
138
  </div>
@@ -1,4 +1,4 @@
1
- import { makeStyles } from '@material-ui/styles'
1
+ import { makeStyles } from '@material-ui/core'
2
2
  import React from 'react'
3
3
  import { UseStyles } from '../Styles'
4
4
 
@@ -1,6 +1,5 @@
1
1
  import { Avatar, Chip, makeStyles, Theme } from '@material-ui/core'
2
2
  import React from 'react'
3
- import Row from '../../Row'
4
3
  import { UseStyles } from '../../Styles'
5
4
 
6
5
  const useStyles = makeStyles(
package/Button/index.tsx CHANGED
@@ -1,5 +1,9 @@
1
- import { Button as MuiButton, ButtonClassKey as MuiButtonClassKey, Theme } from '@material-ui/core'
2
- import { makeStyles } from '@material-ui/styles'
1
+ import {
2
+ Button as MuiButton,
3
+ ButtonClassKey as MuiButtonClassKey,
4
+ Theme,
5
+ makeStyles,
6
+ } from '@material-ui/core'
3
7
  import clsx from 'clsx'
4
8
  import React from 'react'
5
9
 
package/CHANGELOG.md CHANGED
@@ -3,6 +3,55 @@
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.7.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.6.0...@graphcommerce/next-ui@3.7.0) (2021-10-19)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * solve import issue where @material-ui/styles couldn't be found ([efb3771](https://github.com/ho-nl/m2-pwa/commit/efb3771e8c173799779691d4d52857678dab4c15))
12
+
13
+
14
+ ### Features
15
+
16
+ * **framer-scroller:** better defaults so the Scroller doesn't look broken when providing no props ([b177ce9](https://github.com/ho-nl/m2-pwa/commit/b177ce9570abb9ccfd4eb5cc34e43d157bb4e81a))
17
+
18
+
19
+
20
+
21
+
22
+ # [3.6.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.5.0...@graphcommerce/next-ui@3.6.0) (2021-10-18)
23
+
24
+
25
+ ### Features
26
+
27
+ * **message-snackbar:** severity props ([c7be8a5](https://github.com/ho-nl/m2-pwa/commit/c7be8a51faf7a5937b7fab5bb352df2089ae4eea))
28
+
29
+
30
+
31
+
32
+
33
+ # [3.5.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.4.0...@graphcommerce/next-ui@3.5.0) (2021-10-18)
34
+
35
+
36
+ ### Features
37
+
38
+ * **graphcms:** combined multiple models to bypass model creation limit ([fd6dc14](https://github.com/ho-nl/m2-pwa/commit/fd6dc140cb60c5733dab2e0a43b5df2059e0c739))
39
+
40
+
41
+
42
+
43
+
44
+ # [3.4.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.3.3...@graphcommerce/next-ui@3.4.0) (2021-10-15)
45
+
46
+
47
+ ### Features
48
+
49
+ * **DesktopNavBar:** allow custom scroller button icons ([401f457](https://github.com/ho-nl/m2-pwa/commit/401f4572ce67dbe52008dca8e1d4473e2fcbf5cf))
50
+
51
+
52
+
53
+
54
+
6
55
  ## [3.3.3](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.3.2...@graphcommerce/next-ui@3.3.3) (2021-10-13)
7
56
 
8
57
 
@@ -1,5 +1,5 @@
1
1
  import { usePageContext, usePageRouter } from '@graphcommerce/framer-next-pages'
2
- import { makeStyles } from '@material-ui/styles'
2
+ import { makeStyles } from '@material-ui/core'
3
3
  import { AnimatePresence } from 'framer-motion'
4
4
  import React, { useRef } from 'react'
5
5
  import RouterSlide from './Slide'
@@ -73,9 +73,7 @@ const useStyles = makeStyles(
73
73
  top: 0,
74
74
  width: '100%',
75
75
  height: '100%',
76
- display: `grid`,
77
- gridAutoFlow: `column`,
78
- gridTemplateColumns: `repeat(100, 100%)`,
76
+ gridAutoColumns: `100%`,
79
77
  gridTemplateRows: `100%`,
80
78
  cursor: 'zoom-in',
81
79
  },
@@ -4,8 +4,7 @@ import {
4
4
  ScrollerPageCounter,
5
5
  ScrollerProvider,
6
6
  } from '@graphcommerce/framer-scroller'
7
- import { Theme } from '@material-ui/core'
8
- import { makeStyles } from '@material-ui/styles'
7
+ import { Theme, makeStyles } from '@material-ui/core'
9
8
  import React, { ReactNode } from 'react'
10
9
  import { UseStyles } from '../../Styles'
11
10
  import responsiveVal from '../../Styles/responsiveVal'
@@ -31,15 +30,11 @@ const useStyles = makeStyles(
31
30
  },
32
31
  scroller: {
33
32
  width: '100%',
34
- display: 'grid',
35
- gridAutoFlow: 'column',
36
33
  gridColumnGap: theme.spacings.md,
37
34
  gridRowGap: theme.spacings.lg,
38
35
  alignContent: 'space-around',
39
36
  paddingRight: theme.page.horizontal,
40
- '& > *': {
41
- minWidth: responsiveVal(200, 400),
42
- },
37
+ gridAutoColumns: responsiveVal(200, 400),
43
38
  },
44
39
  sliderButtons: {
45
40
  [theme.breakpoints.down('sm')]: {
@@ -13,14 +13,14 @@ type TypeRenderMethod<P> = (props: P) => React.ReactElement | null
13
13
  type TypeRenderMap<
14
14
  T extends TypeObject,
15
15
  TypeNames extends string,
16
- TAdd extends Record<string, unknown>
16
+ TAdd extends Record<string, unknown>,
17
17
  > = {
18
18
  [K in TypeNames]: TypeRenderMethod<FilterTypeByTypename<T, K> & TAdd>
19
19
  }
20
20
 
21
21
  export type TypeRenderer<
22
22
  T extends TypeObject,
23
- TAdd extends Record<string, unknown> = Record<string, unknown>
23
+ TAdd extends Record<string, unknown> = Record<string, unknown>,
24
24
  > = TypeRenderMap<T, T['__typename'], TAdd>
25
25
 
26
26
  /**
@@ -29,12 +29,12 @@ export type TypeRenderer<
29
29
  */
30
30
  export default function RenderType<
31
31
  T extends TypeObject,
32
- A extends Record<string, unknown> = Record<string, unknown>
32
+ A extends Record<string, unknown> = Record<string, unknown>,
33
33
  >(props: { renderer: TypeRenderer<T, A> } & FilterTypeByTypename<T, T['__typename']> & A) {
34
34
  const { renderer, __typename, ...typeItemProps } = props
35
35
  const TypeItem: TypeRenderMethod<typeof typeItemProps> = renderer[__typename]
36
36
  ? renderer[__typename]
37
- : () => <>{__typename}</>
37
+ : () => <>{process.env.NODE_ENV !== 'production' ? __typename : ''}</>
38
38
 
39
39
  return <TypeItem {...typeItemProps} __typename={__typename} />
40
40
  }
@@ -1,5 +1,4 @@
1
- import { Theme } from '@material-ui/core'
2
- import { makeStyles } from '@material-ui/styles'
1
+ import { Theme, makeStyles } from '@material-ui/core'
3
2
  import React from 'react'
4
3
  import Row from '..'
5
4
  import SectionContainer from '../../SectionContainer'
@@ -8,14 +8,10 @@ const useStyles = makeStyles(
8
8
  root: {},
9
9
  scroller: {
10
10
  marginBottom: `${theme.spacings.lg}`,
11
- display: 'grid',
12
- gridAutoFlow: 'column',
13
11
  justifyContent: 'start',
14
12
  gap: `${theme.spacings.md}`,
15
13
  alignContent: 'center',
16
- '& > *': {
17
- minWidth: 'max-content',
18
- },
14
+ gridAutoColumns: `max-content`,
19
15
  },
20
16
  title: {
21
17
  fontWeight: 600,
@@ -1,5 +1,4 @@
1
- import { ContainerProps, Theme } from '@material-ui/core'
2
- import { makeStyles } from '@material-ui/styles'
1
+ import { ContainerProps, Theme, makeStyles } from '@material-ui/core'
3
2
  import { m, useTransform, useViewportScroll } from 'framer-motion'
4
3
  import React from 'react'
5
4
  import Row from '..'
@@ -78,7 +78,7 @@ const useStyles = makeStyles(
78
78
 
79
79
  export type SpecialBannerProps = UseStyles<typeof useStyles> &
80
80
  ContainerProps & {
81
- asset: React.ReactNode
81
+ asset?: React.ReactNode
82
82
  pageLinks?: React.ReactNode
83
83
  topic: React.ReactNode
84
84
  children: React.ReactNode
@@ -1,17 +1,16 @@
1
1
  import {
2
- Button,
3
2
  Fab,
4
3
  makeStyles,
5
- PropTypes,
6
4
  Snackbar,
7
5
  SnackbarContent,
8
6
  SnackbarProps,
9
7
  Theme,
8
+ Portal,
10
9
  } from '@material-ui/core'
11
10
  import clsx from 'clsx'
12
11
  import React, { useEffect, useState } from 'react'
13
- import SvgImage from '../SvgImage'
14
- import { iconClose } from '../icons'
12
+ import SvgImageSimple from '../SvgImage/SvgImageSimple'
13
+ import { iconClose, iconCheckmark, iconSadFace } from '../icons'
15
14
 
16
15
  type Size = 'normal' | 'wide'
17
16
  type Variant = 'contained' | 'pill'
@@ -42,10 +41,8 @@ const useStyles = makeStyles(
42
41
  },
43
42
  },
44
43
  rootPillLarge: {},
45
- rootPillColorPrimary: {
46
- backgroundColor: theme.palette.primary.main,
47
- color: theme.palette.primary.contrastText,
48
- },
44
+ rootPillSeverityInfo: {},
45
+ rootPillSeverityError: {},
49
46
  message: {
50
47
  width: '100%',
51
48
  padding: theme.spacings.xxs,
@@ -61,8 +58,9 @@ const useStyles = makeStyles(
61
58
  },
62
59
  },
63
60
  children: {
61
+ // display: 'flex',
64
62
  gridArea: 'children',
65
- ...theme.typography.h4,
63
+ ...theme.typography.h6,
66
64
  fontWeight: 400,
67
65
 
68
66
  '& .MuiSvgIcon-root': {
@@ -111,21 +109,26 @@ const useStyles = makeStyles(
111
109
  sticky: {
112
110
  position: 'sticky',
113
111
  },
112
+ messageIcon: {
113
+ display: 'inline-block',
114
+ marginRight: 5,
115
+ },
114
116
  }),
115
117
  { name: 'MessageSnackbar' },
116
118
  )
117
119
 
118
120
  export type MessageSnackbarImplProps = Omit<
119
121
  SnackbarProps,
120
- 'autoHideDuration' | 'onClose' | 'anchorOrigin'
122
+ 'autoHideDuration' | 'anchorOrigin' | 'color'
121
123
  > & {
122
124
  autoHide?: boolean
123
125
  sticky?: boolean
124
126
  variant?: Variant
125
127
  size?: Size
126
- color?: PropTypes.Color
128
+ severity?: 'success' | 'info' | 'warning' | 'error'
127
129
  action?: React.ReactNode
128
130
  children?: React.ReactNode
131
+ onClose?: () => void
129
132
  }
130
133
 
131
134
  export default function MessageSnackbarImpl(props: MessageSnackbarImplProps) {
@@ -134,13 +137,14 @@ export default function MessageSnackbarImpl(props: MessageSnackbarImplProps) {
134
137
  const {
135
138
  variant = 'contained',
136
139
  size = 'normal',
137
- color = 'default',
138
140
  autoHide,
139
141
  action,
140
142
  open,
141
143
  message,
142
144
  sticky,
143
145
  children,
146
+ onClose,
147
+ severity = 'info',
144
148
  ...snackbarProps
145
149
  } = props
146
150
 
@@ -150,53 +154,77 @@ export default function MessageSnackbarImpl(props: MessageSnackbarImplProps) {
150
154
  setShowSnackbar(!!open)
151
155
  }, [open])
152
156
 
157
+ const hideSnackbar = () => {
158
+ setShowSnackbar(false)
159
+ onClose?.()
160
+ }
161
+
153
162
  const clsxBonus = (base: string) => {
154
163
  const Size = size[0].toUpperCase() + size.slice(1)
155
- const Color = color[0].toUpperCase() + color.slice(1)
164
+ const Severity = severity[0].toUpperCase() + severity.slice(1)
156
165
  const Variant = variant[0].toUpperCase() + variant.slice(1)
157
166
 
158
167
  return clsx(
159
168
  classes[base],
160
169
  classes[`${base}${Variant}`],
161
170
  classes[`${base}${Variant}Size${Size}`],
162
- classes[`${base}${Variant}Color${Color}`],
171
+ classes[`${base}${Variant}Severity${Severity}`],
163
172
  )
164
173
  }
165
174
 
175
+ let icon = iconCheckmark
176
+ if (severity == 'error') icon = iconSadFace
177
+
166
178
  return (
167
- <Snackbar
168
- {...snackbarProps}
169
- message={message}
170
- anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
171
- open={showSnackbar}
172
- autoHideDuration={autoHide ? 6000 : null}
173
- classes={{
174
- root: classes.snackbarRoot,
175
- anchorOriginBottomCenter: clsx(classes.anchorOriginBottomCenter, sticky && classes.sticky),
176
- }}
177
- >
178
- <SnackbarContent
179
+ <Portal>
180
+ <Snackbar
181
+ {...snackbarProps}
182
+ message={message}
183
+ anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
184
+ open={showSnackbar}
185
+ autoHideDuration={autoHide ? 6000 : null}
179
186
  classes={{
180
- root: clsxBonus('root'),
181
- message: clsxBonus('message'),
182
- action: clsxBonus('action'),
187
+ root: classes.snackbarRoot,
188
+ anchorOriginBottomCenter: clsx(
189
+ classes.anchorOriginBottomCenter,
190
+ sticky && classes.sticky,
191
+ ),
183
192
  }}
184
- message={
185
- <>
186
- <div className={classes.children}>{children}</div>
187
- {action && (
188
- <div className={classes.actionButton} onClick={() => setShowSnackbar(false)}>
189
- {action}
193
+ onClose={hideSnackbar}
194
+ >
195
+ <SnackbarContent
196
+ classes={{
197
+ root: clsxBonus('root'),
198
+ message: clsxBonus('message'),
199
+ action: clsxBonus('action'),
200
+ }}
201
+ message={
202
+ <>
203
+ <div className={classes.children}>
204
+ <div>
205
+ <SvgImageSimple
206
+ src={icon}
207
+ alt='checkmark'
208
+ size='large'
209
+ className={classes.messageIcon}
210
+ />
211
+ {children}
212
+ </div>
213
+ </div>
214
+ {action && (
215
+ <div className={classes.actionButton} onClick={hideSnackbar}>
216
+ {action}
217
+ </div>
218
+ )}
219
+ <div className={classes.closeButton}>
220
+ <Fab aria-label='Close snackbar' size='medium' onClick={hideSnackbar}>
221
+ <SvgImageSimple src={iconClose} size='small' alt='close' />
222
+ </Fab>
190
223
  </div>
191
- )}
192
- <div className={classes.closeButton}>
193
- <Fab aria-label='Close snackbar' size='medium' onClick={() => setShowSnackbar(false)}>
194
- <SvgImage src={iconClose} size='small' alt='close' />
195
- </Fab>
196
- </div>
197
- </>
198
- }
199
- />
200
- </Snackbar>
224
+ </>
225
+ }
226
+ />
227
+ </Snackbar>
228
+ </Portal>
201
229
  )
202
230
  }
@@ -1,5 +1,4 @@
1
- import { Badge } from '@material-ui/core'
2
- import { withStyles } from '@material-ui/styles'
1
+ import { Badge, withStyles } from '@material-ui/core'
3
2
 
4
3
  const StyledBadge = withStyles((theme) => ({
5
4
  colorError: {},
package/index.ts CHANGED
@@ -131,8 +131,6 @@ export * from './SectionHeader'
131
131
  export { default as SectionHeader } from './SectionHeader'
132
132
  export * from './Separator'
133
133
  export { default as Separator } from './Separator'
134
- export * from './Snackbar/ErrorSnackbar'
135
- export { default as ErrorSnackbar } from './Snackbar/ErrorSnackbar'
136
134
  export { default as MessageSnackbar } from './Snackbar/MessageSnackbar'
137
135
  export * from './Snackbar/MessageSnackbarImpl'
138
136
  export { default as MessageSnackbarImpl } from './Snackbar/MessageSnackbarImpl'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/next-ui",
3
- "version": "3.3.3",
3
+ "version": "3.7.0",
4
4
  "author": "",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@apollo/client": "^3.4.16",
13
13
  "@graphcommerce/framer-next-pages": "^2.106.9",
14
- "@graphcommerce/framer-scroller": "^0.2.11",
14
+ "@graphcommerce/framer-scroller": "^0.3.0",
15
15
  "@graphcommerce/framer-sheet": "^2.105.9",
16
16
  "@graphcommerce/framer-utils": "^2.103.8",
17
17
  "@graphcommerce/graphql": "^2.103.7",
@@ -55,5 +55,5 @@
55
55
  "project": "./tsconfig.json"
56
56
  }
57
57
  },
58
- "gitHead": "996d782db6b91323acf71868a7790d608367d918"
58
+ "gitHead": "a7749d81f482a77bc6bcbf237aca551ed3b7a835"
59
59
  }
@@ -1,9 +0,0 @@
1
- import React from 'react'
2
- import MessageSnackbar from './MessageSnackbar'
3
- import { MessageSnackbarImplProps } from './MessageSnackbarImpl'
4
-
5
- export type ErrorSnackbarProps = Omit<MessageSnackbarImplProps, 'severity' | 'action'>
6
-
7
- export default function ErrorSnackbarImpl(props: ErrorSnackbarProps) {
8
- return <MessageSnackbar {...props} />
9
- }