@graphcommerce/next-ui 3.3.2 → 3.6.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
 
@@ -94,7 +99,11 @@ export default function DesktopNavBar(props: MenuTabsProps) {
94
99
  <Scroller className={classes.scroller} hideScrollbar>
95
100
  {menu.map(({ href, children, ...linkProps }) => (
96
101
  <PageLink key={href.toString()} href={href} {...linkProps} passHref>
97
- <Link {...LinkProps} className={clsx(classes.link, LinkProps?.className)}>
102
+ <Link
103
+ variant='h6'
104
+ {...LinkProps}
105
+ className={clsx(classes.link, LinkProps?.className)}
106
+ >
98
107
  {children}
99
108
  <div
100
109
  className={clsx(
@@ -113,7 +122,7 @@ export default function DesktopNavBar(props: MenuTabsProps) {
113
122
  size='small'
114
123
  classes={{ root: clsx(classes.prevNextBtn, classes.prevBtn) }}
115
124
  >
116
- <SvgImageSimple src={iconChevronLeft} />
125
+ {iconScrollerBtnLeft ?? <SvgImageSimple src={iconChevronLeft} />}
117
126
  </ScrollerButton>
118
127
  </m.div>
119
128
 
@@ -123,7 +132,7 @@ export default function DesktopNavBar(props: MenuTabsProps) {
123
132
  size='small'
124
133
  classes={{ root: clsx(classes.prevNextBtn, classes.nextBtn) }}
125
134
  >
126
- <SvgImageSimple src={iconChevronRight} />
135
+ {iconScrollerBtnRight ?? <SvgImageSimple src={iconChevronRight} />}
127
136
  </ScrollerButton>
128
137
  </m.div>
129
138
  </div>
@@ -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/CHANGELOG.md CHANGED
@@ -3,6 +3,50 @@
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.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)
7
+
8
+
9
+ ### Features
10
+
11
+ * **message-snackbar:** severity props ([c7be8a5](https://github.com/ho-nl/m2-pwa/commit/c7be8a51faf7a5937b7fab5bb352df2089ae4eea))
12
+
13
+
14
+
15
+
16
+
17
+ # [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)
18
+
19
+
20
+ ### Features
21
+
22
+ * **graphcms:** combined multiple models to bypass model creation limit ([fd6dc14](https://github.com/ho-nl/m2-pwa/commit/fd6dc140cb60c5733dab2e0a43b5df2059e0c739))
23
+
24
+
25
+
26
+
27
+
28
+ # [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)
29
+
30
+
31
+ ### Features
32
+
33
+ * **DesktopNavBar:** allow custom scroller button icons ([401f457](https://github.com/ho-nl/m2-pwa/commit/401f4572ce67dbe52008dca8e1d4473e2fcbf5cf))
34
+
35
+
36
+
37
+
38
+
39
+ ## [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)
40
+
41
+
42
+ ### Bug Fixes
43
+
44
+ * regression in header ([4738fb7](https://github.com/ho-nl/m2-pwa/commit/4738fb7e13fb3be187f58b474219497783525d72))
45
+
46
+
47
+
48
+
49
+
6
50
  # [3.3.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.2.3...@graphcommerce/next-ui@3.3.0) (2021-10-13)
7
51
 
8
52
 
@@ -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
  }
@@ -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
  }
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.2",
3
+ "version": "3.6.0",
4
4
  "author": "",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -55,5 +55,5 @@
55
55
  "project": "./tsconfig.json"
56
56
  }
57
57
  },
58
- "gitHead": "5e31b902147a68bfce513451e4e10d1c74d23823"
58
+ "gitHead": "beb4b83268176f7c6579cee2fe844752315e2378"
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
- }