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
@@ -277,13 +277,14 @@ Wick.BasketPage = {
277
277
  if (isSwitchVat) {
278
278
  const itemTotalIncVat = context.find(Wick.BasketPage.el.itemTotalIncVat);
279
279
  const itemTotalExcVat = context.find(Wick.BasketPage.el.itemTotalExcVat);
280
- const totalPrice = data.entry.itemTotalWithoutDiscount.formattedValue;
281
- const totalPriceExcVat = data.entry.itemTotalWithoutDiscountExcVat.formattedValue;
280
+ const totalPrice = data.entry.displayItemTotalWithoutDiscount.formattedValue;
281
+ const totalPriceExcVat =
282
+ data.entry.displayItemTotalWithoutDiscountExclusiveVat.formattedValue;
282
283
  itemTotalIncVat.text(totalPrice);
283
284
  itemTotalExcVat.text(totalPriceExcVat);
284
285
  } else {
285
286
  const totalValue = context.find(Wick.BasketPage.el.itemTotal);
286
- const totalPrice = data.entry.itemTotalWithoutDiscount.formattedValue;
287
+ const totalPrice = data.entry.displayItemTotalWithoutDiscount.formattedValue;
287
288
  totalValue.text(totalPrice);
288
289
  }
289
290
  }
@@ -798,20 +799,20 @@ Wick.BasketPage = {
798
799
  <div class="order-item__price-title">Item price:</div>
799
800
  <div class="order-item__price-value">
800
801
  ${
801
- currentItem.basePrice.value === 0
802
+ currentItem.displayBasePrice.value === 0
802
803
  ? '<span class="order-item__value">FREE</span>'
803
804
  : Wick.VatToggle.isToggleVatAvailable()
804
805
  ? `
805
806
  <div class="including-vat"><!--
806
- --><span class="order-item__value">${currentItem.basePrice.formattedValue}</span><!--
807
+ --><span class="order-item__value">${currentItem.displayBasePrice.formattedValue}</span><!--
807
808
  --><div class="price-vat">Inc.VAT</div>
808
809
  </div>
809
810
  <div class="excluding-vat"><!--
810
- --><span class="order-item__value">${currentItem.basePriceExcVat.formattedValue}</span><!--
811
+ --><span class="order-item__value">${currentItem.displayBasePriceExclusiveVat.formattedValue}</span><!--
811
812
  --><div class="price-vat">Exc.VAT</div>
812
813
  </div>
813
814
  `
814
- : `<span class="order-item__value">${currentItem.basePrice.formattedValue}</span>`
815
+ : `<span class="order-item__value">${currentItem.displayBasePrice.formattedValue}</span>`
815
816
  }
816
817
  </div>
817
818
  </div>
@@ -820,20 +821,20 @@ Wick.BasketPage = {
820
821
  <div class="order-item__total-title">Item total:</div>
821
822
  <div class="order-item__total-value">
822
823
  ${
823
- currentItem.itemTotalWithoutDiscount.value === 0
824
+ currentItem.displayItemTotalWithoutDiscount.value === 0
824
825
  ? '<span class="order-item__value">FREE</span>'
825
826
  : Wick.VatToggle.isToggleVatAvailable()
826
827
  ? `
827
828
  <div class="including-vat"><!--
828
- --><span class="order-item__value">${currentItem.itemTotalWithoutDiscount.formattedValue}</span><!--
829
+ --><span class="order-item__value">${currentItem.displayItemTotalWithoutDiscount.formattedValue}</span><!--
829
830
  --><div class="price-vat">Inc.VAT</div><!--
830
831
  --></div>
831
832
  <div class="excluding-vat"><!--
832
- --><span class="order-item__value">${currentItem.itemTotalWithoutDiscountExcVat.formattedValue}</span><!--
833
+ --><span class="order-item__value">${currentItem.displayItemTotalWithoutDiscountExclusiveVat.formattedValue}</span><!--
833
834
  --><div class="price-vat">Exc.VAT</div>
834
835
  </div>
835
836
  `
836
- : `<span class="order-item__value">${currentItem.itemTotalWithoutDiscount.formattedValue}</span>`
837
+ : `<span class="order-item__value">${currentItem.displayItemTotalWithoutDiscount.formattedValue}</span>`
837
838
  }
838
839
  </div>
839
840
  </div>
@@ -929,7 +930,7 @@ Wick.BasketPage = {
929
930
  data.appliedProductPromotions &&
930
931
  data.appliedProductPromotions.forEach((entry) => {
931
932
  entry.consumedEntries.forEach((promo) => {
932
- if (promo.orderEntryNumber === item.entryNumber && entry.description) {
933
+ if (promo.orderEntryNumber === item.entryNumber && entry.displayDescription) {
933
934
  if (arr.length) {
934
935
  let duplicate = arr.every((el) => {
935
936
  return el !== Wick.BasketPage.buildPromotion(entry);
@@ -1115,15 +1116,19 @@ Wick.BasketPage = {
1115
1116
  const arr = [];
1116
1117
  if (data.potentialOrderPromotions && data.potentialOrderPromotions.length) {
1117
1118
  data.potentialOrderPromotions.forEach((promo) => {
1118
- !promo.description ||
1119
+ !promo.displayDescription ||
1119
1120
  arr.push(`
1120
1121
  <div class="p-promotion">
1121
1122
  <div class="p-promotion__icon">
1122
1123
  <i class="icon fas fa-gift"></i>
1123
1124
  </div>
1124
- <div class="p-promotion__description">
1125
- ${promo.description}
1126
- </div>
1125
+ ${
1126
+ Wick.VatToggle.isToggleVatAvailable() &&
1127
+ promo.displayDescriptionExclusiveVat
1128
+ ? `<div class="p-promotion__description including-vat">${promo.displayDescription}</div>
1129
+ <div class="p-promotion__description excluding-vat d-none">${promo.displayDescriptionExclusiveVat}</div>`
1130
+ : `<div class="p-promotion__description">${promo.displayDescription}</div>`
1131
+ }
1127
1132
  <div class="p-promotion__close">
1128
1133
  <i class="icon fas fa-times"></i>
1129
1134
  </div>
@@ -1134,15 +1139,19 @@ Wick.BasketPage = {
1134
1139
 
1135
1140
  if (data.appliedOrderPromotions && data.appliedOrderPromotions.length) {
1136
1141
  data.appliedOrderPromotions.forEach((promo) => {
1137
- !promo.description ||
1142
+ !promo.displayDescription ||
1138
1143
  arr.push(`
1139
1144
  <div class="p-promotion">
1140
1145
  <div class="p-promotion__icon">
1141
1146
  <i class="icon fas fa-gift"></i>
1142
1147
  </div>
1143
- <div class="p-promotion__description">
1144
- ${promo.description}
1145
- </div>
1148
+ ${
1149
+ Wick.VatToggle.isToggleVatAvailable() &&
1150
+ promo.displayDescriptionExclusiveVat
1151
+ ? `<div class="p-promotion__description including-vat">${promo.displayDescription}</div>
1152
+ <div class="p-promotion__description excluding-vat d-none">${promo.displayDescriptionExclusiveVat}</div>`
1153
+ : `<div class="p-promotion__description">${promo.displayDescription}</div>`
1154
+ }
1146
1155
  <div class="p-promotion__close">
1147
1156
  <i class="icon fas fa-times"></i>
1148
1157
  </div>
@@ -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
+ ]);