@riosst100/pwa-marketplace 1.3.2 → 1.3.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.
Files changed (165) hide show
  1. package/.github/workflows/dependabot.yml +28 -28
  2. package/package.json +18 -18
  3. package/src/componentOverrideMapping.js +14 -0
  4. package/src/components/BecomeSellerLink/becomeSellerLink.js +1 -1
  5. package/src/components/BecomeSellerLink/becomeSellerLink.module.css +0 -4
  6. package/src/components/CurrencySwitcher/currencySwitcher.himmer.js +6 -0
  7. package/src/components/CurrencySwitcher/currencySwitcher.module.css +102 -0
  8. package/src/components/CurrencySwitcher/index.js +107 -0
  9. package/src/components/CurrencySwitcher/switcherItem.js +47 -0
  10. package/src/components/CurrencySwitcher/switcherItem.module.css +20 -0
  11. package/src/components/FilterOption/FilterOptionModal.module.css +90 -0
  12. package/src/components/FilterOption/filterOptionModal.js +48 -0
  13. package/src/components/FilterOptionModal/filterOptionModal.js +66 -0
  14. package/src/components/Header/becomeSellerLink.module.css +0 -4
  15. package/src/components/Header/websiteSwitcher.js +0 -1
  16. package/src/components/Header/websiteSwitcher.module.css +107 -111
  17. package/src/components/WebsiteSwitcher/websiteSwitcher.js +18 -6
  18. package/src/components/WebsiteSwitcher/websiteSwitcher.module.css +107 -111
  19. package/src/overwrites/peregrine/lib/talons/FilterModal/useFilterList.js +62 -0
  20. package/src/overwrites/peregrine/lib/talons/MegaMenu/useMegaMenuItem.js +66 -0
  21. package/src/overwrites/peregrine/lib/talons/MegaMenu/useSubMenu.js +20 -0
  22. package/src/overwrites/peregrine/lib/talons/RootComponents/Category/useCategoryContent.js +0 -2
  23. package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/index.js +1 -0
  24. package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/noProductsFound.js +77 -0
  25. package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/noProductsFound.module.css +39 -0
  26. package/src/overwrites/venia-ui/lib/RootComponents/Category/NoProductsFound/noProductsFound.png +0 -0
  27. package/src/overwrites/venia-ui/lib/RootComponents/Category/category.gql.js +17 -0
  28. package/src/overwrites/venia-ui/lib/RootComponents/Category/category.js +91 -0
  29. package/src/overwrites/venia-ui/lib/RootComponents/Category/category.module.css +77 -0
  30. package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.js +12 -14
  31. package/src/overwrites/venia-ui/lib/RootComponents/Category/categoryContent.shimmer.js +74 -0
  32. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/001.jpg +0 -0
  33. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/002.jpg +0 -0
  34. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/003.jpg +0 -0
  35. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/004.jpg +0 -0
  36. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/005.jpg +0 -0
  37. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/006.jpg +0 -0
  38. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/007.jpg +0 -0
  39. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/008.jpg +0 -0
  40. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/009.jpg +0 -0
  41. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/010.jpg +0 -0
  42. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/011.jpg +0 -0
  43. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/012.jpg +0 -0
  44. package/src/overwrites/venia-ui/lib/RootComponents/Category/images/index.js +12 -0
  45. package/src/overwrites/venia-ui/lib/RootComponents/Category/index.js +6 -0
  46. package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.js +112 -0
  47. package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.module.css +32 -0
  48. package/src/overwrites/venia-ui/lib/components/Breadcrumbs/breadcrumbs.shimmer.js +24 -0
  49. package/src/overwrites/venia-ui/lib/components/Breadcrumbs/index.js +2 -0
  50. package/src/overwrites/venia-ui/lib/components/Checkbox/checkbox.js +78 -0
  51. package/src/overwrites/venia-ui/lib/components/Checkbox/checkbox.module.css +73 -0
  52. package/src/overwrites/venia-ui/lib/components/Checkbox/index.js +1 -0
  53. package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.js +60 -0
  54. package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilter.module.css +21 -0
  55. package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.js +65 -0
  56. package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/currentFilters.module.css +17 -0
  57. package/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters/index.js +1 -0
  58. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterDefault.js +18 -18
  59. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterDefault.module.css +0 -0
  60. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItem.js +79 -0
  61. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadio.js +76 -0
  62. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadio.module.css +0 -0
  63. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterItemRadioGroup.js +86 -0
  64. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterList.js +265 -0
  65. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/filterList.module.css +20 -0
  66. package/src/overwrites/venia-ui/lib/components/FilterModal/FilterList/index.js +1 -0
  67. package/src/overwrites/venia-ui/lib/components/FilterModal/filterBlock.js +135 -0
  68. package/src/overwrites/venia-ui/lib/components/FilterModal/filterBlock.module.css +25 -0
  69. package/src/overwrites/venia-ui/lib/components/FilterModal/filterFooter.js +49 -0
  70. package/src/overwrites/venia-ui/lib/components/FilterModal/filterFooter.module.css +10 -0
  71. package/src/overwrites/venia-ui/lib/components/FilterModal/filterModal.js +166 -0
  72. package/src/overwrites/venia-ui/lib/components/FilterModal/filterModal.module.css +87 -0
  73. package/src/overwrites/venia-ui/lib/components/FilterModal/filterSearch.module.css +3 -0
  74. package/src/overwrites/venia-ui/lib/components/FilterModal/index.js +1 -0
  75. package/src/overwrites/venia-ui/lib/components/FilterSidebar/__tests__/filterSidebar.spec.js +246 -0
  76. package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.js +10 -10
  77. package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.module.css +57 -0
  78. package/src/overwrites/venia-ui/lib/components/FilterSidebar/filterSidebar.shimmer.js +24 -0
  79. package/src/overwrites/venia-ui/lib/components/FilterSidebar/index.js +2 -0
  80. package/src/overwrites/venia-ui/lib/components/Gallery/addToCartButton.js +116 -0
  81. package/src/overwrites/venia-ui/lib/components/Gallery/addToCartButton.module.css +38 -0
  82. package/src/overwrites/venia-ui/lib/components/Gallery/gallery.js +56 -0
  83. package/src/overwrites/venia-ui/lib/components/Gallery/gallery.module.css +28 -0
  84. package/src/overwrites/venia-ui/lib/components/Gallery/gallery.shimmer.js +39 -0
  85. package/src/overwrites/venia-ui/lib/components/Gallery/index.js +3 -0
  86. package/src/overwrites/venia-ui/lib/components/Gallery/item.js +204 -0
  87. package/src/overwrites/venia-ui/lib/components/Gallery/item.module.css +109 -0
  88. package/src/overwrites/venia-ui/lib/components/Gallery/item.shimmer.js +38 -0
  89. package/src/overwrites/venia-ui/lib/components/Gallery/star.js +12 -0
  90. package/src/overwrites/venia-ui/lib/components/Header/accountTrigger.js +98 -0
  91. package/src/overwrites/venia-ui/lib/components/Header/cartTrigger.js +116 -0
  92. package/src/overwrites/venia-ui/lib/components/Header/header.js +12 -9
  93. package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.js +22 -8
  94. package/src/overwrites/venia-ui/lib/components/Header/storeSwitcher.module.css +107 -0
  95. package/src/overwrites/venia-ui/lib/components/Header/wishlistTrigger.js +23 -0
  96. package/src/overwrites/venia-ui/lib/components/MegaMenu/megaMenuItem.js +1 -1
  97. package/src/overwrites/venia-ui/lib/components/MegaMenu/submenu.module.css +0 -1
  98. package/src/overwrites/venia-ui/lib/components/Pagination/index.js +1 -0
  99. package/src/overwrites/venia-ui/lib/components/Pagination/navButton.js +65 -0
  100. package/src/overwrites/venia-ui/lib/components/Pagination/pagination.js +107 -0
  101. package/src/overwrites/venia-ui/lib/components/Pagination/tile.js +41 -0
  102. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Boolean/boolean.js +74 -0
  103. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Boolean/boolean.module.css +9 -0
  104. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Boolean/index.js +1 -0
  105. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Date/date.js +82 -0
  106. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Date/date.module.css +9 -0
  107. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Date/index.js +1 -0
  108. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/DateTime/dateTime.js +85 -0
  109. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/DateTime/dateTime.module.css +9 -0
  110. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/DateTime/index.js +1 -0
  111. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Multiselect/index.js +1 -0
  112. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Multiselect/multiselect.js +104 -0
  113. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Multiselect/multiselect.module.css +22 -0
  114. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Price/index.js +1 -0
  115. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Price/price.js +74 -0
  116. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Price/price.module.css +9 -0
  117. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Select/index.js +1 -0
  118. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Select/select.js +99 -0
  119. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Select/select.module.css +13 -0
  120. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Text/index.js +1 -0
  121. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Text/text.js +88 -0
  122. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Text/text.module.css +13 -0
  123. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Textarea/index.js +1 -0
  124. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Textarea/textarea.js +94 -0
  125. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/Textarea/textarea.module.css +13 -0
  126. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/attributeType.js +67 -0
  127. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/AttributeType/index.js +1 -0
  128. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/customAttributes.js +64 -0
  129. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/customAttributes.module.css +9 -0
  130. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/CustomAttributes/index.js +1 -0
  131. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/index.js +1 -0
  132. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.gql.js +7 -0
  133. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.js +413 -0
  134. package/src/overwrites/venia-ui/lib/components/ProductFullDetail/productFullDetail.module.css +203 -0
  135. package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.js +180 -0
  136. package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.module.css +102 -0
  137. package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.shimmer.js +51 -0
  138. package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/carousel.shimmer.module.css +7 -0
  139. package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/index.js +1 -0
  140. package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/thumbnail.js +108 -0
  141. package/src/overwrites/venia-ui/lib/components/ProductImageCarousel/thumbnail.module.css +47 -0
  142. package/src/overwrites/venia-ui/lib/components/ProductSort/index.js +2 -0
  143. package/src/overwrites/venia-ui/lib/components/ProductSort/productSort.js +233 -0
  144. package/src/overwrites/venia-ui/lib/components/ProductSort/productSort.module.css +65 -0
  145. package/src/overwrites/venia-ui/lib/components/ProductSort/productSort.shimmer.js +28 -0
  146. package/src/overwrites/venia-ui/lib/components/ProductSort/productSort.shimmer.module.css +10 -0
  147. package/src/overwrites/venia-ui/lib/components/ProductSort/sortItem.js +57 -0
  148. package/src/overwrites/venia-ui/lib/components/ProductSort/sortItem.module.css +23 -0
  149. package/src/overwrites/venia-ui/lib/components/QuantityStepper/index.js +1 -0
  150. package/src/overwrites/venia-ui/lib/components/QuantityStepper/quantityStepper.js +94 -0
  151. package/src/overwrites/venia-ui/lib/components/QuantityStepper/quantityStepper.module.css +78 -0
  152. package/src/overwrites/venia-ui/lib/components/RichContent/index.js +1 -0
  153. package/src/overwrites/venia-ui/lib/components/RichContent/plainHtmlRenderer.js +17 -0
  154. package/src/overwrites/venia-ui/lib/components/RichContent/richContent.js +59 -0
  155. package/src/overwrites/venia-ui/lib/components/RichContent/richContent.module.css +146 -0
  156. package/src/overwrites/venia-ui/lib/components/RichContent/richContentRenderers.js +7 -0
  157. package/src/overwrites/venia-ui/lib/components/SearchBar/searchBar.module.css +1 -2
  158. package/src/overwrites/venia-ui/lib/components/SearchBar/searchField.js +3 -2
  159. package/src/overwrites/venia-ui/lib/components/TextInput/field.module.css +50 -0
  160. package/src/overwrites/venia-ui/lib/components/TextInput/index.js +1 -0
  161. package/src/overwrites/venia-ui/lib/components/TextInput/textInput.js +48 -0
  162. package/src/overwrites/venia-ui/lib/components/TextInput/textInput.module.css +21 -0
  163. package/src/talons/FilterOption/useFilterOptionModal.js +11 -0
  164. package/src/talons/FilterOptionModal/useFilterOptionModal.js +11 -0
  165. package/src/theme/vars.js +12 -0
