@graphcommerce/next-ui 7.1.0-canary.53 → 7.1.0-canary.55

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,19 @@
1
1
  # Change Log
2
2
 
3
+ ## 7.1.0-canary.55
4
+
5
+ ### Patch Changes
6
+
7
+ - [#2004](https://github.com/graphcommerce-org/graphcommerce/pull/2004) [`da2135744`](https://github.com/graphcommerce-org/graphcommerce/commit/da2135744dddfa0d211c59589090ebb1977c38c9) - Added info icon for Snackbar when severity is set to info ([@bramvanderholst](https://github.com/bramvanderholst))
8
+
9
+ - [#2004](https://github.com/graphcommerce-org/graphcommerce/pull/2004) [`d608830ce`](https://github.com/graphcommerce-org/graphcommerce/commit/d608830ce77f85ff725cc106b9fc55a22012c74c) - Added ‘disableBackdropClick’ prop to MessageSnackbar to allow page interaction without closing the snackbar ([@bramvanderholst](https://github.com/bramvanderholst))
10
+
11
+ - [#2004](https://github.com/graphcommerce-org/graphcommerce/pull/2004) [`94e1ae811`](https://github.com/graphcommerce-org/graphcommerce/commit/94e1ae811fe9eb0051863e8be91c6399ddcdf22f) - Added DismissibleSnackbar component to allow messages to be shown only once ([@bramvanderholst](https://github.com/bramvanderholst))
12
+
13
+ - [#2004](https://github.com/graphcommerce-org/graphcommerce/pull/2004) [`53947d39f`](https://github.com/graphcommerce-org/graphcommerce/commit/53947d39f2f3ee578c14903c96a2b356d99d9475) - Implemented Message variant for RowColumnOne to show an important message which, after dismissing, will not show again ([@bramvanderholst](https://github.com/bramvanderholst))
14
+
15
+ ## 7.1.0-canary.54
16
+
3
17
  ## 7.1.0-canary.53
4
18
 
5
19
  ## 7.1.0-canary.52
@@ -0,0 +1,12 @@
1
+ import {
2
+ DismissibleSnackbar,
3
+ DismissibleSnackbarProps,
4
+ } from '../../../Snackbar/DismissibleSnackbar'
5
+
6
+ export type VariantMessageProps = DismissibleSnackbarProps
7
+
8
+ export function VariantMessage(props: VariantMessageProps) {
9
+ const { ...rest } = props
10
+
11
+ return <DismissibleSnackbar variant='pill' severity='info' disableBackdropClick {...rest} />
12
+ }
@@ -0,0 +1 @@
1
+ export * from './VariantMessage'
package/Row/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from './Row'
2
2
  export * from './ButtonLinkList'
3
3
  export * from './ColumnOne/ColumnOne'
4
+ export * from './ColumnOne/variant'
4
5
  export * from './ColumnOneBoxed/ColumnOneBoxed'
5
6
  export * from './ColumnOneCentered/ColumnOneCentered'
6
7
  export * from './ColumnThree/ColumnThree'
@@ -0,0 +1,28 @@
1
+ import { useEffect, useState } from 'react'
2
+ import { MessageSnackbar } from './MessageSnackbar'
3
+ import { MessageSnackbarProps } from './MessageSnackbarImpl'
4
+
5
+ export type DismissibleSnackbarProps = MessageSnackbarProps & {
6
+ id: string
7
+ storageType?: 'localStorage' | 'sessionStorage'
8
+ }
9
+ export function DismissibleSnackbar(props: DismissibleSnackbarProps) {
10
+ const { storageType = 'localStorage', id, onClose, ...rest } = props
11
+ const messageId = `DismissibleSnackbar_${id}`
12
+ const [open, setOpen] = useState(false)
13
+
14
+ useEffect(() => {
15
+ setOpen(!globalThis[storageType]?.getItem(messageId))
16
+ }, [messageId, storageType])
17
+
18
+ return (
19
+ <MessageSnackbar
20
+ {...rest}
21
+ open={open}
22
+ onClose={() => {
23
+ globalThis[storageType]?.setItem(messageId, `${Date.now()}`)
24
+ onClose?.()
25
+ }}
26
+ />
27
+ )
28
+ }
@@ -14,6 +14,7 @@ import React, { useEffect, useState } from 'react'
14
14
  import { IconSvg } from '../IconSvg'
15
15
  import { extendableComponent, breakpointVal } from '../Styles'
16
16
  import { iconClose, iconCheckmark, iconSadFace } from '../icons'
17
+ import iconInfo from '../icons/info.svg'
17
18
 
18
19
  type Size = 'normal' | 'wide'
19
20
  type Variant = 'contained' | 'pill'
@@ -34,6 +35,10 @@ type OwnerState = {
34
35
  size?: Size
35
36
  severity?: 'success' | 'info' | 'warning' | 'error'
36
37
  variant?: Variant
38
+ /**
39
+ * Setting this to true allows interaction with the rest of the page without closing the Snackbar
40
+ */
41
+ disableBackdropClick?: boolean
37
42
  }
38
43
 
39
44
  const name = 'MessageSnackbarImpl' as const
@@ -56,6 +61,7 @@ export default function MessageSnackbarImpl(props: MessageSnackbarProps) {
56
61
  onClose,
57
62
  severity = 'info',
58
63
  sx,
64
+ disableBackdropClick,
59
65
  ...snackbarProps
60
66
  } = props
61
67
 
@@ -65,7 +71,11 @@ export default function MessageSnackbarImpl(props: MessageSnackbarProps) {
65
71
  setShowSnackbar(!!open)
66
72
  }, [open])
67
73
 
68
- const hideSnackbar = () => {
74
+ const hideSnackbar = (event: React.SyntheticEvent | Event, reason?: string) => {
75
+ if (disableBackdropClick && reason === 'clickaway') {
76
+ return
77
+ }
78
+
69
79
  setShowSnackbar(false)
70
80
  onClose?.()
71
81
  }
@@ -80,6 +90,7 @@ export default function MessageSnackbarImpl(props: MessageSnackbarProps) {
80
90
  }
81
91
 
82
92
  let icon = iconCheckmark
93
+ if (severity === 'info') icon = iconInfo
83
94
  if (severity === 'error') icon = iconSadFace
84
95
 
85
96
  return (
@@ -91,7 +102,13 @@ export default function MessageSnackbarImpl(props: MessageSnackbarProps) {
91
102
  open={showSnackbar}
92
103
  autoHideDuration={autoHide ? 5000 : null}
93
104
  className={classes.root}
94
- sx={sx}
105
+ sx={[
106
+ {
107
+ pointerEvents: 'none',
108
+ '& > *': { pointerEvents: 'auto' },
109
+ },
110
+ ...(Array.isArray(sx) ? sx : [sx]),
111
+ ]}
95
112
  onClose={hideSnackbar}
96
113
  >
97
114
  <SnackbarContent
@@ -22,8 +22,10 @@ export const MuiSnackbar: SnackbarVariants = [
22
22
  },
23
23
  },
24
24
  '&.MuiSnackbar-anchorOriginBottomCenter': {
25
- left: 0,
26
- right: 0,
25
+ [theme.breakpoints.up('md')]: {
26
+ left: theme.page.horizontal,
27
+ right: theme.page.horizontal,
28
+ },
27
29
  transform: 'unset',
28
30
  },
29
31
  }),
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": "7.1.0-canary.53",
5
+ "version": "7.1.0-canary.55",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -26,13 +26,13 @@
26
26
  "typescript": "5.2.2"
27
27
  },
28
28
  "peerDependencies": {
29
- "@graphcommerce/eslint-config-pwa": "^7.1.0-canary.53",
30
- "@graphcommerce/framer-next-pages": "^7.1.0-canary.53",
31
- "@graphcommerce/framer-scroller": "^7.1.0-canary.53",
32
- "@graphcommerce/framer-utils": "^7.1.0-canary.53",
33
- "@graphcommerce/image": "^7.1.0-canary.53",
34
- "@graphcommerce/prettier-config-pwa": "^7.1.0-canary.53",
35
- "@graphcommerce/typescript-config-pwa": "^7.1.0-canary.53",
29
+ "@graphcommerce/eslint-config-pwa": "^7.1.0-canary.55",
30
+ "@graphcommerce/framer-next-pages": "^7.1.0-canary.55",
31
+ "@graphcommerce/framer-scroller": "^7.1.0-canary.55",
32
+ "@graphcommerce/framer-utils": "^7.1.0-canary.55",
33
+ "@graphcommerce/image": "^7.1.0-canary.55",
34
+ "@graphcommerce/prettier-config-pwa": "^7.1.0-canary.55",
35
+ "@graphcommerce/typescript-config-pwa": "^7.1.0-canary.55",
36
36
  "@lingui/core": "^4.2.1",
37
37
  "@lingui/macro": "^4.2.1",
38
38
  "@lingui/react": "^4.2.1",