@riosst100/pwa-marketplace 3.1.2 → 3.1.4
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/BrandLandingPage/brandLanding.js +0 -5
- package/src/components/CheckoutHeader/accountTrigger.js +104 -0
- package/src/components/CheckoutHeader/cartTrigger.js +110 -0
- package/src/components/CheckoutHeader/cartTrigger.module.css +47 -0
- package/src/components/CheckoutHeader/storeSwitcher.js +119 -0
- package/src/components/CheckoutHeader/storeSwitcher.module.css +107 -0
- package/src/components/CheckoutHeader/switcherItem.js +47 -0
- package/src/components/CheckoutHeader/wishlistTrigger.js +23 -0
- package/src/components/FilterListContent/filterListPage.js +0 -25
- package/src/components/FilterTop/filterTop.js +1 -1
- package/src/components/HelpCenter/helpCenter.js +151 -0
- package/src/components/HelpCenter/helpcenter.module.css +225 -0
- package/src/components/HelpCenter/index.js +1 -0
- package/src/components/HelpCenter/questionDetail.js +89 -0
- package/src/components/ProductContent/productContent.js +1 -1
- package/src/components/RMAPage/components/productItem.css +15 -0
- package/src/components/RMAPage/components/productItem.module.css +15 -0
- package/src/components/RelatedProducts/index.js +1 -0
- package/src/components/RelatedProducts/relatedProducts.js +44 -0
- package/src/components/SellerMegaMenu/__tests__/MegaMenu.spec.js +91 -0
- package/src/components/SellerMegaMenu/__tests__/MegaMenuItem.spec.js +123 -0
- package/src/components/SellerMegaMenu/__tests__/Submenu.spec.js +61 -0
- package/src/components/SellerMegaMenu/__tests__/SubmenuColumn.spec.js +50 -0
- package/src/components/SellerMegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -0
- package/src/components/SellerMegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -0
- package/src/components/SellerMegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -0
- package/src/components/SellerMegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -0
- package/src/components/SellerMegaMenu/customSubmenuColumn.js +75 -0
- package/src/components/SellerMegaMenu/customSubmenuColumn.module.css +29 -0
- package/src/components/SellerMegaMenu/shopByColumn.js +121 -0
- package/src/components/SellerProducts/productContent.js +2 -4
- package/src/components/SetsData/setsData.js +0 -25
- package/src/components/ShopBy/shopBy.js +3 -78
- package/src/components/ShopBySets/shopBySets.js +2 -2
- package/src/components/ShowMore/showMore.js +3 -49
- package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderHistoryPage.gql.js +1 -15
- package/src/overwrites/peregrine/lib/talons/OrderHistoryPage/orderRow.gql.js +0 -11
- package/src/overwrites/peregrine/lib/talons/RelatedProducts/productReview.gql.js +89 -0
- package/src/overwrites/peregrine/lib/talons/RelatedProducts/useRelatedProducts.js +833 -0
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/categoryContent.gql.js +0 -16
- package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js +1 -5
- package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +118 -62
- package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +3 -50
- package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +1 -7
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/editModal.js +41 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/index.js +1 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productDetail.js +80 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productDetail.module.css +33 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productForm.js +153 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/EditModal/productForm.module.css +52 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/errorMessage.js +31 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/errorMessage.module.css +13 -0
- package/src/overwrites/venia-ui/lib/components/CartPage/ProductListingBySeller/quantity.js +40 -0
- package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +21 -92
- package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +6 -2
- package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +0 -21
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/Reviews/reviewModal.js +8 -0
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderHistoryPage.js +3 -3
- package/src/overwrites/venia-ui/lib/components/OrderHistoryPage/orderRow.js +4 -85
- package/src/talons/HelpCenter/helpCenter.gql.js +93 -0
- package/src/talons/HelpCenter/useHelpCenter.js +59 -0
- package/src/talons/ProductContent/productContent.gql.js +0 -16
- package/src/talons/ProductContent/useProductContent.js +0 -4
- package/src/talons/RelatedProducts/relatedProducts.gql.js +209 -0
- package/src/talons/RelatedProducts/useRelatedProducts.js +112 -0
- package/src/talons/SellerProducts/productContent.gql.js +1 -17
- package/src/talons/SellerProducts/useProductContent.js +1 -36
- package/src/components/AttributesBlock/attributesBlock.js +0 -54
- package/src/components/AttributesBlock/attributesBlock.module.css +0 -28
- package/src/components/ShopBy/shopBy copy.js +0 -172
- package/src/components/SubCategory/customSubCategory.js +0 -45
- package/src/components/SubCategory/customSubCategory.module.css +0 -22
- package/src/talons/AttributesBlock/attributesBlock.gql.js +0 -15
- package/src/talons/AttributesBlock/useAttributesBlock.js +0 -38
- package/src/talons/SubCategory/useCustomSubCategory.js +0 -50
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
import { act } from 'react-test-renderer';
|
|
4
|
+
|
|
5
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
6
|
+
|
|
7
|
+
import MegaMenuItem from '../megaMenuItem';
|
|
8
|
+
|
|
9
|
+
jest.mock('../../../classify');
|
|
10
|
+
jest.mock('../../Icon', () => props => <mock-Icon {...props} />);
|
|
11
|
+
jest.mock('../submenu', () => props => <mock-Submenu {...props} />);
|
|
12
|
+
jest.mock('react', () => {
|
|
13
|
+
const React = jest.requireActual('react');
|
|
14
|
+
const memoSpy = jest.spyOn(React, 'useMemo');
|
|
15
|
+
|
|
16
|
+
return Object.assign(React, {
|
|
17
|
+
useMemo: memoSpy
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const mockHandleKeyDown = jest.fn();
|
|
22
|
+
|
|
23
|
+
jest.mock('react-router-dom', () => ({
|
|
24
|
+
Link: jest.fn(() => props => <mock-Link {...props} />)
|
|
25
|
+
}));
|
|
26
|
+
|
|
27
|
+
jest.mock('@magento/peregrine/lib/talons/MegaMenu/useMegaMenuItem', () => ({
|
|
28
|
+
useMegaMenuItem: jest.fn(() => {
|
|
29
|
+
return {
|
|
30
|
+
isFocused: false,
|
|
31
|
+
isActive: false,
|
|
32
|
+
handleMenuItemFocus: jest.fn(),
|
|
33
|
+
handleCloseSubMenu: jest.fn(),
|
|
34
|
+
isMenuActive: false,
|
|
35
|
+
handleKeyDown: mockHandleKeyDown
|
|
36
|
+
};
|
|
37
|
+
})
|
|
38
|
+
}));
|
|
39
|
+
|
|
40
|
+
let inputProps = {};
|
|
41
|
+
|
|
42
|
+
const Component = () => {
|
|
43
|
+
return <MegaMenuItem {...inputProps} />;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const givenDefaultValues = () => {
|
|
47
|
+
inputProps = {
|
|
48
|
+
activeCategoryId: 1,
|
|
49
|
+
category: {
|
|
50
|
+
id: 1,
|
|
51
|
+
name: 'Women',
|
|
52
|
+
url_path: 'women',
|
|
53
|
+
isActive: true,
|
|
54
|
+
children: [
|
|
55
|
+
{
|
|
56
|
+
id: 2,
|
|
57
|
+
name: 'Bottoms',
|
|
58
|
+
url_path: 'bottoms',
|
|
59
|
+
children: []
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 3,
|
|
63
|
+
name: 'Tops',
|
|
64
|
+
url_path: 'tops',
|
|
65
|
+
isActive: false,
|
|
66
|
+
children: []
|
|
67
|
+
}
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
rootCategoryName: 'Clothing',
|
|
71
|
+
categoryUrlSuffix: '.html',
|
|
72
|
+
mainNavWidth: 200,
|
|
73
|
+
subMenuState: 'test',
|
|
74
|
+
disableFocus: false
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
describe('Mega menu item renders correctly', () => {
|
|
79
|
+
beforeEach(() => {
|
|
80
|
+
givenDefaultValues();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('it renders correctly', () => {
|
|
84
|
+
const instance = createTestInstance(<Component />);
|
|
85
|
+
|
|
86
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('it marks the active category', () => {
|
|
90
|
+
const { root } = createTestInstance(<Component />);
|
|
91
|
+
|
|
92
|
+
expect(root.findByType(Link).props.className).toEqual('megaMenuLink');
|
|
93
|
+
expect(root.findByType(Link).props.to).toEqual('/women.html');
|
|
94
|
+
expect(root.findByType(Link).props.children[0]).toEqual('Women');
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should call a11yClick', () => {
|
|
98
|
+
const { root } = createTestInstance(<Component />);
|
|
99
|
+
|
|
100
|
+
act(() => {
|
|
101
|
+
root.findByType(Link).props.onKeyDown();
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(mockHandleKeyDown).toHaveBeenCalled();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
test('it does not render submenu when item does not have children', () => {
|
|
108
|
+
const categoryWithoutChildren = {
|
|
109
|
+
id: 3,
|
|
110
|
+
name: 'Tops',
|
|
111
|
+
url_path: 'tops',
|
|
112
|
+
isActive: false,
|
|
113
|
+
children: []
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
const instance = createTestInstance(
|
|
117
|
+
<Component category={categoryWithoutChildren} />
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
expect(instance.toJSON().children.length).toEqual(1);
|
|
121
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import Submenu from '../submenu';
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../classify');
|
|
8
|
+
jest.mock('../submenuColumn', () => props => <mock-SubmenuColumn {...props} />);
|
|
9
|
+
jest.mock('react', () => {
|
|
10
|
+
const React = jest.requireActual('react');
|
|
11
|
+
const callbackSpy = jest.spyOn(React, 'useCallback');
|
|
12
|
+
|
|
13
|
+
return Object.assign(React, {
|
|
14
|
+
callbackSpy: callbackSpy
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const handleCloseSubMenu = jest.fn().mockName('handleCloseSubMenu');
|
|
19
|
+
|
|
20
|
+
describe('Submenu renders correctly', () => {
|
|
21
|
+
const props = {
|
|
22
|
+
items: [
|
|
23
|
+
{
|
|
24
|
+
id: 1,
|
|
25
|
+
name: 'Bottoms',
|
|
26
|
+
url_path: 'bottoms',
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
id: 3,
|
|
30
|
+
name: 'Pants',
|
|
31
|
+
url_path: 'pants',
|
|
32
|
+
isActive: false,
|
|
33
|
+
children: []
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
id: 2,
|
|
39
|
+
name: 'Tops',
|
|
40
|
+
url_path: 'tops',
|
|
41
|
+
isActive: false,
|
|
42
|
+
children: []
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
rootCategoryName: 'Clothing',
|
|
46
|
+
firstLevelCategoryName: 'Women',
|
|
47
|
+
categoryUrlSuffix: '.html',
|
|
48
|
+
handleCloseSubMenu,
|
|
49
|
+
isFocused: false,
|
|
50
|
+
subMenuState: false
|
|
51
|
+
};
|
|
52
|
+
test('it renders correctly', () => {
|
|
53
|
+
const instance = createTestInstance(
|
|
54
|
+
<MemoryRouter>
|
|
55
|
+
<Submenu {...props} />
|
|
56
|
+
</MemoryRouter>
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
60
|
+
});
|
|
61
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { createTestInstance } from '@magento/peregrine';
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
+
|
|
5
|
+
import SubmenuColumn from '../submenuColumn';
|
|
6
|
+
|
|
7
|
+
jest.mock('../../../classify');
|
|
8
|
+
|
|
9
|
+
describe('Submenu column renders correctly', () => {
|
|
10
|
+
const props = {
|
|
11
|
+
category: {
|
|
12
|
+
id: 1,
|
|
13
|
+
name: 'Pants',
|
|
14
|
+
url_path: 'pants',
|
|
15
|
+
children: [
|
|
16
|
+
{
|
|
17
|
+
id: 2,
|
|
18
|
+
name: 'Jeans',
|
|
19
|
+
url_path: 'jeans',
|
|
20
|
+
isActive: true,
|
|
21
|
+
children: []
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
categoryUrlSuffix: '.html'
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
test('it renders correctly', () => {
|
|
29
|
+
const instance = createTestInstance(
|
|
30
|
+
<MemoryRouter>
|
|
31
|
+
<SubmenuColumn {...props} />
|
|
32
|
+
</MemoryRouter>
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
expect(instance.toJSON()).toMatchSnapshot();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('it renders active state', () => {
|
|
39
|
+
const instance = createTestInstance(
|
|
40
|
+
<MemoryRouter>
|
|
41
|
+
<SubmenuColumn {...props} />
|
|
42
|
+
</MemoryRouter>
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const activeLink = instance.root.findByProps({
|
|
46
|
+
className: 'linkActive'
|
|
47
|
+
});
|
|
48
|
+
expect(activeLink.props.children).toEqual('Jeans');
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`#MegaMenu renders empty div if not in viewport 1`] = `
|
|
4
|
+
<nav
|
|
5
|
+
className="megaMenu"
|
|
6
|
+
role="navigation"
|
|
7
|
+
/>
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
exports[`#MegaMenu renders menu if in viewport 1`] = `
|
|
11
|
+
<nav
|
|
12
|
+
className="megaMenu"
|
|
13
|
+
role="navigation"
|
|
14
|
+
>
|
|
15
|
+
<div
|
|
16
|
+
className="megaMenuItem"
|
|
17
|
+
onFocus={[Function]}
|
|
18
|
+
onMouseEnter={[Function]}
|
|
19
|
+
onMouseLeave={[Function]}
|
|
20
|
+
onTouchStart={[Function]}
|
|
21
|
+
>
|
|
22
|
+
<a
|
|
23
|
+
aria-label="Category: Women. 1 sub-categories"
|
|
24
|
+
className="megaMenuLink"
|
|
25
|
+
href="/women.html"
|
|
26
|
+
onClick={[Function]}
|
|
27
|
+
onKeyDown={[Function]}
|
|
28
|
+
>
|
|
29
|
+
Women
|
|
30
|
+
<span
|
|
31
|
+
className="arrowDown"
|
|
32
|
+
>
|
|
33
|
+
<svg
|
|
34
|
+
className="icon"
|
|
35
|
+
fill="none"
|
|
36
|
+
height={16}
|
|
37
|
+
stroke="currentColor"
|
|
38
|
+
strokeLinecap="round"
|
|
39
|
+
strokeLinejoin="round"
|
|
40
|
+
strokeWidth="2"
|
|
41
|
+
viewBox="0 0 24 24"
|
|
42
|
+
width={16}
|
|
43
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
44
|
+
>
|
|
45
|
+
<polyline
|
|
46
|
+
points="6 9 12 15 18 9"
|
|
47
|
+
/>
|
|
48
|
+
</svg>
|
|
49
|
+
</span>
|
|
50
|
+
</a>
|
|
51
|
+
<div
|
|
52
|
+
className="submenu_inactive"
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
className="submenuItems"
|
|
56
|
+
style={
|
|
57
|
+
Object {
|
|
58
|
+
"minWidth": 20,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
<div
|
|
63
|
+
className="submenuColumn"
|
|
64
|
+
>
|
|
65
|
+
<a
|
|
66
|
+
className="link"
|
|
67
|
+
href="/bottoms.html"
|
|
68
|
+
onClick={[Function]}
|
|
69
|
+
onKeyDown={[Function]}
|
|
70
|
+
>
|
|
71
|
+
<span
|
|
72
|
+
className="heading"
|
|
73
|
+
>
|
|
74
|
+
Bottoms
|
|
75
|
+
</span>
|
|
76
|
+
</a>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
</div>
|
|
80
|
+
</div>
|
|
81
|
+
<div
|
|
82
|
+
className="megaMenuItem"
|
|
83
|
+
onFocus={[Function]}
|
|
84
|
+
onMouseEnter={[Function]}
|
|
85
|
+
onMouseLeave={[Function]}
|
|
86
|
+
onTouchStart={[Function]}
|
|
87
|
+
>
|
|
88
|
+
<a
|
|
89
|
+
className="megaMenuLink"
|
|
90
|
+
href="/men.html"
|
|
91
|
+
onClick={[Function]}
|
|
92
|
+
onKeyDown={[Function]}
|
|
93
|
+
>
|
|
94
|
+
Men
|
|
95
|
+
</a>
|
|
96
|
+
</div>
|
|
97
|
+
<div
|
|
98
|
+
className="megaMenuItem"
|
|
99
|
+
onFocus={[Function]}
|
|
100
|
+
onMouseEnter={[Function]}
|
|
101
|
+
onMouseLeave={[Function]}
|
|
102
|
+
onTouchStart={[Function]}
|
|
103
|
+
>
|
|
104
|
+
<a
|
|
105
|
+
className="megaMenuLink"
|
|
106
|
+
href="/gear.html"
|
|
107
|
+
onClick={[Function]}
|
|
108
|
+
onKeyDown={[Function]}
|
|
109
|
+
>
|
|
110
|
+
Gear
|
|
111
|
+
</a>
|
|
112
|
+
</div>
|
|
113
|
+
</nav>
|
|
114
|
+
`;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Mega menu item renders correctly it does not render submenu when item does not have children 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="megaMenuItem"
|
|
6
|
+
onFocus={[Function]}
|
|
7
|
+
onMouseEnter={[Function]}
|
|
8
|
+
onMouseLeave={[Function]}
|
|
9
|
+
onTouchStart={[Function]}
|
|
10
|
+
>
|
|
11
|
+
<mock-Submenu
|
|
12
|
+
categoryUrlSuffix=".html"
|
|
13
|
+
handleCloseSubMenu={[MockFunction]}
|
|
14
|
+
isFocused={false}
|
|
15
|
+
items={
|
|
16
|
+
Array [
|
|
17
|
+
Object {
|
|
18
|
+
"children": Array [],
|
|
19
|
+
"id": 2,
|
|
20
|
+
"name": "Bottoms",
|
|
21
|
+
"url_path": "bottoms",
|
|
22
|
+
},
|
|
23
|
+
Object {
|
|
24
|
+
"children": Array [],
|
|
25
|
+
"id": 3,
|
|
26
|
+
"isActive": false,
|
|
27
|
+
"name": "Tops",
|
|
28
|
+
"url_path": "tops",
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
mainNavWidth={200}
|
|
33
|
+
subMenuState="test"
|
|
34
|
+
/>
|
|
35
|
+
</div>
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
exports[`Mega menu item renders correctly it renders correctly 1`] = `
|
|
39
|
+
<div
|
|
40
|
+
className="megaMenuItem"
|
|
41
|
+
onFocus={[Function]}
|
|
42
|
+
onMouseEnter={[Function]}
|
|
43
|
+
onMouseLeave={[Function]}
|
|
44
|
+
onTouchStart={[Function]}
|
|
45
|
+
>
|
|
46
|
+
<mock-Submenu
|
|
47
|
+
categoryUrlSuffix=".html"
|
|
48
|
+
handleCloseSubMenu={[MockFunction]}
|
|
49
|
+
isFocused={false}
|
|
50
|
+
items={
|
|
51
|
+
Array [
|
|
52
|
+
Object {
|
|
53
|
+
"children": Array [],
|
|
54
|
+
"id": 2,
|
|
55
|
+
"name": "Bottoms",
|
|
56
|
+
"url_path": "bottoms",
|
|
57
|
+
},
|
|
58
|
+
Object {
|
|
59
|
+
"children": Array [],
|
|
60
|
+
"id": 3,
|
|
61
|
+
"isActive": false,
|
|
62
|
+
"name": "Tops",
|
|
63
|
+
"url_path": "tops",
|
|
64
|
+
},
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
mainNavWidth={200}
|
|
68
|
+
subMenuState="test"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
`;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Submenu renders correctly it renders correctly 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="submenu_inactive"
|
|
6
|
+
>
|
|
7
|
+
<div
|
|
8
|
+
className="submenuItems"
|
|
9
|
+
style={
|
|
10
|
+
Object {
|
|
11
|
+
"minWidth": NaN,
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
>
|
|
15
|
+
<mock-SubmenuColumn
|
|
16
|
+
category={
|
|
17
|
+
Object {
|
|
18
|
+
"children": Array [
|
|
19
|
+
Object {
|
|
20
|
+
"children": Array [],
|
|
21
|
+
"id": 3,
|
|
22
|
+
"isActive": false,
|
|
23
|
+
"name": "Pants",
|
|
24
|
+
"url_path": "pants",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
"id": 1,
|
|
28
|
+
"name": "Bottoms",
|
|
29
|
+
"url_path": "bottoms",
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
categoryUrlSuffix=".html"
|
|
33
|
+
handleCloseSubMenu={[MockFunction handleCloseSubMenu]}
|
|
34
|
+
index={0}
|
|
35
|
+
keyboardProps={Object {}}
|
|
36
|
+
/>
|
|
37
|
+
<mock-SubmenuColumn
|
|
38
|
+
category={
|
|
39
|
+
Object {
|
|
40
|
+
"children": Array [],
|
|
41
|
+
"id": 2,
|
|
42
|
+
"isActive": false,
|
|
43
|
+
"name": "Tops",
|
|
44
|
+
"url_path": "tops",
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
categoryUrlSuffix=".html"
|
|
48
|
+
handleCloseSubMenu={[MockFunction handleCloseSubMenu]}
|
|
49
|
+
index={1}
|
|
50
|
+
keyboardProps={
|
|
51
|
+
Object {
|
|
52
|
+
"onKeyDown": [Function],
|
|
53
|
+
"onKeyUp": undefined,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
`;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Submenu column renders correctly it renders correctly 1`] = `
|
|
4
|
+
<div
|
|
5
|
+
className="submenuColumn"
|
|
6
|
+
>
|
|
7
|
+
<a
|
|
8
|
+
className="link"
|
|
9
|
+
href="/pants.html"
|
|
10
|
+
onClick={[Function]}
|
|
11
|
+
>
|
|
12
|
+
<span
|
|
13
|
+
className="heading"
|
|
14
|
+
>
|
|
15
|
+
Pants
|
|
16
|
+
</span>
|
|
17
|
+
</a>
|
|
18
|
+
<ul
|
|
19
|
+
className="submenuChild"
|
|
20
|
+
>
|
|
21
|
+
<li
|
|
22
|
+
className="submenuChildItem"
|
|
23
|
+
>
|
|
24
|
+
<a
|
|
25
|
+
className="linkActive"
|
|
26
|
+
href="/jeans.html"
|
|
27
|
+
onClick={[Function]}
|
|
28
|
+
>
|
|
29
|
+
Jeans
|
|
30
|
+
</a>
|
|
31
|
+
</li>
|
|
32
|
+
</ul>
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import resourceUrl from '@magento/peregrine/lib/util/makeUrl';
|
|
5
|
+
|
|
6
|
+
import { useStyle } from '@magento/venia-ui/lib/classify';
|
|
7
|
+
import defaultClasses from './customSubmenuColumn.module.css';
|
|
8
|
+
import cn from 'classnames';
|
|
9
|
+
|
|
10
|
+
const CustomSubmenuColumn = props => {
|
|
11
|
+
const {
|
|
12
|
+
category,
|
|
13
|
+
categoryUrlSuffix,
|
|
14
|
+
onNavigate,
|
|
15
|
+
handleCloseSubMenu,
|
|
16
|
+
customMenuItems,
|
|
17
|
+
toggleCustomMenu
|
|
18
|
+
} = props;
|
|
19
|
+
|
|
20
|
+
const classes = useStyle(defaultClasses, props.classes);
|
|
21
|
+
|
|
22
|
+
let children = null;
|
|
23
|
+
|
|
24
|
+
if (customMenuItems.length) {
|
|
25
|
+
const childrenItems = customMenuItems.map((submenu, index) => {
|
|
26
|
+
const { name, path } = submenu;
|
|
27
|
+
|
|
28
|
+
const categoryUrl = resourceUrl(
|
|
29
|
+
`/${path}`
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<li key={index} className={cn(classes.submenuChildItem, 'mt-1')}>
|
|
34
|
+
<Link
|
|
35
|
+
className={classes.link}
|
|
36
|
+
data-cy="MegaMenu-CustomSubmenuColumn-link"
|
|
37
|
+
to={categoryUrl}
|
|
38
|
+
onClick={() => {
|
|
39
|
+
handleCloseSubMenu();
|
|
40
|
+
onNavigate();
|
|
41
|
+
toggleCustomMenu();
|
|
42
|
+
}}
|
|
43
|
+
>
|
|
44
|
+
{name}
|
|
45
|
+
</Link>
|
|
46
|
+
</li>
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
children = <>
|
|
51
|
+
<ul className={cn(classes.submenuChild, 'pt-1')}><span className={classes.heading}>Categories</span>{childrenItems}</ul>
|
|
52
|
+
</>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return children;
|
|
56
|
+
// return (
|
|
57
|
+
// <div className={classes.submenuColumn}>
|
|
58
|
+
// <Link
|
|
59
|
+
// // {...keyboardProps}
|
|
60
|
+
// className={classes.link}
|
|
61
|
+
// data-cy="MegaMenu-SubmenuColumn-link"
|
|
62
|
+
// // to={categoryUrl}
|
|
63
|
+
// // onClick={() => {
|
|
64
|
+
// // handleCloseSubMenu();
|
|
65
|
+
// // onNavigate();
|
|
66
|
+
// // }}
|
|
67
|
+
// >
|
|
68
|
+
// <span className={classes.heading}>{category.name}</span>
|
|
69
|
+
// </Link>
|
|
70
|
+
// {children}
|
|
71
|
+
// </div>
|
|
72
|
+
// );
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
export default CustomSubmenuColumn;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.customSubmenuColumn {
|
|
2
|
+
/* composes: max-w-[235px] from global; */
|
|
3
|
+
composes: p-2 from global;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.heading {
|
|
7
|
+
composes: font-medium from global;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.link {
|
|
11
|
+
composes: whitespace-nowrap from global;
|
|
12
|
+
|
|
13
|
+
composes: focus_underline from global;
|
|
14
|
+
|
|
15
|
+
composes: hover_underline from global;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.linkActive {
|
|
19
|
+
composes: underline from global;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.submenuChild {
|
|
23
|
+
margin-left: 15px;
|
|
24
|
+
composes: mt-0 from global;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.submenuChildItem {
|
|
28
|
+
composes: mb-0 from global;
|
|
29
|
+
}
|