@@ -0,0 +1,87 @@
1
+ .root {
2
+ composes: bg-white from global;
3
+ composes: bottom-0 from global;
4
+ composes: grid from global;
5
+ composes: h-full from global;
6
+ composes: left-0 from global;
7
+ composes: max-w-modal from global;
8
+ composes: opacity-0 from global;
9
+ composes: overflow-hidden from global;
10
+ composes: fixed from global;
11
+ composes: top-0 from global;
12
+ composes: w-full from global;
13
+ composes: z-dialog from global;
14
+ grid-template-rows: 1fr 7rem;
15
+ transform: translate3d(-100%, 0, 0);
16
+ transition-duration: 192ms;
17
+ transition-timing-function: var(--venia-global-anim-out);
18
+ transition-property: opacity, transform, visibility;
19
+
20
+ /* TODO @TW: review (B6) */
21
+ /* composes: invisible from global; */
22
+ visibility: hidden;
23
+ }
24
+
25
+ .root_open {
26
+ composes: root;
27
+
28
+ composes: opacity-100 from global;
29
+ composes: shadow-modal from global;
30
+ transform: translate3d(0, 0, 0);
31
+ transition-duration: 224ms;
32
+ transition-timing-function: var(--venia-global-anim-in);
33
+
34
+ /* TODO @TW: review (B6) */
35
+ /* composes: visible from global; */
36
+ visibility: visible;
37
+ }
38
+
39
+ .body {
40
+ composes: border-b from global;
41
+ composes: border-solid from global;
42
+ composes: border-subtle from global;
43
+ composes: overflow-auto from global;
44
+ }
45
+
46
+ .header {
47
+ composes: flex from global;
48
+ composes: justify-between from global;
49
+ composes: pb-0 from global;
50
+ composes: pt-5 from global;
51
+ composes: px-5 from global;
52
+ }
53
+
54
+ .headerTitle {
55
+ composes: flex from global;
56
+ composes: items-center from global;
57
+ composes: leading-none from global;
58
+ composes: text-xl from global;
59
+ }
60
+
61
+ .action {
62
+ composes: pb-0 from global;
63
+ composes: pt-xs from global;
64
+ composes: px-xs from global;
65
+ }
66
+
67
+ /* TODO @TW: cannot compose */
68
+ .action button {
69
+ /* composes: text-sm from global; */
70
+ font-size: 0.875rem;
71
+ /* composes: no-underline from global; */
72
+ text-decoration: none;
73
+ }
74
+
75
+ .blocks {
76
+ composes: pb-0 from global;
77
+ composes: pt-xs from global;
78
+ composes: px-xs from global;
79
+ }
80
+
81
+ /* TODO @TW: cannot compose */
82
+ .blocks > li:last-child {
83
+ /* composes: border-b-2 from global; */
84
+ /* composes: border-solid from global; */
85
+ /* composes: border-subtle from global; */
86
+ border-bottom: 2px solid rgb(var(--venia-global-color-border));
87
+ }
@@ -0,0 +1,3 @@
1
+ .root {
2
+ composes: pb-xs from global;
3
+ }
@@ -0,0 +1 @@
1
+ export { default } from './filterModal';
@@ -0,0 +1,246 @@
1
+ import React from 'react';
2
+ import { act } from 'react-test-renderer';
3
+
4
+ import { createTestInstance } from '@magento/peregrine';
5
+
6
+ import FilterBlock, { mockFilterBlock } from '../../FilterModal/filterBlock';
7
+ import { mockCurrentFilters } from '../../FilterModal/CurrentFilters';
8
+ import LinkButton from '../../LinkButton';
9
+ import FilterSidebar from '../filterSidebar';
10
+
11
+ const mockFilters = [
12
+ {
13
+ attribute_code: 'foo',
14
+ label: 'Foo',
15
+ options: [
16
+ {
17
+ label: 'value 1',
18
+ value: 1
19
+ }
20
+ ]
21
+ },
22
+ {
23
+ attribute_code: 'bar',
24
+ label: 'Bar',
25
+ options: [
26
+ {
27
+ label: 'value 1',
28
+ value: 1
29
+ },
30
+ {
31
+ label: 'value 2',
32
+ value: 2
33
+ }
34
+ ]
35
+ },
36
+ {
37
+ attribute_code: 'baz',
38
+ label: 'Baz',
39
+ options: [
40
+ {
41
+ label: 'value 1',
42
+ value: 1
43
+ }
44
+ ]
45
+ }
46
+ ];
47
+
48
+ const mockFiltersOpenCount = 2;
49
+
50
+ const mockHandleApply = jest.fn();
51
+
52
+ const mockScrollTo = jest.fn();
53
+
54
+ const mockGetBoundingClientRect = jest.fn();
55
+
56
+ let mockFilterState;
57
+
58
+ jest.mock('../../LinkButton', () => props => <mock-LinkButton {...props} />);
59
+
60
+ jest.mock('@magento/peregrine/lib/talons/FilterSidebar', () => ({
61
+ useFilterSidebar: jest.fn(({ filters }) => {
62
+ const names = new Map();
63
+ const itemsByGroup = new Map();
64
+ const filterFrontendInput = new Map();
65
+
66
+ for (const filter of filters) {
67
+ const {
68
+ options,
69
+ label: name,
70
+ attribute_code: group,
71
+ frontend_input
72
+ } = filter;
73
+ const items = [];
74
+ // add filter name
75
+ names.set(group, name);
76
+ filterFrontendInput.set(group, frontend_input);
77
+ // add items
78
+ for (const { label, value } of options) {
79
+ items.push({ title: label, value });
80
+ }
81
+ itemsByGroup.set(group, items);
82
+ }
83
+
84
+ return {
85
+ filterApi: null,
86
+ filterItems: itemsByGroup,
87
+ filterNames: names,
88
+ filterFrontendInput,
89
+ filterState: mockFilterState,
90
+ handleApply: mockHandleApply,
91
+ handleReset: jest.fn()
92
+ };
93
+ })
94
+ }));
95
+
96
+ jest.mock('../../FilterModal/filterBlock', () => {
97
+ const mockedFilterBlock = jest.fn(() => {
98
+ return null;
99
+ });
100
+
101
+ return {
102
+ __esModule: true,
103
+ default: mockedFilterBlock,
104
+ mockFilterBlock: mockedFilterBlock
105
+ };
106
+ });
107
+
108
+ jest.mock('../../FilterModal/CurrentFilters', () => {
109
+ const mockedCurrentFilters = jest.fn(() => {
110
+ return null;
111
+ });
112
+
113
+ return {
114
+ __esModule: true,
115
+ default: mockedCurrentFilters,
116
+ mockCurrentFilters: mockedCurrentFilters
117
+ };
118
+ });
119
+
120
+ let inputProps = {};
121
+
122
+ const Component = () => {
123
+ return <FilterSidebar {...inputProps} />;
124
+ };
125
+
126
+ const givenDefaultValues = () => {
127
+ inputProps = {
128
+ filters: []
129
+ };
130
+
131
+ mockFilterState = new Map();
132
+ };
133
+
134
+ const givenFilters = () => {
135
+ inputProps = {
136
+ filters: mockFilters
137
+ };
138
+ };
139
+
140
+ const givenSelectedFilters = () => {
141
+ inputProps = {
142
+ filters: mockFilters
143
+ };
144
+
145
+ mockFilterState = new Map([['group', 'item']]);
146
+ };
147
+
148
+ const givenFiltersAndAmountToShow = () => {
149
+ inputProps = {
150
+ filters: mockFilters,
151
+ filterCountToOpen: mockFiltersOpenCount
152
+ };
153
+ };
154
+
155
+ describe('#FilterSidebar', () => {
156
+ beforeEach(() => {
157
+ mockFilterBlock.mockClear();
158
+ mockCurrentFilters.mockClear();
159
+
160
+ givenDefaultValues();
161
+ });
162
+
163
+ it('renders without filters', () => {
164
+ createTestInstance(<Component />);
165
+
166
+ expect(mockFilterBlock).not.toHaveBeenCalled();
167
+ expect(mockCurrentFilters).toHaveBeenCalled();
168
+ });
169
+
170
+ it('renders with filters and no selected filters', () => {
171
+ givenFilters();
172
+
173
+ const { root } = createTestInstance(<Component />);
174
+
175
+ expect(() => root.findByType(LinkButton)).toThrow();
176
+ expect(mockFilterBlock).toHaveBeenCalledTimes(mockFilters.length);
177
+ });
178
+
179
+ it('renders with filters and selected filter', () => {
180
+ givenSelectedFilters();
181
+
182
+ const { root } = createTestInstance(<Component />);
183
+
184
+ expect(() => root.findByType(LinkButton)).not.toThrow();
185
+ expect(mockFilterBlock).toHaveBeenCalledTimes(mockFilters.length);
186
+ });
187
+
188
+ it('handles when a user applies a filter and ref is not provided', () => {
189
+ givenSelectedFilters();
190
+
191
+ const { root } = createTestInstance(<Component />);
192
+
193
+ act(() => {
194
+ root.findAllByType(FilterBlock)[0].props.onApply();
195
+ });
196
+
197
+ expect(mockHandleApply).toHaveBeenCalled();
198
+ });
199
+
200
+ it('handles when a user applies a filter and ref is provided', () => {
201
+ givenSelectedFilters();
202
+
203
+ Object.defineProperty(window, 'scrollTo', {
204
+ configurable: true,
205
+ writable: true,
206
+ value: mockScrollTo
207
+ });
208
+
209
+ const { root } = createTestInstance(<Component />, {
210
+ createNodeMock: () => {
211
+ return {
212
+ getBoundingClientRect: mockGetBoundingClientRect.mockReturnValue(
213
+ {
214
+ top: 250
215
+ }
216
+ )
217
+ };
218
+ }
219
+ });
220
+
221
+ act(() => {
222
+ root.findAllByType(FilterBlock)[0].props.onApply();
223
+ });
224
+
225
+ expect(mockGetBoundingClientRect).toBeCalledTimes(1);
226
+ expect(window.scrollTo).toBeCalledTimes(1);
227
+ expect(mockHandleApply).toHaveBeenCalled();
228
+ });
229
+
230
+ it('accepts configurable amount of open filters', () => {
231
+ givenFiltersAndAmountToShow();
232
+ createTestInstance(<Component />);
233
+
234
+ expect(mockFilterBlock).toHaveBeenCalledTimes(mockFilters.length);
235
+
236
+ for (let i = 1; i <= mockFilters.length; i++) {
237
+ expect(mockFilterBlock).toHaveBeenNthCalledWith(
238
+ i,
239
+ expect.objectContaining({
240
+ initialOpen: i <= mockFiltersOpenCount
241
+ }),
242
+ expect.any(Object)
243
+ );
244
+ }
245
+ });
246
+ });
@@ -3,12 +3,13 @@ import { FormattedMessage } from 'react-intl';
3
3
  import { array, arrayOf, shape, string, number } from 'prop-types';
