@riosst100/pwa-marketplace 2.5.8 → 2.5.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/package.json +1 -1
- package/src/components/FilterContent/filterContent.js +376 -0
- package/src/components/FilterContent/filterContent.module.css +76 -0
- package/src/components/FilterContent/filterDefault.js +84 -0
- package/src/components/FilterContent/filterDefault.module.css +0 -0
- package/src/components/FilterContent/filterItem.js +80 -0
- package/src/components/FilterContent/index.js +1 -0
- package/src/components/FilterListContent/filterListPage.js +414 -0
- package/src/components/FilterListContent/index.js +1 -0
- package/src/components/FilterListPage/index.js +1 -0
- package/src/components/Seller/seller.js +0 -6
- package/src/components/SetsData/setsData.js +1 -1
- package/src/overwrites/peregrine/lib/store/actions/cart/asyncActions.js +0 -21
- package/src/overwrites/peregrine/lib/talons/FilterSidebar/useFilterSidebar.js +0 -12
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js +2 -0
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +14 -1
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +2 -6
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/productListing.js +0 -9
- package/src/overwrites/venia-ui/lib/components/CheckoutPage/PaymentInformation/paymentMethods.js +0 -9
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.js +12 -2
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.module.css +4 -3
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.js +2 -1
- package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.module.css +7 -4
- package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterList.js +13 -3
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +0 -3
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/OrderDetails/item.js +0 -1
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/OrderDetails/orderDetails.js +0 -1
- package/src/talons/FilterContent/useFilterContent.js +291 -0
- package/src/talons/FilterTop/useFilterTop.js +0 -2
- package/src/talons/SellerProducts/productContent.gql.js +1 -0
- package/src/talons/SellerProducts/useSellerProducts.js +0 -2
- package/src/talons/ShopBy/useShopBy.js +17 -25
package/package.json
CHANGED
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
import React, { Fragment, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import ErrorView from '@magento/venia-ui/lib/components/ErrorView';
|
|
3
|
+
import { StoreTitle, Meta } from '@magento/venia-ui/lib/components/Head';
|
|
4
|
+
// import { useSetsData } from '@riosst100/pwa-marketplace/src/talons/SetsData/useSetsData';
|
|
5
|
+
import { Link } from 'react-router-dom';
|
|
6
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
7
|
+
import defaultClasses from './filterContent.module.css';
|
|
8
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
9
|
+
import cn from 'classnames';
|
|
10
|
+
import Divider from '@riosst100/pwa-marketplace/src/components/Divider';
|
|
11
|
+
// import { SetsDataShimmer } from '@riosst100/pwa-marketplace/src/components/SetsData';
|
|
12
|
+
import CustomSortBy from '@riosst100/pwa-marketplace/src/components/CustomSortBy';
|
|
13
|
+
import ArraySearchInput from '@riosst100/pwa-marketplace/src/components/ArraySearchInput';
|
|
14
|
+
import { useCustomSort } from '@riosst100/pwa-marketplace/src/hooks/useCustomSort';
|
|
15
|
+
import Breadcrumbs from '@magento/venia-ui/lib/components/Breadcrumbs';
|
|
16
|
+
import { useLocation } from 'react-router-dom';
|
|
17
|
+
// import { getFiltersFromSearch } from '@magento/peregrine/lib/talons/FilterModal/helpers';
|
|
18
|
+
import { useFilterContent } from '@riosst100/pwa-marketplace/src/talons/FilterContent/useFilterContent';
|
|
19
|
+
|
|
20
|
+
const FilterContent = props => {
|
|
21
|
+
const {
|
|
22
|
+
categoryId,
|
|
23
|
+
data,
|
|
24
|
+
filterby,
|
|
25
|
+
isLoading
|
|
26
|
+
} = props || {};
|
|
27
|
+
|
|
28
|
+
const [active, setActive] = useState('all')
|
|
29
|
+
const [activeTab, setActiveTab] = useState('all');
|
|
30
|
+
const [activeFilter, setActiveFilter] = useState('');
|
|
31
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
32
|
+
|
|
33
|
+
const { search } = useLocation();
|
|
34
|
+
|
|
35
|
+
const sortProps = useCustomSort({ sortFromSearch: false, defaultSort: {
|
|
36
|
+
sortText: 'All (A-Z)',
|
|
37
|
+
value: 'all'
|
|
38
|
+
}});
|
|
39
|
+
|
|
40
|
+
const [currentSort] = sortProps;
|
|
41
|
+
|
|
42
|
+
// const { search } = useLocation();
|
|
43
|
+
|
|
44
|
+
// const sortProps = useCustomSort({ sortFromSearch: false, defaultSort: {
|
|
45
|
+
// sortText: 'All (A-Z)',
|
|
46
|
+
// value: 'all'
|
|
47
|
+
// }});
|
|
48
|
+
|
|
49
|
+
// const [currentSort] = sortProps;
|
|
50
|
+
const classes = useStyle(defaultClasses);
|
|
51
|
+
|
|
52
|
+
const talonProps = useFilterContent({
|
|
53
|
+
activeFilter, searchQuery, active, setActive, currentSort,
|
|
54
|
+
categoryId,
|
|
55
|
+
filterby,
|
|
56
|
+
data
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
const {
|
|
60
|
+
title,
|
|
61
|
+
filterData,
|
|
62
|
+
error, loading, dataResult, categoryUrlSuffix, categoryUrlKey, productType, filteredAvailableGroups, availableGroups, attributeData, alpha, category, activeFilters
|
|
63
|
+
} = talonProps;
|
|
64
|
+
|
|
65
|
+
const newAvailableGroups = searchQuery ? filteredAvailableGroups : availableGroups;
|
|
66
|
+
|
|
67
|
+
const splitToNChunks = (array, n) => {
|
|
68
|
+
let result = [];
|
|
69
|
+
for (let i = n; i > 0; i--) {
|
|
70
|
+
result.push(array.splice(0, Math.ceil(array.length / i)));
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let filterSearchArr = search ? search.split('&') : [];
|
|
76
|
+
filterSearchArr = filterSearchArr.filter(function(data) {
|
|
77
|
+
return !data.includes('filterby');
|
|
78
|
+
})
|
|
79
|
+
filterSearchArr = filterSearchArr.filter(function(data) {
|
|
80
|
+
return !data.includes('trains_roadname_country');
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
filterSearchArr = filterSearchArr.filter(function(data) {
|
|
84
|
+
return !data.includes(filterData.attribute_code);
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
let filterSearch = filterSearchArr.join('&')
|
|
88
|
+
|
|
89
|
+
if (!filterSearch.includes('?')) {
|
|
90
|
+
filterSearch = '?'+filterSearch;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let additionalFilter = '';
|
|
94
|
+
if (filterby == 'sc_brands') {
|
|
95
|
+
additionalFilter = '&filterby=release&active_tab=brand';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const setRelases = newAvailableGroups && newAvailableGroups.length && newAvailableGroups.map((group, index) => {
|
|
99
|
+
const optionsResult = [];
|
|
100
|
+
|
|
101
|
+
if (active === 'all' || active === group) {
|
|
102
|
+
dataResult[group] && dataResult[group].length && dataResult[group].map((option, index) => {
|
|
103
|
+
const { count, label, value } = option;
|
|
104
|
+
|
|
105
|
+
const filter = filterData.attribute_code + '[filter]=' + label + ',' + value;
|
|
106
|
+
const params = filterSearch ? filterSearch + '&' + filter + additionalFilter : '?' + filter + additionalFilter;
|
|
107
|
+
|
|
108
|
+
const categoryUrl = resourceUrl(
|
|
109
|
+
`/${category?.url_path}${categoryUrlSuffix || ''}${params}`
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
optionsResult.push(<li key={index} className='list-none'>
|
|
113
|
+
<Link to={categoryUrl} className="hover_bg-darkblue-900 hover_text-white w-full block text-[14px] py-[2px] px-0">
|
|
114
|
+
{label} <span className='text-[12px]'>({count})</span>
|
|
115
|
+
</Link>
|
|
116
|
+
</li>)
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
let optionsResultSplitted = [];
|
|
120
|
+
if (newAvailableGroups.length == 1 || active == group) {
|
|
121
|
+
optionsResultSplitted = splitToNChunks(optionsResult, 3);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// console.log(dataResult)
|
|
125
|
+
|
|
126
|
+
const all = active == "all" ? (
|
|
127
|
+
newAvailableGroups.length == 1 ? (
|
|
128
|
+
optionsResultSplitted && optionsResultSplitted.length && optionsResultSplitted.map((data, index) => (
|
|
129
|
+
<div key={index} className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
130
|
+
{searchQuery && availableGroups.length > 1 && (index == 0 ? <div className='singles_item_group_letter text-xl font-medium border-b border-gray-100 pb-1 mb-2'>{group}</div> :
|
|
131
|
+
<div className='singles_item_group_letter text-xl font-medium pb-1 mb-2' style={{"marginTop":"35px"}}></div>)}
|
|
132
|
+
<div className={cn('singles_item-list flex flex-col')}>{data}</div>
|
|
133
|
+
</div>
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
) : (
|
|
137
|
+
<div className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
138
|
+
<div className='singles_item_group_letter text-xl font-medium border-b border-gray-100 pb-1 mb-2' >
|
|
139
|
+
{group}
|
|
140
|
+
</div>
|
|
141
|
+
<div className={cn('singles_item-list flex flex-col')}>{optionsResult}</div>
|
|
142
|
+
</div>
|
|
143
|
+
)
|
|
144
|
+
) : '';
|
|
145
|
+
|
|
146
|
+
return (
|
|
147
|
+
<>
|
|
148
|
+
{all}
|
|
149
|
+
{active == group ? optionsResultSplitted && optionsResultSplitted.length && optionsResultSplitted.map((optionsResult, index) =>
|
|
150
|
+
<div key={index} className={cn('singles_group-wrapper mb-4 px-2 inline-block', classes.singlesGroupWrapper)}>
|
|
151
|
+
{index == 0 ? <div className='singles_item_group_letter text-xl font-medium border-b border-gray-100 pb-1 mb-2'>{group}</div> :
|
|
152
|
+
<div className='singles_item_group_letter text-xl font-medium pb-1 mb-2' style={{"marginTop":"35px"}}></div>}
|
|
153
|
+
<div className={cn('singles_item-list flex flex-col')}>{optionsResult}</div>
|
|
154
|
+
</div>
|
|
155
|
+
)
|
|
156
|
+
: ''}
|
|
157
|
+
</>
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return null;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
const handleActive = (val) => {
|
|
165
|
+
setActive(val);
|
|
166
|
+
setSearchQuery('')
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// let availableSortBy = [
|
|
170
|
+
// {
|
|
171
|
+
// 'label': 'All (A-Z)',
|
|
172
|
+
// 'value': 'all'
|
|
173
|
+
// }
|
|
174
|
+
// ];
|
|
175
|
+
|
|
176
|
+
let availableSortBy = [
|
|
177
|
+
{
|
|
178
|
+
'label': 'All (A-Z)',
|
|
179
|
+
'value': 'all'
|
|
180
|
+
}
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
let availableFilterOption = [];
|
|
184
|
+
|
|
185
|
+
if (filterby == "vehicles_make" || filterby == "vehicles_brands") {
|
|
186
|
+
availableFilterOption = [
|
|
187
|
+
{
|
|
188
|
+
'code': 'vehicles_diecast',
|
|
189
|
+
'value': 'Cars',
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
'code': 'vehicles_diecast',
|
|
193
|
+
'value': 'Formula Racing'
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
'code': 'vehicles_diecast',
|
|
197
|
+
'value': 'Motorsport'
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
'code': 'vehicles_diecast',
|
|
201
|
+
'value': 'Aircraft'
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
'code': 'vehicles_diecast',
|
|
205
|
+
'value': 'Bikes'
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
'code': 'vehicles_diecast',
|
|
209
|
+
'value': 'Military'
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
'code': 'vehicles_diecast',
|
|
213
|
+
'value': 'Transport'
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
'code': 'vehicles_diecast',
|
|
217
|
+
'value': 'Emergency Services'
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
'code': 'vehicles_diecast',
|
|
221
|
+
'value': 'Heavy Machinery'
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
'code': 'vehicles_diecast',
|
|
225
|
+
'value': 'TV/Movies'
|
|
226
|
+
}
|
|
227
|
+
];
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// console.log(category)
|
|
231
|
+
|
|
232
|
+
if (filterby == "brands" || filterby == "product_line") {
|
|
233
|
+
if (category && category?.url_path.includes('anime-figures')) {
|
|
234
|
+
availableFilterOption = [
|
|
235
|
+
{
|
|
236
|
+
'code': 'anime_figures',
|
|
237
|
+
'value': 'Complete Figures',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
'code': 'anime_figures',
|
|
241
|
+
'value': 'Articulated Figures'
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
'code': 'anime_figures',
|
|
245
|
+
'value': 'Statues'
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
'code': 'anime_figures',
|
|
249
|
+
'value': 'Mini-Figures'
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
'code': 'anime_figures',
|
|
253
|
+
'value': 'Capsule Toys (Gashapon)'
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
'code': 'anime_figures',
|
|
257
|
+
'value': 'Candy Toys'
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
'code': 'anime_figures',
|
|
261
|
+
'value': 'R18+'
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
'code': 'anime_figures',
|
|
265
|
+
'value': 'Model Kits'
|
|
266
|
+
}
|
|
267
|
+
];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
const handleActiveTab = (val) => {
|
|
272
|
+
setActiveTab(val);
|
|
273
|
+
setActive('all');
|
|
274
|
+
setActiveFilter('');
|
|
275
|
+
|
|
276
|
+
setSearchQuery('')
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
const handleActiveFilter = (val) => {
|
|
280
|
+
setActiveFilter(val);
|
|
281
|
+
|
|
282
|
+
setActive('all');
|
|
283
|
+
|
|
284
|
+
setSearchQuery('')
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
return (
|
|
288
|
+
<Fragment>
|
|
289
|
+
<StoreTitle>{title}</StoreTitle>
|
|
290
|
+
<Breadcrumbs categoryId={categoryId} customPage={title} currentFilter={activeFilters} />
|
|
291
|
+
{availableFilterOption.length ?
|
|
292
|
+
<ul className={classes.nav}>
|
|
293
|
+
{availableFilterOption.map((filter, index) => (
|
|
294
|
+
<li className={classes.nav_item}>
|
|
295
|
+
<button
|
|
296
|
+
onClick={() => {
|
|
297
|
+
handleActiveFilter(filter.code + '|' + filter.value)
|
|
298
|
+
}}
|
|
299
|
+
>
|
|
300
|
+
{activeFilter == filter.code + '|' + filter.value ? <b>{filter.value}</b> : filter.value}
|
|
301
|
+
</button>
|
|
302
|
+
</li>
|
|
303
|
+
))}
|
|
304
|
+
<li className={classes.nav_item}>
|
|
305
|
+
<button
|
|
306
|
+
onClick={() => {
|
|
307
|
+
handleActiveFilter('')
|
|
308
|
+
}}
|
|
309
|
+
>
|
|
310
|
+
{activeFilter == '' ? <b>All</b> : 'All'}
|
|
311
|
+
</button>
|
|
312
|
+
</li>
|
|
313
|
+
</ul>
|
|
314
|
+
: ''}
|
|
315
|
+
<h1 className='mx-auto relative block text-xl font-bold text-center pt-10 pb-4'>
|
|
316
|
+
{title}
|
|
317
|
+
</h1>
|
|
318
|
+
<div className='border border-gray-100 px-6'>
|
|
319
|
+
{dataResult ? (
|
|
320
|
+
<div
|
|
321
|
+
className={classes.toolbar}
|
|
322
|
+
>
|
|
323
|
+
<div style={{"width":"35%"}}><ArraySearchInput active={active} searchQuery={searchQuery} placeholder="Search sets..." isOpen={true} setSearchQuery={setSearchQuery} /></div>
|
|
324
|
+
{/* <CustomSortBy sortProps={sortProps} availableSortMethods={availableSortBy} /> */}
|
|
325
|
+
</div>
|
|
326
|
+
) : ''}
|
|
327
|
+
{filterby != "vehicles_year" && filterby != "trains_gauge" && filterby != "vehicles_scale" && filterby != "lego_theme" && filterby != "lego_subtheme" && filterby != "lego_interest" && filterby != "lego_age_level" && productType != "expansion-sets" ? (
|
|
328
|
+
<>
|
|
329
|
+
<section className='single_list-indexing-container relative m-auto pt-5'>
|
|
330
|
+
<ul className='flex gap-2 justify-center flex-wrap'>
|
|
331
|
+
<li>
|
|
332
|
+
<button
|
|
333
|
+
className={cn(
|
|
334
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
335
|
+
'leading-4 font-medium text-base hover_bg-gray-50'
|
|
336
|
+
)}
|
|
337
|
+
onClick={() => {
|
|
338
|
+
handleActive('all')
|
|
339
|
+
}}
|
|
340
|
+
>
|
|
341
|
+
{active == 'all' ? <b>All</b> : 'All'}
|
|
342
|
+
</button>
|
|
343
|
+
</li>
|
|
344
|
+
{alpha && alpha.length && alpha.map((letter, index) => (
|
|
345
|
+
<li key={index}>
|
|
346
|
+
<button
|
|
347
|
+
className={cn(
|
|
348
|
+
'rounded-md border border-solid border-gray-100 p-2 min-w-[28px]',
|
|
349
|
+
'leading-4 font-medium text-base ',
|
|
350
|
+
availableGroups.includes(letter) > 0 ? 'hover_bg-gray-50' : 'bg-gray-100 text-gray-400',
|
|
351
|
+
)}
|
|
352
|
+
onClick={() => {
|
|
353
|
+
handleActive(letter)
|
|
354
|
+
}}
|
|
355
|
+
disabled={availableGroups.includes(letter) > 0 ? false : true}
|
|
356
|
+
>
|
|
357
|
+
{active == letter ? <b>{letter}</b> : letter}
|
|
358
|
+
</button>
|
|
359
|
+
</li>
|
|
360
|
+
))}
|
|
361
|
+
</ul>
|
|
362
|
+
</section>
|
|
363
|
+
</>
|
|
364
|
+
) : ''}
|
|
365
|
+
{dataResult && Object.keys(dataResult).length != 0 ? <Divider className="mb-5 px-4 mt-5" /> : <span className="mb-5 px-4 mt-5"></span>}
|
|
366
|
+
<section className='singles-container'>
|
|
367
|
+
<div className={cn('singles-wrapper block', classes.singlesWrapper)}>
|
|
368
|
+
{dataResult && Object.keys(dataResult).length != 0 ? setRelases : (searchQuery ? <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No filter options found for <b>{searchQuery}</b> search query.</div> : <div className='singles_group-wrapper mb-4 px-2 inline-block w-full'>No filter options found.</div>)}
|
|
369
|
+
</div>
|
|
370
|
+
</section>
|
|
371
|
+
</div>
|
|
372
|
+
</Fragment>
|
|
373
|
+
);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export default FilterContent;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.toolbar {
|
|
2
|
+
composes: relative from global;
|
|
3
|
+
composes: ml-2xs from global;
|
|
4
|
+
display: flex;
|
|
5
|
+
justify-content: space-between;
|
|
6
|
+
margin-top: 20px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.nav {
|
|
10
|
+
composes: flex from global;
|
|
11
|
+
composes: flex-wrap from global;
|
|
12
|
+
margin: 50px 0 30px 0;
|
|
13
|
+
composes: gap-[10px] from global;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.nav_item {
|
|
17
|
+
composes: px-4 from global;
|
|
18
|
+
composes: py-2 from global;
|
|
19
|
+
composes: transition-colors from global;
|
|
20
|
+
composes: duration-150 from global;
|
|
21
|
+
composes: border from global;
|
|
22
|
+
composes: border-solid from global;
|
|
23
|
+
composes: leading-normal from global;
|
|
24
|
+
composes: text-base from global;
|
|
25
|
+
composes: text-colorDefault from global;
|
|
26
|
+
composes: bg-white from global;
|
|
27
|
+
composes: border-gray-100 from global;
|
|
28
|
+
border-radius: 5px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.tabs {
|
|
32
|
+
composes: flex from global;
|
|
33
|
+
composes: flex-wrap from global;
|
|
34
|
+
composes: mt-3 from global;
|
|
35
|
+
composes: gap-[10px] from global;
|
|
36
|
+
margin-bottom: 30px;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.tabs_item {
|
|
40
|
+
composes: px-4 from global;
|
|
41
|
+
composes: py-2 from global;
|
|
42
|
+
composes: transition-colors from global;
|
|
43
|
+
composes: duration-150 from global;
|
|
44
|
+
composes: border from global;
|
|
45
|
+
composes: border-solid from global;
|
|
46
|
+
composes: leading-normal from global;
|
|
47
|
+
composes: text-base from global;
|
|
48
|
+
composes: text-colorDefault from global;
|
|
49
|
+
composes: bg-white from global;
|
|
50
|
+
composes: border-gray-100 from global;
|
|
51
|
+
border-radius: 5px;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.singlesWrapper {
|
|
55
|
+
column-count: 1;
|
|
56
|
+
display: flex;
|
|
57
|
+
width: 100%;
|
|
58
|
+
flex-wrap: wrap;
|
|
59
|
+
flex-direction: row;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.singlesGroupWrapper {
|
|
63
|
+
width: 100%;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@media screen and (min-width: 768px) {
|
|
67
|
+
.singlesGroupWrapper {
|
|
68
|
+
width: 50%;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@media screen and (min-width: 1023px) {
|
|
73
|
+
.singlesGroupWrapper {
|
|
74
|
+
width: 33.33%;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { bool, shape, string } from 'prop-types';
|
|
4
|
+
|
|
5
|
+
import Checkbox from '@magento/venia-ui/lib/components/Checkbox';
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import defaultClasses from './filterDefault.module.css';
|
|
8
|
+
import { useCurrencySwitcher } from '@magento/peregrine/lib/talons/Header/useCurrencySwitcher';
|
|
9
|
+
|
|
10
|
+
const FilterDefault = props => {
|
|
11
|
+
const {
|
|
12
|
+
classes: propsClasses,
|
|
13
|
+
isSelected,
|
|
14
|
+
item,
|
|
15
|
+
onMouseDown,
|
|
16
|
+
group,
|
|
17
|
+
...restProps
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
const { label, value_index } = item || {};
|
|
21
|
+
const classes = useStyle(defaultClasses, propsClasses);
|
|
22
|
+
const { currentCurrencyCode } = useCurrencySwitcher();
|
|
23
|
+
const currencySymbolMap = {
|
|
24
|
+
USD: '$',
|
|
25
|
+
EUR: '€'
|
|
26
|
+
};
|
|
27
|
+
const currencySymbol = currencySymbolMap[currentCurrencyCode] != undefined ? currencySymbolMap[currentCurrencyCode] : currentCurrencyCode;
|
|
28
|
+
const title =
|
|
29
|
+
group === 'price'
|
|
30
|
+
? label.replace('-', ' - ')
|
|
31
|
+
: label;
|
|
32
|
+
const { formatMessage } = useIntl();
|
|
33
|
+
|
|
34
|
+
const ariaLabel = !isSelected
|
|
35
|
+
? formatMessage(
|
|
36
|
+
{
|
|
37
|
+
id: 'filterModal.item.applyFilter',
|
|
38
|
+
defaultMessage: 'Apply filter "{optionName}".'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
optionName: label
|
|
42
|
+
}
|
|
43
|
+
)
|
|
44
|
+
: formatMessage(
|
|
45
|
+
{
|
|
46
|
+
id: 'filterModal.item.clearFilter',
|
|
47
|
+
defaultMessage: 'Remove filter "{optionName}".'
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
optionName: label
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<Checkbox
|
|
56
|
+
classes={classes}
|
|
57
|
+
field={`${label}-${value_index}`}
|
|
58
|
+
fieldValue={!!isSelected}
|
|
59
|
+
label={title}
|
|
60
|
+
ariaLabel={ariaLabel}
|
|
61
|
+
data-cy="FilterDefault-checkbox"
|
|
62
|
+
onClick={onMouseDown}
|
|
63
|
+
{...restProps}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export default FilterDefault;
|
|
69
|
+
|
|
70
|
+
FilterDefault.propTypes = {
|
|
71
|
+
classes: shape({
|
|
72
|
+
root: string,
|
|
73
|
+
icon: string,
|
|
74
|
+
label: string,
|
|
75
|
+
checked: string
|
|
76
|
+
}),
|
|
77
|
+
group: string,
|
|
78
|
+
isSelected: bool,
|
|
79
|
+
item: shape({
|
|
80
|
+
label: string.isRequired,
|
|
81
|
+
value_index: string.isRequired
|
|
82
|
+
}).isRequired,
|
|
83
|
+
label: string
|
|
84
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useCallback, useMemo } from 'react';
|
|
2
|
+
import { func, number, oneOfType, shape, string } from 'prop-types';
|
|
3
|
+
import setValidator from '@magento/peregrine/lib/validators/set';
|
|
4
|
+
|
|
5
|
+
import FilterDefault from './filterDefault';
|
|
6
|
+
|
|
7
|
+
const FilterItem = props => {
|
|
8
|
+
const { filterApi, filterState, group, item, onApply } = props;
|
|
9
|
+
const { toggleItem } = filterApi;
|
|
10
|
+
const { title, value } = item;
|
|
11
|
+
const isSelected = filterState && filterState.has(item);
|
|
12
|
+
|
|
13
|
+
// create and memoize an item that matches the tile interface
|
|
14
|
+
const tileItem = useMemo(
|
|
15
|
+
() => ({
|
|
16
|
+
label: title,
|
|
17
|
+
value_index: value
|
|
18
|
+
}),
|
|
19
|
+
[title, value]
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const handleClick = useCallback(
|
|
23
|
+
e => {
|
|
24
|
+
// use only left click for selection
|
|
25
|
+
if (e.button !== 0) return;
|
|
26
|
+
|
|
27
|
+
toggleItem({ group, item });
|
|
28
|
+
|
|
29
|
+
if (typeof onApply === 'function') {
|
|
30
|
+
onApply(group, item);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
[group, item, toggleItem, onApply]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const handleKeyDown = useCallback(
|
|
37
|
+
e => {
|
|
38
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
toggleItem({ group, item });
|
|
41
|
+
if (typeof onApply === 'function') {
|
|
42
|
+
onApply(group, item);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
[group, item, onApply, toggleItem]
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<FilterDefault
|
|
51
|
+
isSelected={isSelected}
|
|
52
|
+
item={tileItem}
|
|
53
|
+
onMouseDown={handleClick}
|
|
54
|
+
onKeyDown={handleKeyDown}
|
|
55
|
+
group={group}
|
|
56
|
+
title={title}
|
|
57
|
+
value={value}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
FilterItem.defaultProps = {
|
|
63
|
+
onChange: null
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
FilterItem.propTypes = {
|
|
67
|
+
filterApi: shape({
|
|
68
|
+
toggleItem: func.isRequired
|
|
69
|
+
}).isRequired,
|
|
70
|
+
filterState: setValidator,
|
|
71
|
+
group: string.isRequired,
|
|
72
|
+
item: shape({
|
|
73
|
+
title: string.isRequired,
|
|
74
|
+
value: oneOfType([number, string]).isRequired,
|
|
75
|
+
path: string
|
|
76
|
+
}).isRequired,
|
|
77
|
+
onChange: func
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default FilterItem;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './filterContent';
|