@riosst100/pwa-marketplace 1.6.1 → 1.6.3
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/package.json +3 -2
- package/src/components/AlphaFilter/alphaFilter.js +36 -8
- package/src/components/AlphaFilter/alphaFilter.shimmer.js +50 -0
- package/src/components/ArraySearchInput/arraySearchInput.js +100 -0
- package/src/components/ArraySearchInput/arraySearchInput.module.css +48 -0
- package/src/components/ArraySearchInput/index.js +1 -0
- package/src/components/CollectibleGameSets/collectibleGameSets.js +53 -25
- package/src/components/CollectibleGameSets/collectibleGameSets.module.css +8 -0
- package/src/components/CrossSeller/crossSellerBuy.js +19 -0
- package/src/components/CrossSeller/index.js +15 -0
- package/src/components/CrossSeller/item.js +79 -0
- package/src/components/CrossSeller/logo_seller.png +0 -0
- package/src/components/CrossSeller/starIcon.js +14 -0
- package/src/components/CrossSeller/verifyIcon.js +12 -0
- package/src/components/CustomSortBy/customSortBy.js +9 -11
- package/src/components/CustomSortBy/productSort.module.css +65 -0
- package/src/components/CustomSortBy/productSort.shimmer.js +28 -0
- package/src/components/CustomSortBy/productSort.shimmer.module.css +10 -0
- package/src/components/CustomSubCategory/subCategory.js +49 -0
- package/src/components/CustomSubCategory/subCategory.module.css +22 -0
- package/src/components/FilterTop/CurrentTopFilters/currentTopFilter.js +47 -0
- package/src/components/FilterTop/CurrentTopFilters/currentTopFilter.module.css +22 -0
- package/src/components/FilterTop/CurrentTopFilters/currentTopFilters.js +50 -0
- package/src/components/FilterTop/CurrentTopFilters/currentTopFilters.module.css +21 -0
- package/src/components/FilterTop/CurrentTopFilters/index.js +1 -0
- package/src/components/FilterTop/CustomFilters/customFilters.js +68 -30
- package/src/components/FilterTop/FilterBlockList/filterBlockList.js +50 -0
- package/src/components/FilterTop/FilterBlockList/filterBlockList.module.css +8 -0
- package/src/components/FilterTop/FilterBlockList/filterTopItem.js +40 -0
- package/src/components/FilterTop/FilterBlockList/filterTopItem.module.css +14 -0
- package/src/components/FilterTop/FilterBlockList/filterTopItemGroup.js +91 -0
- package/src/components/FilterTop/FilterBlockList/filterTopItemGroup.module.css +23 -0
- package/src/components/FilterTop/FilterBlockList/index.js +1 -0
- package/src/components/FilterTop/filterTop.js +131 -13
- package/src/components/FilterTop/filterTop.module.css +23 -58
- package/src/components/FilterTop/filterTop.shimmer.js +24 -24
- package/src/components/FilterTop/filterTopBlock.js +54 -0
- package/src/components/FilterTop/index.js +2 -2
- package/src/components/FilterTopBackup/CustomFilters/customFilter.js +83 -0
- package/src/components/FilterTopBackup/CustomFilters/customFilter.module.css +22 -0
- package/src/components/FilterTopBackup/CustomFilters/customFilters.js +132 -0
- package/src/components/FilterTopBackup/CustomFilters/customFilters.module.css +23 -0
- package/src/components/FilterTopBackup/CustomFilters/index.js +1 -0
- package/src/components/FilterTopBackup/filterTop.js +14 -0
- package/src/components/FilterTopBackup/filterTop.module.css +23 -0
- package/src/components/FilterTopBackup/filterTop.shimmer.js +24 -0
- package/src/components/FilterTopBackup/index.js +2 -0
- package/src/components/RelatedProduct/index.js +16 -0
- package/src/components/RelatedProduct/relatedProduct.js +112 -0
- package/src/components/RelatedProduct/sample.json +154 -0
- package/src/components/ShopBy/index.js +2 -0
- package/src/components/ShopBy/shopBy.js +237 -0
- package/src/components/ShopBy/shopBy.module.css +46 -0
- package/src/components/ShopBy/shopBy.shimmer.js +50 -0
- package/src/components/ShopByPage/index.js +1 -0
- package/src/components/ShopByPage/shopByPage.js +12 -0
- package/src/hooks/useCustomSort.js +21 -0
- package/src/intercept.js +1 -8
- package/src/overwrites/peregrine/lib/talons/FilterSidebar/useFilterSidebar.js +2 -2
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js +1 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryFragments.gql.js +31 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/noProductsFound.js +0 -13
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +13 -2
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +31 -6
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +3 -2
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +5 -5
- package/src/overwrites/venia-ui/lib/components/Gallery/gallery.js +3 -3
- package/src/overwrites/venia-ui/lib/components/Gallery/item.js +3 -1
- package/src/overwrites/venia-ui/lib/components/Newsletter/newsletter.js +2 -2
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/customAttributes.js +1 -1
- package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +13 -1
- package/src/overwrites/venia-ui/lib/components/QuantityStepper/quantityStepper.js +2 -2
- package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +1 -1
- package/src/talons/ArraySearchInput/useArraySearchInput.js +58 -0
- package/src/talons/CollectibleGameSets/useCollectibleGameSets.js +75 -2
- package/src/talons/CustomFilters/useCustomFilters.js +163 -5
- package/src/talons/FilterTop/customFilters.gql.js +45 -0
- package/src/talons/FilterTop/filterTop.gql.js +45 -0
- package/src/talons/FilterTop/index.js +1 -0
- package/src/talons/FilterTop/useFilterTop.js +330 -0
- package/src/talons/ShopBy/shopBy.gql.js +47 -0
- package/src/talons/ShopBy/useShopBy.js +171 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import React, { useMemo, useEffect } from 'react';
|
|
2
|
+
import FilterTopItem from './filterTopItem';
|
|
3
|
+
import { useFieldApi } from 'informed';
|
|
4
|
+
import useFieldState from '@magento/peregrine/lib/hooks/hook-wrappers/useInformedFieldStateWrapper';
|
|
5
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
|
+
import defaultClasses from './filterTopItemGroup.module.css';
|
|
7
|
+
import CurrentTopFilter from '@riosst100/pwa-marketplace/src/components/FilterTop/CurrentTopFilters/currentTopFilter';
|
|
8
|
+
|
|
9
|
+
const FilterTopItemGroup = props => {
|
|
10
|
+
const { filterApi, filterState, group, items, onApply, labels, filterNames, originalFilterState } = props;
|
|
11
|
+
|
|
12
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
13
|
+
|
|
14
|
+
const currentGroup = group;
|
|
15
|
+
const { removeItem } = filterApi;
|
|
16
|
+
const activeFilters = [];
|
|
17
|
+
|
|
18
|
+
// Current Filters
|
|
19
|
+
const filterElements = useMemo(() => {
|
|
20
|
+
const elements = [];
|
|
21
|
+
for (const [group, items] of originalFilterState) {
|
|
22
|
+
for (const item of items) {
|
|
23
|
+
const { title, value } = item || {};
|
|
24
|
+
const key = `${group}::${title}_${value}`;
|
|
25
|
+
|
|
26
|
+
if (group === currentGroup) {
|
|
27
|
+
activeFilters.push(item.value)
|
|
28
|
+
elements.push(
|
|
29
|
+
<CurrentTopFilter
|
|
30
|
+
group={group}
|
|
31
|
+
item={item}
|
|
32
|
+
removeItem={removeItem}
|
|
33
|
+
onRemove={onApply}
|
|
34
|
+
/>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return elements;
|
|
41
|
+
}, [originalFilterState, removeItem, onApply]);
|
|
42
|
+
|
|
43
|
+
const radioItems = useMemo(() => {
|
|
44
|
+
return items.map(item => {
|
|
45
|
+
const code = `item-${group}-${item.value}`;
|
|
46
|
+
return (
|
|
47
|
+
<FilterTopItem
|
|
48
|
+
key={code}
|
|
49
|
+
filterApi={filterApi}
|
|
50
|
+
filterState={filterState}
|
|
51
|
+
group={group}
|
|
52
|
+
activeFilters={activeFilters}
|
|
53
|
+
item={item}
|
|
54
|
+
onApply={onApply}
|
|
55
|
+
labels={labels}
|
|
56
|
+
/>
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
}, [filterApi, filterState, group, items, labels, onApply]);
|
|
60
|
+
|
|
61
|
+
const fieldValue = useMemo(() => {
|
|
62
|
+
if (filterState) {
|
|
63
|
+
for (const item of items) {
|
|
64
|
+
if (filterState.has(item)) {
|
|
65
|
+
return item.value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return null;
|
|
71
|
+
}, [filterState, items]);
|
|
72
|
+
const field = `item-${group}`;
|
|
73
|
+
const fieldApi = useFieldApi(field);
|
|
74
|
+
const fieldState = useFieldState(field);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
if (field && fieldValue === null) {
|
|
77
|
+
fieldApi.reset();
|
|
78
|
+
} else if (field && fieldValue !== fieldState.value) {
|
|
79
|
+
fieldApi.setValue(fieldValue);
|
|
80
|
+
}
|
|
81
|
+
}, [field, fieldApi, fieldState.value, fieldValue]);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className={classes.root}>
|
|
85
|
+
{radioItems}
|
|
86
|
+
{filterElements && filterElements.length ? filterElements : <span className={classes.item}><b>All</b></span>}
|
|
87
|
+
</div>
|
|
88
|
+
);
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export default FilterTopItemGroup;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
composes: flex from global;
|
|
3
|
+
composes: flex-wrap from global;
|
|
4
|
+
composes: mt-3 from global;
|
|
5
|
+
composes: gap-[10px] from global;
|
|
6
|
+
margin-bottom: 10px;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.item {
|
|
11
|
+
composes: px-4 from global;
|
|
12
|
+
composes: py-2 from global;
|
|
13
|
+
composes: transition-colors from global;
|
|
14
|
+
composes: duration-150 from global;
|
|
15
|
+
composes: border from global;
|
|
16
|
+
composes: border-solid from global;
|
|
17
|
+
composes: leading-normal from global;
|
|
18
|
+
composes: text-base from global;
|
|
19
|
+
composes: text-colorDefault from global;
|
|
20
|
+
composes: bg-white from global;
|
|
21
|
+
composes: border-gray-100 from global;
|
|
22
|
+
border-radius: 5px;
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './filterBlockList';
|
|
@@ -1,13 +1,131 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import React, { useMemo, useCallback, useRef } from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { array, arrayOf, shape, string, number } from 'prop-types';
|
|
4
|
+
import { useFilterTop } from '@riosst100/pwa-marketplace/src/talons/FilterTop';
|
|
5
|
+
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import LinkButton from '@magento/venia-ui/lib/components/LinkButton';
|
|
8
|
+
import FilterTopBlock from './filterTopBlock';
|
|
9
|
+
import defaultClasses from './filterTop.module.css';
|
|
10
|
+
import { Filter } from 'iconsax-react';
|
|
11
|
+
import cn from 'classnames';
|
|
12
|
+
import { useHistory } from 'react-router-dom';
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
const SCROLL_OFFSET = 150;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A view that displays applicable and applied filters.
|
|
19
|
+
*
|
|
20
|
+
* @param {Object} props.filters - filters to display
|
|
21
|
+
*/
|
|
22
|
+
const FilterTop = props => {
|
|
23
|
+
const { filters, filterCountToOpen, allowedFilters } = props;
|
|
24
|
+
const talonProps = useFilterTop({ filters });
|
|
25
|
+
const {
|
|
26
|
+
filterApi,
|
|
27
|
+
filterItems,
|
|
28
|
+
filterNames,
|
|
29
|
+
filterFrontendInput,
|
|
30
|
+
filterState,
|
|
31
|
+
handleApply,
|
|
32
|
+
handleReset,
|
|
33
|
+
customFilters
|
|
34
|
+
} = talonProps;
|
|
35
|
+
|
|
36
|
+
const filterRef = useRef();
|
|
37
|
+
|
|
38
|
+
const handleApplyFilter = useCallback(
|
|
39
|
+
(...args) => {
|
|
40
|
+
const filterElement = filterRef.current;
|
|
41
|
+
if (
|
|
42
|
+
filterElement &&
|
|
43
|
+
typeof filterElement.getBoundingClientRect === 'function'
|
|
44
|
+
) {
|
|
45
|
+
const filterTop = filterElement.getBoundingClientRect().top;
|
|
46
|
+
const windowScrollY =
|
|
47
|
+
window.scrollY + filterTop - SCROLL_OFFSET;
|
|
48
|
+
window.scrollTo(0, windowScrollY);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
handleApply(...args);
|
|
52
|
+
},
|
|
53
|
+
[handleApply, filterRef]
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const history = useHistory();
|
|
57
|
+
|
|
58
|
+
const handleCategoryApplyFilter = useCallback(
|
|
59
|
+
(...args) => {
|
|
60
|
+
// const filterElement = filterRef.current;
|
|
61
|
+
// if (
|
|
62
|
+
// filterElement &&
|
|
63
|
+
// typeof filterElement.getBoundingClientRect === 'function'
|
|
64
|
+
// ) {
|
|
65
|
+
// const filterTop = filterElement.getBoundingClientRect().top;
|
|
66
|
+
// const windowScrollY =
|
|
67
|
+
// window.scrollY + filterTop - SCROLL_OFFSET;
|
|
68
|
+
// window.scrollTo(0, windowScrollY);
|
|
69
|
+
// }
|
|
70
|
+
|
|
71
|
+
history.push('/'+args[1].path+'.html');
|
|
72
|
+
|
|
73
|
+
if (args[0] != "category_uid") {
|
|
74
|
+
handleApply(...args);
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
[handleApply, filterRef]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// const allowedFiltersArr = [];
|
|
81
|
+
|
|
82
|
+
// allowedFilters.length && allowedFilters.map((val, index) => {
|
|
83
|
+
// allowedFiltersArr.push(val.code);
|
|
84
|
+
// });
|
|
85
|
+
// const allowedFiltersArr = ['card_rarity','card_print_version','card_set', 'card_product_type'];
|
|
86
|
+
|
|
87
|
+
// console.log(customFilters)
|
|
88
|
+
|
|
89
|
+
const filtersList = useMemo(
|
|
90
|
+
() =>
|
|
91
|
+
Array.from(filterItems, ([group, items], iteration) => {
|
|
92
|
+
const blockState = filterState.get(group);
|
|
93
|
+
const groupName = filterNames.get(group);
|
|
94
|
+
const frontendInput = filterFrontendInput.get(group);
|
|
95
|
+
if (customFilters && customFilters.length && customFilters.includes(group)) {
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<FilterTopBlock
|
|
99
|
+
key={group}
|
|
100
|
+
filterNames={filterNames}
|
|
101
|
+
filterApi={filterApi}
|
|
102
|
+
filterState={blockState}
|
|
103
|
+
originalFilterState={filterState}
|
|
104
|
+
filterFrontendInput={frontendInput}
|
|
105
|
+
group={group}
|
|
106
|
+
items={items}
|
|
107
|
+
name={groupName}
|
|
108
|
+
onApply={group == "category_uid" ? handleCategoryApplyFilter : handleApplyFilter}
|
|
109
|
+
initialOpen={iteration < filterCountToOpen}
|
|
110
|
+
/>
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
[
|
|
115
|
+
filterApi,
|
|
116
|
+
filterItems,
|
|
117
|
+
filterNames,
|
|
118
|
+
filterFrontendInput,
|
|
119
|
+
filterState,
|
|
120
|
+
filterCountToOpen,
|
|
121
|
+
customFilters,
|
|
122
|
+
handleApplyFilter
|
|
123
|
+
]
|
|
124
|
+
);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<div>{filtersList}</div>
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export default FilterTop;
|
|
@@ -1,58 +1,23 @@
|
|
|
1
|
-
.root {
|
|
2
|
-
composes:
|
|
3
|
-
composes:
|
|
4
|
-
composes:
|
|
5
|
-
composes:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
composes:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
composes:
|
|
19
|
-
composes:
|
|
20
|
-
composes:
|
|
21
|
-
composes:
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.headerTitle {
|
|
26
|
-
composes: flex from global;
|
|
27
|
-
composes: items-center from global;
|
|
28
|
-
composes: leading-none from global;
|
|
29
|
-
composes: text-lg from global;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
.action {
|
|
33
|
-
composes: pb-0 from global;
|
|
34
|
-
composes: pt-xs from global;
|
|
35
|
-
composes: px-xs from global;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/* TODO @TW: cannot compose */
|
|
39
|
-
.action button {
|
|
40
|
-
/* composes: text-sm from global; */
|
|
41
|
-
font-size: 0.875rem;
|
|
42
|
-
/* composes: no-underline from global; */
|
|
43
|
-
text-decoration: none;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
.blocks {
|
|
47
|
-
composes: pb-0 from global;
|
|
48
|
-
composes: pt-xs from global;
|
|
49
|
-
composes: px-xs from global;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/* TODO @TW: cannot compose */
|
|
53
|
-
.blocks > li:last-child {
|
|
54
|
-
/* composes: border-b-2 from global; */
|
|
55
|
-
/* composes: border-solid from global; */
|
|
56
|
-
/* composes: border-subtle from global; */
|
|
57
|
-
border-bottom: 2px solid rgb(var(--venia-global-color-border));
|
|
58
|
-
}
|
|
1
|
+
.root {
|
|
2
|
+
composes: flex from global;
|
|
3
|
+
composes: flex-wrap from global;
|
|
4
|
+
composes: mt-3 from global;
|
|
5
|
+
composes: gap-[15px] from global;
|
|
6
|
+
margin-bottom: 10px;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.item {
|
|
11
|
+
composes: px-4 from global;
|
|
12
|
+
composes: py-2 from global;
|
|
13
|
+
composes: transition-colors from global;
|
|
14
|
+
composes: duration-150 from global;
|
|
15
|
+
composes: border from global;
|
|
16
|
+
composes: border-solid from global;
|
|
17
|
+
composes: leading-normal from global;
|
|
18
|
+
composes: text-base from global;
|
|
19
|
+
composes: text-colorDefault from global;
|
|
20
|
+
composes: bg-white from global;
|
|
21
|
+
composes: border-gray-100 from global;
|
|
22
|
+
border-radius: 5px;
|
|
23
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shape, string } from 'prop-types';
|
|
3
|
-
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
4
|
-
|
|
5
|
-
import Shimmer from '@magento/venia-ui/lib/components/Shimmer';
|
|
6
|
-
import defaultClasses from './filterTop.module.css';
|
|
7
|
-
|
|
8
|
-
const FilterTop = props => {
|
|
9
|
-
const classes = useStyle(defaultClasses, props.classes);
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
<aside className={classes.root} aria-live="polite" aria-busy="true">
|
|
13
|
-
<Shimmer width="95%" height="70vh" style={{ marginBottom: 25 }} />
|
|
14
|
-
</aside>
|
|
15
|
-
);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
FilterTop.propTypes = {
|
|
19
|
-
classes: shape({
|
|
20
|
-
root: string
|
|
21
|
-
})
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default FilterTop;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shape, string } from 'prop-types';
|
|
3
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
4
|
+
|
|
5
|
+
import Shimmer from '@magento/venia-ui/lib/components/Shimmer';
|
|
6
|
+
import defaultClasses from './filterTop.module.css';
|
|
7
|
+
|
|
8
|
+
const FilterTop = props => {
|
|
9
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<aside className={classes.root} aria-live="polite" aria-busy="true">
|
|
13
|
+
<Shimmer width="95%" height="70vh" style={{ marginBottom: 25 }} />
|
|
14
|
+
</aside>
|
|
15
|
+
);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
FilterTop.propTypes = {
|
|
19
|
+
classes: shape({
|
|
20
|
+
root: string
|
|
21
|
+
})
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export default FilterTop;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { arrayOf, shape, string, func, bool } from 'prop-types';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
import { ChevronDown as ArrowDown, ChevronUp as ArrowUp } from 'react-feather';
|
|
5
|
+
import { Form } from 'informed';
|
|
6
|
+
|
|
7
|
+
import { useFilterBlock } from '@magento/peregrine/lib/talons/FilterModal';
|
|
8
|
+
import setValidator from '@magento/peregrine/lib/validators/set';
|
|
9
|
+
|
|
10
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
11
|
+
import Icon from '@magento/venia-ui/lib/components/Icon';
|
|
12
|
+
import FilterBlockList from './FilterBlockList';
|
|
13
|
+
import { ArrowUp2 } from 'iconsax-react';
|
|
14
|
+
import cn from 'classnames';
|
|
15
|
+
|
|
16
|
+
const FilterTopBlock = props => {
|
|
17
|
+
const {
|
|
18
|
+
filterApi,
|
|
19
|
+
filterState,
|
|
20
|
+
filterFrontendInput,
|
|
21
|
+
group,
|
|
22
|
+
items,
|
|
23
|
+
name,
|
|
24
|
+
onApply,
|
|
25
|
+
filterNames,
|
|
26
|
+
initialOpen,
|
|
27
|
+
originalFilterState
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
30
|
+
const { formatMessage } = useIntl();
|
|
31
|
+
const talonProps = useFilterBlock({
|
|
32
|
+
filterState,
|
|
33
|
+
items,
|
|
34
|
+
initialOpen
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const list = <Form>
|
|
38
|
+
<FilterBlockList
|
|
39
|
+
filterApi={filterApi}
|
|
40
|
+
filterState={filterState}
|
|
41
|
+
originalFilterState={originalFilterState}
|
|
42
|
+
name={name}
|
|
43
|
+
filterFrontendInput={filterFrontendInput}
|
|
44
|
+
group={group}
|
|
45
|
+
items={items}
|
|
46
|
+
filterNames={filterNames}
|
|
47
|
+
onApply={onApply}
|
|
48
|
+
/>
|
|
49
|
+
</Form>
|
|
50
|
+
|
|
51
|
+
return list;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export default FilterTopBlock;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from './filterTop';
|
|
2
|
-
export { default as FilterTopShimmer } from './filterTop.shimmer';
|
|
1
|
+
export { default } from './filterTop';
|
|
2
|
+
export { default as FilterTopShimmer } from './filterTop.shimmer';
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { shape, string, func } from 'prop-types';
|
|
4
|
+
import { X as Remove } from 'react-feather';
|
|
5
|
+
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import Icon from '@magento/venia-ui/lib/components/Icon';
|
|
8
|
+
import Trigger from '@magento/venia-ui/lib/components/Trigger';
|
|
9
|
+
import defaultClasses from './customFilter.module.css';
|
|
10
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
11
|
+
|
|
12
|
+
import { Link } from 'react-router-dom';
|
|
13
|
+
|
|
14
|
+
const CustomFilter = props => {
|
|
15
|
+
const { group, item, onRemove } = props;
|
|
16
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
17
|
+
const { formatMessage } = useIntl();
|
|
18
|
+
|
|
19
|
+
const ariaLabel = formatMessage(
|
|
20
|
+
{
|
|
21
|
+
id: 'filterModal.action.clearFilterItem.ariaLabel',
|
|
22
|
+
defaultMessage: 'Clear filter "{name}"'
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: item.label ? item.label : item.title
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const normalizedData = [
|
|
30
|
+
{
|
|
31
|
+
'label': 'Sealed Products',
|
|
32
|
+
'path': '/'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
'label': 'Singles',
|
|
36
|
+
'path': '/'
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
'label': 'Supplies',
|
|
40
|
+
'path': '/'
|
|
41
|
+
}
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
const subCategory = [];
|
|
45
|
+
|
|
46
|
+
const customAttributeLandingPage = ['card_set', 'sc_baseball_release'];
|
|
47
|
+
|
|
48
|
+
if (customAttributeLandingPage.includes(group)) {
|
|
49
|
+
normalizedData && normalizedData.map(({ label, path }, index) => {
|
|
50
|
+
subCategory.push(
|
|
51
|
+
<Link
|
|
52
|
+
key={index}
|
|
53
|
+
to={resourceUrl(path)}
|
|
54
|
+
>
|
|
55
|
+
<li className={classes.item}>{label}</li>
|
|
56
|
+
</Link>
|
|
57
|
+
)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<ul className={classes.root}>{subCategory}</ul>
|
|
64
|
+
// <span className={classes.root} data-cy="CustomFilter-root">
|
|
65
|
+
// <span className={classes.text}>
|
|
66
|
+
// {item.label ? item.label : item.title}
|
|
67
|
+
// </span>
|
|
68
|
+
// </span>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export default CustomFilter;
|
|
73
|
+
|
|
74
|
+
CustomFilter.defaultProps = {
|
|
75
|
+
onRemove: null
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
CustomFilter.propTypes = {
|
|
79
|
+
classes: shape({
|
|
80
|
+
root: string
|
|
81
|
+
}),
|
|
82
|
+
onRemove: func
|
|
83
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
composes: flex from global;
|
|
3
|
+
composes: flex-wrap from global;
|
|
4
|
+
composes: mt-3 from global;
|
|
5
|
+
composes: gap-[15px] from global;
|
|
6
|
+
margin-bottom: 10px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.item {
|
|
10
|
+
composes: px-4 from global;
|
|
11
|
+
composes: py-2 from global;
|
|
12
|
+
composes: transition-colors from global;
|
|
13
|
+
composes: duration-150 from global;
|
|
14
|
+
composes: border from global;
|
|
15
|
+
composes: border-solid from global;
|
|
16
|
+
composes: leading-normal from global;
|
|
17
|
+
composes: text-base from global;
|
|
18
|
+
composes: text-colorDefault from global;
|
|
19
|
+
composes: bg-white from global;
|
|
20
|
+
composes: border-gray-100 from global;
|
|
21
|
+
border-radius: 5px;
|
|
22
|
+
}
|