@graphcommerce/magento-product 4.4.25 → 4.5.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.
@@ -8,9 +8,6 @@ fragment ProductListItem on ProductInterface @injectable {
8
8
  label
9
9
  }
10
10
  price_range {
11
- maximum_price {
12
- ...ProductListPrice
13
- }
14
11
  minimum_price {
15
12
  ...ProductListPrice
16
13
  }
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`755d2cf83`](https://github.com/graphcommerce-org/graphcommerce/commit/755d2cf83343a5ad3d61063eff595d821de360aa), [`dc7f2dda4`](https://github.com/graphcommerce-org/graphcommerce/commit/dc7f2dda40ff8572fc11161de6eb62ca13e720dd)]:
8
+ - @graphcommerce/next-ui@4.23.0
9
+ - @graphcommerce/framer-scroller@2.1.34
10
+ - @graphcommerce/magento-cart@4.7.2
11
+ - @graphcommerce/magento-store@4.2.30
12
+
13
+ ## 4.5.1
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`448c77681`](https://github.com/graphcommerce-org/graphcommerce/commit/448c77681f9a7794e84ec93139d7e0f16afafbd9)]:
18
+ - @graphcommerce/graphql-mesh@4.1.9
19
+ - @graphcommerce/magento-store@4.2.29
20
+ - @graphcommerce/magento-cart@4.7.1
21
+
22
+ ## 4.5.0
23
+
24
+ ### Minor Changes
25
+
26
+ - [#1602](https://github.com/graphcommerce-org/graphcommerce/pull/1602) [`5f781a217`](https://github.com/graphcommerce-org/graphcommerce/commit/5f781a217ce63ed56bc1a9983487b04400a8a315) Thanks [@ErwinOtten](https://github.com/ErwinOtten)! - Default styles and layout fixes
27
+
28
+ - Scaled icons and fonts down. Size in typography is now more gradual: https://graphcommerce.vercel.app/test/typography
29
+ - Multiple accessibility fixes. Missing button/input labels, and fixed spacing issues resulting in high % appropriately sized tap targets
30
+ - Replaced responsiveVal usage with better performaning breakpointVal where possible
31
+ - All buttons are now Pill by default.
32
+ - Cleaned up checkout styles
33
+
34
+ ### Patch Changes
35
+
36
+ - [#1590](https://github.com/graphcommerce-org/graphcommerce/pull/1590) [`b40a352f7`](https://github.com/graphcommerce-org/graphcommerce/commit/b40a352f7bccdb831dce1d45baf98d51b0921d58) Thanks [@paales](https://github.com/paales)! - Split ProductList query into two separate queries so the backend can use varnish more effectively
37
+
38
+ * [#1590](https://github.com/graphcommerce-org/graphcommerce/pull/1590) [`40983df17`](https://github.com/graphcommerce-org/graphcommerce/commit/40983df170ed0435c47496285dfe30aafeb2eeac) Thanks [@paales](https://github.com/paales)! - Implement search results with a base static page and dynamic pages after paginating/filtering
39
+
40
+ - [#1590](https://github.com/graphcommerce-org/graphcommerce/pull/1590) [`ec96a0eb0`](https://github.com/graphcommerce-org/graphcommerce/commit/ec96a0eb049ee2204f32f9c578455cf9c131dbd2) Thanks [@paales](https://github.com/paales)! - Filtered category pages are now servered by a separate route with getServerSideProps. Since there are practically infinite variations of filters, it doesn't make sense to query those on a URL level and we're leveraging the backend caching possibilities.
41
+
42
+ - Updated dependencies [[`3ff0e7f2d`](https://github.com/graphcommerce-org/graphcommerce/commit/3ff0e7f2d26edad228848268d24e9aaf56cd2c30), [`04708dacc`](https://github.com/graphcommerce-org/graphcommerce/commit/04708daccc213c6ea927bc67fa3bd0d5b1fad619), [`bb94e7045`](https://github.com/graphcommerce-org/graphcommerce/commit/bb94e7045460cb671c45d612a0833731d7c20c30), [`b0dc4e2e1`](https://github.com/graphcommerce-org/graphcommerce/commit/b0dc4e2e1982d502d38dd50a0f493396360a7a15), [`4a5286dfe`](https://github.com/graphcommerce-org/graphcommerce/commit/4a5286dfeaa1719e594a0078f274fbab53969c4e), [`d46d5ed0c`](https://github.com/graphcommerce-org/graphcommerce/commit/d46d5ed0cc5794391b7527fc17bbb68ec2212e33), [`e573278e4`](https://github.com/graphcommerce-org/graphcommerce/commit/e573278e43506a6b17a2981e61d0e9fad41eb2eb), [`5f781a217`](https://github.com/graphcommerce-org/graphcommerce/commit/5f781a217ce63ed56bc1a9983487b04400a8a315), [`ac6eedbb1`](https://github.com/graphcommerce-org/graphcommerce/commit/ac6eedbb14d3abd8cf1231a98dc2a8b7f4659f1f)]:
43
+ - @graphcommerce/graphql-mesh@4.1.8
44
+ - @graphcommerce/next-ui@4.22.0
45
+ - @graphcommerce/magento-cart@4.7.0
46
+ - @graphcommerce/magento-store@4.2.28
47
+ - @graphcommerce/framer-scroller@2.1.33
48
+ - @graphcommerce/graphql@3.4.7
49
+ - @graphcommerce/image@3.1.9
50
+
3
51
  ## 4.4.25
4
52
 
5
53
  ### Patch Changes
@@ -8,11 +8,9 @@ import {
8
8
  iconChevronRight,
9
9
  IconSvg,
10
10
  extendableComponent,
11
- AnimatedRow,
12
11
  } from '@graphcommerce/next-ui'
13
12
  import { Trans } from '@lingui/react'
14
- import { Divider, Typography, ButtonProps, Box, Alert } from '@mui/material'
15
- import { AnimatePresence } from 'framer-motion'
13
+ import { Divider, Typography, ButtonProps, Box, Alert, useMediaQuery, Theme } from '@mui/material'
16
14
  import PageLink from 'next/link'
17
15
  import React from 'react'
18
16
  import { ProductAddToCartDocument, ProductAddToCartMutationVariables } from './ProductAddToCart.gql'
@@ -100,13 +98,11 @@ export function ProductAddToCart(
100
98
 
101
99
  <ApolloCartErrorAlert error={error} />
102
100
 
103
- <AnimatePresence initial={false}>
104
- {data?.addProductsToCart?.user_errors.map((e) => (
105
- <AnimatedRow layout key={e?.code}>
106
- <Alert severity='error'>{e?.message}</Alert>
107
- </AnimatedRow>
108
- ))}
109
- </AnimatePresence>
101
+ {data?.addProductsToCart?.user_errors.map((e) => (
102
+ <Box key={e?.code}>
103
+ <Alert severity='error'>{e?.message}</Alert>
104
+ </Box>
105
+ ))}
110
106
 
111
107
  <MessageSnackbar
112
108
  open={
@@ -116,6 +112,7 @@ export function ProductAddToCart(
116
112
  !data?.addProductsToCart?.user_errors?.length
117
113
  }
118
114
  variant='pill'
115
+ autoHide
119
116
  action={
120
117
  <PageLink href='/cart' passHref>
121
118
  <Button
@@ -4,8 +4,6 @@ query ProductList(
4
4
  $filters: ProductAttributeFilterInput = {}
5
5
  $sort: ProductAttributeSortInput = {}
6
6
  $search: String = ""
7
- $categoryUid: String!
8
7
  ) {
9
8
  ...ProductListQueryFragment
10
- ...ProductFiltersQueryFragment
11
9
  }
@@ -30,7 +30,7 @@ export function FilterCheckboxType(props: FilterCheckboxTypeProps) {
30
30
  filters={{ ...params.filters, [attribute_code]: filter }}
31
31
  currentPage={undefined}
32
32
  noLink
33
- link={{ scroll: false, replace: true }}
33
+ link={{ replace: true, prefetch: false }}
34
34
  >
35
35
  <Chip
36
36
  component='button'
@@ -115,7 +115,7 @@ export function FilterEqualType(props: FilterEqualTypeProps) {
115
115
  currentPage={undefined}
116
116
  key={option?.value}
117
117
  color='inherit'
118
- link={{ replace: anyFilterActive }}
118
+ link={{ replace: anyFilterActive, prefetch: false }}
119
119
  >
120
120
  <ListItem
121
121
  dense
@@ -0,0 +1,5 @@
1
+ query ProductFilters($filters: ProductAttributeFilterInput = {}, $search: String) {
2
+ filters: products(filter: $filters, currentPage: 1, pageSize: 1, search: $search) {
3
+ ...ProductListFilters
4
+ }
5
+ }
@@ -1,5 +1,10 @@
1
1
  import { Image, ImageProps } from '@graphcommerce/image'
2
- import { responsiveVal, extendableComponent, useNumberFormat } from '@graphcommerce/next-ui'
2
+ import {
3
+ responsiveVal,
4
+ extendableComponent,
5
+ useNumberFormat,
6
+ breakpointVal,
7
+ } from '@graphcommerce/next-ui'
3
8
  import { Trans } from '@lingui/react'
4
9
  import { ButtonBase, Typography, Box, styled, SxProps, Theme } from '@mui/material'
5
10
  import PageLink from 'next/link'
@@ -83,7 +88,12 @@ export function ProductListItem(props: ProductListItemProps) {
83
88
  display: 'block',
84
89
  position: 'relative',
85
90
  height: '100%',
86
- borderRadius: responsiveVal(theme.shape.borderRadius * 2, theme.shape.borderRadius * 3),
91
+ ...breakpointVal(
92
+ 'borderRadius',
93
+ theme.shape.borderRadius * 2,
94
+ theme.shape.borderRadius * 3,
95
+ theme.breakpoints.values,
96
+ ),
87
97
  }),
88
98
  ...(Array.isArray(sx) ? sx : [sx]),
89
99
  ]}
@@ -93,7 +103,13 @@ export function ProductListItem(props: ProductListItemProps) {
93
103
  sx={(theme) => ({
94
104
  display: 'grid',
95
105
  bgcolor: 'background.image',
96
- borderRadius: responsiveVal(theme.shape.borderRadius * 2, theme.shape.borderRadius * 3),
106
+ ...breakpointVal(
107
+ 'borderRadius',
108
+ theme.shape.borderRadius * 2,
109
+ theme.shape.borderRadius * 3,
110
+ theme.breakpoints.values,
111
+ ),
112
+ overflow: 'hidden',
97
113
  padding: responsiveVal(8, 12),
98
114
  '& > picture': {
99
115
  gridArea: `1 / 1 / 3 / 3`,
@@ -18,7 +18,7 @@ export function parseParams(
18
18
  let error = false
19
19
  query.reduce<string | undefined>((param, value) => {
20
20
  // We parse everything in pairs, every second loop we parse
21
- if (!param) return value
21
+ if (!param || param === 'q') return value
22
22
 
23
23
  if (param === 'page') {
24
24
  categoryVariables.currentPage = Number(value)
@@ -64,10 +64,12 @@ export function parseParams(
64
64
  export function extractUrlQuery(params?: { url: string[] }) {
65
65
  if (!params?.url) return [undefined, undefined] as const
66
66
 
67
- const queryIndex = params.url.findIndex((slug) => slug === 'q')
67
+ const queryIndex = params.url.findIndex(
68
+ (slug) => slug === 'q' || slug === 'page' || slug === 'dir',
69
+ )
68
70
  const qIndex = queryIndex < 0 ? params.url.length : queryIndex
69
71
  const url = params.url.slice(0, qIndex).join('/')
70
- const query = params.url.slice(qIndex + 1)
72
+ const query = params.url.slice(qIndex)
71
73
 
72
74
  if (queryIndex > 0 && !query.length) return [undefined, undefined] as const
73
75
  return [url, query] as const
@@ -2,7 +2,7 @@ import {
2
2
  ColumnTwoWithTop,
3
3
  ColumnTwoWithTopProps,
4
4
  extendableComponent,
5
- responsiveVal,
5
+ breakpointVal,
6
6
  } from '@graphcommerce/next-ui'
7
7
  import { Box, SxProps, Theme, Typography } from '@mui/material'
8
8
  import { Variant } from '@mui/material/styles/createTypography'
@@ -52,11 +52,12 @@ export function ProductPageDescription(props: ProductPageDescriptionProps) {
52
52
  display: 'inline',
53
53
  },
54
54
  },
55
- fontSize === 'responsive' && {
56
- '& p, & li': {
57
- fontSize: responsiveVal(16, 30),
58
- },
59
- },
55
+ fontSize === 'responsive' &&
56
+ ((theme) => ({
57
+ '& p, & li': {
58
+ ...breakpointVal('fontSize', 16, 30, theme.breakpoints.values),
59
+ },
60
+ })),
60
61
  fontSize !== 'responsive' && {
61
62
  '& p, & li': {
62
63
  fontSize,
@@ -1,23 +1,5 @@
1
1
  fragment ProductPagePrice on ProductInterface {
2
2
  price_range {
3
- maximum_price {
4
- regular_price {
5
- ...Money
6
- }
7
- discount {
8
- amount_off
9
- percent_off
10
- }
11
- final_price {
12
- ...Money
13
- }
14
- fixed_product_taxes {
15
- amount {
16
- ...Money
17
- }
18
- label
19
- }
20
- }
21
3
  minimum_price {
22
4
  regular_price {
23
5
  ...Money
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  responsiveVal,
3
+ breakpointVal,
3
4
  iconOrderBefore,
4
5
  IconSvg,
5
6
  extendableComponent,
@@ -28,7 +29,12 @@ export function ProductSidebarDelivery() {
28
29
  ? darken(theme.palette.background.default, 0.01)
29
30
  : lighten(theme.palette.background.default, 0.2),
30
31
  padding: theme.spacings.xxs,
31
- borderRadius: responsiveVal(theme.shape.borderRadius * 3, theme.shape.borderRadius * 4),
32
+ ...breakpointVal(
33
+ 'borderRadius',
34
+ theme.shape.borderRadius * 3,
35
+ theme.shape.borderRadius * 4,
36
+ theme.breakpoints.values,
37
+ ),
32
38
  })}
33
39
  >
34
40
  <IconSvg
@@ -3,6 +3,7 @@ export * from './ProductAddToCart/ProductAddToCart'
3
3
  export * from './ProductAddToCart/ProductAddToCart.gql'
4
4
  export * from './ProductList/ProductList.gql'
5
5
  export * from './ProductListCount/ProductListCount'
6
+ export * from './ProductListFilters/ProductFilters.gql'
6
7
  export * from './ProductListFilters/ProductListFilters'
7
8
  export * from './ProductListFiltersContainer/ProductListFiltersContainer'
8
9
  export * from './ProductListItem/ProductListItem'
@@ -6,31 +6,40 @@ import {
6
6
  } from '../components/ProductListItems/filterTypes'
7
7
 
8
8
  export function createProductListLink(props: ProductListParams): string {
9
- const { url, sort, currentPage, filters } = props
9
+ const { url, sort, currentPage, filters: incomming } = props
10
+
11
+ const filters = { ...incomming, category_uid: undefined }
12
+ const uid = incomming.category_uid?.eq || incomming.category_uid?.in?.[0]
10
13
 
11
14
  // base url path generation
12
- let href = ``
15
+ let paginateSort = ``
16
+ let query = ``
13
17
 
14
- if (currentPage && currentPage > 1) href += `/page/${currentPage}`
18
+ if (currentPage && currentPage > 1) paginateSort += `/page/${currentPage}`
15
19
 
16
20
  // todo(paales): How should the URL look like with multiple sorts?
17
21
  // Something like: /sort/position,price/dir/asc,asc
18
22
  const [sortBy] = Object.keys(sort)
19
- if (sort && sortBy) href += `/sort/${sortBy}`
20
- if (sort && sortBy && sort[sortBy] && sort[sortBy] === 'DESC') href += `/dir/desc`
23
+ if (sort && sortBy) query += `/sort/${sortBy}`
24
+ if (sort && sortBy && sort[sortBy] && sort[sortBy] === 'DESC') query += `/dir/desc`
21
25
 
22
26
  // Apply filters
23
27
  if (filters)
24
28
  Object.entries(filters).forEach(([param, value]) => {
25
- if (value && isFilterTypeEqual(value) && value.in?.length)
26
- href += `/${param}/${value.in?.join(',')}`
27
- if (value && isFilterTypeMatch(value)) href += `/${param}/${value.match}`
28
- if (value && isFilterTypeRange(value))
29
- href += `/${param}/${value.from ?? '*'}-${value.to ?? '*'}`
29
+ if (!value) return
30
+ if (isFilterTypeEqual(value) && value.in?.length) query += `/${param}/${value.in?.join(',')}`
31
+ if (isFilterTypeEqual(value) && value.eq) query += `/${param}/${value.eq}`
32
+ if (isFilterTypeMatch(value)) paginateSort += `/${param}/${value.match}`
33
+ if (isFilterTypeRange(value)) query += `/${param}/${value.from ?? '*'}-${value.to ?? '*'}`
30
34
  })
31
35
 
32
- href = `/${url}${href && `/q${href}`}`
33
- return href
36
+ const result = query
37
+ ? `/${url.startsWith('search') ? url : `c/${url}`}${paginateSort}/q${
38
+ uid ? `/category_uid/${uid}` : ''
39
+ }${query}`
40
+ : `/${url}${paginateSort}`
41
+
42
+ return result
34
43
  }
35
44
 
36
45
  export function useProductListLink(props: ProductListParams): string {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/magento-product",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "4.4.25",
5
+ "version": "4.5.2",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -19,13 +19,13 @@
19
19
  "type-fest": "^2.12.2"
20
20
  },
21
21
  "dependencies": {
22
- "@graphcommerce/framer-scroller": "2.1.32",
23
- "@graphcommerce/graphql": "3.4.6",
24
- "@graphcommerce/graphql-mesh": "4.1.7",
25
- "@graphcommerce/image": "3.1.8",
26
- "@graphcommerce/magento-cart": "4.6.9",
27
- "@graphcommerce/magento-store": "4.2.27",
28
- "@graphcommerce/next-ui": "4.21.0",
22
+ "@graphcommerce/framer-scroller": "2.1.34",
23
+ "@graphcommerce/graphql": "3.4.7",
24
+ "@graphcommerce/graphql-mesh": "4.1.9",
25
+ "@graphcommerce/image": "3.1.9",
26
+ "@graphcommerce/magento-cart": "4.7.2",
27
+ "@graphcommerce/magento-store": "4.2.30",
28
+ "@graphcommerce/next-ui": "4.23.0",
29
29
  "schema-dts": "^1.1.0"
30
30
  },
31
31
  "peerDependencies": {
@@ -1,5 +0,0 @@
1
- fragment ProductFiltersQueryFragment on Query {
2
- filters: products(filter: { category_uid: { eq: $categoryUid } }) {
3
- ...ProductListFilters
4
- }
5
- }