@riosst100/pwa-marketplace 1.2.4 → 1.2.5

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.
Files changed (70) hide show
  1. package/package.json +1 -1
  2. package/src/componentOverrideMapping.js +2 -1
  3. package/src/components/Filter/index.js +7 -7
  4. package/src/components/OperatingHours/index.js +1 -0
  5. package/src/components/OperatingHours/operatingHours.js +32 -0
  6. package/src/components/Pagination/index.js +26 -17
  7. package/src/components/Search/index.js +1 -1
  8. package/src/components/Seller/seller.js +137 -46
  9. package/src/components/Seller/sellerAddressCard.js +48 -0
  10. package/src/components/SellerDetail/index.js +1 -0
  11. package/src/components/SellerDetail/sellerDetail.js +158 -0
  12. package/src/components/SellerInformation/sellerInformation.js +51 -26
  13. package/src/components/SellerLocation/sellerLocation.js +6 -2
  14. package/src/components/SellerLocation/sellerLocationItem.js +6 -8
  15. package/src/components/SellerProducts/sellerProducts.js +33 -12
  16. package/src/components/SellerReview/sellerReview.js +29 -29
  17. package/src/components/SellerReviewItem/sellerReviewItem.js +8 -8
  18. package/src/components/SortBy/index.js +13 -5
  19. package/src/components/commons/Tabs/index.js +11 -9
  20. package/src/overwrites/venia-ui/lib/components/Header/header.js +46 -34
  21. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenu.spec.js +91 -0
  22. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/MegaMenuItem.spec.js +123 -0
  23. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/Submenu.spec.js +61 -0
  24. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/SubmenuColumn.spec.js +50 -0
  25. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenu.spec.js.snap +114 -0
  26. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/MegaMenuItem.spec.js.snap +71 -0
  27. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/Submenu.spec.js.snap +59 -0
  28. package/src/overwrites/venia-ui/lib/components/MegaMenu/__tests__/__snapshots__/SubmenuColumn.spec.js.snap +34 -0
  29. package/src/overwrites/venia-ui/lib/components/MegaMenu/index.js +1 -0
  30. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.js +90 -0
  31. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenu.module.css +12 -0
  32. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +156 -0
  33. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.module.css +31 -0
  34. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.js +89 -0
  35. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +43 -0
  36. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.js +99 -0
  37. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenuColumn.module.css +28 -0
  38. package/src/overwrites/venia-ui/lib/components/SearchBar/__stories__/searchBar.js +11 -0
  39. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/searchField.spec.js.snap +72 -0
  40. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedCategories.spec.js.snap +30 -0
  41. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProduct.spec.js.snap +69 -0
  42. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestedProducts.spec.js.snap +7 -0
  43. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/__snapshots__/suggestions.spec.js.snap +12 -0
  44. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/autocomplete.spec.js +52 -0
  45. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchBar.spec.js +82 -0
  46. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/searchField.spec.js +87 -0
  47. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedCategories.spec.js +45 -0
  48. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProduct.spec.js +43 -0
  49. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestedProducts.spec.js +45 -0
  50. package/src/overwrites/venia-ui/lib/components/SearchBar/__tests__/suggestions.spec.js +110 -0
  51. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.js +172 -0
  52. package/src/overwrites/venia-ui/lib/components/SearchBar/autocomplete.module.css +62 -0
  53. package/src/overwrites/venia-ui/lib/components/SearchBar/index.js +1 -0
  54. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.js +74 -0
  55. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +50 -0
  56. package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +40 -0
  57. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.js +48 -0
  58. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategories.module.css +13 -0
  59. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.js +49 -0
  60. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedCategory.module.css +0 -0
  61. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.js +97 -0
  62. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProduct.module.css +24 -0
  63. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.js +43 -0
  64. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestedProducts.module.css +13 -0
  65. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.js +75 -0
  66. package/src/overwrites/venia-ui/lib/components/SearchBar/suggestions.module.css +6 -0
  67. package/src/talons/Seller/seller.gql.js +70 -5
  68. package/src/talons/Seller/useSeller.js +6 -1
  69. package/src/talons/SellerProducts/useSellerProducts.js +129 -0
  70. package/src/theme/vars.js +7 -0
