@graphcommerce/magento-product 3.8.13 → 4.0.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 +422 -315
- package/components/ProductAddToCart/ProductAddToCart.tsx +32 -30
- package/components/ProductListCount/ProductListCount.tsx +46 -0
- package/components/ProductListFilters/FilterCheckboxType.tsx +6 -13
- package/components/ProductListFilters/FilterEqualType.tsx +107 -102
- package/components/ProductListFilters/FilterRangeType.tsx +32 -40
- package/components/ProductListFilters/ProductListFilters.graphql +2 -0
- package/components/ProductListFilters/{index.tsx → ProductListFilters.tsx} +0 -1
- package/components/ProductListFiltersContainer/index.tsx +104 -91
- package/components/ProductListItem/index.tsx +186 -146
- package/components/ProductListItems/ProductListItemsBase.tsx +22 -32
- package/components/ProductListItems/getFilterTypes.ts +1 -1
- package/components/ProductListLink/ProductListLink.tsx +2 -2
- package/components/ProductListPagination/index.tsx +2 -2
- package/components/ProductListPrice/index.tsx +21 -21
- package/components/ProductListSort/index.tsx +15 -13
- package/components/ProductPageDescription/index.tsx +38 -37
- package/components/ProductShortDescription/index.tsx +7 -17
- package/components/ProductSidebarDelivery/index.tsx +48 -44
- package/components/ProductSpecs/index.tsx +32 -41
- package/components/ProductStaticPaths/getProductStaticPaths.ts +1 -1
- package/components/ProductWeight/index.tsx +1 -1
- package/components/index.ts +16 -26
- package/package.json +22 -26
- package/components/ProductListCount/index.tsx +0 -55
|
@@ -1,34 +1,9 @@
|
|
|
1
|
-
import { RenderType,
|
|
2
|
-
import {
|
|
3
|
-
import clsx from 'clsx'
|
|
4
|
-
import React from 'react'
|
|
1
|
+
import { RenderType, responsiveVal } from '@graphcommerce/next-ui'
|
|
2
|
+
import { Box, BoxProps } from '@mui/material'
|
|
5
3
|
import { ProductListItemFragment } from '../../Api/ProductListItem.gql'
|
|
6
4
|
import { ProductListItemProps } from '../ProductListItem'
|
|
7
5
|
import { ProductListItemRenderer } from './renderer'
|
|
8
6
|
|
|
9
|
-
export const useStyles = makeStyles(
|
|
10
|
-
(theme: Theme) => ({
|
|
11
|
-
productList: {
|
|
12
|
-
display: 'grid',
|
|
13
|
-
gridColumnGap: theme.spacings.md,
|
|
14
|
-
gridRowGap: theme.spacings.md,
|
|
15
|
-
},
|
|
16
|
-
productListsmall: {
|
|
17
|
-
gridTemplateColumns: `repeat(auto-fill, minmax(${responsiveVal(150, 280)}, 1fr))`,
|
|
18
|
-
},
|
|
19
|
-
productListnormal: {
|
|
20
|
-
gridTemplateColumns: `repeat(2, 1fr)`,
|
|
21
|
-
[theme.breakpoints.up('md')]: {
|
|
22
|
-
gridTemplateColumns: `repeat(3, 1fr)`,
|
|
23
|
-
},
|
|
24
|
-
[theme.breakpoints.up('lg')]: {
|
|
25
|
-
gridTemplateColumns: `repeat(4, 1fr)`,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
}),
|
|
29
|
-
{ name: 'ProductList' },
|
|
30
|
-
)
|
|
31
|
-
|
|
32
7
|
export type ProductItemsGridProps = {
|
|
33
8
|
items?:
|
|
34
9
|
| Array<(ProductListItemFragment & ProductListItemProps) | null | undefined>
|
|
@@ -37,14 +12,29 @@ export type ProductItemsGridProps = {
|
|
|
37
12
|
renderers: ProductListItemRenderer
|
|
38
13
|
loadingEager?: number
|
|
39
14
|
size?: 'normal' | 'small'
|
|
40
|
-
|
|
15
|
+
sx?: BoxProps['sx']
|
|
16
|
+
}
|
|
41
17
|
|
|
42
18
|
export default function ProductListItemsBase(props: ProductItemsGridProps) {
|
|
43
|
-
const { items, renderers, loadingEager = 0, size = 'normal'
|
|
44
|
-
const classes = useStyles(props)
|
|
19
|
+
const { items, sx = [], renderers, loadingEager = 0, size = 'normal' } = props
|
|
45
20
|
|
|
46
21
|
return (
|
|
47
|
-
<
|
|
22
|
+
<Box
|
|
23
|
+
sx={[
|
|
24
|
+
(theme) => ({
|
|
25
|
+
display: 'grid',
|
|
26
|
+
gridColumnGap: theme.spacings.md,
|
|
27
|
+
gridRowGap: theme.spacings.md,
|
|
28
|
+
}),
|
|
29
|
+
size === 'small' && {
|
|
30
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${responsiveVal(150, 280)}, 1fr))`,
|
|
31
|
+
},
|
|
32
|
+
size === 'normal' && {
|
|
33
|
+
gridTemplateColumns: { xs: `repeat(2, 1fr)`, md: `repeat(3, 1fr)`, lg: `repeat(4, 1fr)` },
|
|
34
|
+
},
|
|
35
|
+
...(Array.isArray(sx) ? sx : [sx]),
|
|
36
|
+
]}
|
|
37
|
+
>
|
|
48
38
|
{items?.map((item, idx) =>
|
|
49
39
|
item ? (
|
|
50
40
|
<RenderType
|
|
@@ -61,6 +51,6 @@ export default function ProductListItemsBase(props: ProductItemsGridProps) {
|
|
|
61
51
|
/>
|
|
62
52
|
) : null,
|
|
63
53
|
)}
|
|
64
|
-
</
|
|
54
|
+
</Box>
|
|
65
55
|
)
|
|
66
56
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { gql, ApolloClient, NormalizedCacheObject } from '@
|
|
1
|
+
import { gql, ApolloClient, NormalizedCacheObject } from '@graphcommerce/graphql'
|
|
2
2
|
import { Exact } from '@graphcommerce/graphql'
|
|
3
3
|
import { AllFilterInputTypes, FilterTypes } from './filterTypes'
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Link, LinkProps } from '@material
|
|
1
|
+
import { Link, LinkProps } from '@mui/material'
|
|
2
2
|
import PageLink, { LinkProps as PageLinkProps } from 'next/link'
|
|
3
3
|
import React, { PropsWithChildren } from 'react'
|
|
4
4
|
import { useProductListLink } from '../../hooks/useProductListLink'
|
|
@@ -42,7 +42,7 @@ const ProductListLink = React.forwardRef<HTMLAnchorElement, ProductListLinkProps
|
|
|
42
42
|
{noLink ? (
|
|
43
43
|
children
|
|
44
44
|
) : (
|
|
45
|
-
<Link rel={rel} {...linkProps} ref={ref} onClick={updateParams}>
|
|
45
|
+
<Link rel={rel} {...linkProps} ref={ref} onClick={updateParams} underline='hover'>
|
|
46
46
|
{children}
|
|
47
47
|
</Link>
|
|
48
48
|
)}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Pagination } from '@graphcommerce/next-ui'
|
|
2
|
-
import { PaginationProps } from '@material
|
|
2
|
+
import { PaginationProps } from '@mui/material'
|
|
3
3
|
import React from 'react'
|
|
4
4
|
import { useProductListParamsContext } from '../../hooks/useProductListParamsContext'
|
|
5
5
|
import ProductListLink from '../ProductListLink/ProductListLink'
|
|
@@ -21,7 +21,7 @@ export default function ProductListPagination({
|
|
|
21
21
|
count={page_info?.total_pages}
|
|
22
22
|
page={page_info?.current_page ?? 1}
|
|
23
23
|
renderLink={(page: number, icon: React.ReactNode, btnProps: any) => (
|
|
24
|
-
<ProductListLink {...btnProps} {...params} currentPage={btnProps.page}>
|
|
24
|
+
<ProductListLink {...btnProps} {...params} currentPage={btnProps.page} color='inherit'>
|
|
25
25
|
{icon}
|
|
26
26
|
</ProductListLink>
|
|
27
27
|
)}
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { Money } from '@graphcommerce/magento-store'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import React from 'react'
|
|
2
|
+
import { extendableComponent } from '@graphcommerce/next-ui'
|
|
3
|
+
import { Typography, TypographyProps, Box } from '@mui/material'
|
|
5
4
|
import { ProductListPriceFragment } from './ProductListPrice.gql'
|
|
6
5
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
textDecoration: 'line-through',
|
|
12
|
-
color: theme.palette.text.disabled,
|
|
13
|
-
display: 'inline',
|
|
14
|
-
marginRight: 8,
|
|
15
|
-
},
|
|
16
|
-
}),
|
|
17
|
-
{ name: 'ProductListPrice' },
|
|
18
|
-
)
|
|
6
|
+
const { classes, selectors } = extendableComponent('ProductListPrice', [
|
|
7
|
+
'root',
|
|
8
|
+
'discountPrice',
|
|
9
|
+
] as const)
|
|
19
10
|
|
|
20
|
-
type ProductListPriceProps = ProductListPriceFragment &
|
|
11
|
+
type ProductListPriceProps = ProductListPriceFragment & Pick<TypographyProps, 'sx'>
|
|
21
12
|
|
|
22
13
|
export default function ProductListPrice(props: ProductListPriceProps) {
|
|
23
|
-
const { regular_price, final_price } = props
|
|
24
|
-
const classes = useStyles(props)
|
|
14
|
+
const { regular_price, final_price, sx } = props
|
|
25
15
|
|
|
26
16
|
return (
|
|
27
|
-
<Typography component='div' variant='body1' className={classes.root}>
|
|
17
|
+
<Typography component='div' variant='body1' className={classes.root} sx={sx}>
|
|
28
18
|
{regular_price.value !== final_price.value && (
|
|
29
|
-
<
|
|
19
|
+
<Box
|
|
20
|
+
component='span'
|
|
21
|
+
sx={{
|
|
22
|
+
textDecoration: 'line-through',
|
|
23
|
+
color: 'text.disabled',
|
|
24
|
+
marginRight: '8px',
|
|
25
|
+
}}
|
|
26
|
+
className={classes.discountPrice}
|
|
27
|
+
>
|
|
30
28
|
<Money {...regular_price} />
|
|
31
|
-
</
|
|
29
|
+
</Box>
|
|
32
30
|
)}
|
|
33
31
|
<Money {...final_price} />
|
|
34
32
|
</Typography>
|
|
35
33
|
)
|
|
36
34
|
}
|
|
35
|
+
|
|
36
|
+
ProductListPrice.selectors = selectors
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { useQuery } from '@
|
|
2
|
-
import { cloneDeep } from '@apollo/client/utilities'
|
|
1
|
+
import { useQuery, cloneDeep } from '@graphcommerce/graphql'
|
|
3
2
|
import { StoreConfigDocument } from '@graphcommerce/magento-store'
|
|
4
3
|
import { ChipMenu, ChipMenuProps } from '@graphcommerce/next-ui'
|
|
5
|
-
import { ListItem, ListItemText } from '@material
|
|
4
|
+
import { ListItem, ListItemText } from '@mui/material'
|
|
6
5
|
import React from 'react'
|
|
7
6
|
import { useProductListLinkReplace } from '../../hooks/useProductListLinkReplace'
|
|
8
7
|
import { useProductListParamsContext } from '../../hooks/useProductListParamsContext'
|
|
@@ -53,17 +52,20 @@ export default function ProductListSort(props: ProductListSortProps) {
|
|
|
53
52
|
key={option?.value ?? ''}
|
|
54
53
|
dense
|
|
55
54
|
selected={option?.value === currentSort}
|
|
56
|
-
component={React.memo(
|
|
57
|
-
<
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
component={React.memo(
|
|
56
|
+
React.forwardRef<HTMLAnchorElement>((chipProps, ref) => (
|
|
57
|
+
<ProductListLink
|
|
58
|
+
{...chipProps}
|
|
59
|
+
{...linkParams}
|
|
60
|
+
ref={ref}
|
|
61
|
+
color='inherit'
|
|
62
|
+
underline='none'
|
|
63
|
+
link={{ scroll: false, replace: true }}
|
|
64
|
+
/>
|
|
65
|
+
)),
|
|
66
|
+
)}
|
|
65
67
|
>
|
|
66
|
-
<ListItemText
|
|
68
|
+
<ListItemText>{option?.label}</ListItemText>
|
|
67
69
|
</ListItem>
|
|
68
70
|
)
|
|
69
71
|
})}
|
|
@@ -1,47 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
ColumnTwoWithTop,
|
|
3
|
+
ColumnTwoWithTopProps,
|
|
4
|
+
extendableComponent,
|
|
5
|
+
} from '@graphcommerce/next-ui'
|
|
6
|
+
import { Box, SxProps, Theme, Typography } from '@mui/material'
|
|
4
7
|
import { ProductPageDescriptionFragment } from './ProductPageDescription.gql'
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
description: {
|
|
9
|
-
'& p:first-of-type': {
|
|
10
|
-
marginTop: 0,
|
|
11
|
-
},
|
|
12
|
-
'& p, & li': {
|
|
13
|
-
...theme.typography.body1,
|
|
14
|
-
fontWeight: 400,
|
|
9
|
+
export type ProductPageDescriptionProps = ProductPageDescriptionFragment &
|
|
10
|
+
Omit<ColumnTwoWithTopProps, 'top' | 'left'> & { sx?: SxProps<Theme> }
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
...theme.typography.h3,
|
|
18
|
-
fontWeight: 400,
|
|
19
|
-
'@supports (font-variation-settings: normal)': {
|
|
20
|
-
fontVariationSettings: "'wght' 420",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
'& ul': {
|
|
25
|
-
padding: 0,
|
|
26
|
-
margin: 0,
|
|
27
|
-
display: 'inline',
|
|
28
|
-
listStyleType: 'none',
|
|
29
|
-
},
|
|
30
|
-
'& li': {
|
|
31
|
-
display: 'inline',
|
|
32
|
-
},
|
|
33
|
-
},
|
|
34
|
-
}))
|
|
35
|
-
|
|
36
|
-
export type ProductPageDescriptionProps = UseStyles<typeof useStyles> & ProductPageDescriptionFragment &
|
|
37
|
-
Omit<ColumnTwoWithTopProps, 'top' | 'left'>
|
|
12
|
+
const { classes } = extendableComponent('ProductPageDescription', ['root', 'description'] as const)
|
|
38
13
|
|
|
39
14
|
export default function ProductPageDescription(props: ProductPageDescriptionProps) {
|
|
40
|
-
const
|
|
41
|
-
const { description, name, right } = props
|
|
15
|
+
const { description, name, right, sx = [] } = props
|
|
42
16
|
|
|
43
17
|
return (
|
|
44
18
|
<ColumnTwoWithTop
|
|
19
|
+
className={classes.root}
|
|
20
|
+
sx={sx}
|
|
45
21
|
top={
|
|
46
22
|
<Typography variant='h1' component='h2'>
|
|
47
23
|
{name}
|
|
@@ -49,10 +25,35 @@ export default function ProductPageDescription(props: ProductPageDescriptionProp
|
|
|
49
25
|
}
|
|
50
26
|
left={
|
|
51
27
|
description && (
|
|
52
|
-
<
|
|
28
|
+
<Box
|
|
53
29
|
className={classes.description}
|
|
54
30
|
// eslint-disable-next-line react/no-danger
|
|
55
31
|
dangerouslySetInnerHTML={{ __html: description.html }}
|
|
32
|
+
sx={(theme) => ({
|
|
33
|
+
'& p:first-of-type': {
|
|
34
|
+
marginTop: 0,
|
|
35
|
+
},
|
|
36
|
+
'& p, & li': {
|
|
37
|
+
typography: 'body1',
|
|
38
|
+
fontWeight: 400,
|
|
39
|
+
[theme.breakpoints.up('md')]: {
|
|
40
|
+
typography: 'h3',
|
|
41
|
+
fontWeight: 400,
|
|
42
|
+
'@supports (font-variation-settings: normal)': {
|
|
43
|
+
fontVariationSettings: "'wght' 420",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
'& ul': {
|
|
48
|
+
padding: 0,
|
|
49
|
+
margin: 0,
|
|
50
|
+
display: 'inline',
|
|
51
|
+
listStyleType: 'none',
|
|
52
|
+
},
|
|
53
|
+
'& li': {
|
|
54
|
+
display: 'inline',
|
|
55
|
+
},
|
|
56
|
+
})}
|
|
56
57
|
/>
|
|
57
58
|
)
|
|
58
59
|
}
|
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import React from 'react'
|
|
1
|
+
import { extendableComponent } from '@graphcommerce/next-ui'
|
|
2
|
+
import { SxProps, Theme, Typography } from '@mui/material'
|
|
4
3
|
import { ProductShortDescriptionFragment } from './ProductShortDescription.gql'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
root: {
|
|
9
|
-
'& > p': {
|
|
10
|
-
marginTop: 0,
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
{ name: 'ProductShortDescription' },
|
|
15
|
-
)
|
|
5
|
+
type ProductShortDescriptionProps = ProductShortDescriptionFragment & { sx?: SxProps<Theme> }
|
|
16
6
|
|
|
17
|
-
|
|
7
|
+
const { classes } = extendableComponent('ProductShortDescription', ['description'] as const)
|
|
18
8
|
|
|
19
9
|
export default function ProductShortDescription(props: ProductShortDescriptionProps) {
|
|
20
|
-
const { short_description } = props
|
|
21
|
-
const classes = useStyles(props)
|
|
10
|
+
const { short_description, sx = [] } = props
|
|
22
11
|
|
|
23
12
|
return (
|
|
24
13
|
<Typography
|
|
25
14
|
variant='body1'
|
|
26
15
|
component='div'
|
|
27
|
-
|
|
16
|
+
className={classes.description}
|
|
28
17
|
dangerouslySetInnerHTML={{ __html: short_description?.html ?? '' }}
|
|
18
|
+
sx={[{ '& > p': { marginTop: 0 } }, ...(Array.isArray(sx) ? sx : [sx])]}
|
|
29
19
|
/>
|
|
30
20
|
)
|
|
31
21
|
}
|
|
@@ -1,54 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import {
|
|
2
|
+
responsiveVal,
|
|
3
|
+
iconOrderBefore,
|
|
4
|
+
SvgIcon,
|
|
5
|
+
extendableComponent,
|
|
6
|
+
} from '@graphcommerce/next-ui'
|
|
7
|
+
import { Box, darken, lighten, Typography } from '@mui/material'
|
|
4
8
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
root: {
|
|
8
|
-
display: 'grid',
|
|
9
|
-
alignItems: 'center',
|
|
10
|
-
gridTemplate: `
|
|
11
|
-
"image title"
|
|
12
|
-
". subtitle"
|
|
13
|
-
`,
|
|
14
|
-
gridTemplateColumns: `min-content auto`,
|
|
15
|
-
columnGap: theme.spacings.xxs,
|
|
16
|
-
marginTop: theme.spacings.xxs,
|
|
17
|
-
background:
|
|
18
|
-
theme.palette.type === 'light'
|
|
19
|
-
? darken(theme.palette.background.default, 0.01)
|
|
20
|
-
: lighten(theme.palette.background.default, 0.2),
|
|
21
|
-
padding: theme.spacings.xxs,
|
|
22
|
-
borderRadius: responsiveVal(theme.shape.borderRadius * 3, theme.shape.borderRadius * 4),
|
|
23
|
-
},
|
|
24
|
-
text: {},
|
|
25
|
-
image: {
|
|
26
|
-
gridArea: 'image',
|
|
27
|
-
},
|
|
28
|
-
title: {
|
|
29
|
-
gridArea: 'title',
|
|
30
|
-
fontWeight: 600,
|
|
31
|
-
},
|
|
32
|
-
subtitle: {
|
|
33
|
-
gridArea: 'subtitle',
|
|
34
|
-
color: theme.palette.text.primary,
|
|
35
|
-
},
|
|
36
|
-
}),
|
|
37
|
-
{ name: 'ProductSidebarDelivery' },
|
|
38
|
-
)
|
|
9
|
+
const parts = ['root', 'text', 'image', 'title', 'subtitle'] as const
|
|
10
|
+
const { classes } = extendableComponent('ProductSidebarDelivery', parts)
|
|
39
11
|
|
|
40
12
|
export default function ProductSidebarDelivery() {
|
|
41
|
-
const classes = useStyles()
|
|
42
|
-
|
|
43
13
|
return (
|
|
44
|
-
<
|
|
45
|
-
|
|
46
|
-
|
|
14
|
+
<Box
|
|
15
|
+
className={classes.root}
|
|
16
|
+
sx={(theme) => ({
|
|
17
|
+
display: 'grid',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
gridTemplate: `
|
|
20
|
+
"image title"
|
|
21
|
+
". subtitle"
|
|
22
|
+
`,
|
|
23
|
+
gridTemplateColumns: `min-content auto`,
|
|
24
|
+
columnGap: theme.spacings.xxs,
|
|
25
|
+
marginTop: theme.spacings.xxs,
|
|
26
|
+
background:
|
|
27
|
+
theme.palette.mode === 'light'
|
|
28
|
+
? darken(theme.palette.background.default, 0.01)
|
|
29
|
+
: lighten(theme.palette.background.default, 0.2),
|
|
30
|
+
padding: theme.spacings.xxs,
|
|
31
|
+
borderRadius: responsiveVal(theme.shape.borderRadius * 3, theme.shape.borderRadius * 4),
|
|
32
|
+
})}
|
|
33
|
+
>
|
|
34
|
+
<SvgIcon
|
|
35
|
+
className={classes.image}
|
|
36
|
+
src={iconOrderBefore}
|
|
37
|
+
size='small'
|
|
38
|
+
sx={{ gridArea: 'image' }}
|
|
39
|
+
/>
|
|
40
|
+
<Typography
|
|
41
|
+
className={classes.title}
|
|
42
|
+
variant='body2'
|
|
43
|
+
component='div'
|
|
44
|
+
sx={{ gridArea: 'title', fontWeight: 600 }}
|
|
45
|
+
>
|
|
47
46
|
Order before 22:00
|
|
48
47
|
</Typography>
|
|
49
|
-
<Typography
|
|
48
|
+
<Typography
|
|
49
|
+
className={classes.subtitle}
|
|
50
|
+
variant='body2'
|
|
51
|
+
component='div'
|
|
52
|
+
sx={(theme) => ({ gridArea: 'subtitle', color: theme.palette.text.primary })}
|
|
53
|
+
>
|
|
50
54
|
Next day delivery - Shipping free
|
|
51
55
|
</Typography>
|
|
52
|
-
</
|
|
56
|
+
</Box>
|
|
53
57
|
)
|
|
54
58
|
}
|
|
@@ -1,67 +1,58 @@
|
|
|
1
|
-
import { responsiveVal, Row, SectionContainer,
|
|
2
|
-
import {
|
|
3
|
-
import React from 'react'
|
|
1
|
+
import { responsiveVal, Row, SectionContainer, extendableComponent } from '@graphcommerce/next-ui'
|
|
2
|
+
import { Box, SxProps, Theme } from '@mui/material'
|
|
4
3
|
import { ProductSpecsFragment } from './ProductSpecs.gql'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
root: {
|
|
8
|
-
...theme.typography.subtitle1,
|
|
9
|
-
},
|
|
10
|
-
sectionHeaderWrapper: {
|
|
11
|
-
marginBottom: theme.spacings.md,
|
|
12
|
-
},
|
|
13
|
-
specs: {
|
|
14
|
-
display: 'grid',
|
|
15
|
-
justifyContent: 'start',
|
|
16
|
-
margin: 0,
|
|
17
|
-
padding: 0,
|
|
18
|
-
gap: theme.spacings.xs,
|
|
19
|
-
'& > *': {
|
|
20
|
-
display: 'grid',
|
|
21
|
-
gridTemplateColumns: `minmax(${responsiveVal(150, 200)}, 1fr) 1fr`,
|
|
22
|
-
gap: theme.spacings.xs,
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
options: {
|
|
26
|
-
display: 'grid',
|
|
27
|
-
gridAutoFlow: 'row',
|
|
28
|
-
},
|
|
29
|
-
}))
|
|
5
|
+
export type ProductSpecsProps = ProductSpecsFragment & { title?: string; sx?: SxProps<Theme> }
|
|
30
6
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
7
|
+
const name = 'ProductSpecs' as const
|
|
8
|
+
const parts = ['root', 'specs', 'options'] as const
|
|
9
|
+
const { classes } = extendableComponent(name, parts)
|
|
34
10
|
|
|
35
11
|
export default function ProductSpecs(props: ProductSpecsProps) {
|
|
36
|
-
const { aggregations, title } = props
|
|
37
|
-
const classes = useStyles(props)
|
|
12
|
+
const { aggregations, title, sx = [] } = props
|
|
38
13
|
const filter = ['price', 'category_id', 'size', 'new', 'sale', 'color']
|
|
39
14
|
const specs = aggregations?.filter(
|
|
40
15
|
(attr) => !filter.includes(attr?.attribute_code ?? '') && attr?.options?.[0]?.value !== '0',
|
|
41
16
|
)
|
|
42
17
|
|
|
43
|
-
if (specs?.length === 0)
|
|
44
|
-
return null
|
|
45
|
-
}
|
|
18
|
+
if (specs?.length === 0) return null
|
|
46
19
|
|
|
47
20
|
return (
|
|
48
|
-
<Row
|
|
21
|
+
<Row
|
|
22
|
+
className={classes.root}
|
|
23
|
+
sx={[{ typographt: 'subtitle1' }, ...(Array.isArray(sx) ? sx : [sx])]}
|
|
24
|
+
>
|
|
49
25
|
<SectionContainer
|
|
50
26
|
labelLeft={title}
|
|
51
|
-
|
|
27
|
+
sx={(theme) => ({ '& .SectionHeader': { marginBottom: theme.spacings.md } })}
|
|
52
28
|
>
|
|
53
|
-
<
|
|
29
|
+
<Box
|
|
30
|
+
component='ul'
|
|
31
|
+
className={classes.specs}
|
|
32
|
+
sx={(theme) => ({
|
|
33
|
+
display: 'grid',
|
|
34
|
+
justifyContent: 'start',
|
|
35
|
+
margin: 0,
|
|
36
|
+
padding: 0,
|
|
37
|
+
gap: theme.spacings.xs,
|
|
38
|
+
'& > *': {
|
|
39
|
+
display: 'grid',
|
|
40
|
+
gridTemplateColumns: `minmax(${responsiveVal(150, 200)}, 1fr) 1fr`,
|
|
41
|
+
gap: theme.spacings.xs,
|
|
42
|
+
},
|
|
43
|
+
})}
|
|
44
|
+
>
|
|
54
45
|
{specs?.map((aggregation) => (
|
|
55
46
|
<li key={aggregation?.attribute_code}>
|
|
56
47
|
<div>{aggregation?.label}</div>
|
|
57
|
-
<
|
|
48
|
+
<Box className={classes.options} sx={{ display: 'grid', gridAutoFlow: 'row' }}>
|
|
58
49
|
{aggregation?.options?.map((option) => (
|
|
59
50
|
<span key={option?.label}>{option?.label === '1' ? 'Yes' : option?.label}</span>
|
|
60
51
|
))}
|
|
61
|
-
</
|
|
52
|
+
</Box>
|
|
62
53
|
</li>
|
|
63
54
|
))}
|
|
64
|
-
</
|
|
55
|
+
</Box>
|
|
65
56
|
</SectionContainer>
|
|
66
57
|
</Row>
|
|
67
58
|
)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApolloClient, ApolloQueryResult, NormalizedCacheObject } from '@
|
|
1
|
+
import { ApolloClient, ApolloQueryResult, NormalizedCacheObject } from '@graphcommerce/graphql'
|
|
2
2
|
import { GetStaticPathsResult } from 'next'
|
|
3
3
|
import { ProductStaticPathsDocument, ProductStaticPathsQuery } from './ProductStaticPaths.gql'
|
|
4
4
|
|
package/components/index.ts
CHANGED
|
@@ -1,50 +1,40 @@
|
|
|
1
1
|
export * from './JsonLdProduct'
|
|
2
|
-
|
|
3
2
|
export * from './ProductAddToCart/ProductAddToCart'
|
|
4
3
|
export { default as ProductAddToCart } from './ProductAddToCart/ProductAddToCart'
|
|
5
|
-
|
|
6
4
|
export * from './ProductList/ProductList.gql'
|
|
7
|
-
|
|
8
|
-
export
|
|
5
|
+
export * from './ProductListCount/ProductListCount'
|
|
6
|
+
export * from './ProductListFilters/ProductListFilters'
|
|
7
|
+
export { default as ProductListFilters } from './ProductListFilters/ProductListFilters'
|
|
8
|
+
export * from './ProductListFiltersContainer'
|
|
9
|
+
export { default as ProductListFiltersContainer } from './ProductListFiltersContainer'
|
|
9
10
|
export * from './ProductListItem'
|
|
10
|
-
|
|
11
|
+
export { default as ProductListItem } from './ProductListItem'
|
|
11
12
|
export { default as ProductListItems } from './ProductListItems'
|
|
12
13
|
export * from './ProductListItems/filteredProductList'
|
|
13
14
|
export * from './ProductListItems/filterTypes'
|
|
14
|
-
export { default as ProductListItemsBase } from './ProductListItems/ProductListItemsBase'
|
|
15
|
-
export * from './ProductListItems/ProductListItemsBase'
|
|
16
15
|
export * from './ProductListItems/getFilterTypes'
|
|
17
|
-
export * from './ProductListItems/renderer'
|
|
18
16
|
export * from './ProductListItems/ProductListItems.gql'
|
|
17
|
+
export * from './ProductListItems/ProductListItemsBase'
|
|
18
|
+
export { default as ProductListItemsBase } from './ProductListItems/ProductListItemsBase'
|
|
19
19
|
export { default as ProductListParamsProvider } from './ProductListItems/ProductListParamsProvider'
|
|
20
|
+
export * from './ProductListItems/renderer'
|
|
20
21
|
export * from './ProductListLink/ProductListLink'
|
|
21
22
|
export { default as ProductListLink } from './ProductListLink/ProductListLink'
|
|
22
|
-
|
|
23
|
-
export * from './ProductListCount'
|
|
24
|
-
export { default as ProductListCount } from './ProductListCount'
|
|
25
|
-
export { default as ProductSidebarDelivery } from './ProductSidebarDelivery'
|
|
26
|
-
export * from './ProductListFilters'
|
|
27
|
-
export { default as ProductListFilters } from './ProductListFilters'
|
|
28
|
-
export * from './ProductListFiltersContainer'
|
|
29
|
-
export { default as ProductListFiltersContainer } from './ProductListFiltersContainer'
|
|
30
|
-
|
|
31
|
-
export * from './ProductRelated/RelatedProducts.gql'
|
|
32
|
-
|
|
33
23
|
export * from './ProductListPagination'
|
|
34
24
|
export { default as ProductListPagination } from './ProductListPagination'
|
|
35
25
|
export * from './ProductListSort'
|
|
36
26
|
export { default as ProductListSort } from './ProductListSort'
|
|
27
|
+
export { default as productPageCategory } from './ProductPageCategory'
|
|
37
28
|
export * from './ProductPageDescription'
|
|
38
29
|
export { default as ProductPageDescription } from './ProductPageDescription'
|
|
39
|
-
export * from './ProductSpecs'
|
|
40
|
-
export { default as ProductSpecs } from './ProductSpecs'
|
|
41
|
-
export { default as productPageCategory } from './ProductPageCategory'
|
|
42
30
|
export { default as ProductPageGallery } from './ProductPageGallery'
|
|
43
31
|
export { default as ProductPageMeta } from './ProductPageMeta'
|
|
44
|
-
export
|
|
45
|
-
export { default as ProductWeight } from './ProductWeight'
|
|
46
|
-
|
|
32
|
+
export * from './ProductRelated/RelatedProducts.gql'
|
|
47
33
|
export { default as ProductShortDescription } from './ProductShortDescription'
|
|
48
34
|
export * from './ProductShortDescription/ProductShortDescription.gql'
|
|
49
|
-
|
|
35
|
+
export { default as ProductSidebarDelivery } from './ProductSidebarDelivery'
|
|
36
|
+
export * from './ProductSpecs'
|
|
37
|
+
export { default as ProductSpecs } from './ProductSpecs'
|
|
38
|
+
export { getProductStaticPaths } from './ProductStaticPaths/getProductStaticPaths'
|
|
50
39
|
export * from './ProductUpsells/UpsellProducts.gql'
|
|
40
|
+
export { default as ProductWeight } from './ProductWeight'
|