@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
|
@@ -156,12 +156,13 @@ const CustomSortBy = props => {
|
|
|
156
156
|
});
|
|
157
157
|
|
|
158
158
|
return (
|
|
159
|
-
<div
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
>
|
|
159
|
+
// <div
|
|
160
|
+
// ref={elementRef}
|
|
161
|
+
// className={classes.root}
|
|
162
|
+
// data-cy="CustomSortBy-root"
|
|
163
|
+
// aria-busy="false"
|
|
164
|
+
// >
|
|
165
|
+
<>
|
|
165
166
|
<Button
|
|
166
167
|
priority={'low'}
|
|
167
168
|
classes={{
|
|
@@ -181,17 +182,14 @@ const CustomSortBy = props => {
|
|
|
181
182
|
</span>
|
|
182
183
|
<span className={cn(classes.desktopText, 'flex items-center gap-[15px]')}>
|
|
183
184
|
<span className={classes.sortText}>
|
|
184
|
-
<FormattedMessage
|
|
185
|
-
id={'productSort.sortByButton'}
|
|
186
|
-
defaultMessage={'Sort by'}
|
|
187
|
-
/>
|
|
188
185
|
{currentSort.sortText}
|
|
189
186
|
</span>
|
|
190
187
|
<ArrowUp2 size={15} className={cn('text-gray-900 transition-all stroke-[#292D32]', expanded ? 'rotate-0' : 'rotate-180')} />
|
|
191
188
|
</span>
|
|
192
189
|
</Button>
|
|
193
190
|
{sortElements}
|
|
194
|
-
|
|
191
|
+
</>
|
|
192
|
+
// </div>
|
|
195
193
|
);
|
|
196
194
|
};
|
|
197
195
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
composes: relative from global;
|
|
3
|
+
composes: ml-2xs from global;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.menu {
|
|
7
|
+
composes: absolute from global;
|
|
8
|
+
composes: bg-clip-padding from global;
|
|
9
|
+
composes: bg-white from global;
|
|
10
|
+
composes: border from global;
|
|
11
|
+
composes: border-solid from global;
|
|
12
|
+
composes: border-gray-100 from global;
|
|
13
|
+
composes: list-none from global;
|
|
14
|
+
composes: mb-0 from global;
|
|
15
|
+
composes: min-w-[10rem] from global;
|
|
16
|
+
composes: mt-0.5 from global;
|
|
17
|
+
composes: mx-0 from global;
|
|
18
|
+
composes: right-0 from global;
|
|
19
|
+
composes: rounded from global;
|
|
20
|
+
composes: shadow-menu from global;
|
|
21
|
+
composes: text-colorDefault from global;
|
|
22
|
+
composes: text-left from global;
|
|
23
|
+
composes: top-[110%] from global;
|
|
24
|
+
composes: z-menu from global;
|
|
25
|
+
composes: p-2.5 from global;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.menuItem {
|
|
29
|
+
composes: hover_bg-gray-100 from global;
|
|
30
|
+
composes: rounded-[5px] from global;
|
|
31
|
+
composes: relative from global;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.sortButton {
|
|
35
|
+
composes: rounded-[5px] from global;
|
|
36
|
+
composes: p-2.5 from global;
|
|
37
|
+
|
|
38
|
+
composes: min-w-[154px] from global;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.desktopText {
|
|
42
|
+
composes: hidden from global;
|
|
43
|
+
|
|
44
|
+
composes: lg_inline-flex from global;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.sortText {
|
|
48
|
+
composes: leading-normal from global;
|
|
49
|
+
composes: text-colorDefault from global;
|
|
50
|
+
composes: text-base from global;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.desktopIconWrapper {
|
|
54
|
+
transform: translateX(10px);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.desktopIcon {
|
|
58
|
+
/* composes: icon from '../Icon/icon.module.css'; */
|
|
59
|
+
|
|
60
|
+
composes: stroke-gray-500 from global;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.mobileText {
|
|
64
|
+
composes: lg_hidden from global;
|
|
65
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 './productSort.shimmer.module.css';
|
|
7
|
+
|
|
8
|
+
const ProductSortShimmer = props => {
|
|
9
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div className={classes.root} aria-live="polite" aria-busy="true">
|
|
13
|
+
<Shimmer
|
|
14
|
+
classes={{ root_button: classes.sortButtonShimmer }}
|
|
15
|
+
type="button"
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
ProductSortShimmer.propTypes = {
|
|
22
|
+
classes: shape({
|
|
23
|
+
root: string,
|
|
24
|
+
sortButtonShimmer: string
|
|
25
|
+
})
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default ProductSortShimmer;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useSubCategory } from '@riosst100/pwa-marketplace/src/talons/SubCategory/useSubCategory';
|
|
2
|
+
import React, { useState } from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
5
|
+
import defaultClasses from './subCategory.module.css';
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import { useFilterSidebar } from '@magento/peregrine/lib/talons/FilterSidebar';
|
|
8
|
+
import CollectibleGameSets from '@riosst100/pwa-marketplace/src/components/CollectibleGameSets/collectibleGameSets';
|
|
9
|
+
|
|
10
|
+
const SubCategory = props => {
|
|
11
|
+
const { children } = props;
|
|
12
|
+
|
|
13
|
+
const talonProps = useSubCategory({ children });
|
|
14
|
+
|
|
15
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
16
|
+
|
|
17
|
+
const {
|
|
18
|
+
normalizedData
|
|
19
|
+
} = talonProps;
|
|
20
|
+
|
|
21
|
+
const subCategory = [];
|
|
22
|
+
|
|
23
|
+
normalizedData && normalizedData.map(({ text, path }, index) => {
|
|
24
|
+
console.log(path)
|
|
25
|
+
subCategory.push(
|
|
26
|
+
<Link
|
|
27
|
+
key={index}
|
|
28
|
+
to={path}
|
|
29
|
+
>
|
|
30
|
+
<li className={classes.item}>{text}</li>
|
|
31
|
+
</Link>
|
|
32
|
+
)
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return subCategory.length ? <ul className={classes.root}>{subCategory}</ul> : '';
|
|
36
|
+
|
|
37
|
+
// const [activeTab, setActiveTab] = useState('singles')
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<>
|
|
41
|
+
<ul className={classes.root}>
|
|
42
|
+
<li className={classes.item}>All Sets</li>
|
|
43
|
+
<li className={classes.item}>Expansion Sets</li>
|
|
44
|
+
</ul>
|
|
45
|
+
</>
|
|
46
|
+
)
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default SubCategory;
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
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 '../FilterBlockList/filterTopItem.module.css';
|
|
10
|
+
|
|
11
|
+
const CurrentTopFilter = props => {
|
|
12
|
+
const { group, item, removeItem, onRemove } = props;
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
|
|
15
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
16
|
+
|
|
17
|
+
const handleClick = useCallback(() => {
|
|
18
|
+
removeItem({ group, item });
|
|
19
|
+
if (typeof onRemove === 'function') {
|
|
20
|
+
onRemove(group, item);
|
|
21
|
+
}
|
|
22
|
+
}, [group, item, removeItem, onRemove]);
|
|
23
|
+
|
|
24
|
+
const ariaLabel = formatMessage(
|
|
25
|
+
{
|
|
26
|
+
id: 'filterModal.action.clearFilterItem.ariaLabel',
|
|
27
|
+
defaultMessage: 'Clear filter "{name}"'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: item.label ? item.label : item.title
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<span className={classes.item} data-cy="CurrentTopFilter-root">
|
|
36
|
+
<Trigger
|
|
37
|
+
action={handleClick}
|
|
38
|
+
aria-label={ariaLabel}
|
|
39
|
+
data-cy="CurrentTopFilter-trigger"
|
|
40
|
+
>
|
|
41
|
+
All
|
|
42
|
+
</Trigger>
|
|
43
|
+
</span>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export default CurrentTopFilter;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
min-height: 24px;
|
|
3
|
+
composes: border from global;
|
|
4
|
+
composes: border-gray-100 from global;
|
|
5
|
+
composes: font-semibold from global;
|
|
6
|
+
composes: gap-2xs from global;
|
|
7
|
+
composes: grid-flow-col from global;
|
|
8
|
+
composes: inline-grid from global;
|
|
9
|
+
composes: items-center from global;
|
|
10
|
+
composes: justify-center from global;
|
|
11
|
+
composes: px-2 from global;
|
|
12
|
+
composes: py-1 from global;
|
|
13
|
+
composes: rounded-md from global;
|
|
14
|
+
/* composes: text-white from global; */
|
|
15
|
+
composes: text-base from global;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* TODO @TW: cannot compose */
|
|
19
|
+
.root svg {
|
|
20
|
+
/* composes: stroke-white from global; */
|
|
21
|
+
stroke: rgb(var(--venia-global-color-gray-600));
|
|
22
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { func, shape, string } from 'prop-types';
|
|
3
|
+
import { useIntl } from 'react-intl';
|
|
4
|
+
|
|
5
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
6
|
+
import CurrentTopFilter from './currentTopFilter';
|
|
7
|
+
import defaultClasses from '../FilterBlockList/filterTopItem.module.css';
|
|
8
|
+
|
|
9
|
+
const CurrentTopFilters = props => {
|
|
10
|
+
const { filterApi, filterState, onRemove, currentGroup } = props;
|
|
11
|
+
const { removeItem } = filterApi;
|
|
12
|
+
const { formatMessage } = useIntl();
|
|
13
|
+
|
|
14
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
15
|
+
|
|
16
|
+
// create elements and params at the same time for efficiency
|
|
17
|
+
const filterElements = useMemo(() => {
|
|
18
|
+
const elements = [];
|
|
19
|
+
for (const [group, items] of filterState) {
|
|
20
|
+
for (const item of items) {
|
|
21
|
+
const { title, value } = item || {};
|
|
22
|
+
const key = `${group}::${title}_${value}`;
|
|
23
|
+
|
|
24
|
+
const customAttributeLandingPage = ['card_set', 'sc_baseball_release'];
|
|
25
|
+
|
|
26
|
+
if (group === currentGroup && !customAttributeLandingPage.includes(group)) {
|
|
27
|
+
elements.push(
|
|
28
|
+
<CurrentTopFilter
|
|
29
|
+
group={group}
|
|
30
|
+
item={item}
|
|
31
|
+
removeItem={removeItem}
|
|
32
|
+
onRemove={onRemove}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return elements;
|
|
40
|
+
}, [filterState, removeItem, onRemove]);
|
|
41
|
+
|
|
42
|
+
const currentFiltersAriaLabel = formatMessage({
|
|
43
|
+
id: 'filterModal.currentFilters.ariaLabel',
|
|
44
|
+
defaultMessage: 'Current Filters'
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
return filterElements && filterElements.length ? filterElements : <span className={classes.item}><b>All</b></span>
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default CurrentTopFilters;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
composes: px-[10px] from global;
|
|
3
|
+
composes: py-2 from global;
|
|
4
|
+
composes: overflow-auto from global;
|
|
5
|
+
composes: flex from global;
|
|
6
|
+
composes: flex-wrap from global;
|
|
7
|
+
composes: gap-2 from global;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* TODO @TW: cannot compose */
|
|
11
|
+
.root:empty {
|
|
12
|
+
display: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.item {
|
|
16
|
+
composes: float-left from global;
|
|
17
|
+
composes: pb-0 from global;
|
|
18
|
+
composes: pl-0 from global;
|
|
19
|
+
composes: pr-2 from global;
|
|
20
|
+
composes: pt-2 from global;
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './currentFilter';
|
|
@@ -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
|
+
}
|