@riosst100/pwa-marketplace 2.4.7 → 2.4.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/componentOverrideMapping.js +3 -0
- package/src/components/Seller/seller.js +8 -0
- package/src/components/SellerDetail/sellerDetail.js +4 -3
- package/src/components/SellerMegaMenu/index.js +1 -0
- package/src/components/SellerMegaMenu/sellerMegaMenu.js +92 -0
- package/src/components/SellerMegaMenu/sellerMegaMenu.module.css +12 -0
- package/src/components/SellerMegaMenu/sellerMegaMenuItem.js +164 -0
- package/src/components/SellerMegaMenu/sellerMegaMenuItem.module.css +31 -0
- package/src/components/SellerMegaMenu/sellerSubmenu.js +106 -0
- package/src/components/SellerMegaMenu/sellerSubmenu.module.css +57 -0
- package/src/components/SellerMegaMenu/sellerSubmenuColumn.js +173 -0
- package/src/components/SellerMegaMenu/sellerSubmenuColumn.module.css +33 -0
- package/src/components/SellerProducts/productContent.js +70 -11
- package/src/components/SellerProducts/sellerProducts.js +51 -12
- package/src/intercept.js +14 -0
- package/src/overwrites/peregrine/lib/context/cart.js +136 -0
- package/src/overwrites/peregrine/lib/store/actions/cart/asyncActions.js +589 -0
- package/src/overwrites/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary.js +4 -1
- package/src/overwrites/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js +434 -0
- package/src/overwrites/venia-ui/lib/components/Adapter/adapter.js +0 -9
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/product.js +2 -2
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListing/productListing.js +8 -8
- package/src/overwrites/venia-ui/lib/components/Header/header.js +1 -1
- package/src/talons/Seller/useSeller.js +1 -1
- package/src/talons/SellerMegaMenu/megaMenu.gql.js +96 -0
- package/src/talons/SellerMegaMenu/useSellerMegaMenu.js +199 -0
- package/src/talons/SellerMegaMenu/useSellerMegaMenuItem.js +66 -0
- package/src/talons/SellerMegaMenu/useSellerSubMenu.js +21 -0
- package/src/talons/SellerProducts/sellerProducts.gql.js +24 -1
- package/src/talons/SellerProducts/useProductContent.js +17 -23
- package/src/talons/SellerProducts/useSellerProducts.js +44 -28
package/package.json
CHANGED
|
@@ -10,6 +10,9 @@ module.exports = componentOverrideMapping = {
|
|
|
10
10
|
[`@magento/peregrine/lib/talons/Region/useRegion.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/Region/useRegion.js',
|
|
11
11
|
[`@magento/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql`]: '@riosst100/pwa-marketplace/src/overwrites/pwa-buildpack/lib/queries/getAvailableStoresConfigData.graphql',
|
|
12
12
|
[`@magento/peregrine/lib/store/actions/user/asyncActions.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/store/actions/user/asyncActions.js',
|
|
13
|
+
[`@magento/peregrine/lib/store/actions/cart/asyncActions.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/store/actions/cart/asyncActions.js',
|
|
14
|
+
[`@magento/peregrine/lib/context/cart.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/context/cart.js',
|
|
15
|
+
[`@magento/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/CheckoutPage/useCheckoutPage.js',
|
|
13
16
|
[`@magento/peregrine/lib/talons/SignIn/signIn.gql.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/SignIn/signIn.gql.js',
|
|
14
17
|
[`@magento/peregrine/lib/talons/SignIn/useSignIn.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/SignIn/useSignIn.js',
|
|
15
18
|
[`@magento/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js`]: '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/AccountMenu/useAccountMenuItems.js',
|
|
@@ -7,12 +7,20 @@ import mapSeller from '@riosst100/pwa-marketplace/src/util/mapSeller';
|
|
|
7
7
|
import SellerDetail from '@riosst100/pwa-marketplace/src/components/SellerDetail/sellerDetail';
|
|
8
8
|
|
|
9
9
|
const Seller = props => {
|
|
10
|
+
const { categoryUrlKey } = props;
|
|
11
|
+
|
|
12
|
+
console.log('categoryUrlKey+'+categoryUrlKey)
|
|
13
|
+
console.log(props)
|
|
14
|
+
|
|
10
15
|
const talonProps = useSeller({
|
|
11
16
|
mapSeller
|
|
12
17
|
});
|
|
13
18
|
|
|
14
19
|
const { error, loading, seller } = talonProps;
|
|
15
20
|
|
|
21
|
+
console.log('---seller')
|
|
22
|
+
console.log(seller)
|
|
23
|
+
|
|
16
24
|
if (loading && !seller)
|
|
17
25
|
return '';
|
|
18
26
|
// return <SellerShimmer />;
|
|
@@ -53,7 +53,7 @@ const SellerDetail = props => {
|
|
|
53
53
|
{
|
|
54
54
|
id: 'product-tab',
|
|
55
55
|
title: 'All Products',
|
|
56
|
-
content: <SellerProducts sellerId={seller?.seller_id} />
|
|
56
|
+
content: <SellerProducts sellerId={seller?.seller_id} seller={seller} />
|
|
57
57
|
},
|
|
58
58
|
{
|
|
59
59
|
id: 'store-information',
|
|
@@ -102,6 +102,7 @@ const SellerDetail = props => {
|
|
|
102
102
|
<Image
|
|
103
103
|
alt={seller.name}
|
|
104
104
|
width='100'
|
|
105
|
+
style={{"height":'100px',"objectFit":"cover"}}
|
|
105
106
|
src={seller.thumbnail || ''} />
|
|
106
107
|
) : (
|
|
107
108
|
<div className='flex items-center justify-center bg-gray-300 border rounded-radius1 relative w-[100px] h-[100px]'>
|
|
@@ -166,8 +167,8 @@ const SellerDetail = props => {
|
|
|
166
167
|
</div>
|
|
167
168
|
</div>
|
|
168
169
|
</div>
|
|
169
|
-
<div class="flex items-center gap-[20px] px-[10px] py-[
|
|
170
|
-
<img class="relative self-stretch w-px object-cover" alt="Line" src="https://c.animaapp.com/2pP7niVX/img/line-16.svg" />
|
|
170
|
+
<div class="flex items-center gap-[20px] px-[10px] py-[10px] relative">
|
|
171
|
+
{/* <img class="relative self-stretch w-px object-cover" alt="Line" src="https://c.animaapp.com/2pP7niVX/img/line-16.svg" /> */}
|
|
171
172
|
<div class="flex flex-col items-center justify-center gap-[9px] p-[10px] relative">
|
|
172
173
|
<div class="flex items-center gap-[5px] relative">
|
|
173
174
|
<Star1 color='#F7C317' size={18} className='fill-[#F7C317]' />
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './sellerMegaMenu';
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
|
|
4
|
+
import { useSellerMegaMenu } from '@riosst100/pwa-marketplace/src/talons/SellerMegaMenu/useSellerMegaMenu';
|
|
5
|
+
// import { useMegaMenu } from '@riosst100/pwa-marketplace/src/overwrites/peregrine/lib/talons/MegaMenu/useMegaMenu';
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
|
|
8
|
+
import SellerMegaMenuItem from './sellerMegaMenuItem';
|
|
9
|
+
import defaultClasses from './sellerMegaMenu.module.css';
|
|
10
|
+
import cn from 'classnames';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The SellerMegaMenu component displays menu with categories on desktop devices
|
|
14
|
+
*/
|
|
15
|
+
const SellerMegaMenu = (props) => {
|
|
16
|
+
const { rootClassName, seller, sellerMegaMenuItemClassname, titleClassName } = props
|
|
17
|
+
const mainNavRef = useRef(null);
|
|
18
|
+
|
|
19
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
20
|
+
// const rootClass = cn(classes.sellerMegaMenu, rootClassName);
|
|
21
|
+
const rootClass = cn('flex items-end gap-[40px] px-[30px] py-0 rounded-[6px] border border-solid border-gray-100 xs_hidden xl_flex flex-grow justify-self-center', rootClassName);
|
|
22
|
+
|
|
23
|
+
const {
|
|
24
|
+
megaMenuData,
|
|
25
|
+
activeCategoryId,
|
|
26
|
+
sellerSubMenuState,
|
|
27
|
+
disableFocus,
|
|
28
|
+
handleSellerSubMenuFocus,
|
|
29
|
+
categoryUrlSuffix,
|
|
30
|
+
handleNavigate,
|
|
31
|
+
handleClickOutside
|
|
32
|
+
} = useSellerMegaMenu({ mainNavRef });
|
|
33
|
+
|
|
34
|
+
const [mainNavWidth, setMainNavWidth] = useState(0);
|
|
35
|
+
const shouldRenderItems = useIsInViewport({
|
|
36
|
+
elementRef: mainNavRef
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const handleResize = () => {
|
|
41
|
+
const navWidth = mainNavRef.current
|
|
42
|
+
? mainNavRef.current.offsetWidth
|
|
43
|
+
: null;
|
|
44
|
+
|
|
45
|
+
setMainNavWidth(navWidth);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
window.addEventListener('resize', handleResize);
|
|
49
|
+
|
|
50
|
+
handleResize();
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
window.removeEventListener('resize', handleResize);
|
|
54
|
+
};
|
|
55
|
+
}, [setMainNavWidth]);
|
|
56
|
+
|
|
57
|
+
const items = megaMenuData.children
|
|
58
|
+
? megaMenuData.children.map(category => {
|
|
59
|
+
return (
|
|
60
|
+
<SellerMegaMenuItem
|
|
61
|
+
category={category}
|
|
62
|
+
activeCategoryId={activeCategoryId}
|
|
63
|
+
categoryUrlSuffix={categoryUrlSuffix}
|
|
64
|
+
mainNavWidth={mainNavWidth}
|
|
65
|
+
onNavigate={handleNavigate}
|
|
66
|
+
key={category.uid}
|
|
67
|
+
seller={seller}
|
|
68
|
+
sellerSubMenuState={sellerSubMenuState}
|
|
69
|
+
disableFocus={disableFocus}
|
|
70
|
+
handleSellerSubMenuFocus={handleSellerSubMenuFocus}
|
|
71
|
+
handleClickOutside={handleClickOutside}
|
|
72
|
+
sellerMegaMenuItemClassname={sellerMegaMenuItemClassname}
|
|
73
|
+
titleClassName={titleClassName}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
76
|
+
})
|
|
77
|
+
: null;
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<nav
|
|
81
|
+
ref={mainNavRef}
|
|
82
|
+
className={rootClass}
|
|
83
|
+
data-cy="SellerMegaMenu-sellerMegaMenu"
|
|
84
|
+
role="navigation"
|
|
85
|
+
onFocus={handleSellerSubMenuFocus}
|
|
86
|
+
>
|
|
87
|
+
{shouldRenderItems ? items : null}
|
|
88
|
+
</nav>
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export default SellerMegaMenu;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
.sellerMegaMenu {
|
|
2
|
+
composes: col-end-10 from global;
|
|
3
|
+
composes: col-start-3 from global;
|
|
4
|
+
composes: flex-grow from global;
|
|
5
|
+
composes: hidden from global;
|
|
6
|
+
composes: justify-self-center from global;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/* Large screen styles */
|
|
10
|
+
.sellerMegaMenu {
|
|
11
|
+
composes: lg_flex from global;
|
|
12
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { ChevronDown as ArrowDown } from 'react-feather';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
|
|
6
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
7
|
+
import { useSellerMegaMenuItem } from '@riosst100/pwa-marketplace/src/talons/SellerMegaMenu/useSellerMegaMenuItem';
|
|
8
|
+
|
|
9
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
10
|
+
import defaultClasses from './sellerMegaMenuItem.module.css';
|
|
11
|
+
import SellerSubmenu from './sellerSubmenu';
|
|
12
|
+
import { ArrowDown2 } from 'iconsax-react';
|
|
13
|
+
import { textPrimary } from '@riosst100/pwa-marketplace/src/theme/vars';
|
|
14
|
+
import cn from 'classnames';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The SellerMegaMenuItem component displays mega menu item
|
|
18
|
+
*
|
|
19
|
+
* @param {MegaMenuCategory} props.category
|
|
20
|
+
* @param {String} props.activeCategoryId - uid of active category
|
|
21
|
+
* @param {int} props.mainNavWidth - width of the main nav. It's used for setting min-width of the submenu
|
|
22
|
+
* @param {function} props.onNavigate - function called when clicking on Link
|
|
23
|
+
*/
|
|
24
|
+
const SellerMegaMenuItem = props => {
|
|
25
|
+
const {
|
|
26
|
+
activeCategoryId,
|
|
27
|
+
category,
|
|
28
|
+
mainNavWidth,
|
|
29
|
+
categoryUrlSuffix,
|
|
30
|
+
sellerSubMenuState,
|
|
31
|
+
seller,
|
|
32
|
+
disableFocus,
|
|
33
|
+
onNavigate,
|
|
34
|
+
handleSellerSubMenuFocus,
|
|
35
|
+
handleClickOutside,
|
|
36
|
+
sellerMegaMenuItemClassname,
|
|
37
|
+
titleClassName,
|
|
38
|
+
} = props;
|
|
39
|
+
|
|
40
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
41
|
+
const categoryUrl = resourceUrl(
|
|
42
|
+
`/${category.url_path}${categoryUrlSuffix || ''}`
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const talonProps = useSellerMegaMenuItem({
|
|
46
|
+
category,
|
|
47
|
+
activeCategoryId,
|
|
48
|
+
sellerSubMenuState,
|
|
49
|
+
disableFocus
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const {
|
|
53
|
+
isFocused,
|
|
54
|
+
isActive,
|
|
55
|
+
handleMenuItemFocus,
|
|
56
|
+
handleCloseSellerSubMenu,
|
|
57
|
+
isMenuActive,
|
|
58
|
+
handleKeyDown
|
|
59
|
+
} = talonProps;
|
|
60
|
+
|
|
61
|
+
const itemClassName = isMenuActive
|
|
62
|
+
? classes.sellerMegaMenuItem_active
|
|
63
|
+
: classes.sellerMegaMenuItem;
|
|
64
|
+
|
|
65
|
+
const arrow = <ArrowDown2 className='ml-2 stroke-current' size="14" color={textPrimary} variant="Outline" />;
|
|
66
|
+
|
|
67
|
+
const children = useMemo(() => {
|
|
68
|
+
return category.children.length || category.name == "Lego" ? (
|
|
69
|
+
<SellerSubmenu
|
|
70
|
+
isFocused={isFocused}
|
|
71
|
+
sellerSubMenuState={sellerSubMenuState}
|
|
72
|
+
items={category.children}
|
|
73
|
+
seller={seller}
|
|
74
|
+
parentCategory={category}
|
|
75
|
+
shopByItems={category.shop_by}
|
|
76
|
+
mainNavWidth={mainNavWidth}
|
|
77
|
+
handleCloseSellerSubMenu={handleCloseSellerSubMenu}
|
|
78
|
+
categoryUrlSuffix={categoryUrlSuffix}
|
|
79
|
+
onNavigate={onNavigate}
|
|
80
|
+
arrow={arrow}
|
|
81
|
+
/>
|
|
82
|
+
) : null;
|
|
83
|
+
}, [
|
|
84
|
+
category,
|
|
85
|
+
isFocused,
|
|
86
|
+
mainNavWidth,
|
|
87
|
+
sellerSubMenuState,
|
|
88
|
+
handleCloseSellerSubMenu,
|
|
89
|
+
categoryUrlSuffix,
|
|
90
|
+
onNavigate
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
const maybeDownArrowIcon = category.children.length ? (
|
|
94
|
+
<ArrowDown2 className='ml-2' size={12} color={textPrimary} variant="Outline" />
|
|
95
|
+
) : null;
|
|
96
|
+
|
|
97
|
+
const linkAttributes = category.children.length
|
|
98
|
+
? {
|
|
99
|
+
'aria-label': `Category: ${category.name}. ${category.children.length
|
|
100
|
+
} sub-categories`
|
|
101
|
+
}
|
|
102
|
+
: {};
|
|
103
|
+
|
|
104
|
+
return category.name != 'Auction' && (
|
|
105
|
+
<div
|
|
106
|
+
className={cn(itemClassName, sellerMegaMenuItemClassname)}
|
|
107
|
+
data-cy="SellerMegaMenu-SellerMegaMenuItem-sellerMegaMenuItem"
|
|
108
|
+
onMouseEnter={() => {
|
|
109
|
+
handleSellerSubMenuFocus();
|
|
110
|
+
handleMenuItemFocus();
|
|
111
|
+
}}
|
|
112
|
+
onFocus={() => {
|
|
113
|
+
handleSellerSubMenuFocus();
|
|
114
|
+
handleMenuItemFocus();
|
|
115
|
+
}}
|
|
116
|
+
onTouchStart={() => {
|
|
117
|
+
handleSellerSubMenuFocus();
|
|
118
|
+
handleMenuItemFocus();
|
|
119
|
+
}}
|
|
120
|
+
onMouseLeave={e => {
|
|
121
|
+
handleClickOutside(e);
|
|
122
|
+
handleCloseSellerSubMenu();
|
|
123
|
+
}}
|
|
124
|
+
>
|
|
125
|
+
<Link
|
|
126
|
+
{...linkAttributes}
|
|
127
|
+
onKeyDown={handleKeyDown}
|
|
128
|
+
className={cn(
|
|
129
|
+
isActive ? classes.sellerMegaMenuLinkActive : classes.sellerMegaMenuLink,
|
|
130
|
+
titleClassName,
|
|
131
|
+
'flex items-center'
|
|
132
|
+
)}
|
|
133
|
+
data-cy="SellerMegaMenu-SellerMegaMenuItem-link"
|
|
134
|
+
to={'/seller/' + seller?.url_key + categoryUrl}
|
|
135
|
+
onClick={onNavigate}
|
|
136
|
+
>
|
|
137
|
+
{category.name}
|
|
138
|
+
{/* {maybeDownArrowIcon} */}
|
|
139
|
+
</Link>
|
|
140
|
+
{children}
|
|
141
|
+
</div>
|
|
142
|
+
);
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export default SellerMegaMenuItem;
|
|
146
|
+
|
|
147
|
+
SellerMegaMenuItem.propTypes = {
|
|
148
|
+
category: PropTypes.shape({
|
|
149
|
+
children: PropTypes.array,
|
|
150
|
+
uid: PropTypes.string.isRequired,
|
|
151
|
+
include_in_menu: PropTypes.number,
|
|
152
|
+
isActive: PropTypes.bool.isRequired,
|
|
153
|
+
name: PropTypes.string.isRequired,
|
|
154
|
+
path: PropTypes.array.isRequired,
|
|
155
|
+
position: PropTypes.number.isRequired,
|
|
156
|
+
url_path: PropTypes.string.isRequired
|
|
157
|
+
}).isRequired,
|
|
158
|
+
activeCategoryId: PropTypes.string,
|
|
159
|
+
mainNavWidth: PropTypes.number.isRequired,
|
|
160
|
+
categoryUrlSuffix: PropTypes.string,
|
|
161
|
+
onNavigate: PropTypes.func.isRequired,
|
|
162
|
+
handleSellerSubMenuFocus: PropTypes.func.isRequired,
|
|
163
|
+
handleClickOutside: PropTypes.func.isRequired
|
|
164
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.sellerMegaMenuItem {
|
|
2
|
+
/* composes: px-3 from global;
|
|
3
|
+
composes: py-0 from global; */
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.sellerMegaMenuLink {
|
|
7
|
+
composes: items-center from global;
|
|
8
|
+
composes: inline-flex from global;
|
|
9
|
+
/* min-height: 5rem; */
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.sellerMegaMenuLinkActive {
|
|
13
|
+
composes: sellerMegaMenuLink;
|
|
14
|
+
composes: underline from global;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.sellerMegaMenuItem_active {
|
|
18
|
+
composes: sellerMegaMenuItem;
|
|
19
|
+
composes: flex from global;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.arrowDown {
|
|
23
|
+
composes: leading-[0] from global;
|
|
24
|
+
composes: pl-2xs from global;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* TODO @TW: cannot compose */
|
|
28
|
+
.sellerMegaMenuItem:hover .sellerMegaMenuLink,
|
|
29
|
+
.sellerMegaMenuItem:focus .sellerMegaMenuLink {
|
|
30
|
+
text-decoration: underline;
|
|
31
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
import { useSellerSubMenu } from '@riosst100/pwa-marketplace/src/talons/SellerMegaMenu/useSellerSubMenu';
|
|
5
|
+
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import defaultClasses from './sellerSubmenu.module.css';
|
|
8
|
+
import SellerSubmenuColumn from './sellerSubmenuColumn';
|
|
9
|
+
import ShopByColumn from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/MegaMenu/shopByColumn';
|
|
10
|
+
import CustomSubmenuColumn from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/MegaMenu/customSubmenuColumn';
|
|
11
|
+
import cn from 'classnames';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The Submenu component displays sellerSubmenu in mega menu
|
|
15
|
+
*
|
|
16
|
+
* @param {array} props.items - categories to display
|
|
17
|
+
* @param {int} props.mainNavWidth - width of the main nav. It's used for setting min-width of the sellerSubmenu
|
|
18
|
+
* @param {function} props.onNavigate - function called when clicking on Link
|
|
19
|
+
*/
|
|
20
|
+
const SellerSubmenu = props => {
|
|
21
|
+
const {
|
|
22
|
+
items,
|
|
23
|
+
shopByItems,
|
|
24
|
+
mainNavWidth,
|
|
25
|
+
seller,
|
|
26
|
+
isFocused,
|
|
27
|
+
sellerSubMenuState,
|
|
28
|
+
handleCloseSellerSubMenu,
|
|
29
|
+
categoryUrlSuffix,
|
|
30
|
+
parentCategory,
|
|
31
|
+
onNavigate,
|
|
32
|
+
arrow
|
|
33
|
+
} = props;
|
|
34
|
+
const PADDING_OFFSET = 20;
|
|
35
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
36
|
+
|
|
37
|
+
const talonProps = useSellerSubMenu({
|
|
38
|
+
isFocused,
|
|
39
|
+
sellerSubMenuState,
|
|
40
|
+
handleCloseSellerSubMenu
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const { isSellerSubMenuActive } = talonProps;
|
|
44
|
+
|
|
45
|
+
const subMenuClassname = isSellerSubMenuActive
|
|
46
|
+
? classes.sellerSubmenu_active
|
|
47
|
+
: classes.sellerSubmenu_inactive;
|
|
48
|
+
|
|
49
|
+
const subMenus = items.map((category, index) => {
|
|
50
|
+
const keyboardProps =
|
|
51
|
+
index === items.length - 1 ? talonProps.keyboardProps : {};
|
|
52
|
+
return (
|
|
53
|
+
<SellerSubmenuColumn
|
|
54
|
+
index={index}
|
|
55
|
+
keyboardProps={keyboardProps}
|
|
56
|
+
key={category.uid}
|
|
57
|
+
category={category}
|
|
58
|
+
seller={seller}
|
|
59
|
+
categoryUrlSuffix={categoryUrlSuffix}
|
|
60
|
+
onNavigate={onNavigate}
|
|
61
|
+
arrow={arrow}
|
|
62
|
+
handleCloseSellerSubMenu={handleCloseSellerSubMenu}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const shopBy = shopByItems.map((shopBy, index) => {
|
|
68
|
+
const keyboardProps =
|
|
69
|
+
index === shopByItems.length - 1 ? talonProps.keyboardProps : {};
|
|
70
|
+
return (
|
|
71
|
+
<ShopByColumn
|
|
72
|
+
index={index}
|
|
73
|
+
keyboardProps={keyboardProps}
|
|
74
|
+
key={shopBy.code}
|
|
75
|
+
category={parentCategory}
|
|
76
|
+
shopBy={shopBy}
|
|
77
|
+
categoryUrlSuffix={categoryUrlSuffix}
|
|
78
|
+
onNavigate={onNavigate}
|
|
79
|
+
handleCloseSellerSubMenu={handleCloseSellerSubMenu}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<div className={subMenuClassname}>
|
|
86
|
+
<div
|
|
87
|
+
className={cn(
|
|
88
|
+
classes.sellerSubmenuContainer,
|
|
89
|
+
// 'grid grid-cols-4'
|
|
90
|
+
)}
|
|
91
|
+
>
|
|
92
|
+
<div
|
|
93
|
+
className={cn(
|
|
94
|
+
classes.sellerSubmenuItems,
|
|
95
|
+
'grid grid-cols-6',
|
|
96
|
+
)}
|
|
97
|
+
>
|
|
98
|
+
{subMenus}
|
|
99
|
+
{shopBy}
|
|
100
|
+
</div>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default SellerSubmenu;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
.sellerSubmenu {
|
|
2
|
+
composes: absolute from global;
|
|
3
|
+
composes: bg-white from global;
|
|
4
|
+
composes: left-0 from global;
|
|
5
|
+
composes: px-3 from global;
|
|
6
|
+
composes: py-1 from global;
|
|
7
|
+
composes: right-0 from global;
|
|
8
|
+
top: 608px;
|
|
9
|
+
/* box-shadow: 0 3px rgb(var(--venia-global-color-gray-100)); */
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.sellerSubmenuContainer {
|
|
13
|
+
composes: w-full from global;
|
|
14
|
+
composes: max-w-[1180px] from global;
|
|
15
|
+
composes: mx-[auto] from global;
|
|
16
|
+
composes: gap-[15px] from global;
|
|
17
|
+
composes: max-h-[50vh] from global;
|
|
18
|
+
composes: overflow-y-auto from global;
|
|
19
|
+
composes: rounded-[6px] from global;
|
|
20
|
+
composes: border from global;
|
|
21
|
+
composes: border-solid from global;
|
|
22
|
+
composes: border-gray-100 from global;
|
|
23
|
+
z-index: 99;
|
|
24
|
+
background-color: white;
|
|
25
|
+
position: relative;
|
|
26
|
+
/* box-shadow: 0 3px 6px rgb(var(--venia-global-color-gray-100)); */
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* TODO @TW: cannot compose */
|
|
30
|
+
.sellerSubmenu::before {
|
|
31
|
+
/* box-shadow: inset 0 2px rgb(var(--venia-global-color-gray-100)); */
|
|
32
|
+
content: '';
|
|
33
|
+
height: 1px;
|
|
34
|
+
left: 0;
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
position: absolute;
|
|
37
|
+
right: 0;
|
|
38
|
+
top: 0;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.sellerSubmenu_inactive {
|
|
42
|
+
composes: sellerSubmenu;
|
|
43
|
+
composes: hidden from global;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sellerSubmenu_active {
|
|
47
|
+
composes: sellerSubmenu;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.sellerSubmenuItems {
|
|
51
|
+
composes: grid from global;
|
|
52
|
+
composes: grid-cols-6 pb-2 from global;
|
|
53
|
+
/* composes: justify-between from global; */
|
|
54
|
+
/* composes: ml-auto from global; */
|
|
55
|
+
/* composes: mr-auto from global; */
|
|
56
|
+
/* composes: flex-col from global; */
|
|
57
|
+
}
|