@riosst100/pwa-marketplace 1.6.1 → 1.6.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/package.json +3 -2
- package/src/components/AlphaFilter/alphaFilter.js +14 -3
- package/src/components/AlphaFilter/alphaFilter.shimmer.js +50 -0
- package/src/components/CollectibleGameSets/collectibleGameSets.js +1 -1
- 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/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 +48 -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/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/noProductsFound.js +0 -13
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +1 -1
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +3 -2
- 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/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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
2
|
import { func, shape, string } from 'prop-types';
|
|
3
3
|
import { useIntl } from 'react-intl';
|
|
4
4
|
|
|
@@ -10,25 +10,70 @@ import { Link } from 'react-router-dom';
|
|
|
10
10
|
import { useCustomFilters } from '@riosst100/pwa-marketplace/src/talons/CustomFilters/useCustomFilters';
|
|
11
11
|
|
|
12
12
|
const CustomFilters = props => {
|
|
13
|
-
const {
|
|
13
|
+
const { onRemove, clearAll, category, filters } = props;
|
|
14
14
|
const classes = useStyle(defaultClasses, props.classes);
|
|
15
15
|
const { formatMessage } = useIntl();
|
|
16
16
|
|
|
17
|
-
const talonProps = useCustomFilters();
|
|
17
|
+
const talonProps = useCustomFilters({ filters });
|
|
18
18
|
|
|
19
|
-
const {
|
|
19
|
+
const {
|
|
20
|
+
customFiltersData,
|
|
21
|
+
categoryUrlSuffix,
|
|
22
|
+
search,
|
|
23
|
+
pathname,
|
|
24
|
+
filterApi,
|
|
25
|
+
// filterItems,
|
|
26
|
+
// filterNames,
|
|
27
|
+
// filterFrontendInput,
|
|
28
|
+
filterState
|
|
29
|
+
} = talonProps;
|
|
20
30
|
|
|
21
31
|
const params = search ? JSON.parse('{"' + decodeURI(search).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g,'":"') + '"}') : {};
|
|
22
32
|
|
|
33
|
+
const { removeItem } = filterApi;
|
|
34
|
+
|
|
35
|
+
const activeFilters = useMemo(() => {
|
|
36
|
+
const elements = [];
|
|
37
|
+
for (const [group, items] of filterState) {
|
|
38
|
+
for (const item of items) {
|
|
39
|
+
elements.push(
|
|
40
|
+
{
|
|
41
|
+
group: group,
|
|
42
|
+
item: item,
|
|
43
|
+
removeItem: removeItem
|
|
44
|
+
}
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return elements;
|
|
50
|
+
}, [filterState, removeItem]);
|
|
51
|
+
|
|
52
|
+
// console.log(activeFilters)\\
|
|
53
|
+
|
|
54
|
+
// const handleClick = useCallback(() => {
|
|
55
|
+
// removeItem({ group, item });
|
|
56
|
+
// }, [group, item, removeItem]);
|
|
57
|
+
|
|
23
58
|
// create elements and params at the same time for efficiency
|
|
24
59
|
const filterElements = useMemo(() => {
|
|
25
60
|
const elements = [];
|
|
26
61
|
customFiltersData && customFiltersData.map((filter, index) => {
|
|
27
62
|
const { label, attribute_code, options } = filter || {};
|
|
28
63
|
|
|
64
|
+
const group = attribute_code;
|
|
65
|
+
|
|
66
|
+
// const handleClick = useCallback(() => {
|
|
67
|
+
// removeItem({ group, item });
|
|
68
|
+
// if (typeof onRemove === 'function') {
|
|
69
|
+
// onRemove(group, item);
|
|
70
|
+
// }
|
|
71
|
+
// }, [group, item, removeItem, onRemove]);
|
|
72
|
+
|
|
29
73
|
if (options.length) {
|
|
30
74
|
const items = [];
|
|
31
|
-
options.map((
|
|
75
|
+
options.map((item, index) => {
|
|
76
|
+
const { label, value } = item
|
|
32
77
|
// const path = '/';
|
|
33
78
|
|
|
34
79
|
// const path = resourceUrl(
|
|
@@ -51,20 +96,27 @@ const CustomFilters = props => {
|
|
|
51
96
|
const finalParams = params ? Object.keys(params).map(key => `${key}=${params[key]}`).join('&') : '';
|
|
52
97
|
const path = pathname + finalParams;
|
|
53
98
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
<
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
99
|
+
if (value != "all") {
|
|
100
|
+
items.push(
|
|
101
|
+
<li key={index}>
|
|
102
|
+
<Link
|
|
103
|
+
to={path}
|
|
104
|
+
>
|
|
105
|
+
<span className={classes.item}>{label}</span>
|
|
106
|
+
</Link>
|
|
107
|
+
</li>
|
|
108
|
+
)
|
|
109
|
+
} else {
|
|
110
|
+
items.push(
|
|
111
|
+
<li key={index}>
|
|
112
|
+
<span className={classes.item} onClick={removeItem({ group, item })}>{label}</span>
|
|
113
|
+
</li>
|
|
114
|
+
)
|
|
115
|
+
}
|
|
64
116
|
});
|
|
65
117
|
|
|
66
118
|
elements.push(
|
|
67
|
-
<ul className={classes.root}>{items}</ul>
|
|
119
|
+
<ul key={index} className={classes.root}>{items}</ul>
|
|
68
120
|
);
|
|
69
121
|
}
|
|
70
122
|
})
|
|
@@ -77,18 +129,4 @@ const CustomFilters = props => {
|
|
|
77
129
|
);
|
|
78
130
|
};
|
|
79
131
|
|
|
80
|
-
CustomFilters.defaultProps = {
|
|
81
|
-
onRemove: null
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
CustomFilters.propTypes = {
|
|
85
|
-
classes: shape({
|
|
86
|
-
root: string,
|
|
87
|
-
item: string,
|
|
88
|
-
button: string,
|
|
89
|
-
icon: string
|
|
90
|
-
}),
|
|
91
|
-
onRemove: func
|
|
92
|
-
};
|
|
93
|
-
|
|
94
132
|
export default CustomFilters;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { Fragment, useMemo } from 'react';
|
|
2
|
+
import FilterTopItemGroup from './filterTopItemGroup';
|
|
3
|
+
|
|
4
|
+
const labels = new WeakMap();
|
|
5
|
+
|
|
6
|
+
const FilterBlockList = props => {
|
|
7
|
+
const {
|
|
8
|
+
filterApi,
|
|
9
|
+
filterState,
|
|
10
|
+
name,
|
|
11
|
+
group,
|
|
12
|
+
items,
|
|
13
|
+
onApply,
|
|
14
|
+
filterNames,
|
|
15
|
+
originalFilterState
|
|
16
|
+
} = props;
|
|
17
|
+
|
|
18
|
+
const itemElements = useMemo(() => {
|
|
19
|
+
const key = `item-${group}`;
|
|
20
|
+
return (
|
|
21
|
+
<FilterTopItemGroup
|
|
22
|
+
filterApi={filterApi}
|
|
23
|
+
filterState={filterState}
|
|
24
|
+
group={group}
|
|
25
|
+
name={name}
|
|
26
|
+
originalFilterState={originalFilterState}
|
|
27
|
+
items={items}
|
|
28
|
+
onApply={onApply}
|
|
29
|
+
labels={labels}
|
|
30
|
+
filterNames={filterNames}
|
|
31
|
+
key={key}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
}, [
|
|
35
|
+
filterApi,
|
|
36
|
+
filterState,
|
|
37
|
+
name,
|
|
38
|
+
group,
|
|
39
|
+
items,
|
|
40
|
+
onApply
|
|
41
|
+
]);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<Fragment>
|
|
45
|
+
{itemElements}
|
|
46
|
+
</Fragment>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default FilterBlockList;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React, { useCallback } from 'react';
|
|
2
|
+
import defaultClasses from './filterTopItem.module.css';
|
|
3
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
4
|
+
|
|
5
|
+
const FilterTopItem = props => {
|
|
6
|
+
const { filterApi, group, item, onApply, labels, activeFilters } = props;
|
|
7
|
+
const { removeGroup, toggleItem } = filterApi;
|
|
8
|
+
const { title, value } = item;
|
|
9
|
+
|
|
10
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
11
|
+
|
|
12
|
+
const label = item.label ? item.label : item.title;
|
|
13
|
+
|
|
14
|
+
const handleOnchange = useCallback(
|
|
15
|
+
e => {
|
|
16
|
+
if (group != "category_uid") {
|
|
17
|
+
removeGroup({ group });
|
|
18
|
+
if (e === item.value) {
|
|
19
|
+
toggleItem({ group, item });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (typeof onApply === 'function') {
|
|
23
|
+
onApply(group, item);
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
[group, item, onApply, removeGroup, toggleItem]
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const element = activeFilters.includes(value) ? (
|
|
30
|
+
<span className={classes.item}><b>{title}</b></span>
|
|
31
|
+
) : (
|
|
32
|
+
<span className={classes.item} onClick={() =>handleOnchange(value)}>{title}</span>
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
labels.set(element, label);
|
|
36
|
+
|
|
37
|
+
return element;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default FilterTopItem;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.item {
|
|
2
|
+
composes: px-4 from global;
|
|
3
|
+
composes: py-2 from global;
|
|
4
|
+
composes: transition-colors from global;
|
|
5
|
+
composes: duration-150 from global;
|
|
6
|
+
composes: border from global;
|
|
7
|
+
composes: border-solid from global;
|
|
8
|
+
composes: leading-normal from global;
|
|
9
|
+
composes: text-base from global;
|
|
10
|
+
composes: text-colorDefault from global;
|
|
11
|
+
composes: bg-white from global;
|
|
12
|
+
composes: border-gray-100 from global;
|
|
13
|
+
border-radius: 5px;
|
|
14
|
+
}
|
|
@@ -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-[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
|
+
}
|
|
@@ -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;
|