4
4
  import { useFilterSidebar } from '@magento/peregrine/lib/talons/FilterSidebar';
5
5
 
6
- import { useStyle } from '../../classify';
7
- import LinkButton from '../LinkButton';
8
- import CurrentFilters from '../FilterModal/CurrentFilters';
9
- import FilterBlock from '../FilterModal/filterBlock';
6
+ import { useStyle } from '@magento/venia-ui/lib/classify';
7
+ import LinkButton from '@magento/venia-ui/lib/components/LinkButton';
8
+ import CurrentFilters from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/FilterModal/CurrentFilters';
9
+ import FilterBlock from '@riosst100/pwa-marketplace/src/overwrites/venia-ui/lib/components/FilterModal/filterBlock';
10
10
  import defaultClasses from './filterSidebar.module.css';
11
- import ShopByCategory from '@riosst100/pwa-marketplace/src/components/ShopByCategory';
11
+ import { Filter } from 'iconsax-react';
12
+ import cn from 'classnames';
12
13
 
13
14
  const SCROLL_OFFSET = 150;
14
15
 
@@ -18,8 +19,7 @@ const SCROLL_OFFSET = 150;
18
19
  * @param {Object} props.filters - filters to display
19
20
  */
20
21
  const FilterSidebar = props => {
21
- const { categoryName, children, parent, filters, filterCountToOpen } = props;
22
-
22
+ const { filters, filterCountToOpen } = props;
23
23
  const talonProps = useFilterSidebar({ filters });
24
24
  const {
25
25
  filterApi,
@@ -106,15 +106,16 @@ const FilterSidebar = props => {
106
106
  aria-busy="false"
107
107
  >
108
108
  <div className={classes.body}>
109
- <div className={classes.header}>
109
+ <div className={cn(classes.header)}>
110
110
  <h2
111
111
  data-cy="FilterSidebar-headerTitle"
112
- className={classes.headerTitle}
112
+ className={cn(classes.headerTitle, 'flex w-full justify-between items-center')}
113
113
  >
114
114
  <FormattedMessage
115
115
  id={'filterModal.headerTitle'}
116
116
  defaultMessage={'Filters'}
117
117
  />
118
+ <Filter size={15} className='text-gray-900' />
118
119
  </h2>
119
120
  </div>
120
121
  <CurrentFilters
@@ -125,7 +126,6 @@ const FilterSidebar = props => {
125
126
  />
126
127
  {clearAll}
127
128
  <ul className={classes.blocks}>{filtersList}</ul>
128
- <ul className={classes.blocks}><ShopByCategory categoryName={categoryName} children={children} parent={parent} /></ul>
129
129
  </div>
130
130
  </aside>
131
131
  );
@@ -0,0 +1,57 @@
1
+ .root {
2
+ composes: bg-white from global;
3
+ composes: bottom-0 from global;
4
+ composes: hidden from global;
5
+ composes: max-w-modal from global;
6
+ composes: w-full from global;
7
+ composes: z-foreground from global;
8
+ grid-template-rows: 1fr 7rem;
9
+
10
+ composes: lg_grid from global;
11
+ composes: border from global;
12
+ composes: border-gray-100 from global;
13
+ composes: shadow-type-1 from global;
14
+ composes: rounded-[6px] from global;
15
+ composes: py-2.5 from global;
16
+
17
+ }
18
+
19
+ .body {
20
+ composes: overflow-auto from global;
21
+ }
22
+
23
+ .header {
24
+ composes: flex from global;
25
+ composes: justify-between from global;
26
+ }
27
+
28
+ .headerTitle {
29
+ composes: flex from global;
30
+ composes: items-center from global;
31
+ composes: leading-normal from global;
32
+ composes: text-[16px] from global;
33
+ composes: font-semibold from global;
34
+ composes: px-2.5 from global;
35
+ composes: mb-2.5 from global;
36
+ }
37
+
38
+ .action {
39
+ composes: px-2.5 from global;
40
+ composes: py-[5px] from global;
41
+ }
42
+
43
+ /* TODO @TW: cannot compose */
44
+ .action button {
45
+ /* composes: text-sm from global; */
46
+ font-size: 13px;
47
+ /* composes: no-underline from global; */
48
+ font-weight: 500;
49
+ text-decoration: underline;
50
+ }
51
+
52
+ .blocks {
53
+ composes: px-2.5 from global;
54
+ composes: flex from global;
55
+ composes: flex-col from global;
56
+ composes: gap-2.5 from global;
57
+ }
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { shape, string } from 'prop-types';
3
+ import { useStyle } from '@magento/venia-ui/lib/classify';
4
+
5
+ import Shimmer from '@magento/venia-ui/lib/components/Shimmer';
6
+ import defaultClasses from './filterSidebar.module.css';
7
+
8
+ const FilterSidebar = props => {
9
+ const classes = useStyle(defaultClasses, props.classes);
10
+
11
+ return (
12
+ <aside className={classes.root} aria-live="polite" aria-busy="true">
13
+ <Shimmer width="95%" height="70vh" style={{ marginBottom: 25 }} />
14
+ </aside>
15
+ );
16
+ };
17
+
18
+ FilterSidebar.propTypes = {
19
+ classes: shape({
20
+ root: string
21
+ })
22
+ };
23
+
24
+ export default FilterSidebar;
@@ -0,0 +1,2 @@
1
+ export { default } from './filterSidebar';
2
+ export { default as FilterSidebarShimmer } from './filterSidebar.shimmer';
@@ -0,0 +1,116 @@
1
+ import React from 'react';
2
+ import { FormattedMessage, useIntl } from 'react-intl';
3
+ import { string, number, shape } from 'prop-types';
4
+ import { useAddToCartButton } from '@magento/peregrine/lib/talons/Gallery/useAddToCartButton';
5
+ import { ShoppingBag, XSquare } from 'react-feather';
6
+ import Icon from '@magento/venia-ui/lib/components/Icon';
7
+ import Button from '@magento/venia-ui/lib/components/Button';
8
+ import { useStyle } from '@magento/venia-ui/lib/classify';
9
+ import defaultClasses from './addToCartButton.module.css';
10
+
11
+ const AddToCartButton = props => {
12
+ const { item, urlSuffix } = props;
13
+ const talonProps = useAddToCartButton({
14
+ item,
15
+ urlSuffix
16
+ });
17
+ const { handleAddToCart, isDisabled, isInStock } = talonProps;
18
+ const { formatMessage } = useIntl();
19
+
20
+ const classes = useStyle(defaultClasses, props.classes);
21
+
22
+ const AddToCartIcon = (
23
+ <Icon
24
+ classes={{ icon: classes.icon }}
25
+ src={ShoppingBag}
26
+ attrs={{ width: 16 }}
27
+ />
28
+ );
29
+
30
+ const OutOfStockIcon = (
31
+ <Icon
32
+ classes={{ icon: classes.icon }}
33
+ src={XSquare}
34
+ attrs={{ width: 16 }}
35
+ />
36
+ );
37
+
38
+ const buttonInStock = (
39
+ <Button
40
+ data-cy="AddToCartButton-buttonInStock"
41
+ aria-label={formatMessage({
42
+ id: 'addToCartButton.addItemToCartAriaLabel',
43
+ defaultMessage: 'Add to Cart'
44
+ })}
45
+ className={classes.root}
46
+ disabled={isDisabled}
47
+ onPress={handleAddToCart}
48
+ priority="high"
49
+ type="button"
50
+ >
51
+ {AddToCartIcon}
52
+ <span className={classes.text}>
53
+ <FormattedMessage
54
+ id="addToCartButton.addItemToCart"
55
+ defaultMessage="ADD TO CART"
56
+ />
57
+ </span>
58
+ </Button>
59
+ );
60
+
61
+ const buttonOutOfStock = (
62
+ <Button
63
+ data-cy="AddtoCartButton-buttonOutOfStock"
64
+ aria-label={formatMessage({
65
+ id: 'addToCartButton.itemOutOfStockAriaLabel',
66
+ defaultMessage: 'Out of Stock'
67
+ })}
68
+ className={classes.root}
69
+ disabled={isDisabled}
70
+ onPress={handleAddToCart}
71
+ priority="high"
72
+ type="button"
73
+ >
74
+ {OutOfStockIcon}
75
+ <span className={classes.text}>
76
+ <FormattedMessage
77
+ id="addToCartButton.itemOutOfStock"
78
+ defaultMessage="OUT OF STOCK"
79
+ />
80
+ </span>
81
+ </Button>
82
+ );
83
+
84
+ return isInStock ? buttonInStock : buttonOutOfStock;
85
+ };
86
+
87
+ export default AddToCartButton;
88
+
89
+ AddToCartButton.propTypes = {
90
+ classes: shape({
91
+ root: string,
92
+ root_selected: string
93
+ }),
94
+ item: shape({
95
+ id: number.isRequired,
96
+ uid: string.isRequired,
97
+ name: string.isRequired,
98
+ small_image: shape({
99
+ url: string
100
+ }),
101
+ stock_status: string.isRequired,
102
+ __typename: string.isRequired,
103
+ url_key: string.isRequired,
104
+ url_suffix: string,
105
+ sku: string.isRequired,
106
+ price: shape({
107
+ regularPrice: shape({
108
+ amount: shape({
109
+ value: number,
110
+ currency: string
111
+ })
112
+ })
113
+ })
114
+ }),
115
+ urlSuffix: string
116
+ };
@@ -0,0 +1,38 @@
1
+ .root {
2
+ composes: root;
3
+
4
+ composes: bg-brand-dark from global;
5
+ composes: border-brand-dark from global;
6
+ composes: text-white from global;
7
+
8
+ composes: active_bg-brand-darkest from global;
9
+ composes: active_border-brand-darkest from global;
10
+ composes: active_text-white from global;
11
+
12
+ composes: hover_bg-brand-darkest from global;
13
+ composes: hover_border-brand-darkest from global;
14
+ composes: hover_text-white from global;
15
+
16
+ composes: min-w-[6.125rem] from global;
17
+ composes: -ml-2xs from global;
18
+ composes: px-2xs from global;
19
+ composes: py-0 from global;
20
+ composes: self-center from global;
21
+ min-height: 2rem;
22
+
23
+ composes: sm_min-w-[8rem] from global;
24
+ /* composes: md_min-w-0 from global; */
25
+ }
26
+
27
+ .icon {
28
+ composes: inline from global;
29
+ composes: stroke-white from global;
30
+
31
+ composes: xs_hidden from global;
32
+ }
33
+
34
+ .text {
35
+ composes: hidden from global;
36
+
37
+ composes: xs_inline from global;
38
+ }
@@ -0,0 +1,56 @@
1
+ import React, { useMemo } from 'react';
2
+ import { string, shape, array } from 'prop-types';
3
+
4
+ import { useStyle } from '@magento/venia-ui/lib/classify';
5
+ import GalleryItem from './item';
6
+ import GalleryItemShimmer from './item.shimmer';
7
+ import defaultClasses from './gallery.module.css';
8
+ import { useGallery } from '@magento/peregrine/lib/talons/Gallery/useGallery';
9
+
10
+ /**
11
+ * Renders a Gallery of items. If items is an array of nulls Gallery will render
12
+ * a placeholder item for each.
13
+ *
14
+ * @params {Array} props.items an array of items to render
15
+ */
16
+ const Gallery = props => {
17
+ const { items } = props;
18
+ const classes = useStyle(defaultClasses, props.classes);
19
+ const talonProps = useGallery();
20
+ const { storeConfig } = talonProps;
21
+
22
+ const galleryItems = useMemo(
23
+ () =>
24
+ items.map((item, index) => {
25
+ if (item === null) {
26
+ return <GalleryItemShimmer key={index} />;
27
+ }
28
+ return (
29
+ <GalleryItem
30
+ key={item.id}
31
+ item={item}
32
+ storeConfig={storeConfig}
33
+ />
34
+ );
35
+ }),
36
+ [items, storeConfig]
37
+ );
38
+
39
+ return (
40
+ <div data-cy="Gallery-root" className={classes.root} aria-busy="false">
41
+ <div className={classes.items}>{galleryItems}</div>
42
+ </div>
43
+ );
44
+ };
45
+
46
+ Gallery.propTypes = {
47
+ classes: shape({
48
+ filters: string,
49
+ items: string,
50
+ pagination: string,
51
+ root: string
52
+ }),
53
+ items: array.isRequired
54
+ };
55
+
56
+ export default Gallery;