@magento/venia-pwa-live-search 1.0.0-alpha10
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 +31 -0
- package/postcss.config.js +3 -0
- package/src/api/fragments.js +193 -0
- package/src/api/graphql.js +26 -0
- package/src/api/mutations.js +94 -0
- package/src/api/queries.js +225 -0
- package/src/api/search.js +222 -0
- package/src/components/AddToCartButton/AddToCartButton.jsx +32 -0
- package/src/components/AddToCartButton/AddToCartButton.stories.mdx +14 -0
- package/src/components/AddToCartButton/index.js +10 -0
- package/src/components/Alert/Alert.jsx +155 -0
- package/src/components/Alert/index.js +11 -0
- package/src/components/Breadcrumbs/Breadcrumbs.jsx +34 -0
- package/src/components/Breadcrumbs/MockPages.js +14 -0
- package/src/components/Breadcrumbs/index.js +11 -0
- package/src/components/ButtonShimmer/ButtonShimmer.css +32 -0
- package/src/components/ButtonShimmer/ButtonShimmer.jsx +23 -0
- package/src/components/ButtonShimmer/index.js +11 -0
- package/src/components/CategoryFilters/CategoryFilters.jsx +59 -0
- package/src/components/CategoryFilters/index.js +10 -0
- package/src/components/Facets/Facets.jsx +50 -0
- package/src/components/Facets/Range/RangeFacet.js +20 -0
- package/src/components/Facets/Scalar/ScalarFacet.js +29 -0
- package/src/components/Facets/SelectedFilters.js +80 -0
- package/src/components/Facets/format.js +52 -0
- package/src/components/Facets/index.js +14 -0
- package/src/components/Facets/mocks.js +119 -0
- package/src/components/FacetsShimmer/FacetsShimmer.css +49 -0
- package/src/components/FacetsShimmer/FacetsShimmer.jsx +25 -0
- package/src/components/FacetsShimmer/index.js +11 -0
- package/src/components/FilterButton/FilterButton.jsx +40 -0
- package/src/components/FilterButton/index.js +11 -0
- package/src/components/ImageCarousel/Image.jsx +34 -0
- package/src/components/ImageCarousel/ImageCarousel.jsx +103 -0
- package/src/components/ImageCarousel/index.js +11 -0
- package/src/components/InputButtonGroup/InputButtonGroup.jsx +120 -0
- package/src/components/InputButtonGroup/index.js +11 -0
- package/src/components/LabelledInput/LabelledInput.jsx +51 -0
- package/src/components/LabelledInput/index.js +11 -0
- package/src/components/Loading/Loading.jsx +32 -0
- package/src/components/Loading/index.js +11 -0
- package/src/components/NoResults/NoResults.jsx +55 -0
- package/src/components/NoResults/index.js +11 -0
- package/src/components/Pagination/Pagination.jsx +105 -0
- package/src/components/Pagination/index.js +10 -0
- package/src/components/PerPagePicker/PerPagePicker.jsx +114 -0
- package/src/components/PerPagePicker/index.js +11 -0
- package/src/components/Pill/Pill.jsx +34 -0
- package/src/components/Pill/index.js +11 -0
- package/src/components/Pill/mock.js +23 -0
- package/src/components/ProductCardShimmer/ProductCardShimmer.css +72 -0
- package/src/components/ProductCardShimmer/ProductCardShimmer.jsx +28 -0
- package/src/components/ProductCardShimmer/index.js +11 -0
- package/src/components/ProductItem/MockData.js +508 -0
- package/src/components/ProductItem/ProductItem.css +84 -0
- package/src/components/ProductItem/ProductItem.jsx +347 -0
- package/src/components/ProductItem/ProductPrice.jsx +181 -0
- package/src/components/ProductItem/index.js +11 -0
- package/src/components/ProductList/MockData.js +190 -0
- package/src/components/ProductList/ProductList.jsx +127 -0
- package/src/components/ProductList/index.js +11 -0
- package/src/components/ProductList/product-list.css +18 -0
- package/src/components/SearchBar/SearchBar.jsx +33 -0
- package/src/components/SearchBar/index.js +11 -0
- package/src/components/Shimmer/Shimmer.css +82 -0
- package/src/components/Shimmer/Shimmer.jsx +66 -0
- package/src/components/Shimmer/index.js +11 -0
- package/src/components/Slider/Slider.css +61 -0
- package/src/components/Slider/Slider.jsx +103 -0
- package/src/components/Slider/index.jsx +11 -0
- package/src/components/SliderDoubleControl/SliderDoubleControl.css +83 -0
- package/src/components/SliderDoubleControl/SliderDoubleControl.jsx +220 -0
- package/src/components/SliderDoubleControl/index.js +11 -0
- package/src/components/SortDropdown/SortDropdown.jsx +126 -0
- package/src/components/SortDropdown/index.js +11 -0
- package/src/components/SwatchButton/SwatchButton.jsx +72 -0
- package/src/components/SwatchButton/index.js +11 -0
- package/src/components/SwatchButtonGroup/SwatchButtonGroup.jsx +86 -0
- package/src/components/SwatchButtonGroup/index.js +11 -0
- package/src/components/ViewSwitcher/ViewSwitcher.jsx +46 -0
- package/src/components/ViewSwitcher/index.js +11 -0
- package/src/components/WishlistButton/WishlistButton.jsx +67 -0
- package/src/components/WishlistButton/index.js +11 -0
- package/src/containers/App.jsx +145 -0
- package/src/containers/LiveSearchPLPLoader.jsx +24 -0
- package/src/containers/LiveSearchPopoverLoader.jsx +190 -0
- package/src/containers/LiveSearchSRLPLoader.jsx +24 -0
- package/src/containers/ProductListingPage.jsx +66 -0
- package/src/containers/ProductsContainer.jsx +145 -0
- package/src/containers/ProductsHeader.jsx +123 -0
- package/src/context/attributeMetadata.js +63 -0
- package/src/context/cart.js +97 -0
- package/src/context/displayChange.js +90 -0
- package/src/context/events.js +160 -0
- package/src/context/index.js +19 -0
- package/src/context/products.jsx +336 -0
- package/src/context/resultsModifierContext.js +35 -0
- package/src/context/search.jsx +127 -0
- package/src/context/store.jsx +93 -0
- package/src/context/translation.jsx +125 -0
- package/src/context/widgetConfig.jsx +120 -0
- package/src/context/wishlist.jsx +97 -0
- package/src/hooks/eventing/useEventListener.js +13 -0
- package/src/hooks/eventing/useLocation.js +21 -0
- package/src/hooks/eventing/useMagentoExtensionContext.js +28 -0
- package/src/hooks/eventing/usePageView.js +36 -0
- package/src/hooks/eventing/useShopperContext.js +33 -0
- package/src/hooks/eventing/useStorefrontInstanceContext.js +46 -0
- package/src/hooks/eventing/useViewedOffsets.js +74 -0
- package/src/hooks/useAccessibleDropdown.js +148 -0
- package/src/hooks/useLiveSearchPLPConfig.js +112 -0
- package/src/hooks/useLiveSearchPopoverConfig.js +83 -0
- package/src/hooks/useLiveSearchSRLPConfig.js +97 -0
- package/src/hooks/usePagination.js +83 -0
- package/src/hooks/useRangeFacet.js +62 -0
- package/src/hooks/useScalarFacet.js +61 -0
- package/src/hooks/useSliderFacet.js +43 -0
- package/src/i18n/Sorani.js +60 -0
- package/src/i18n/ar_AE.js +60 -0
- package/src/i18n/bg_BG.js +60 -0
- package/src/i18n/bn_IN.js +60 -0
- package/src/i18n/ca_ES.js +60 -0
- package/src/i18n/cs_CZ.js +60 -0
- package/src/i18n/da_DK.js +60 -0
- package/src/i18n/de_DE.js +60 -0
- package/src/i18n/el_GR.js +60 -0
- package/src/i18n/en_GA.js +60 -0
- package/src/i18n/en_GB.js +60 -0
- package/src/i18n/en_US.js +70 -0
- package/src/i18n/es_ES.js +60 -0
- package/src/i18n/et_EE.js +60 -0
- package/src/i18n/eu_ES.js +60 -0
- package/src/i18n/fa_IR.js +60 -0
- package/src/i18n/fi_FI.js +60 -0
- package/src/i18n/fr_FR.js +60 -0
- package/src/i18n/gl_ES.js +60 -0
- package/src/i18n/hi_IN.js +60 -0
- package/src/i18n/hu_HU.js +60 -0
- package/src/i18n/hy_AM.js +60 -0
- package/src/i18n/id_ID.js +60 -0
- package/src/i18n/index.js +89 -0
- package/src/i18n/it_IT.js +60 -0
- package/src/i18n/ja_JP.js +60 -0
- package/src/i18n/ko_KR.js +60 -0
- package/src/i18n/lt_LT.js +60 -0
- package/src/i18n/lv_LV.js +60 -0
- package/src/i18n/nb_NO.js +60 -0
- package/src/i18n/nl_NL.js +60 -0
- package/src/i18n/pt_BR.js +60 -0
- package/src/i18n/pt_PT.js +60 -0
- package/src/i18n/ro_RO.js +60 -0
- package/src/i18n/ru_RU.js +60 -0
- package/src/i18n/sv_SE.js +60 -0
- package/src/i18n/th_TH.js +60 -0
- package/src/i18n/tr_TR.js +60 -0
- package/src/i18n/zh_Hans_CN.js +60 -0
- package/src/i18n/zh_Hant_TW.js +60 -0
- package/src/icons/NoImage.svg +1 -0
- package/src/icons/adjustments.svg +3 -0
- package/src/icons/cart.svg +3 -0
- package/src/icons/checkmark.svg +3 -0
- package/src/icons/chevron.svg +3 -0
- package/src/icons/emptyHeart.svg +3 -0
- package/src/icons/error.svg +3 -0
- package/src/icons/filledHeart.svg +3 -0
- package/src/icons/filter.svg +29 -0
- package/src/icons/gridView.svg +11 -0
- package/src/icons/info.svg +3 -0
- package/src/icons/listView.svg +5 -0
- package/src/icons/loading.svg +6 -0
- package/src/icons/plus.svg +4 -0
- package/src/icons/sort.svg +18 -0
- package/src/icons/warning.svg +3 -0
- package/src/icons/x.svg +3 -0
- package/src/index.jsx +65 -0
- package/src/queries/customerGroupCode.gql.js +10 -0
- package/src/queries/eventing/getMagentoExtensionContext.gql.js +13 -0
- package/src/queries/eventing/getPageType.gql.js +14 -0
- package/src/queries/eventing/getStorefrontContext.gql.js +27 -0
- package/src/queries/index.js +3 -0
- package/src/queries/liveSearchPlpConfigs.gql.js +30 -0
- package/src/queries/liveSearchPopoverConfigs.gql.js +28 -0
- package/src/styles/autocomplete.module.css +56 -0
- package/src/styles/index.css +1638 -0
- package/src/styles/searchBar.module.css +119 -0
- package/src/styles/tokens.css +99 -0
- package/src/targets/intercept.js +21 -0
- package/src/utils/constants.js +26 -0
- package/src/utils/decodeHtmlString.js +13 -0
- package/src/utils/dom.js +14 -0
- package/src/utils/eventing/getCookie.js +9 -0
- package/src/utils/eventing/usePageTypeFromUrl.js +26 -0
- package/src/utils/getProductImage.js +94 -0
- package/src/utils/getProductPrice.js +83 -0
- package/src/utils/getUserViewHistory.js +27 -0
- package/src/utils/handleUrlFilters.js +164 -0
- package/src/utils/htmlStringDecode.js +13 -0
- package/src/utils/modifyResults.js +164 -0
- package/src/utils/sort.js +95 -0
- package/src/utils/useIntersectionObserver.js +27 -0
- package/src/utils/validateStoreDetails.js +39 -0
- package/src/wrappers/wrapUseApp.js +28 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
11
|
+
|
|
12
|
+
import { updateSearchInputCtx, updateSearchResultsCtx } from '../context';
|
|
13
|
+
import { SEARCH_UNIT_ID } from '../utils/constants';
|
|
14
|
+
import {
|
|
15
|
+
ATTRIBUTE_METADATA_QUERY,
|
|
16
|
+
PRODUCT_SEARCH_QUERY,
|
|
17
|
+
REFINE_PRODUCT_QUERY
|
|
18
|
+
} from './queries';
|
|
19
|
+
|
|
20
|
+
const getHeaders = headers => {
|
|
21
|
+
return {
|
|
22
|
+
'Magento-Environment-Id': headers.environmentId,
|
|
23
|
+
'Magento-Website-Code': headers.websiteCode,
|
|
24
|
+
'Magento-Store-Code': headers.storeCode,
|
|
25
|
+
'Magento-Store-View-Code': headers.storeViewCode,
|
|
26
|
+
'X-Api-Key': headers.apiKey,
|
|
27
|
+
'X-Request-Id': headers.xRequestId,
|
|
28
|
+
'Content-Type': 'application/json',
|
|
29
|
+
'Magento-Customer-Group': headers.customerGroup
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getProductSearch = async ({
|
|
34
|
+
environmentId,
|
|
35
|
+
websiteCode,
|
|
36
|
+
storeCode,
|
|
37
|
+
storeViewCode,
|
|
38
|
+
apiKey,
|
|
39
|
+
apiUrl,
|
|
40
|
+
phrase,
|
|
41
|
+
pageSize = 24,
|
|
42
|
+
displayOutOfStock,
|
|
43
|
+
currentPage = 1,
|
|
44
|
+
xRequestId = uuidv4(),
|
|
45
|
+
filter = [],
|
|
46
|
+
sort = [],
|
|
47
|
+
context,
|
|
48
|
+
categorySearch = false
|
|
49
|
+
}) => {
|
|
50
|
+
const variables = {
|
|
51
|
+
phrase,
|
|
52
|
+
pageSize,
|
|
53
|
+
currentPage,
|
|
54
|
+
filter,
|
|
55
|
+
sort,
|
|
56
|
+
context
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
// default filters if search is "catalog (category)" or "search"
|
|
60
|
+
let searchType = 'Search';
|
|
61
|
+
if (categorySearch) {
|
|
62
|
+
searchType = 'Catalog';
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const defaultFilters = {
|
|
66
|
+
attribute: 'visibility',
|
|
67
|
+
in: [searchType, 'Catalog, Search']
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
variables.filter.push(defaultFilters); //add default visibility filter
|
|
71
|
+
|
|
72
|
+
const displayInStockOnly = displayOutOfStock != '1'; // '!=' is intentional for conversion
|
|
73
|
+
|
|
74
|
+
const inStockFilter = {
|
|
75
|
+
attribute: 'inStock',
|
|
76
|
+
eq: 'true'
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
if (displayInStockOnly) {
|
|
80
|
+
variables.filter.push(inStockFilter);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const headers = getHeaders({
|
|
84
|
+
environmentId,
|
|
85
|
+
websiteCode,
|
|
86
|
+
storeCode,
|
|
87
|
+
storeViewCode,
|
|
88
|
+
apiKey,
|
|
89
|
+
xRequestId,
|
|
90
|
+
customerGroup:
|
|
91
|
+
context && context.customerGroup ? context.customerGroup : ''
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
// ====== initialize data collection =====
|
|
95
|
+
const searchRequestId = uuidv4();
|
|
96
|
+
|
|
97
|
+
updateSearchInputCtx(
|
|
98
|
+
SEARCH_UNIT_ID,
|
|
99
|
+
searchRequestId,
|
|
100
|
+
phrase,
|
|
101
|
+
filter,
|
|
102
|
+
pageSize,
|
|
103
|
+
currentPage,
|
|
104
|
+
sort
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const magentoStorefrontEvtPublish = window.magentoStorefrontEvents?.publish;
|
|
108
|
+
|
|
109
|
+
if (magentoStorefrontEvtPublish?.searchRequestSent) {
|
|
110
|
+
magentoStorefrontEvtPublish.searchRequestSent(SEARCH_UNIT_ID);
|
|
111
|
+
}
|
|
112
|
+
// ====== end of data collection =====
|
|
113
|
+
|
|
114
|
+
const response = await fetch(apiUrl, {
|
|
115
|
+
method: 'POST',
|
|
116
|
+
headers,
|
|
117
|
+
body: JSON.stringify({
|
|
118
|
+
query: PRODUCT_SEARCH_QUERY,
|
|
119
|
+
variables: { ...variables }
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const results = await response.json();
|
|
124
|
+
// ====== initialize data collection =====
|
|
125
|
+
updateSearchResultsCtx(
|
|
126
|
+
SEARCH_UNIT_ID,
|
|
127
|
+
searchRequestId,
|
|
128
|
+
results?.data?.productSearch
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
if (magentoStorefrontEvtPublish?.searchResponseReceived) {
|
|
132
|
+
magentoStorefrontEvtPublish.searchResponseReceived(SEARCH_UNIT_ID);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (categorySearch) {
|
|
136
|
+
magentoStorefrontEvtPublish?.categoryResultsView &&
|
|
137
|
+
magentoStorefrontEvtPublish.categoryResultsView(SEARCH_UNIT_ID);
|
|
138
|
+
} else {
|
|
139
|
+
magentoStorefrontEvtPublish?.searchResultsView &&
|
|
140
|
+
magentoStorefrontEvtPublish.searchResultsView(SEARCH_UNIT_ID);
|
|
141
|
+
}
|
|
142
|
+
// ====== end of data collection =====
|
|
143
|
+
|
|
144
|
+
return results?.data;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const getAttributeMetadata = async ({
|
|
148
|
+
environmentId,
|
|
149
|
+
websiteCode,
|
|
150
|
+
storeCode,
|
|
151
|
+
storeViewCode,
|
|
152
|
+
apiKey,
|
|
153
|
+
apiUrl,
|
|
154
|
+
xRequestId = uuidv4()
|
|
155
|
+
}) => {
|
|
156
|
+
const headers = getHeaders({
|
|
157
|
+
environmentId,
|
|
158
|
+
websiteCode,
|
|
159
|
+
storeCode,
|
|
160
|
+
storeViewCode,
|
|
161
|
+
apiKey,
|
|
162
|
+
xRequestId,
|
|
163
|
+
customerGroup: ''
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
try {
|
|
167
|
+
const response = await fetch(apiUrl, {
|
|
168
|
+
method: 'POST',
|
|
169
|
+
headers,
|
|
170
|
+
body: JSON.stringify({
|
|
171
|
+
query: ATTRIBUTE_METADATA_QUERY
|
|
172
|
+
})
|
|
173
|
+
});
|
|
174
|
+
const results = await response.json();
|
|
175
|
+
return results?.data;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error('Metadata fetch failed:', error);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
const refineProductSearch = async ({
|
|
182
|
+
environmentId,
|
|
183
|
+
websiteCode,
|
|
184
|
+
storeCode,
|
|
185
|
+
storeViewCode,
|
|
186
|
+
apiKey,
|
|
187
|
+
apiUrl,
|
|
188
|
+
xRequestId = uuidv4(),
|
|
189
|
+
context,
|
|
190
|
+
optionIds,
|
|
191
|
+
sku
|
|
192
|
+
}) => {
|
|
193
|
+
const variables = {
|
|
194
|
+
optionIds,
|
|
195
|
+
sku
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
const headers = getHeaders({
|
|
199
|
+
environmentId,
|
|
200
|
+
websiteCode,
|
|
201
|
+
storeCode,
|
|
202
|
+
storeViewCode,
|
|
203
|
+
apiKey,
|
|
204
|
+
xRequestId,
|
|
205
|
+
customerGroup:
|
|
206
|
+
context && context.customerGroup ? context.customerGroup : ''
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const response = await fetch(apiUrl, {
|
|
210
|
+
method: 'POST',
|
|
211
|
+
headers,
|
|
212
|
+
body: JSON.stringify({
|
|
213
|
+
query: REFINE_PRODUCT_QUERY,
|
|
214
|
+
variables: { ...variables }
|
|
215
|
+
})
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
const results = await response.json();
|
|
219
|
+
return results?.data;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export { getAttributeMetadata, getProductSearch, refineProductSearch };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
|
|
12
|
+
import CartIcon from '../../icons/cart.svg';
|
|
13
|
+
|
|
14
|
+
const AddToCartButton = ({ onClick }) => {
|
|
15
|
+
return (
|
|
16
|
+
<div className="ds-sdk-add-to-cart-button">
|
|
17
|
+
<button
|
|
18
|
+
className="flex items-center justify-center text-white text-sm rounded-full h-[32px] w-full p-sm"
|
|
19
|
+
style={{
|
|
20
|
+
backgroundColor: '#464646'
|
|
21
|
+
}}
|
|
22
|
+
onClick={onClick}
|
|
23
|
+
>
|
|
24
|
+
<img src={CartIcon} className="w-[24px] pr-4" />
|
|
25
|
+
{/* <CartIcon className="w-[24px] pr-4" /> */}
|
|
26
|
+
Add To Cart
|
|
27
|
+
</button>
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default AddToCartButton;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Meta, Canvas, Story, ArgsTable } from '@storybook/addon-docs';
|
|
2
|
+
import { action } from '@storybook/addon-actions';
|
|
3
|
+
import AddToCartButton from '../AddToCartButton';
|
|
4
|
+
|
|
5
|
+
<Meta
|
|
6
|
+
title="PLP/AddToCartButton"
|
|
7
|
+
component={AddToCartButton}
|
|
8
|
+
parameters={{ layout: 'centered' }}
|
|
9
|
+
/>
|
|
10
|
+
|
|
11
|
+
export const Template = (args) => <AddToCartButton {...args} />;
|
|
12
|
+
|
|
13
|
+
# AddToCartButton
|
|
14
|
+
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import Checkmark from '../../icons/checkmark.svg';
|
|
12
|
+
import Error from '../../icons/error.svg';
|
|
13
|
+
import Info from '../../icons/info.svg';
|
|
14
|
+
import Warning from '../../icons/warning.svg';
|
|
15
|
+
import X from '../../icons/x.svg';
|
|
16
|
+
|
|
17
|
+
export const Alert = ({ title, type, description, url, onClick }) => {
|
|
18
|
+
return (
|
|
19
|
+
<div className="mx-auto max-w-8xl">
|
|
20
|
+
{(() => {
|
|
21
|
+
switch (type) {
|
|
22
|
+
case 'error':
|
|
23
|
+
return (
|
|
24
|
+
<div className="rounded-md bg-red-50 p-4">
|
|
25
|
+
<div className="flex items-center">
|
|
26
|
+
<div className="flex-shrink-0 p-1">
|
|
27
|
+
<img src={Error} className="h-5 w-5 text-red-400" aria-hidden="true" />
|
|
28
|
+
{/* <Error
|
|
29
|
+
className="h-5 w-5 text-red-400"
|
|
30
|
+
aria-hidden="true"
|
|
31
|
+
/> */}
|
|
32
|
+
</div>
|
|
33
|
+
<div className="ml-3">
|
|
34
|
+
<h3 className="text-sm font-medium text-red-800">
|
|
35
|
+
{title}
|
|
36
|
+
</h3>
|
|
37
|
+
{description?.length > 0 && (
|
|
38
|
+
<div className="mt-2 text-sm text-red-700">
|
|
39
|
+
<p>{description}</p>
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
case 'warning':
|
|
47
|
+
return (
|
|
48
|
+
<div className="rounded-md bg-yellow-50 p-4">
|
|
49
|
+
<div className="flex items-center">
|
|
50
|
+
<div className="flex-shrink-0 p-1">
|
|
51
|
+
<img src={Warning} className="h-5 w-5 text-yellow-400" aria-hidden="true" />
|
|
52
|
+
{/* <Warning
|
|
53
|
+
className="h-5 w-5 text-yellow-400"
|
|
54
|
+
aria-hidden="true"
|
|
55
|
+
/> */}
|
|
56
|
+
</div>
|
|
57
|
+
<div className="ml-3">
|
|
58
|
+
<h3 className="text-sm font-medium text-yellow-800">
|
|
59
|
+
{title}
|
|
60
|
+
</h3>
|
|
61
|
+
{description?.length > 0 && (
|
|
62
|
+
<div className="mt-2 text-sm text-yellow-700">
|
|
63
|
+
<p>{description}</p>
|
|
64
|
+
</div>
|
|
65
|
+
)}
|
|
66
|
+
</div>
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
);
|
|
70
|
+
case 'info':
|
|
71
|
+
return (
|
|
72
|
+
<div className="rounded-md bg-blue-50 p-4">
|
|
73
|
+
<div className="flex items-center">
|
|
74
|
+
<div className="flex-shrink-0 p-1">
|
|
75
|
+
<img src={Info} className="h-5 w-5 text-blue-400" aria-hidden="true" />
|
|
76
|
+
{/* <Info
|
|
77
|
+
className="h-5 w-5 text-blue-400"
|
|
78
|
+
aria-hidden="true"
|
|
79
|
+
/> */}
|
|
80
|
+
</div>
|
|
81
|
+
<div className="ml-3 flex-1 md:flex md:justify-between">
|
|
82
|
+
<div>
|
|
83
|
+
<h3 className="text-sm font-medium text-blue-800">
|
|
84
|
+
{title}
|
|
85
|
+
</h3>
|
|
86
|
+
{description?.length > 0 && (
|
|
87
|
+
<div className="mt-2 text-sm text-blue-700">
|
|
88
|
+
<p>{description}</p>
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
{url && (
|
|
93
|
+
<div className="mt-4 text-sm md:ml-6">
|
|
94
|
+
<a
|
|
95
|
+
href={url}
|
|
96
|
+
className="whitespace-nowrap font-medium text-blue-700 hover:text-blue-600"
|
|
97
|
+
>
|
|
98
|
+
Details
|
|
99
|
+
<span aria-hidden="true">→</span>
|
|
100
|
+
</a>
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
case 'success':
|
|
108
|
+
return (
|
|
109
|
+
<div className="rounded-md bg-green-50 p-4">
|
|
110
|
+
<div className="flex items-center">
|
|
111
|
+
<div className="flex-shrink-0 p-1">
|
|
112
|
+
<img src={Checkmark} alt="Success" className="h-5 w-5 text-green-400" aria-hidden="true" />
|
|
113
|
+
{/* <Checkmark
|
|
114
|
+
className="h-5 w-5 text-green-400"
|
|
115
|
+
aria-hidden="true"
|
|
116
|
+
/> */}
|
|
117
|
+
</div>
|
|
118
|
+
<div className="ml-3">
|
|
119
|
+
<h3 className="text-sm font-medium text-green-800">
|
|
120
|
+
{title}
|
|
121
|
+
</h3>
|
|
122
|
+
{description?.length > 0 && (
|
|
123
|
+
<div className="mt-2 text-sm text-green-700">
|
|
124
|
+
<p>{description}</p>
|
|
125
|
+
</div>
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
{onClick && (
|
|
129
|
+
<div className="ml-auto">
|
|
130
|
+
<div className="md:ml-6">
|
|
131
|
+
<button
|
|
132
|
+
type="button"
|
|
133
|
+
className="inline-flex rounded-md bg-green-50 p-1.5 text-green-500 ring-off hover:bg-green-100 focus:outline-none focus:ring-2 focus:ring-green-600 focus:ring-offset-2 focus:ring-offset-green-50"
|
|
134
|
+
onClick={onClick}
|
|
135
|
+
>
|
|
136
|
+
<span className="sr-only">Dismiss</span>
|
|
137
|
+
<img src={X} className="h-5 w-5" aria-hidden="true" />
|
|
138
|
+
{/* <X
|
|
139
|
+
className="h-5 w-5"
|
|
140
|
+
aria-hidden="true"
|
|
141
|
+
/> */}
|
|
142
|
+
</button>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
)}
|
|
146
|
+
</div>
|
|
147
|
+
</div>
|
|
148
|
+
);
|
|
149
|
+
default:
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
})()}
|
|
153
|
+
</div>
|
|
154
|
+
);
|
|
155
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from './Alert';
|
|
11
|
+
export { Alert as default } from './Alert';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Chevron from '../../icons/chevron.svg';
|
|
3
|
+
|
|
4
|
+
export const Breadcrumbs = ({ pages }) => {
|
|
5
|
+
return (
|
|
6
|
+
<nav className="ds-sdk-breadcrumbs flex" aria-label="Breadcrumbs">
|
|
7
|
+
<ol role="list" className="flex column items-center space-x-2">
|
|
8
|
+
{pages.map((page, index) => (
|
|
9
|
+
<li key={page.name} className="ds-sdk-breadcrumbs__item">
|
|
10
|
+
<div className="flex items-center">
|
|
11
|
+
{index > 0 && (
|
|
12
|
+
<Chevron className="h-sm w-sm transform -rotate-90 stroke-gray-400" />
|
|
13
|
+
)}
|
|
14
|
+
|
|
15
|
+
<a
|
|
16
|
+
href={page.href}
|
|
17
|
+
className={`ml-2 text-sm font-normal hover:text-gray-900 first:ml-0 ${
|
|
18
|
+
page.current
|
|
19
|
+
? 'ds-sdk-breadcrumbs__item--current text-gray-500 font-light'
|
|
20
|
+
: 'text-black'
|
|
21
|
+
}`}
|
|
22
|
+
aria-current={page.current ? 'page' : undefined}
|
|
23
|
+
>
|
|
24
|
+
{page.name}
|
|
25
|
+
</a>
|
|
26
|
+
</div>
|
|
27
|
+
</li>
|
|
28
|
+
))}
|
|
29
|
+
</ol>
|
|
30
|
+
</nav>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default Breadcrumbs;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const pages = [
|
|
11
|
+
{ name: 'Category I', href: '#', current: false },
|
|
12
|
+
{ name: 'Category II', href: '#', current: false },
|
|
13
|
+
{ name: 'Category III', href: '#', current: true }
|
|
14
|
+
];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from './Breadcrumbs';
|
|
11
|
+
export { Breadcrumbs as default } from './Breadcrumbs';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@keyframes placeholderShimmer {
|
|
2
|
+
0% {
|
|
3
|
+
background-position: calc(100vw + 40px);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
100% {
|
|
7
|
+
background-position: calc(100vw - 40px);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.shimmer-animation-button {
|
|
12
|
+
background-color: #f6f7f8;
|
|
13
|
+
background-image: linear-gradient(
|
|
14
|
+
to right,
|
|
15
|
+
#f6f7f8 0%,
|
|
16
|
+
#edeef1 20%,
|
|
17
|
+
#f6f7f8 40%,
|
|
18
|
+
#f6f7f8 100%
|
|
19
|
+
);
|
|
20
|
+
background-repeat: no-repeat;
|
|
21
|
+
background-size: 100vw 4rem;
|
|
22
|
+
animation-duration: 1s;
|
|
23
|
+
animation-fill-mode: forwards;
|
|
24
|
+
animation-iteration-count: infinite;
|
|
25
|
+
animation-name: placeholderShimmer;
|
|
26
|
+
animation-timing-function: linear;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.ds-plp-facets__button {
|
|
30
|
+
height: 3rem;
|
|
31
|
+
width: 160px;
|
|
32
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import '../ButtonShimmer/ButtonShimmer.css';
|
|
11
|
+
import React from 'react';
|
|
12
|
+
|
|
13
|
+
export const ButtonShimmer = () => {
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<div className="ds-plp-facets ds-plp-facets--loading">
|
|
17
|
+
<div className="ds-plp-facets__button shimmer-animation-button" />
|
|
18
|
+
</div>
|
|
19
|
+
</>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
//export default ButtonShimmer;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export * from './ButtonShimmer';
|
|
11
|
+
export { ButtonShimmer as default } from './ButtonShimmer';
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2024 Adobe
|
|
3
|
+
All Rights Reserved.
|
|
4
|
+
|
|
5
|
+
NOTICE: Adobe permits you to use, modify, and distribute this file in
|
|
6
|
+
accordance with the terms of the Adobe license agreement accompanying
|
|
7
|
+
it.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { useTranslation } from '../../context/translation';
|
|
12
|
+
import { Facets } from '../Facets';
|
|
13
|
+
import { FilterButton } from '../FilterButton';
|
|
14
|
+
|
|
15
|
+
export const CategoryFilters = ({
|
|
16
|
+
loading,
|
|
17
|
+
pageLoading,
|
|
18
|
+
totalCount,
|
|
19
|
+
facets,
|
|
20
|
+
categoryName,
|
|
21
|
+
phrase,
|
|
22
|
+
setShowFilters,
|
|
23
|
+
filterCount,
|
|
24
|
+
}) => {
|
|
25
|
+
const translation = useTranslation();
|
|
26
|
+
let title = categoryName || '';
|
|
27
|
+
if (phrase) {
|
|
28
|
+
const text = translation.CategoryFilters.results;
|
|
29
|
+
title = text.replace('{phrase}', `"${phrase}"`);
|
|
30
|
+
}
|
|
31
|
+
const resultsTranslation = translation.CategoryFilters.products;
|
|
32
|
+
const results = resultsTranslation.replace('{totalCount}', `${totalCount}`);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="sm:flex ds-widgets-_actions relative max-w-[21rem] w-full h-full px-2 flex-col overflow-y-auto">
|
|
36
|
+
<div className="ds-widgets_actions_header flex justify-between items-center mb-md">
|
|
37
|
+
{title && <span> {title}</span>}
|
|
38
|
+
{!loading && <span className="text-primary text-sm">{results}</span>}
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
{!pageLoading && facets.length > 0 && (
|
|
42
|
+
<>
|
|
43
|
+
<div className="flex pb-4 w-full h-full">
|
|
44
|
+
<FilterButton
|
|
45
|
+
displayFilter={() => setShowFilters(false)}
|
|
46
|
+
type="desktop"
|
|
47
|
+
title={`${translation.Filter.hideTitle}${
|
|
48
|
+
filterCount > 0 ? ` (${filterCount})` : ''
|
|
49
|
+
}`}
|
|
50
|
+
/>
|
|
51
|
+
</div>
|
|
52
|
+
<Facets searchFacets={facets} />
|
|
53
|
+
</>
|
|
54
|
+
)}
|
|
55
|
+
</div>
|
|
56
|
+
);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export default CategoryFilters;
|