@graphcommerce/magento-product 3.6.3 → 3.7.2

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,48 @@
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.2](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-product@3.7.1...@graphcommerce/magento-product@3.7.2) (2021-12-03)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * make sure elements that use scroll positioning are using the right hook ([80ee33f](https://github.com/ho-nl/m2-pwa/commit/80ee33f68ecc223147d63fc37e5b9ba94df4564e))
12
+
13
+
14
+
15
+
16
+
17
+ # [3.7.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-product@3.6.4...@graphcommerce/magento-product@3.7.0) (2021-12-01)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * borderRadius ([b9cffcc](https://github.com/ho-nl/m2-pwa/commit/b9cffccf444cb2ff8d6257ef3a64c0ea18e30477))
23
+ * icon OrderBefore ([25a2390](https://github.com/ho-nl/m2-pwa/commit/25a2390321c7047c5191a15a9352020b8161ff7a))
24
+
25
+
26
+ ### Features
27
+
28
+ * borderRadius based on theme.shape.borderRadius ([7c34937](https://github.com/ho-nl/m2-pwa/commit/7c349376cd41a131c628324c299106fdb7e60484))
29
+ * introduce borderRadius ([183afbc](https://github.com/ho-nl/m2-pwa/commit/183afbc8ee269f6694c372b06afdf41302f86c09))
30
+ * variable font weights ([bfd8142](https://github.com/ho-nl/m2-pwa/commit/bfd8142b96742efd1208556e3c48de382d8d8ceb))
31
+
32
+
33
+
34
+
35
+
36
+ ## [3.6.4](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-product@3.6.3...@graphcommerce/magento-product@3.6.4) (2021-11-27)
37
+
38
+
39
+ ### Bug Fixes
40
+
41
+ * incorrect usage of offsetTop ([94f1616](https://github.com/ho-nl/m2-pwa/commit/94f161638017b64d898a2ab990bf69d31dc38319))
42
+ * shadows ([8f43f33](https://github.com/ho-nl/m2-pwa/commit/8f43f33190e429e8abea8eddc0646ffd670f2ce8))
43
+
44
+
45
+
46
+
47
+
6
48
  # [3.6.0](https://github.com/ho-nl/m2-pwa/compare/@graphcommerce/magento-product@3.5.22...@graphcommerce/magento-product@3.6.0) (2021-11-12)
7
49
 
8
50
 
@@ -1,5 +1,5 @@
1
1
  import { cloneDeep } from '@apollo/client/utilities'
2
- import { useChipMenuStyles, SvgImage, iconCancelAlt, SvgImageSimple } from '@graphcommerce/next-ui'
2
+ import { useChipMenuStyles, iconCancelAlt, SvgImageSimple } from '@graphcommerce/next-ui'
3
3
  import { Chip, ChipProps } from '@material-ui/core'
4
4
  import clsx from 'clsx'
5
5
  import React from 'react'
@@ -3,7 +3,6 @@ import { FilterEqualTypeInput } from '@graphcommerce/graphql'
3
3
  import { ChipMenu, ChipMenuProps, responsiveVal } from '@graphcommerce/next-ui'
4
4
  import {
5
5
  Checkbox,
6
- lighten,
7
6
  ListItem,
8
7
  ListItemSecondaryAction,
9
8
  ListItemText,
@@ -40,7 +40,7 @@ const useFilterRangeType = makeStyles(
40
40
  marginLeft: `-${sliderThumbWidth * 0.5}px`,
41
41
  marginTop: `-${sliderThumbWidth * 0.5}px`,
42
42
  background: theme.palette.background.default,
43
- boxShadow: theme.shadows[4],
43
+ boxShadow: theme.shadows[6],
44
44
  },
45
45
  },
46
46
  }),
@@ -53,7 +53,11 @@ export default function ProductListFilters(props: ProductFiltersProps) {
53
53
  />
54
54
  )
55
55
  }
56
- console.log('Filter not recognized', aggregation)
56
+ console.log(
57
+ 'Filter not recognized',
58
+ aggregation.attribute_code,
59
+ filterTypes[aggregation.attribute_code],
60
+ )
57
61
  return null // `FilterMatchTypeInput not ${aggregation.attribute_code}`
58
62
  })}
59
63
  </>
@@ -4,11 +4,12 @@ import {
4
4
  iconChevronRight,
5
5
  responsiveVal,
6
6
  SvgImageSimple,
7
+ useScrollY,
7
8
  UseStyles,
8
9
  } from '@graphcommerce/next-ui'
9
10
  import { makeStyles, Theme } from '@material-ui/core'
10
11
  import clsx from 'clsx'
11
- import { m, useMotionTemplate, useTransform, useViewportScroll } from 'framer-motion'
12
+ import { m, useTransform } from 'framer-motion'
12
13
  import React, { PropsWithChildren, useEffect, useRef, useState } from 'react'
13
14
 
14
15
  const useStyles = makeStyles(
@@ -33,6 +34,7 @@ const useStyles = makeStyles(
33
34
  },
34
35
  },
35
36
  container: {
37
+ position: 'relative',
36
38
  maxWidth: '100%',
37
39
  padding: 6,
38
40
  paddingLeft: 0,
@@ -41,6 +43,16 @@ const useStyles = makeStyles(
41
43
  background: theme.palette.background.default,
42
44
  borderRadius: '99em',
43
45
  },
46
+ },
47
+ shadow: {
48
+ pointerEvents: 'none',
49
+ zindex: '-1',
50
+ borderRadius: '99em',
51
+ position: 'absolute',
52
+ height: '100%',
53
+ width: '100%',
54
+ top: 0,
55
+ boxShadow: theme.shadows[6],
44
56
  [theme.breakpoints.down('sm')]: {
45
57
  boxShadow: 'none !important',
46
58
  },
@@ -80,7 +92,7 @@ export type ProductListFiltersContainerProps = PropsWithChildren<UseStyles<typeo
80
92
  export default function ProductListFiltersContainer(props: ProductListFiltersContainerProps) {
81
93
  const { children } = props
82
94
  const classes = useStyles(props)
83
- const { scrollY } = useViewportScroll()
95
+ const scrollY = useScrollY()
84
96
 
85
97
  const [isSticky, setIsSticky] = useState<boolean>(false)
86
98
  const [startPosition, setStartPosition] = useState<number>(100)
@@ -94,11 +106,12 @@ export default function ProductListFiltersContainer(props: ProductListFiltersCon
94
106
  useEffect(() => {
95
107
  const observer = new ResizeObserver(([entry]) => {
96
108
  if (window.scrollY > 100) return
97
- const offset = wrapperRef.current?.offsetTop ?? 0
109
+ const offset = wrapperRef.current?.getBoundingClientRect()?.top ?? 0
98
110
  const elemHeigh = entry.contentRect.height
99
111
  const nextOffset =
100
- (wrapperRef.current?.parentElement?.nextElementSibling as HTMLElement | null)?.offsetTop ??
101
- 0
112
+ (
113
+ wrapperRef.current?.parentElement?.nextElementSibling as HTMLElement | null
114
+ )?.getBoundingClientRect()?.top ?? 0
102
115
  const modifier = 5
103
116
 
104
117
  setSpacing((nextOffset - elemHeigh - offset + 20) * modifier)
@@ -121,10 +134,7 @@ export default function ProductListFiltersContainer(props: ProductListFiltersCon
121
134
  return scrollY.onChange(onCheckStickyChange)
122
135
  }, [isSticky, scrollHalfway, scrollY])
123
136
 
124
- const opacity = useTransform(scrollY, [startPosition, startPosition + spacing], [0, 0.1])
125
- const boxShadow = useMotionTemplate`
126
- 0 4px 12px 0 rgba(0, 0, 0, ${opacity})
127
- `
137
+ const opacity = useTransform(scrollY, [startPosition, startPosition + spacing], [0, 1])
128
138
 
129
139
  return (
130
140
  <m.div className={classes.wrapper} ref={wrapperRef}>
@@ -132,17 +142,15 @@ export default function ProductListFiltersContainer(props: ProductListFiltersCon
132
142
  <ScrollerButton direction='left' className={classes.sliderPrev}>
133
143
  <SvgImageSimple src={iconChevronLeft} />
134
144
  </ScrollerButton>
135
- <m.div
136
- className={clsx(classes.container, isSticky && classes.containerSticky)}
137
- style={{ boxShadow }}
138
- >
145
+ <div className={clsx(classes.container, isSticky && classes.containerSticky)}>
139
146
  <Scroller
140
147
  className={clsx(classes.scroller, isSticky && classes.scrollerSticky)}
141
148
  hideScrollbar
142
149
  >
143
150
  {children}
144
151
  </Scroller>
145
- </m.div>
152
+ <m.div className={classes.shadow} style={{ opacity }} />
153
+ </div>
146
154
  <ScrollerButton direction='right' className={classes.sliderNext}>
147
155
  <SvgImageSimple src={iconChevronRight} />
148
156
  </ScrollerButton>
@@ -1,9 +1,9 @@
1
+ import { usePageRouter } from '@graphcommerce/framer-next-pages'
1
2
  import { Image, ImageProps } from '@graphcommerce/image'
2
3
  import { responsiveVal, UseStyles } from '@graphcommerce/next-ui'
3
- import { ButtonBase, Link as MuiLink, makeStyles, Theme, Typography } from '@material-ui/core'
4
+ import { ButtonBase, makeStyles, Theme, Typography } from '@material-ui/core'
4
5
  import clsx from 'clsx'
5
6
  import PageLink from 'next/link'
6
- import { useRouter } from 'next/router'
7
7
  import React, { PropsWithChildren, useCallback } from 'react'
8
8
  import { ProductListItemFragment } from '../../Api/ProductListItem.gql'
9
9
  import { useProductLink } from '../../hooks/useProductLink'
@@ -88,6 +88,7 @@ export const useProductListItemStyles = makeStyles(
88
88
  position: 'relative',
89
89
  paddingTop: `calc(100% / ${aspectRatio[0]} * ${aspectRatio[1]})`,
90
90
  background: theme.palette.background.image, // theme specific,
91
+ borderRadius: responsiveVal(theme.shape.borderRadius * 2, theme.shape.borderRadius * 3),
91
92
  }),
92
93
  placeholder: {
93
94
  display: 'flex',
@@ -156,7 +157,7 @@ export default function ProductListItem(props: ProductListItemProps) {
156
157
  const classes = useProductListItemStyles(props)
157
158
  const productLink = useProductLink(props)
158
159
  const discount = Math.floor(price_range.minimum_price.discount?.percent_off ?? 0)
159
- const { locale } = useRouter()
160
+ const { locale } = usePageRouter()
160
161
 
161
162
  // eslint-disable-next-line react-hooks/exhaustive-deps
162
163
  const format = useCallback(
@@ -1,4 +1,3 @@
1
- import { Maybe } from '@graphcommerce/graphql'
2
1
  import { RenderType, UseStyles, responsiveVal } from '@graphcommerce/next-ui'
3
2
  import { Theme, makeStyles } from '@material-ui/core'
4
3
  import clsx from 'clsx'
@@ -1,4 +1,4 @@
1
- import { PropsWithChildren, useState, useEffect } from 'react'
1
+ import { PropsWithChildren, useState, useEffect, useMemo } from 'react'
2
2
  import { productListParamsContext } from '../../context/productListParamsContext'
3
3
  import { ProductListParams } from './filterTypes'
4
4
 
@@ -8,13 +8,11 @@ export default function ProductListParamsProvider({
8
8
  }: PropsWithChildren<{ value: ProductListParams }>) {
9
9
  const [params, setParams] = useState<ProductListParams>(value)
10
10
 
11
- useEffect(() => {
12
- setParams(value)
13
- }, [value])
11
+ useEffect(() => setParams(value), [value])
12
+
13
+ const prov = useMemo(() => ({ params, setParams }), [params])
14
14
 
15
15
  return (
16
- <productListParamsContext.Provider value={{ params, setParams }}>
17
- {children}
18
- </productListParamsContext.Provider>
16
+ <productListParamsContext.Provider value={prov}>{children}</productListParamsContext.Provider>
19
17
  )
20
18
  }
@@ -53,7 +53,7 @@ export default function ProductListSort(props: ProductListSortProps) {
53
53
  key={option?.value ?? ''}
54
54
  dense
55
55
  selected={option?.value === currentSort}
56
- component={(chipProps) => (
56
+ component={React.memo((chipProps) => (
57
57
  <ProductListLink
58
58
  {...chipProps}
59
59
  {...linkParams}
@@ -61,7 +61,7 @@ export default function ProductListSort(props: ProductListSortProps) {
61
61
  underline='none'
62
62
  link={{ scroll: false, replace: true }}
63
63
  />
64
- )}
64
+ ))}
65
65
  >
66
66
  <ListItemText secondary>{option?.label}</ListItemText>
67
67
  </ListItem>
@@ -6,22 +6,19 @@ import { ProductPageDescriptionFragment } from './ProductPageDescription.gql'
6
6
  const useStyles = makeStyles((theme: Theme) => ({
7
7
  /* nested styles because we don't know beforehand which elements the description contains */
8
8
  description: {
9
- ...theme.typography.body2,
10
- fontWeight: 400,
11
- [theme.breakpoints.up('md')]: {
12
- ...theme.typography.h4,
13
- lineHeight: 1.7,
14
- fontWeight: 400,
15
- },
16
9
  '& p:first-of-type': {
17
10
  marginTop: 0,
18
11
  },
19
12
  '& p, & li': {
20
- ...theme.typography.h4,
13
+ ...theme.typography.body1,
21
14
  fontWeight: 400,
15
+
22
16
  [theme.breakpoints.up('md')]: {
23
17
  ...theme.typography.h3,
24
18
  fontWeight: 400,
19
+ '@supports (font-variation-settings: normal)': {
20
+ fontVariationSettings: "'wght' 420",
21
+ },
25
22
  },
26
23
  },
27
24
  '& ul': {
@@ -44,23 +41,22 @@ export default function ProductPageDescription(props: ProductPageDescriptionProp
44
41
  const { description, name, right } = props
45
42
 
46
43
  return (
47
- <>
48
- <ColumnTwoWithTop
49
- top={
50
- <Typography variant='h1' component='h2'>
51
- {name}
52
- </Typography>
53
- }
54
- left={
55
- description && (
56
- <div
57
- className={classes.description}
58
- dangerouslySetInnerHTML={{ __html: description.html }}
59
- />
60
- )
61
- }
62
- right={right}
63
- />
64
- </>
44
+ <ColumnTwoWithTop
45
+ top={
46
+ <Typography variant='h1' component='h2'>
47
+ {name}
48
+ </Typography>
49
+ }
50
+ left={
51
+ description && (
52
+ <div
53
+ className={classes.description}
54
+ // eslint-disable-next-line react/no-danger
55
+ dangerouslySetInnerHTML={{ __html: description.html }}
56
+ />
57
+ )
58
+ }
59
+ right={right}
60
+ />
65
61
  )
66
62
  }
@@ -1,19 +1,17 @@
1
1
  import { UseStyles } from '@graphcommerce/next-ui'
2
- import { makeStyles, Theme, Typography } from '@material-ui/core'
2
+ import { makeStyles, Typography } from '@material-ui/core'
3
3
  import React from 'react'
4
4
  import { ProductShortDescriptionFragment } from './ProductShortDescription.gql'
5
5
 
6
6
  const useStyles = makeStyles(
7
- (theme: Theme) => ({
7
+ {
8
8
  root: {
9
9
  '& > p': {
10
10
  marginTop: 0,
11
11
  },
12
12
  },
13
- }),
14
- {
15
- name: 'ProductShortDescription',
16
13
  },
14
+ { name: 'ProductShortDescription' },
17
15
  )
18
16
 
19
17
  type ProductShortDescriptionProps = ProductShortDescriptionFragment & UseStyles<typeof useStyles>
@@ -1,5 +1,5 @@
1
- import { SvgImage, responsiveVal, iconBox, SvgImageSimple } from '@graphcommerce/next-ui'
2
- import { makeStyles, Theme, Typography } from '@material-ui/core'
1
+ import { responsiveVal, iconOrderBefore, SvgImageSimple } from '@graphcommerce/next-ui'
2
+ import { darken, lighten, makeStyles, Theme, Typography } from '@material-ui/core'
3
3
  import React from 'react'
4
4
 
5
5
  const useStyles = makeStyles(
@@ -14,16 +14,16 @@ const useStyles = makeStyles(
14
14
  gridTemplateColumns: `min-content auto`,
15
15
  columnGap: theme.spacings.xxs,
16
16
  marginTop: theme.spacings.xxs,
17
- background: theme.palette.background.paper,
18
- border: `1px solid ${theme.palette.divider}`,
17
+ background:
18
+ theme.palette.type === 'light'
19
+ ? darken(theme.palette.background.default, 0.01)
20
+ : lighten(theme.palette.background.default, 0.2),
19
21
  padding: theme.spacings.xxs,
20
- borderRadius: responsiveVal(4, 6),
22
+ borderRadius: responsiveVal(theme.shape.borderRadius * 3, theme.shape.borderRadius * 4),
21
23
  },
22
24
  text: {},
23
25
  image: {
24
26
  gridArea: 'image',
25
- width: responsiveVal(18, 24),
26
- height: responsiveVal(18, 24),
27
27
  },
28
28
  title: {
29
29
  gridArea: 'title',
@@ -42,7 +42,7 @@ export default function ProductSidebarDelivery() {
42
42
 
43
43
  return (
44
44
  <div className={classes.root}>
45
- <SvgImageSimple className={classes.image} src={iconBox} />
45
+ <SvgImageSimple className={classes.image} src={iconOrderBefore} size='small' />
46
46
  <Typography className={classes.title} variant='body2' component='div'>
47
47
  Order before 22:00
48
48
  </Typography>
@@ -1,4 +1,4 @@
1
- import { default as Router } from 'next/router'
1
+ import { useRouter } from 'next/router'
2
2
  import { ProductListParams } from '../components/ProductListItems/filterTypes'
3
3
  import { createProductListLink } from './useProductListLink'
4
4
  import { useProductListParamsContext } from './useProductListParamsContext'
@@ -11,9 +11,10 @@ type UseProductLinkPushProps = {
11
11
 
12
12
  export function useProductListLinkReplace(props?: UseProductLinkPushProps) {
13
13
  const { setParams } = useProductListParamsContext()
14
+ const router = useRouter()
14
15
 
15
16
  return (params: ProductListParams) => {
16
- const queryUrl = Router.query.url ?? []
17
+ const queryUrl = router.query.url ?? []
17
18
  const comingFromURLWithoutFilters = !queryUrl.includes('q')
18
19
 
19
20
  setParams(params)
@@ -23,10 +24,10 @@ export function useProductListLinkReplace(props?: UseProductLinkPushProps) {
23
24
  // push the first filter, so the new route (on browser back) will be e.g. /women/fruit instead of /women
24
25
  if (comingFromURLWithoutFilters) {
25
26
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
26
- Router.push(path, path, props)
27
+ router.push(path, path, props)
27
28
  } else {
28
29
  // eslint-disable-next-line @typescript-eslint/no-floating-promises
29
- Router.replace(path, path, props)
30
+ router.replace(path, path, props)
30
31
  }
31
32
  }
32
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphcommerce/magento-product",
3
- "version": "3.6.3",
3
+ "version": "3.7.2",
4
4
  "sideEffects": false,
5
5
  "prettier": "@graphcommerce/prettier-config-pwa",
6
6
  "browserslist": [
@@ -14,19 +14,19 @@
14
14
  },
15
15
  "devDependencies": {
16
16
  "@graphcommerce/browserslist-config-pwa": "^3.0.2",
17
- "@graphcommerce/eslint-config-pwa": "^3.1.5",
17
+ "@graphcommerce/eslint-config-pwa": "^3.1.6",
18
18
  "@graphcommerce/prettier-config-pwa": "^3.0.4",
19
19
  "@graphcommerce/typescript-config-pwa": "^3.1.1",
20
20
  "@playwright/test": "^1.16.2"
21
21
  },
22
22
  "dependencies": {
23
23
  "@apollo/client": "^3.4.16",
24
- "@graphcommerce/framer-scroller": "^1.0.4",
25
- "@graphcommerce/graphql": "^2.105.5",
26
- "@graphcommerce/image": "^2.105.4",
27
- "@graphcommerce/magento-cart": "^3.7.3",
28
- "@graphcommerce/magento-store": "^3.3.3",
29
- "@graphcommerce/next-ui": "^3.18.1",
24
+ "@graphcommerce/framer-scroller": "^1.1.0",
25
+ "@graphcommerce/graphql": "^2.105.6",
26
+ "@graphcommerce/image": "^2.105.5",
27
+ "@graphcommerce/magento-cart": "^3.8.2",
28
+ "@graphcommerce/magento-store": "^3.3.7",
29
+ "@graphcommerce/next-ui": "^3.20.0",
30
30
  "@lingui/macro": "^3.12.1",
31
31
  "@material-ui/core": "^4.12.3",
32
32
  "@material-ui/lab": "^4.0.0-alpha.60",
@@ -38,5 +38,5 @@
38
38
  "schema-dts": "^1.0.0",
39
39
  "type-fest": "^2.5.1"
40
40
  },
41
- "gitHead": "5ed153aa2213be8363138c0956872fe2fde2f590"
41
+ "gitHead": "8f156415c7f5a963e363f0d6d18fe5d6bbd5dba2"
42
42
  }