wickes-css2 2.112.0-develop.4 → 2.112.0-develop.7

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 (66) hide show
  1. package/Readme.md +1 -1
  2. package/build/css/category-main.css +1 -1
  3. package/build/css/components/global-search.css +1 -1
  4. package/build/css/homepage-main.css +1 -1
  5. package/build/css/kitchen-plp-main.css +1 -1
  6. package/build/css/main.css +1 -1
  7. package/build/css/my-account-main-v2.css +1 -1
  8. package/build/css/my-account-main.css +1 -1
  9. package/build/css/pages/page_product-details-critical.css +1 -1
  10. package/build/css/pages/page_product-details.css +1 -1
  11. package/build/css/pdp-main-before-combine.css +1 -1
  12. package/build/css/pdp-main-critical.css +1 -1
  13. package/build/css/pdp-main-non-critical.css +1 -1
  14. package/build/css/pdp-main.css +1 -1
  15. package/build/css/plp-main.css +1 -1
  16. package/build/css/store-locator-main.css +1 -1
  17. package/build/js/basket.min.js +1 -1
  18. package/build/js/bloomreach-widget.min.js +1 -1
  19. package/build/js/emulation.min.js +664 -38
  20. package/build/js/page/basket-v2.js +29 -20
  21. package/build/js/page/bloomreach-widget/bloomreach-widget.js +250 -0
  22. package/build/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js} +205 -359
  23. package/build/js/page/bloomreach-widget/why-not-add-widget.js +198 -0
  24. package/package.json +1 -5
  25. package/src/components/bloomreach/complete-card.hbs +4 -32
  26. package/src/components/bloomreach/why-not-add-card-skeleton.hbs +14 -0
  27. package/src/components/bloomreach/why-not-add-card.hbs +73 -0
  28. package/src/components/bloomreach/why-not-add-content.hbs +41 -0
  29. package/src/components/bloomreach/why-not-add-skeleton.hbs +9 -0
  30. package/src/components/bloomreach/why-not-add.hbs +6 -0
  31. package/src/components/my-account/order.hbs +6 -1
  32. package/src/components/order-item.hbs +7 -7
  33. package/src/components/pdp-price-actions.hbs +2 -2
  34. package/src/components/potential-promotion.hbs +4 -4
  35. package/src/components/price-badges.hbs +12 -0
  36. package/src/components/price-block-v2.hbs +5 -12
  37. package/src/components/reviews-rating.hbs +22 -0
  38. package/src/components/share-list-modal-without-social-icons.hbs +2 -2
  39. package/src/components/share-list-modal.hbs +7 -3
  40. package/src/data/data_shopping-cart-v2.json +46 -2
  41. package/src/data/data_shopping-cart-with-energy.json +26 -2
  42. package/src/data/my-account/data_my-order.json +8 -0
  43. package/src/js/emulation/basket-data.js +312 -0
  44. package/src/js/emulation/bloomreach-widget-loading.js +2 -2
  45. package/src/js/emulation/mock.js +309 -0
  46. package/src/js/emulation/shopping-list.js +40 -49
  47. package/src/js/emulation/why-not-add-loading.js +11 -0
  48. package/src/js/emulation/why-not-add.js +28 -0
  49. package/src/js/page/basket-v2.js +29 -20
  50. package/src/js/page/bloomreach-widget/bloomreach-widget.js +250 -0
  51. package/src/js/page/{bloomreach-widget.js → bloomreach-widget/complete-your-project-widget.js} +205 -359
  52. package/src/js/page/bloomreach-widget/why-not-add-widget.js +198 -0
  53. package/src/page_product-details-bloomreach.html +1 -1
  54. package/src/page_product-details-with-global-search-v2.html +2 -1
  55. package/src/page_product-details-with-why-not-add-single.html +131 -0
  56. package/src/page_track-my-order-result.html +1 -0
  57. package/src/scss/components/_tradepro-discount-banner.scss +10 -14
  58. package/src/scss/components/bloomreach/_bloomreach.scss +3 -0
  59. package/src/scss/components/bloomreach/_complete-card.scss +0 -38
  60. package/src/scss/components/bloomreach/_reviews.scss +60 -0
  61. package/src/scss/components/bloomreach/_why-not-add-card.scss +223 -0
  62. package/src/scss/components/bloomreach/_why-not-add.scss +143 -0
  63. package/src/scss/components/global-search.scss +0 -6
  64. package/src/scss/pages/page_product-details-critical.scss +7 -0
  65. package/src/scss/pages/page_product-details.scss +7 -0
  66. package/src/sitemap.html +10 -4
