@graphcommerce/magento-compare 6.2.0-canary.9
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 +3 -0
- package/Config.graphqls +17 -0
- package/components/CompareFab.tsx +100 -0
- package/components/CompareListAttributes.tsx +45 -0
- package/components/CompareListForm.tsx +83 -0
- package/components/CompareListIntroText.tsx +21 -0
- package/components/CompareListItems.tsx +28 -0
- package/components/CompareListRow.tsx +62 -0
- package/components/CompareListRowMoreInformation.tsx +58 -0
- package/components/CompareListSelect.tsx +77 -0
- package/components/CompareMessageSnackbar.tsx +59 -0
- package/components/CompareProductButton.tsx +59 -0
- package/components/CompareProductToggle.tsx +155 -0
- package/components/EmptyCompareList.tsx +19 -0
- package/components/EmptyCompareListButton.tsx +58 -0
- package/components/index.ts +13 -0
- package/graphql/AddProductsToCompareList.graphql +5 -0
- package/graphql/AssignCustomerToCompareList.graphql +5 -0
- package/graphql/ComparableItem.graphql +11 -0
- package/graphql/CompareList.graphql +5 -0
- package/graphql/CompareListFragment.graphql +12 -0
- package/graphql/CompareProductIdInternal.graphql +6 -0
- package/graphql/CompareSummary.graphql +5 -0
- package/graphql/CompareSummaryFragment.graphql +7 -0
- package/graphql/CreateCompareList.graphql +5 -0
- package/graphql/CurrentCompareUid.graphql +6 -0
- package/graphql/CurrentCompareUid.graphqls +7 -0
- package/graphql/CustomerCompareList.graphql +7 -0
- package/graphql/DeleteCompareList.graphql +5 -0
- package/graphql/RemoveProductsFromCompareList.graphql +5 -0
- package/graphql/index.ts +12 -0
- package/hooks/index.ts +6 -0
- package/hooks/useAssignCurrentCompareListUid.ts +16 -0
- package/hooks/useClearCurrentCompareListUid.ts +15 -0
- package/hooks/useCompareList.ts +10 -0
- package/hooks/useCompareListStyles.ts +21 -0
- package/hooks/useCompareListUidCreate.ts +27 -0
- package/hooks/useCompareSummary.ts +13 -0
- package/index.ts +3 -0
- package/next-env.d.ts +4 -0
- package/package.json +38 -0
- package/plugins/AddCompareFabNextToCart.tsx +19 -0
- package/plugins/AddCompareToProductPage.tsx +36 -0
- package/plugins/AddCompareTypePolicies.tsx +25 -0
- package/plugins/CompareAbleProductListItem.tsx +41 -0
- package/tsconfig.json +5 -0
- package/typePolicies.ts +12 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ProductListItemProps } from '@graphcommerce/magento-product'
|
|
2
|
+
import type { IfConfig, PluginProps } from '@graphcommerce/next-config'
|
|
3
|
+
import { Box } from '@mui/material'
|
|
4
|
+
import { CompareProductToggle } from '../components'
|
|
5
|
+
|
|
6
|
+
export const component = 'ProductListItem' // Component to extend, required
|
|
7
|
+
export const exported = '@graphcommerce/magento-product' // Location where the component is exported, required
|
|
8
|
+
export const ifConfig: IfConfig = 'compare'
|
|
9
|
+
|
|
10
|
+
function CompareAbleProductListItem(props: PluginProps<ProductListItemProps>) {
|
|
11
|
+
const { Prev, ...rest } = props
|
|
12
|
+
const { children, topRight } = props
|
|
13
|
+
if (import.meta.graphCommerce.compareVariant === 'CHECKBOX')
|
|
14
|
+
return (
|
|
15
|
+
<Prev topRight={topRight} {...rest}>
|
|
16
|
+
<Box sx={{ display: 'flex', justifyContent: 'flex-end' }}>
|
|
17
|
+
<CompareProductToggle {...rest} product={props} />
|
|
18
|
+
</Box>
|
|
19
|
+
{children}
|
|
20
|
+
</Prev>
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
if (
|
|
24
|
+
import.meta.graphCommerce.compareVariant === 'ICON' ||
|
|
25
|
+
!import.meta.graphCommerce.compareVariant
|
|
26
|
+
)
|
|
27
|
+
return (
|
|
28
|
+
<Prev
|
|
29
|
+
{...rest}
|
|
30
|
+
topRight={
|
|
31
|
+
<>
|
|
32
|
+
{topRight}
|
|
33
|
+
<CompareProductToggle {...rest} product={props} />
|
|
34
|
+
</>
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
{children}
|
|
38
|
+
</Prev>
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
export const Plugin = CompareAbleProductListItem
|
package/tsconfig.json
ADDED
package/typePolicies.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { StrictTypedTypePolicies } from '@graphcommerce/graphql'
|
|
2
|
+
import type { QuerycompareListArgs } from '@graphcommerce/graphql-mesh'
|
|
3
|
+
|
|
4
|
+
export const compareTypePolicies: StrictTypedTypePolicies = {
|
|
5
|
+
Query: {
|
|
6
|
+
fields: {
|
|
7
|
+
// currentCartId: (_, { toReference }) => toReference({ __typename: 'CurrentCartId' }),
|
|
8
|
+
compareList: (_, { args, toReference }) =>
|
|
9
|
+
toReference({ __typename: 'CompareList', uid: (args as QuerycompareListArgs)?.uid }),
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
}
|