@graphcommerce/magento-product 4.6.1 → 4.7.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.
@@ -2,6 +2,7 @@ fragment ProductPageItem on ProductInterface @injectable {
2
2
  __typename
3
3
  uid
4
4
  ...ProductPageCategory
5
+ ...ProductPageBreadcrumb
5
6
  ...ProductPageDescription
6
7
  ...ProductPageGallery
7
8
  ...ProductPageMeta
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Change Log
2
2
 
3
+ ## 4.7.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`93c8f3a3f`](https://github.com/graphcommerce-org/graphcommerce/commit/93c8f3a3f2fd2d16e5a5132652bf489858583f63), [`0c21c5c23`](https://github.com/graphcommerce-org/graphcommerce/commit/0c21c5c233ebab15f6629c234e3de1cc8c0452e1), [`de8925aa9`](https://github.com/graphcommerce-org/graphcommerce/commit/de8925aa910b191c62041530c68c697a58a1e52d), [`f5eae0afd`](https://github.com/graphcommerce-org/graphcommerce/commit/f5eae0afdbd474b1f81c450425ffadf2d025187a), [`9e0ca73eb`](https://github.com/graphcommerce-org/graphcommerce/commit/9e0ca73eb50ded578f4a98e40a7eb920bf8ab421)]:
8
+ - @graphcommerce/magento-cart@4.8.6
9
+ - @graphcommerce/next-ui@4.28.0
10
+ - @graphcommerce/framer-scroller@2.1.40
11
+ - @graphcommerce/framer-next-pages@3.3.1
12
+ - @graphcommerce/ecommerce-ui@1.5.2
13
+ - @graphcommerce/magento-store@4.3.1
14
+
15
+ ## 4.7.0
16
+
17
+ ### Minor Changes
18
+
19
+ - [#1659](https://github.com/graphcommerce-org/graphcommerce/pull/1659) [`6987ec7d2`](https://github.com/graphcommerce-org/graphcommerce/commit/6987ec7d21ce2d481fabbd6eda039702fcf5242b) Thanks [@Jessevdpoel](https://github.com/Jessevdpoel)! - Added product and category breadcrumbs
20
+
3
21
  ## 4.6.1
4
22
 
5
23
  ### Patch Changes
@@ -0,0 +1,14 @@
1
+ fragment ProductPageBreadcrumb on ProductInterface {
2
+ name
3
+ categories {
4
+ uid
5
+ name
6
+ url_path
7
+ include_in_menu
8
+ breadcrumbs {
9
+ category_name
10
+ category_uid
11
+ category_url_path
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,42 @@
1
+ import { usePrevPageRouter } from '@graphcommerce/framer-next-pages'
2
+ import { Trans } from '@lingui/react'
3
+ import { Breadcrumbs, BreadcrumbsProps, Container, Link, Typography } from '@mui/material'
4
+ import PageLink from 'next/link'
5
+ import { productPageCategory } from '../ProductPageCategory/productPageCategory'
6
+ import { ProductPageBreadcrumbFragment } from './ProductPageBreadcrumb.gql'
7
+
8
+ type ProductPageBreadcrumbsProps = ProductPageBreadcrumbFragment & BreadcrumbsProps
9
+
10
+ export function ProductPageBreadcrumb(props: ProductPageBreadcrumbsProps) {
11
+ const { categories, name } = props
12
+ const prev = usePrevPageRouter()
13
+
14
+ const category =
15
+ categories?.find((c) => `/${c?.url_path}` === prev?.asPath) ?? productPageCategory(props)
16
+
17
+ return (
18
+ <Container maxWidth={false}>
19
+ <Breadcrumbs>
20
+ <PageLink href='/' passHref>
21
+ <Link underline='hover' color='inherit'>
22
+ <Trans id='Home' />
23
+ </Link>
24
+ </PageLink>
25
+ {category?.breadcrumbs?.map((mapped_category, i) => (
26
+ <Link
27
+ underline='hover'
28
+ key={mapped_category?.category_uid}
29
+ color='inherit'
30
+ href={`/${mapped_category?.category_url_path}`}
31
+ >
32
+ {mapped_category?.category_name}
33
+ </Link>
34
+ ))}
35
+ <Link underline='hover' color='inherit' href={`/${category?.url_path}`}>
36
+ {category?.name}
37
+ </Link>
38
+ <Typography color='text.primary'>{name}</Typography>
39
+ </Breadcrumbs>
40
+ </Container>
41
+ )
42
+ }
@@ -0,0 +1,2 @@
1
+ export * from './ProductPageBreadcrumb.gql'
2
+ export * from './ProductPageBreadcrumb'
@@ -6,7 +6,9 @@ import { ProductPageCategoryFragment } from './ProductPageCategory.gql'
6
6
  * - Prefers categories that are included in the menu
7
7
  * - Prefers categories that have a longer path than shorter ones.
8
8
  */
9
- export function productPageCategory(product?: ProductPageCategoryFragment | null) {
9
+ export function productPageCategory<Product extends ProductPageCategoryFragment>(
10
+ product?: Product | null,
11
+ ): NonNullable<Product['categories']>[number] | undefined {
10
12
  if (!product?.categories?.length) return undefined
11
13
  return product?.categories?.reduce((carry, value) => {
12
14
  if (!value?.include_in_menu) return carry
@@ -1,6 +1,7 @@
1
1
  export * from './AddProductsToCart'
2
2
  export * from './JsonLdProduct/jsonLdProduct'
3
3
  export * from './ProductAddToCart'
4
+ export * from './ProductCustomizable'
4
5
  export * from './ProductList/ProductList.gql'
5
6
  export * from './ProductListCount/ProductListCount'
6
7
  export * from './ProductListFilters/ProductFilters.gql'
@@ -18,6 +19,7 @@ export * from './ProductListItems/renderer'
18
19
  export * from './ProductListLink/ProductListLink'
19
20
  export * from './ProductListPagination/ProductListPagination'
20
21
  export * from './ProductListSort/ProductListSort'
22
+ export * from './ProductPageBreadcrumb'
21
23
  export * from './ProductPageCategory/productPageCategory'
22
24
  export * from './ProductPageDescription/ProductPageDescription'
23
25
  export * from './ProductPageGallery/ProductPageGallery'
@@ -31,4 +33,3 @@ export * from './ProductSpecs/ProductSpecs'
31
33
  export * from './ProductStaticPaths/getProductStaticPaths'
32
34
  export * from './ProductUpsells/UpsellProducts.gql'
33
35
  export * from './ProductWeight/ProductWeight'
34
- export * from './ProductCustomizable'
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.6.1",
5
+ "version": "4.7.1",
6
6
  "sideEffects": false,
7
7
  "prettier": "@graphcommerce/prettier-config-pwa",
8
8
  "eslintConfig": {
@@ -19,14 +19,15 @@
19
19
  "type-fest": "^2.12.2"
20
20
  },
21
21
  "dependencies": {
22
- "@graphcommerce/ecommerce-ui": "1.5.1",
23
- "@graphcommerce/framer-scroller": "2.1.39",
22
+ "@graphcommerce/ecommerce-ui": "1.5.2",
23
+ "@graphcommerce/framer-scroller": "2.1.40",
24
+ "@graphcommerce/framer-next-pages": "3.3.1",
24
25
  "@graphcommerce/graphql": "3.4.8",
25
26
  "@graphcommerce/graphql-mesh": "4.2.0",
26
27
  "@graphcommerce/image": "3.1.9",
27
- "@graphcommerce/magento-cart": "4.8.5",
28
- "@graphcommerce/magento-store": "4.3.0",
29
- "@graphcommerce/next-ui": "4.27.0",
28
+ "@graphcommerce/magento-cart": "4.8.6",
29
+ "@graphcommerce/magento-store": "4.3.1",
30
+ "@graphcommerce/next-ui": "4.28.0",
30
31
  "schema-dts": "^1.1.0"
31
32
  },
32
33
  "peerDependencies": {