@@ -0,0 +1,250 @@
1
+ var Wick = window.Wick || {};
2
+
3
+ import { isApp } from '../utils/helpers';
4
+ import { createEvent } from '../utils/create-event';
5
+ import CompleteYourProjectWidget from './complete-your-project-widget';
6
+ import WhyNotAddWidget from './why-not-add-widget';
7
+
8
+ Wick.BloomreachWidget = {
9
+ widgets: {},
10
+
11
+ el: {
12
+ loadingButtonText: '.loading-button__text',
13
+ loadingButtonLoader: '.loading-button__loader',
14
+ ratingOverlay: '.rating-overlay',
15
+ starOverlay: '.star-overlay',
16
+ vatInc: '.including-vat-inherit',
17
+ vatExc: '.excluding-vat-inherit',
18
+ },
19
+
20
+ registerWidgets(widgetList) {
21
+ widgetList.forEach(function ({ type, widget }) {
22
+ Wick.BloomreachWidget.widgets[type] = widget;
23
+ });
24
+ },
25
+
26
+ getWidget(type) {
27
+ return Wick.BloomreachWidget.widgets[type];
28
+ },
29
+
30
+ init(type, payloadData) {
31
+ const widget = Wick.BloomreachWidget.getWidget(type);
32
+
33
+ if (!widget || typeof widget.init !== 'function') {
34
+ return;
35
+ }
36
+
37
+ widget.init(payloadData, Wick.BloomreachWidget);
38
+ },
39
+
40
+ normalizePayload(payloadData) {
41
+ if (Array.isArray(payloadData)) {
42
+ return payloadData;
43
+ }
44
+
45
+ if (payloadData && Array.isArray(payloadData.recommendedProducts)) {
46
+ return payloadData.recommendedProducts;
47
+ }
48
+
49
+ return [];
50
+ },
51
+
52
+ hasRecommendations(payloadData) {
53
+ return Wick.BloomreachWidget.normalizePayload(payloadData).length > 0;
54
+ },
55
+
56
+ getDisplayPrice(product) {
57
+ return product.displayPrice || product.price || {};
58
+ },
59
+
60
+ getDisplayPriceExcVat(product) {
61
+ return product.displayPriceExclusiveVat || product.priceExclusiveVat || null;
62
+ },
63
+
64
+ getPriceValue(price) {
65
+ return price && typeof price.value === 'number' ? price.value : 0;
66
+ },
67
+
68
+ getPriceFormattedValue(price) {
69
+ if (!price) {
70
+ return '';
71
+ }
72
+
73
+ if (price.formattedValue) {
74
+ return price.formattedValue;
75
+ }
76
+
77
+ if (typeof price.value === 'number') {
78
+ return Wick.BloomreachWidget.formatPrice(price.value);
79
+ }
80
+
81
+ return '';
82
+ },
83
+
84
+ removeBlankTargets($root) {
85
+ if (!isApp()) {
86
+ return;
87
+ }
88
+
89
+ $root.find('a[target="_blank"]').removeAttr('target');
90
+ },
91
+
92
+ getWasPrice(product) {
93
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
94
+
95
+ return displayPrice && displayPrice.wasPrice ? displayPrice.wasPrice : null;
96
+ },
97
+
98
+ getWasPriceFormatted(product) {
99
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
100
+ const wasPrice = Wick.BloomreachWidget.getWasPrice(product);
101
+
102
+ if (wasPrice && wasPrice.formattedValue) {
103
+ return wasPrice.formattedValue;
104
+ }
105
+
106
+ if (typeof wasPrice === 'number') {
107
+ return Wick.BloomreachWidget.formatPrice(wasPrice);
108
+ }
109
+
110
+ if (wasPrice) {
111
+ return `${displayPrice.currencySymbol || '£'}${wasPrice}`;
112
+ }
113
+
114
+ return '';
115
+ },
116
+
117
+ getExcVatWasPrice(product) {
118
+ const priceExclusiveVat = product.priceExclusiveVat || null;
119
+ const displayPriceExclusiveVat = product.displayPriceExclusiveVat || null;
120
+ const wasPrice =
121
+ (displayPriceExclusiveVat && displayPriceExclusiveVat.wasPrice) ||
122
+ (priceExclusiveVat && priceExclusiveVat.wasPrice);
123
+
124
+ if (wasPrice && wasPrice.formattedValue) {
125
+ return wasPrice.formattedValue;
126
+ }
127
+
128
+ if (typeof wasPrice === 'number') {
129
+ return Wick.BloomreachWidget.formatPrice(wasPrice);
130
+ }
131
+
132
+ return wasPrice || '';
133
+ },
134
+
135
+ getProductImage(product, fallbackProduct) {
136
+ const productImages = product.images || [];
137
+ const fallbackImages = fallbackProduct ? fallbackProduct.images || [] : [];
138
+ const images = productImages.length ? productImages : fallbackImages;
139
+
140
+ return (
141
+ images.find(function (item) {
142
+ return item.format === 'product';
143
+ }) ||
144
+ images.find(function (item) {
145
+ return item.imageType === 'PRIMARY';
146
+ }) ||
147
+ images[0] ||
148
+ {}
149
+ );
150
+ },
151
+
152
+ getProductRenderData(product, options = {}) {
153
+ const displayPrice = Wick.BloomreachWidget.getDisplayPrice(product);
154
+ const displayPriceExcVat = Wick.BloomreachWidget.getDisplayPriceExcVat(product);
155
+ const wasPriceFormatted = Wick.BloomreachWidget.getWasPriceFormatted(product);
156
+ const excVatWasPriceFormatted = Wick.BloomreachWidget.getExcVatWasPrice(product);
157
+ const isSwitchVat = !!(window.ACC && window.ACC.app && window.ACC.app.isVatToggleAvailable);
158
+
159
+ return {
160
+ ...product,
161
+ price: displayPrice,
162
+ image:
163
+ options.image ||
164
+ Wick.BloomreachWidget.getProductImage(product, options.fallbackProduct),
165
+ wasPriceFormatted,
166
+ 'switch-vat': isSwitchVat,
167
+ incVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPrice),
168
+ incVatValue: Wick.BloomreachWidget.getPriceValue(displayPrice),
169
+ excVatFormattedValue: Wick.BloomreachWidget.getPriceFormattedValue(displayPriceExcVat),
170
+ excVatValue: Wick.BloomreachWidget.getPriceValue(displayPriceExcVat),
171
+ incVatWasPriceFormatted: wasPriceFormatted,
172
+ excVatWasPriceFormatted: Wick.BloomreachWidget.getExcVatWasPrice(product),
173
+ };
174
+ },
175
+
176
+ drawRating($root) {
177
+ const { ratingOverlay, starOverlay } = Wick.BloomreachWidget.el;
178
+
179
+ $root.find(ratingOverlay).each(function () {
180
+ let rating = parseFloat($(this).attr('data-rating')) || 0;
181
+ const $stars = $(this).children(starOverlay);
182
+
183
+ $stars.each(function () {
184
+ const $star = $(this);
185
+
186
+ if (rating >= 1) {
187
+ rating--;
188
+ } else if (rating > 0) {
189
+ const width = Math.asin(2 * rating - 1) / Math.PI + 0.5;
190
+ $star.css('width', width + 'rem');
191
+ rating = 0;
192
+ } else {
193
+ $star.css('width', '0rem');
194
+ }
195
+ });
196
+ });
197
+ },
198
+
199
+ dispatchWidgetEvent(eventName, payload) {
200
+ return new Promise(function (resolve, reject) {
201
+ const eventDetail = { resolve, reject };
202
+ const event = createEvent(eventName, payload, eventDetail);
203
+
204
+ window.dispatchEvent(event);
205
+ });
206
+ },
207
+
208
+ reapplyVatDisplay() {
209
+ if (!Wick.VatToggle || typeof Wick.VatToggle.isActive !== 'function') {
210
+ return;
211
+ }
212
+
213
+ const { vatInc, vatExc } = Wick.BloomreachWidget.el;
214
+ const hiddenClassName = Wick.VatToggle.HIDDEN_CLASS_NAME || 'd-none';
215
+ const isExcVatActive = Wick.VatToggle.isActive();
216
+
217
+ $(vatInc).toggleClass(hiddenClassName, isExcVatActive);
218
+ $(vatExc).toggleClass(hiddenClassName, !isExcVatActive);
219
+ },
220
+
221
+ bindVatToggle(namespace) {
222
+ if (!Wick.VatToggle || !Wick.VatToggle.TOGGLE_VAT_EVENT_NAME) {
223
+ return;
224
+ }
225
+
226
+ const eventName = `${Wick.VatToggle.TOGGLE_VAT_EVENT_NAME}.${namespace}`;
227
+
228
+ $(window).off(eventName).on(eventName, Wick.BloomreachWidget.reapplyVatDisplay);
229
+ },
230
+
231
+ formatPrice(value) {
232
+ return new Intl.NumberFormat('en-GB', {
233
+ style: 'currency',
234
+ currency: 'GBP',
235
+ minimumFractionDigits: 2,
236
+ maximumFractionDigits: 2,
237
+ }).format(value);
238
+ },
239
+ };
240
+
241
+ Wick.BloomreachWidget.registerWidgets([
242
+ {
243
+ type: 'completeYourProject',
244
+ widget: CompleteYourProjectWidget,
245
+ },
246
+ {
247
+ type: 'whyNotAdd',
248
+ widget: WhyNotAddWidget,
249
+ },
250
+ ]);