@@ -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 @@
1
+ export { default } from './megaMenu';
@@ -0,0 +1,90 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+
3
+ import { useIsInViewport } from '@magento/peregrine/lib/hooks/useIsInViewport';
4
+ import { useMegaMenu } from '@magento/peregrine/lib/talons/MegaMenu/useMegaMenu';
5
+ import { useStyle } from '@magento/venia-ui/lib/classify';
6
+
7
+ import MegaMenuItem from './megaMenuItem';
8
+ import defaultClasses from './megaMenu.module.css';
9
+ import cn from 'classnames';
10
+
11
+ /**
12
+ * The MegaMenu component displays menu with categories on desktop devices
13
+ */
14
+ const MegaMenu = (props) => {
15
+ const { rootClassName, megaMenuItemClassname, titleClassName } = props
16
+ const mainNavRef = useRef(null);
17
+
18
+ const classes = useStyle(defaultClasses, props.classes);
19
+ // const rootClass = cn(classes.megaMenu, rootClassName);
20
+ const rootClass = cn('xs_hidden xl_flex flex-grow justify-self-center', rootClassName);
21
+
22
+ const {
23
+ megaMenuData,
24
+ activeCategoryId,
25
+ subMenuState,
26
+ disableFocus,
27
+ handleSubMenuFocus,
28
+ categoryUrlSuffix,
29
+ handleNavigate,
30
+ handleClickOutside
31
+ } = useMegaMenu({ mainNavRef });
32
+
33
+ const [mainNavWidth, setMainNavWidth] = useState(0);
34
+ const shouldRenderItems = useIsInViewport({
35
+ elementRef: mainNavRef
36
+ });
37
+
38
+ useEffect(() => {
39
+ const handleResize = () => {
40
+ const navWidth = mainNavRef.current
41
+ ? mainNavRef.current.offsetWidth
42
+ : null;
43
+
44
+ setMainNavWidth(navWidth);
45
+ };
46
+
47
+ window.addEventListener('resize', handleResize);
48
+
49
+ handleResize();
50
+
51
+ return () => {
52
+ window.removeEventListener('resize', handleResize);
53
+ };
54
+ });
55
+
56
+ const items = megaMenuData.children
57
+ ? megaMenuData.children.map(category => {
58
+ return (
59
+ <MegaMenuItem
60
+ category={category}
61
+ activeCategoryId={activeCategoryId}
62
+ categoryUrlSuffix={categoryUrlSuffix}
63
+ mainNavWidth={mainNavWidth}
64
+ onNavigate={handleNavigate}
65
+ key={category.uid}
66
+ subMenuState={subMenuState}
67
+ disableFocus={disableFocus}
68
+ handleSubMenuFocus={handleSubMenuFocus}
69
+ handleClickOutside={handleClickOutside}
70
+ megaMenuItemClassname={megaMenuItemClassname}
71
+ titleClassName={titleClassName}
72
+ />
73
+ );
74
+ })
75
+ : null;
76
+
77
+ return (
78
+ <nav
79
+ ref={mainNavRef}
80
+ className={rootClass}
81
+ data-cy="MegaMenu-megaMenu"
82
+ role="navigation"
83
+ onFocus={handleSubMenuFocus}
84
+ >
85
+ {shouldRenderItems ? items : null}
86
+ </nav>
87
+ );
88
+ };
89
+
90
+ export default MegaMenu;
@@ -0,0 +1,12 @@
1
+ .megaMenu {
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
+ .megaMenu {
11
+ composes: lg_flex from global;
12
+ }
@@ -0,0 +1,156 @@
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 { useMegaMenuItem } from '@magento/peregrine/lib/talons/MegaMenu/useMegaMenuItem';
8
+
9
+ import { useStyle } from '@magento/venia-ui/lib/classify';
10
+ import defaultClasses from './megaMenuItem.module.css';
11
+ import Submenu from './submenu';
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 MegaMenuItem 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 MegaMenuItem = props => {
25
+ const {
26
+ activeCategoryId,
27
+ category,
28
+ mainNavWidth,
29
+ categoryUrlSuffix,
30
+ subMenuState,
31
+ disableFocus,
32
+ onNavigate,
33
+ handleSubMenuFocus,
34
+ handleClickOutside,
35
+ megaMenuItemClassname,
36
+ titleClassName,
37
+ } = props;
38
+
39
+ const classes = useStyle(defaultClasses, props.classes);
40
+ const categoryUrl = resourceUrl(
41
+ `/${category.url_path}${categoryUrlSuffix || ''}`
42
+ );
43
+
44
+ const talonProps = useMegaMenuItem({
45
+ category,
46
+ activeCategoryId,
47
+ subMenuState,
48
+ disableFocus
49
+ });
50
+
51
+ const {
52
+ isFocused,
53
+ isActive,
54
+ handleMenuItemFocus,
55
+ handleCloseSubMenu,
56
+ isMenuActive,
57
+ handleKeyDown
58
+ } = talonProps;
59
+
60
+ const itemClassName = isMenuActive
61
+ ? classes.megaMenuItem_active
62
+ : classes.megaMenuItem;
63
+
64
+ const children = useMemo(() => {
65
+ return category.children.length ? (
66
+ <Submenu
67
+ isFocused={isFocused}
68
+ subMenuState={subMenuState}
69
+ items={category.children}
70
+ mainNavWidth={mainNavWidth}
71
+ handleCloseSubMenu={handleCloseSubMenu}
72
+ categoryUrlSuffix={categoryUrlSuffix}
73
+ onNavigate={onNavigate}
74
+ />
75
+ ) : null;
76
+ }, [
77
+ category,
78
+ isFocused,
79
+ mainNavWidth,
80
+ subMenuState,
81
+ handleCloseSubMenu,
82
+ categoryUrlSuffix,
83
+ onNavigate
84
+ ]);
85
+
86
+ const maybeDownArrowIcon = category.children.length ? (
87
+ <ArrowDown2 className='ml-2' size="16" color={textPrimary} variant="Outline" />
88
+ ) : null;
89
+
90
+ const linkAttributes = category.children.length
91
+ ? {
92
+ 'aria-label': `Category: ${category.name}. ${category.children.length
93
+ } sub-categories`
94
+ }
95
+ : {};
96
+
97
+ return (
98
+ <div
99
+ className={cn(itemClassName, megaMenuItemClassname)}
100
+ data-cy="MegaMenu-MegaMenuItem-megaMenuItem"
101
+ onMouseEnter={() => {
102
+ handleSubMenuFocus();
103
+ handleMenuItemFocus();
104
+ }}
105
+ onFocus={() => {
106
+ handleSubMenuFocus();
107
+ handleMenuItemFocus();
108
+ }}
109
+ onTouchStart={() => {
110
+ handleSubMenuFocus();
111
+ handleMenuItemFocus();
112
+ }}
113
+ onMouseLeave={e => {
114
+ handleClickOutside(e);
115
+ handleCloseSubMenu();
116
+ }}
117
+ >
118
+ <Link
119
+ {...linkAttributes}
120
+ onKeyDown={handleKeyDown}
121
+ className={cn(
122
+ isActive ? classes.megaMenuLinkActive : classes.megaMenuLink,
123
+ titleClassName
124
+ )}
125
+ data-cy="MegaMenu-MegaMenuItem-link"
126
+ to={categoryUrl}
127
+ onClick={onNavigate}
128
+ >
129
+ {category.name}
130
+ {maybeDownArrowIcon}
131
+ </Link>
132
+ {children}
133
+ </div>
134
+ );
135
+ };
136
+
137
+ export default MegaMenuItem;
138
+
139
+ MegaMenuItem.propTypes = {
140
+ category: PropTypes.shape({
141
+ children: PropTypes.array,
142
+ uid: PropTypes.string.isRequired,
143
+ include_in_menu: PropTypes.number,
144
+ isActive: PropTypes.bool.isRequired,
145
+ name: PropTypes.string.isRequired,
146
+ path: PropTypes.array.isRequired,
147
+ position: PropTypes.number.isRequired,
148
+ url_path: PropTypes.string.isRequired
149
+ }).isRequired,
150
+ activeCategoryId: PropTypes.string,
151
+ mainNavWidth: PropTypes.number.isRequired,
152
+ categoryUrlSuffix: PropTypes.string,
153
+ onNavigate: PropTypes.func.isRequired,
154
+ handleSubMenuFocus: PropTypes.func.isRequired,
155
+ handleClickOutside: PropTypes.func.isRequired
156
+ };
@@ -0,0 +1,31 @@
1
+ .megaMenuItem {
2
+ /* composes: px-3 from global;
3
+ composes: py-0 from global; */
4
+ }
5
+
6
+ .megaMenuLink {
7
+ composes: items-center from global;
8
+ composes: inline-flex from global;
9
+ /* min-height: 5rem; */
10
+ }
11
+
12
+ .megaMenuLinkActive {
13
+ composes: megaMenuLink;
14
+ composes: underline from global;
15
+ }
16
+
17
+ .megaMenuItem_active {
18
+ composes: megaMenuItem;
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
+ .megaMenuItem:hover .megaMenuLink,
29
+ .megaMenuItem:focus .megaMenuLink {
30
+ text-decoration: underline;
31
+ }
@@ -0,0 +1,89 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+
4
+ import { useSubMenu } from '@magento/peregrine/lib/talons/MegaMenu/useSubMenu';
5
+
6
+ import { useStyle } from '@magento/venia-ui/lib/classify';
7
+ import defaultClasses from './submenu.module.css';
8
+ import SubmenuColumn from './submenuColumn';
9
+
10
+ /**
11
+ * The Submenu component displays submenu in mega menu
12
+ *
13
+ * @param {array} props.items - categories to display
14
+ * @param {int} props.mainNavWidth - width of the main nav. It's used for setting min-width of the submenu
15
+ * @param {function} props.onNavigate - function called when clicking on Link
16
+ */
17
+ const Submenu = props => {
18
+ const {
19
+ items,
20
+ mainNavWidth,
21
+ isFocused,
22
+ subMenuState,
23
+ handleCloseSubMenu,
24
+ categoryUrlSuffix,
25
+ onNavigate
26
+ } = props;
27
+ const PADDING_OFFSET = 20;
28
+ const classes = useStyle(defaultClasses, props.classes);
29
+
30
+ const talonProps = useSubMenu({
31
+ isFocused,
32
+ subMenuState,
33
+ handleCloseSubMenu
34
+ });
35
+
36
+ const { isSubMenuActive } = talonProps;
37
+
38
+ const subMenuClassname = isSubMenuActive
39
+ ? classes.submenu_active
40
+ : classes.submenu_inactive;
41
+
42
+ const subMenus = items.map((category, index) => {
43
+ const keyboardProps =
44
+ index === items.length - 1 ? talonProps.keyboardProps : {};
45
+ return (
46
+ <SubmenuColumn
47
+ index={index}
48
+ keyboardProps={keyboardProps}
49
+ key={category.uid}
50
+ category={category}
51
+ categoryUrlSuffix={categoryUrlSuffix}
52
+ onNavigate={onNavigate}
53
+ handleCloseSubMenu={handleCloseSubMenu}
54
+ />
55
+ );
56
+ });
57
+
58
+ return (
59
+ <div className={subMenuClassname}>
60
+ <div
61
+ className={classes.submenuItems}
62
+ style={{ minWidth: mainNavWidth + PADDING_OFFSET }}
63
+ >
64
+ {subMenus}
65
+ </div>
66
+ </div>
67
+ );
68
+ };
69
+
70
+ export default Submenu;
71
+
72
+ Submenu.propTypes = {
73
+ items: PropTypes.arrayOf(
74
+ PropTypes.shape({
75
+ children: PropTypes.array.isRequired,
76
+ uid: PropTypes.string.isRequired,
77
+ include_in_menu: PropTypes.number.isRequired,
78
+ isActive: PropTypes.bool.isRequired,
79
+ name: PropTypes.string.isRequired,
80
+ path: PropTypes.array.isRequired,
81
+ position: PropTypes.number.isRequired,
82
+ url_path: PropTypes.string.isRequired
83
+ })
84
+ ).isRequired,
85
+ mainNavWidth: PropTypes.number.isRequired,
86
+ categoryUrlSuffix: PropTypes.string,
87
+ onNavigate: PropTypes.func.isRequired,
88
+ handleCloseSubMenu: PropTypes.func.isRequired
89
+ };
@@ -0,0 +1,43 @@
1
+ .submenu {
2
+ composes: absolute from global;
3
+ composes: bg-white from global;
4
+ composes: flex-wrap from global;
5
+ composes: justify-between from global;
6
+ composes: left-0 from global;
7
+ composes: px-3 from global;
8
+ composes: py-5 from global;
9
+ composes: right-0 from global;
10
+ top: 139px;
11
+ box-shadow: 0 3px rgb(var(--venia-global-color-gray-100));
12
+ }
13
+
14
+ /* TODO @TW: cannot compose */
15
+ .submenu::before {
16
+ box-shadow: inset 0 2px rgb(var(--venia-global-color-gray-100));
17
+ content: '';
18
+ height: 1px;
19
+ left: 0;
20
+ pointer-events: none;
21
+ position: absolute;
22
+ right: 0;
23
+ top: 0;
24
+ }
25
+
26
+ .submenu_inactive {
27
+ composes: submenu;
28
+ composes: hidden from global;
29
+ }
30
+
31
+ .submenu_active {
32
+ composes: submenu;
33
+ composes: flex from global;
34
+ }
35
+
36
+ .submenuItems {
37
+ composes: flex from global;
38
+ composes: flex-wrap from global;
39
+ composes: justify-between from global;
40
+ composes: max-w-site from global;
41
+ composes: ml-auto from global;
42
+ composes: mr-auto from global;
43
+ }