@riosst100/pwa-marketplace 1.6.0 → 1.6.1
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 +1 -1
- package/src/components/AlphaFilter/alphaFilter.js +75 -0
- package/src/components/AlphaFilter/alphaFilter.module.css +38 -0
- package/src/components/AlphaFilter/index.js +2 -0
- package/src/components/SubCategory/subCategory.js +2 -2
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +29 -6
- package/src/overwrites/venia-ui/lib/components/Gallery/gallery.js +7 -2
package/package.json
CHANGED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React, { Fragment, useState } from 'react';
|
|
2
|
+
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import { useSeller } from '@riosst100/pwa-marketplace/src/talons/Seller/useSeller';
|
|
4
|
+
import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
|
|
5
|
+
import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
|
|
6
|
+
import { useCollectibleGameSets } from '@riosst100/pwa-marketplace/src/talons/CollectibleGameSets/useCollectibleGameSets';
|
|
7
|
+
import { Link } from 'react-router-dom';
|
|
8
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
9
|
+
import defaultClasses from './alphaFilter.module.css';
|
|
10
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
11
|
+
import cn from 'classnames';
|
|
12
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
13
|
+
import { CollectibleGameSetsShimmer } from '@riosst100/pwa-marketplace/src/components/CollectibleGameSets';
|
|
14
|
+
import ProductSort from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/ProductSort';
|
|
15
|
+
import CustomSortBy from '@riosst100/pwa-marketplace/src/components/CustomSortBy';
|
|
16
|
+
|
|
17
|
+
const AlphaFilter = props => {
|
|
18
|
+
const {items, handleActiveLetter} = props;
|
|
19
|
+
|
|
20
|
+
const groupSinglesFirstLetter = (data) => {
|
|
21
|
+
return data.reduce((acc, item) => {
|
|
22
|
+
if (item && item.name) {
|
|
23
|
+
const firstLetter = item.name.charAt(0).toUpperCase();
|
|
24
|
+
acc[firstLetter] = acc[firstLetter] || [];
|
|
25
|
+
acc[firstLetter].push(item);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const groupedSingles = items ? groupSinglesFirstLetter(items) : null;
|
|
33
|
+
const availableLetter = groupedSingles ? Object.keys(groupedSingles).sort() : [];
|
|
34
|
+
|
|
35
|
+
const alpha = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'];
|
|
36
|
+
|
|
37
|
+
return <>
|
|
38
|
+
<section className='single_list-indexing-container relative m-auto py-1'>
|
|
39
|
+
<ul className='flex gap-2 justify-center flex-wrap'>
|
|
40
|
+
{alpha.map((letter, index) => (
|
|
41
|
+
<li key={index}>
|
|
42
|
+
<button
|
|
43
|
+
className={cn(
|
|
44
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
45
|
+
'leading-4 font-medium text-base ',
|
|
46
|
+
availableLetter.includes(letter) ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
|
|
47
|
+
)}
|
|
48
|
+
onClick={() => {
|
|
49
|
+
handleActiveLetter(letter)
|
|
50
|
+
}}
|
|
51
|
+
disabled={availableLetter.includes(letter) > 0 ? false : true}
|
|
52
|
+
>
|
|
53
|
+
{letter}
|
|
54
|
+
</button>
|
|
55
|
+
</li>
|
|
56
|
+
))}
|
|
57
|
+
<li>
|
|
58
|
+
<button
|
|
59
|
+
className={cn(
|
|
60
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
61
|
+
'leading-4 font-medium text-base hover_bg-gray-50'
|
|
62
|
+
)}
|
|
63
|
+
onClick={() => {
|
|
64
|
+
handleActiveLetter('all')
|
|
65
|
+
}}
|
|
66
|
+
>
|
|
67
|
+
All
|
|
68
|
+
</button>
|
|
69
|
+
</li>
|
|
70
|
+
</ul>
|
|
71
|
+
</section>
|
|
72
|
+
</>
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default AlphaFilter;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
.tabs {
|
|
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: 30px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.tabs_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
|
+
}
|
|
23
|
+
|
|
24
|
+
.singlesWrapper {
|
|
25
|
+
column-count: 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@media screen and (min-width: 768px) {
|
|
29
|
+
.singlesWrapper {
|
|
30
|
+
column-count: 2;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@media screen and (min-width: 1023px) {
|
|
35
|
+
.singlesWrapper {
|
|
36
|
+
column-count: 3;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -16,7 +16,7 @@ const SubCategory = props => {
|
|
|
16
16
|
normalizedData
|
|
17
17
|
} = talonProps;
|
|
18
18
|
|
|
19
|
-
const maxSubCategory =
|
|
19
|
+
const maxSubCategory = 7;
|
|
20
20
|
|
|
21
21
|
const subCategory = [];
|
|
22
22
|
|
|
@@ -38,7 +38,7 @@ const SubCategory = props => {
|
|
|
38
38
|
<Link
|
|
39
39
|
to={resourceUrl('/')}
|
|
40
40
|
>
|
|
41
|
-
<li className={classes.item}>{"
|
|
41
|
+
<li className={classes.item}>{"More " + parent[0].name}</li>
|
|
42
42
|
</Link>
|
|
43
43
|
)
|
|
44
44
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { Fragment, Suspense, useMemo, useRef } from 'react';
|
|
1
|
+
import React, { Fragment, Suspense, useMemo, useRef, useState } from 'react';
|
|
2
2
|
import { FormattedMessage } from 'react-intl';
|
|
3
3
|
import { array, number, shape, string } from 'prop-types';
|
|
4
4
|
|
|
@@ -32,6 +32,7 @@ import CollectibleGameSets from '@riosst100/pwa-marketplace/src/components/Colle
|
|
|
32
32
|
import { useLocation } from 'react-router-dom';
|
|
33
33
|
import { getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
34
34
|
import CustomSubCategory from '@riosst100/pwa-marketplace/src/components/SubCategory/customSubCategory';
|
|
35
|
+
import AlphaFilter from '@riosst100/pwa-marketplace/src/components/AlphaFilter';
|
|
35
36
|
|
|
36
37
|
const FilterModal = React.lazy(() => import('@magento/venia-ui/lib/components/FilterModal'));
|
|
37
38
|
const FilterSidebar = React.lazy(() =>
|
|
@@ -73,6 +74,26 @@ const CategoryContent = props => {
|
|
|
73
74
|
virtualCategoryFilters
|
|
74
75
|
} = talonProps;
|
|
75
76
|
|
|
77
|
+
const [activeLetter, setActiveLetter] = useState('all')
|
|
78
|
+
|
|
79
|
+
const handleActiveLetter = (val) => {
|
|
80
|
+
setActiveLetter(val);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const galleryItems = [];
|
|
84
|
+
|
|
85
|
+
useMemo(() => {
|
|
86
|
+
items && items.map((item, index) => {
|
|
87
|
+
if (item) {
|
|
88
|
+
const firstLetter = item.name.charAt(0).toUpperCase();
|
|
89
|
+
if (activeLetter == "all" || activeLetter != "all" && firstLetter == activeLetter) {
|
|
90
|
+
return galleryItems.push(item);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}),
|
|
94
|
+
[items, activeLetter]
|
|
95
|
+
});
|
|
96
|
+
|
|
76
97
|
const sidebarRef = useRef(null);
|
|
77
98
|
const classes = useStyle(defaultClasses, props.classes);
|
|
78
99
|
const shouldRenderSidebarContent = useIsInViewport({
|
|
@@ -127,11 +148,11 @@ const CategoryContent = props => {
|
|
|
127
148
|
) : null;
|
|
128
149
|
|
|
129
150
|
const categoryResultsHeading =
|
|
130
|
-
|
|
151
|
+
galleryItems.length > 0 ? (
|
|
131
152
|
<FormattedMessage
|
|
132
153
|
id={'categoryContent.resultCount'}
|
|
133
154
|
values={{
|
|
134
|
-
count:
|
|
155
|
+
count: galleryItems.length
|
|
135
156
|
}}
|
|
136
157
|
defaultMessage={'{count} Results'}
|
|
137
158
|
/>
|
|
@@ -149,9 +170,9 @@ const CategoryContent = props => {
|
|
|
149
170
|
}
|
|
150
171
|
|
|
151
172
|
const gallery = totalPagesFromData ? (
|
|
152
|
-
<Gallery items={
|
|
173
|
+
<Gallery items={galleryItems} activeLetter={activeLetter} />
|
|
153
174
|
) : (
|
|
154
|
-
<GalleryShimmer items={
|
|
175
|
+
<GalleryShimmer items={galleryItems} />
|
|
155
176
|
);
|
|
156
177
|
|
|
157
178
|
const pagination = totalPagesFromData ? (
|
|
@@ -171,7 +192,8 @@ const CategoryContent = props => {
|
|
|
171
192
|
isLoading,
|
|
172
193
|
items,
|
|
173
194
|
pageControl,
|
|
174
|
-
totalPagesFromData
|
|
195
|
+
totalPagesFromData,
|
|
196
|
+
activeLetter
|
|
175
197
|
]);
|
|
176
198
|
|
|
177
199
|
const categoryTitle = categoryName ? categoryName : <Shimmer width={5} />;
|
|
@@ -219,6 +241,7 @@ const CategoryContent = props => {
|
|
|
219
241
|
</div>
|
|
220
242
|
{/* {activeFilters.size <= 0 && category && category.custom_landing_page ? ( */}
|
|
221
243
|
<>
|
|
244
|
+
{currentFilter && <AlphaFilter items={items} handleActiveLetter={handleActiveLetter} activeLetter={activeLetter} />}
|
|
222
245
|
<SubCategory parent={parent} children={children} />
|
|
223
246
|
{!currentFilter && <CustomSubCategory customSubCategory={category ? category.custom_subcategory : null} />}
|
|
224
247
|
</>
|
|
@@ -14,7 +14,7 @@ import { useGallery } from '@magento/peregrine/lib/talons/Gallery/useGallery';
|
|
|
14
14
|
* @params {Array} props.items an array of items to render
|
|
15
15
|
*/
|
|
16
16
|
const Gallery = props => {
|
|
17
|
-
const { items } = props;
|
|
17
|
+
const { items, activeLetter } = props;
|
|
18
18
|
const classes = useStyle(defaultClasses, props.classes);
|
|
19
19
|
const talonProps = useGallery();
|
|
20
20
|
const { storeConfig } = talonProps;
|
|
@@ -25,6 +25,10 @@ const Gallery = props => {
|
|
|
25
25
|
if (item === null) {
|
|
26
26
|
return <GalleryItemShimmer key={index} />;
|
|
27
27
|
}
|
|
28
|
+
|
|
29
|
+
const firstLetter = item.name.charAt(0).toUpperCase();
|
|
30
|
+
|
|
31
|
+
if (activeLetter == "all" || activeLetter != "all" && firstLetter == activeLetter) {
|
|
28
32
|
return (
|
|
29
33
|
<GalleryItem
|
|
30
34
|
key={item.id}
|
|
@@ -32,8 +36,9 @@ const Gallery = props => {
|
|
|
32
36
|
storeConfig={storeConfig}
|
|
33
37
|
/>
|
|
34
38
|
);
|
|
39
|
+
}
|
|
35
40
|
}),
|
|
36
|
-
[items, storeConfig]
|
|
41
|
+
[items, storeConfig, activeLetter]
|
|
37
42
|
);
|
|
38
43
|
|
|
39
44
|
return (
|