@graphcommerce/next-ui 3.22.0 → 3.23.1

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
@@ -3,6 +3,57 @@
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.23.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.23.0...@graphcommerce/next-ui@3.23.1) (2022-01-04)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * close button on mobile ([a0c6c07](https://github.com/ho-nl/m2-pwa/commit/a0c6c075a1ee2541c864a561cd5318ed5fb5760c))
12
+
13
+
14
+
15
+
16
+
17
+ # [3.23.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.22.2...@graphcommerce/next-ui@3.23.0) (2022-01-04)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * backbutton wasn't translated ([5f841c0](https://github.com/ho-nl/m2-pwa/commit/5f841c052b454c0d565a68829f78492c5a3b6dab))
23
+
24
+
25
+ ### Features
26
+
27
+ * introduced a withTheme hoc to allow theming per route ([55e3fc1](https://github.com/ho-nl/m2-pwa/commit/55e3fc178b385d0ccdc19a5c09a7887be5db14dc))
28
+
29
+
30
+
31
+
32
+
33
+ ## [3.22.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.22.1...@graphcommerce/next-ui@3.22.2) (2022-01-04)
34
+
35
+
36
+ ### Bug Fixes
37
+
38
+ * broder radius of drawer was too small on desktop ([f8b3962](https://github.com/ho-nl/m2-pwa/commit/f8b3962825972e6bc232387e0a2e801289fcc492))
39
+ * close button of bottom sheet spacing ([be33c20](https://github.com/ho-nl/m2-pwa/commit/be33c20fc8f41ad85d90bff15842738bc370b81e))
40
+ * regression where primary action wasn't visible ([66f8ed2](https://github.com/ho-nl/m2-pwa/commit/66f8ed20ea0728881be81994d49bd6c399f2e914))
41
+
42
+
43
+
44
+
45
+
46
+ ## [3.22.1](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.22.0...@graphcommerce/next-ui@3.22.1) (2022-01-04)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * overlay would have a height instead of minHeight ([07dba4b](https://github.com/ho-nl/m2-pwa/commit/07dba4b875a37beac2ab6a8afe50e6b7a7ba1bf9))
52
+
53
+
54
+
55
+
56
+
6
57
  # [3.22.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/next-ui@3.21.15...@graphcommerce/next-ui@3.22.0) (2022-01-03)
7
58
 
8
59
 
@@ -117,7 +117,7 @@ export function LayoutHeader(props: LayoutHeaderProps) {
117
117
  if (back) left = back
118
118
 
119
119
  if (!right) right = close
120
- else if (!left) right = close
120
+ else if (!left) left = close
121
121
 
122
122
  if (!left && !right && !children) return null
123
123
 
@@ -3,15 +3,28 @@ import React from 'react'
3
3
  import Button from '../../Button'
4
4
  import SvgImageSimple from '../../SvgImage/SvgImageSimple'
5
5
  import { iconClose } from '../../icons'
6
+ import { makeStyles, Theme } from '@material-ui/core'
7
+ import { responsiveVal } from '../../Styles/responsiveVal'
8
+ import { Trans } from '@lingui/macro'
6
9
 
7
10
  export function useShowClose() {
8
11
  const { overlayGroup } = usePageContext()
9
12
  return !!overlayGroup
10
13
  }
11
14
 
15
+ const useStyles = makeStyles((theme: Theme) => ({
16
+ close: {
17
+ [theme.breakpoints.up('md')]: {
18
+ marginLeft: `calc(${responsiveVal(12, 22)} * -1)`,
19
+ marginRight: `calc(${responsiveVal(12, 22)} * -1)`,
20
+ },
21
+ },
22
+ }))
23
+
12
24
  export default function LayoutHeaderClose() {
13
25
  const { closeSteps } = usePageContext()
14
26
  const onClick = useGo(closeSteps * -1)
27
+ const classes = useStyles()
15
28
 
16
29
  return (
17
30
  <Button
@@ -20,8 +33,9 @@ export default function LayoutHeaderClose() {
20
33
  aria-label='Close'
21
34
  variant='text'
22
35
  startIcon={<SvgImageSimple src={iconClose} />}
36
+ className={classes.close}
23
37
  >
24
- Close
38
+ <Trans>Close</Trans>
25
39
  </Button>
26
40
  )
27
41
  }
@@ -55,6 +55,7 @@ const useStyles = makeStyles(
55
55
  )
56
56
 
57
57
  export type LayoutDefaultProps = {
58
+ className?: string
58
59
  header: React.ReactNode
59
60
  footer: React.ReactNode
60
61
  menuFab?: React.ReactNode
@@ -64,14 +65,14 @@ export type LayoutDefaultProps = {
64
65
  } & UseStyles<typeof useStyles>
65
66
 
66
67
  export function LayoutDefault(props: LayoutDefaultProps) {
67
- const { children, header, footer, menuFab, cartFab, noSticky } = props
68
+ const { children, header, footer, menuFab, cartFab, noSticky, className } = props
68
69
  const classes = useStyles(props)
69
70
 
70
71
  const offset = useScrollOffset().y
71
72
  const scrollWithOffset = useTransform(useViewportScroll().scrollY, (y) => y + offset)
72
73
 
73
74
  return (
74
- <div className={classes.root}>
75
+ <div className={clsx(classes.root, className)}>
75
76
  <LayoutProvider scroll={scrollWithOffset}>
76
77
  <header className={clsx(classes.header, !noSticky && classes.headerSticky)}>
77
78
  {header}
@@ -94,8 +94,8 @@ const useStyles = makeStyles(
94
94
  },
95
95
  overlayPaneVariantMdBottom: {
96
96
  [theme.breakpoints.up('md')]: {
97
- borderTopLeftRadius: theme.shape.borderRadius * 3,
98
- borderTopRightRadius: theme.shape.borderRadius * 3,
97
+ borderTopLeftRadius: theme.shape.borderRadius * 4,
98
+ borderTopRightRadius: theme.shape.borderRadius * 4,
99
99
  },
100
100
  },
101
101
  overlayPaneSizeSmFloating: {
@@ -105,7 +105,7 @@ const useStyles = makeStyles(
105
105
  },
106
106
  overlayPaneSizeMdFloating: {
107
107
  [theme.breakpoints.up('md')]: {
108
- borderRadius: theme.shape.borderRadius * 3,
108
+ borderRadius: theme.shape.borderRadius * 4,
109
109
  },
110
110
  },
111
111
  overlayPaneSmVariantSizeLeftFull: {
@@ -178,6 +178,7 @@ type StyleProps = {
178
178
 
179
179
  export type LayoutOverlayBaseProps = {
180
180
  children?: React.ReactNode
181
+ className?: string
181
182
  } & StyleProps &
182
183
  UseStyles<typeof useStyles>
183
184
 
@@ -193,6 +194,7 @@ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
193
194
  variantSm,
194
195
  variantMd,
195
196
  classes: _classes,
197
+ className,
196
198
  sizeSm = 'full',
197
199
  sizeMd = 'full',
198
200
  justifySm = 'stretch',
@@ -211,7 +213,7 @@ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
211
213
  const position = useMotionValue<OverlayPosition>(OverlayPosition.UNOPENED)
212
214
 
213
215
  const classes = useStyles({ classes: _classes, sizeSm, sizeMd, justifySm, justifyMd })
214
- const className = classesPicker(classes, {
216
+ const clsName = classesPicker(classes, {
215
217
  variantSm,
216
218
  variantMd,
217
219
  sizeSm,
@@ -353,17 +355,12 @@ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
353
355
  // scrollSnapAlign: 'end',
354
356
  [theme.breakpoints.down('sm')]: {
355
357
  minWidth: '80vw',
356
- ...((sizeSm === 'full' || sizeSm === 'minimal') && {
357
- paddingBottom: 56,
358
- }),
359
- ...(variantSm === 'bottom' && sizeSm === 'full' && { height: 'calc(100vh - 56px)' }),
358
+ ...((sizeSm === 'full' || sizeSm === 'minimal') && { paddingBottom: 56 }),
359
+ ...(variantSm === 'bottom' && sizeSm === 'full' && { minHeight: 'calc(100vh - 56px)' }),
360
360
  },
361
361
  [theme.breakpoints.up('md')]: {
362
- ...(variantMd === 'bottom' && sizeMd === 'full' && { height: '100vh' }),
363
-
364
- ...(sizeMd === 'full' && {
365
- minWidth: 'max(600px, 50vw)',
366
- }),
362
+ ...(variantMd === 'bottom' && sizeMd === 'full' && { minHeight: '100vh' }),
363
+ ...(sizeMd === 'full' && { minWidth: 'max(600px, 50vw)' }),
367
364
  },
368
365
  }),
369
366
  { name: 'OverlayPane' },
@@ -395,11 +392,11 @@ export function LayoutOverlayBase(props: LayoutOverlayBaseProps) {
395
392
 
396
393
  return (
397
394
  <>
398
- <m.div {...className('backdrop')} style={{ opacity: positions.open.visible }} />
399
- <Scroller {...className('root')} grid={false} hideScrollbar onClick={onClickAway}>
395
+ <m.div {...clsName('backdrop')} style={{ opacity: positions.open.visible }} />
396
+ <Scroller {...clsName('root')} grid={false} hideScrollbar onClick={onClickAway}>
400
397
  <BeforeOverlay onClick={onClickAway} ref={beforeRef} />
401
- <Overlay {...className('overlay')} ref={overlayRef}>
402
- <OverlayPane {...className('overlayPane')}>
398
+ <Overlay {...clsName('overlay')} ref={overlayRef}>
399
+ <OverlayPane {...clsName('overlayPane', className)}>
403
400
  <LayoutProvider scroll={scrollWithoffset}>{children}</LayoutProvider>
404
401
  </OverlayPane>
405
402
  </Overlay>
package/Styles/index.tsx CHANGED
@@ -1,3 +1,8 @@
1
1
  export type UseStyles<T extends (...args: never[]) => unknown> = {
2
2
  classes?: Partial<ReturnType<T>>
3
3
  }
4
+
5
+ export * from './breakpointVal'
6
+ export * from './responsiveVal'
7
+ export * from './classesPicker'
8
+ export * from './withTheme'
@@ -0,0 +1,51 @@
1
+ import { makeStyles, Theme, ThemeProvider } from '@material-ui/core'
2
+
3
+ const useStyles = makeStyles(
4
+ {
5
+ // These theme specific styles are copied from
6
+ // https://github.com/mui-org/material-ui/blob/master/packages/mui-material/src/CssBaseline/CssBaseline.js#L18-L24
7
+ root: (theme: Theme) => ({
8
+ color: theme.palette.text.primary,
9
+ ...theme.typography.body1,
10
+ backgroundColor: theme.palette.background.default,
11
+ }),
12
+ },
13
+ { name: 'Theme' },
14
+ )
15
+
16
+ /**
17
+ * It will provide a theme for the underlying tree and will set the color/font and backgroundColor
18
+ * for the child.
19
+ *
20
+ * To use it, wrap your component with it.
21
+ *
22
+ * Example:
23
+ *
24
+ * ```tsx
25
+ * const MyPage = () => {
26
+ * return <div>Your regular page content</div>
27
+ * }
28
+ * export default MyPage
29
+ * ```
30
+ *
31
+ * Becomes:
32
+ *
33
+ * ```tsx
34
+ * const MyPage = () => {
35
+ * return <div>Your regular page content, but now in darkMode</div>
36
+ * }
37
+ *
38
+ * export default withTheme(MyPage, darkTheme)
39
+ * ```
40
+ */
41
+ export function withTheme<P extends { className?: string }>(Component: React.FC<P>, theme: Theme) {
42
+ return (props: P) => {
43
+ const classes = useStyles(theme)
44
+
45
+ return (
46
+ <ThemeProvider theme={theme}>
47
+ <Component {...props} className={classes.root} />
48
+ </ThemeProvider>
49
+ )
50
+ }
51
+ }
package/index.ts CHANGED
@@ -106,9 +106,6 @@ export * from './Stepper/Stepper'
106
106
  export { default as Stepper } from './Stepper/Stepper'
107
107
  export { default as StyledBadge } from './StyledBadge'
108
108
  export * from './Styles'
109
- export * from './Styles/breakpointVal'
110
- export * from './Styles/responsiveVal'
111
- export * from './Styles/classesPicker'
112
109
  export * from './SvgImage'
113
110
  export { default as SvgImage } from './SvgImage'
114
111
  export { default as SvgImageSimple } from './SvgImage/SvgImageSimple'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/next-ui",
3
- "version": "3.22.0",
3
+ "version": "3.23.1",
4
4
  "author": "",
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -10,11 +10,11 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@apollo/client": "^3.5.6",
13
- "@graphcommerce/framer-next-pages": "^2.109.0",
14
- "@graphcommerce/framer-scroller": "^1.2.0",
13
+ "@graphcommerce/framer-next-pages": "^2.109.2",
14
+ "@graphcommerce/framer-scroller": "^1.2.4",
15
15
  "@graphcommerce/framer-utils": "^2.103.21",
16
16
  "@graphcommerce/graphql": "^2.105.13",
17
- "@graphcommerce/image": "^2.105.12",
17
+ "@graphcommerce/image": "^2.105.13",
18
18
  "@lingui/macro": "^3.13.0",
19
19
  "@material-ui/core": "^4.12.3",
20
20
  "@material-ui/lab": "^4.0.0-alpha.60",
@@ -25,7 +25,6 @@
25
25
  "next": "^12.0.7",
26
26
  "react": "^17.0.2",
27
27
  "react-dom": "^17.0.2",
28
- "react-focus-lock": "^2.7.1",
29
28
  "react-is": "^17.0.2",
30
29
  "react-schemaorg": "^2.0.0",
31
30
  "schema-dts": "^1.0.0",
@@ -52,5 +51,5 @@
52
51
  "project": "./tsconfig.json"
53
52
  }
54
53
  },
55
- "gitHead": "bc5423d7547f8685db4cd8fc6d8f7a2a51ebed05"
54
+ "gitHead": "7f9638808769894f9804b7a7f476833d4adf74e4"
56
55
  }