@lancom/shared 0.0.216 → 0.0.218

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.
@@ -1,6 +1,8 @@
1
1
 
2
2
  import { _get, _post, _put, _delete, _patch } from './helpers';
3
3
  import adminApi from './admin';
4
+ import { unminifySimpleProducts } from './utils/simple-products';
5
+ import { unminifyProduct } from './utils/product';
4
6
 
5
7
  const api = {
6
8
  fetchClientSettings(shop, params) {
@@ -48,8 +50,8 @@ const api = {
48
50
  fetchPricingProducts(shop, params) {
49
51
  return _get(`shop/${shop}/products/pricing-products`, params);
50
52
  },
51
- fetchProduct(shop, alias, params) {
52
- return _get(`shop/${shop}/products/${alias}`, params);
53
+ async fetchProduct(shop, alias, params) {
54
+ return unminifyProduct(await _get(`shop/${shop}/products/${alias}`, params));
53
55
  },
54
56
  fetchCouponByCode(shop, code) {
55
57
  return _get(`shop/${shop}/coupons/${code}`);
@@ -72,8 +74,8 @@ const api = {
72
74
  fetchNewsTag(shop, alias) {
73
75
  return _get(`shop/${shop}/news-tag/${alias}`);
74
76
  },
75
- fetchProductDetails(shop, alias, params) {
76
- return _get(`shop/${shop}/products/${alias}/simple-products`, params);
77
+ async fetchProductDetails(shop, alias, params) {
78
+ return unminifySimpleProducts(await _get(`shop/${shop}/products/${alias}/simple-products`, params));
77
79
  },
78
80
  fetchRelatedProducts(shop, alias, params) {
79
81
  return _get(`shop/${shop}/products/${alias}/related-products`, params);
@@ -0,0 +1,65 @@
1
+ export function unminifyProduct(product) {
2
+ const { mapPrintTypes, mapPrintAreas, mapPrintSizes } = product;
3
+
4
+ product.printTypes = (product.printTypes || []).map(pt => {
5
+ return mapPrintTypes.find(({ _id }) => _id === pt);
6
+ });
7
+ if (product.productType) {
8
+ product.productType.printTypes = (product.productType.printTypes || []).map(pt => {
9
+ return mapPrintTypes.find(({ _id }) => _id === pt);
10
+ });
11
+ }
12
+
13
+
14
+ product.printAreas = (product.printAreas || []).map(pa => {
15
+ return mapPrintAreas.find(({ _id }) => _id === pa || _id === pa?._id);
16
+ });
17
+ if (product.productType) {
18
+ product.productType.printAreas = (product.productType.printAreas || []).map(pa => {
19
+ return mapPrintAreas.find(({ _id }) => _id === pa || _id === pa?._id);
20
+ });
21
+ }
22
+
23
+
24
+ (product.printAreas || []).forEach(pa => {
25
+ if (pa.printSize) {
26
+ pa.printSize = mapPrintSizes.find(({ _id }) => _id === pa.printSize || _id === pa.printSize?._id);
27
+ }
28
+ (pa.sizes || []).forEach(size => {
29
+ if (size.printSize) {
30
+ size.printSize = mapPrintSizes.find(({ _id }) => _id === size.printSize || _id === size.printSize?._id);
31
+ }
32
+ });
33
+ });
34
+ (product.printTypes || []).forEach(pt => {
35
+ (pt.printAreas || []).forEach(pa => {
36
+ pa.printSizes = (pa.printSizes || []).map(size => {
37
+ return mapPrintSizes.find(({ _id }) => _id === size || _id === size?._id);
38
+ });
39
+ });
40
+ });
41
+ if (product.productType) {
42
+ (product.productType.printAreas || []).forEach(pa => {
43
+ if (pa.printSize) {
44
+ pa.printSize = mapPrintSizes.find(({ _id }) => _id === pa.printSize || _id === pa.printSize?._id);
45
+ }
46
+ (pa.sizes || []).forEach(size => {
47
+ if (size.printSize) {
48
+ size.printSize = mapPrintSizes.find(({ _id }) => _id === size.printSize || _id === size.printSize?._id);
49
+ }
50
+ });
51
+ });
52
+ (product.productType.printTypes || []).forEach(pt => {
53
+ (pt.printAreas || []).forEach(pa => {
54
+ pa.printSizes = (pa.printSizes || []).map(size => {
55
+ return mapPrintSizes.find(({ _id }) => _id === size || _id === size?._id);
56
+ });
57
+ });
58
+ });
59
+ }
60
+
61
+
62
+
63
+
64
+ return product;
65
+ }
@@ -0,0 +1,7 @@
1
+ export function unminifySimpleProducts({ simpleProducts, colors, sizes }) {
2
+ simpleProducts.forEach(sp => {
3
+ sp.color = colors.find(c => c._id === sp.color);
4
+ sp.size = sizes.find(s => s._id === sp.size);
5
+ });
6
+ return simpleProducts;
7
+ }
@@ -49,10 +49,10 @@ export const getProductOriginCover = (product, type, color) => getProductCover(p
49
49
 
50
50
  export const getBgStyle = img => img && ({ 'background-image': `url("${img}")` });
51
51
 
52
- export function getColorBackgroundStyle(color) {
52
+ export function getColorBackgroundStyle(color, skipPattern) {
53
53
  const { rgb, pattern, name } = color || {};
54
54
 
55
- if (pattern) {
55
+ if (pattern && !skipPattern) {
56
56
  return {
57
57
  'background-image': `url("${staticLink(pattern)}")`
58
58
  };
@@ -24,7 +24,7 @@
24
24
  </template>
25
25
 
26
26
  <script>
27
- import { Power3, TimelineLite } from 'gsap';
27
+ // import { Power3, TimelineLite } from 'gsap';
28
28
  import api from '@lancom/shared/assets/js/api';
29
29
  import { staticLink } from '@lancom/shared/assets/js/utils/filters';
30
30
  import FailedConversionModal from '@lancom/shared/components/modals/failed_conversion_modal/failed-conversion-modal';
@@ -48,7 +48,7 @@ export default {
48
48
  rendered: null,
49
49
  error: null,
50
50
  progress: 0,
51
- timelineLite: new TimelineLite()
51
+ // timelineLite: new TimelineLite()
52
52
  };
53
53
  },
54
54
  methods: {
@@ -96,8 +96,8 @@ export default {
96
96
  }
97
97
  },
98
98
  onProgress(progress) {
99
- const duration = progress ? 0.1 : 0;
100
- this.timelineLite.to(this, duration, { progress, ease: Power3.easeIn });
99
+ // const duration = progress ? 0.1 : 0;
100
+ // this.timelineLite.to(this, duration, { progress, ease: Power3.easeIn });
101
101
  },
102
102
  toggle() {
103
103
  this.$refs.fileUploaderField.click();
@@ -1,8 +1,9 @@
1
1
  <template>
2
2
  <div
3
- class="Gallery__wrapper">
3
+ class="Gallery__wrapper"
4
+ @click="canLoadImages = true">
4
5
  <div class="Gallery__big">
5
- <vue-slick-carousel
6
+ <!-- <vue-slick-carousel
6
7
  ref="bigCarousel"
7
8
  :key="updateCarouselTime"
8
9
  :arrows="true"
@@ -12,14 +13,13 @@
12
13
  :speed="800"
13
14
  @beforeChange="onChange">
14
15
  <div
15
- v-for="image in filteredImages"
16
+ v-for="(image, index) in filteredImages"
16
17
  :key="image.large"
17
18
  v-hammer:press="onPanstart"
18
19
  v-hammer:pan="onPan"
19
20
  v-hammer:pressup="onPanend"
20
21
  v-hammer:panend="onPanend"
21
22
  class="Gallery__big-image"
22
- style="width: 300px; height: 300px;"
23
23
  :style="{
24
24
  // 'background-image': `url(${staticLink(image.large)}`,
25
25
  // 'background-size': backgroundSize,
@@ -31,10 +31,10 @@
31
31
  @mouseleave="onMouseLeave"
32
32
  @mousemove="onMouseMove">
33
33
  <img
34
+ v-if="index === 0 || canLoadImages"
34
35
  :src="staticLink(image.large)"
35
36
  :alt="product.name"
36
- class="Gallery__big-image-src"
37
- />
37
+ class="Gallery__big-image-src" />
38
38
  <div
39
39
  v-if="image.print"
40
40
  class="Gallery__big-print">
@@ -51,7 +51,7 @@
51
51
  </div>
52
52
  </div>
53
53
  </div>
54
- </vue-slick-carousel>
54
+ </vue-slick-carousel> -->
55
55
  <div
56
56
  v-if="!isTouch"
57
57
  class="Gallery__zoom"
@@ -60,7 +60,7 @@
60
60
  </div>
61
61
  </div>
62
62
  <div class="Gallery__small">
63
- <vue-slick-carousel
63
+ <!-- <vue-slick-carousel
64
64
  ref="smallCarousel"
65
65
  :key="updateCarouselTime"
66
66
  :slides-per-row="slidesPerRow"
@@ -80,15 +80,15 @@
80
80
  // 'background-image': `url(${staticLink(image.small)}`
81
81
  }">
82
82
  <img
83
+ v-if="index < 6 || canLoadImages"
83
84
  :src="staticLink(image.small)"
84
85
  :alt="product.name"
85
- class="Gallery__small-image-src"
86
- />
86
+ class="Gallery__small-image-src" />
87
87
  <div class="Gallery__small-printed">
88
88
  {{ image.printType ? 'Printed' : (product.prePrint ? product.prePrintText : image.colorName || 'Blank') }}
89
89
  </div>
90
90
  </div>
91
- </vue-slick-carousel>
91
+ </vue-slick-carousel> -->
92
92
  </div>
93
93
  <div
94
94
  v-if="hasValidFilters"
@@ -112,8 +112,8 @@
112
112
 
113
113
  <script>
114
114
  import { mapGetters, mapActions } from 'vuex';
115
- import VueSlickCarousel from 'vue-slick-carousel';
116
- import 'vue-slick-carousel/dist/vue-slick-carousel.css';
115
+ // import VueSlickCarousel from 'vue-slick-carousel';
116
+ // import 'vue-slick-carousel/dist/vue-slick-carousel.css';
117
117
  import { staticLink } from '@lancom/shared/assets/js/utils/filters';
118
118
  import { isValidImageTypes } from '@lancom/shared/assets/js/utils/colors';
119
119
  import Price from '@lancom/shared/components/common/price';
@@ -121,7 +121,7 @@ import Price from '@lancom/shared/components/common/price';
121
121
  export default {
122
122
  name: 'Gallery',
123
123
  components: {
124
- VueSlickCarousel,
124
+ // VueSlickCarousel,
125
125
  Price
126
126
  },
127
127
  props: {
@@ -135,6 +135,7 @@ export default {
135
135
  isTouch: ('ontouchstart' in window),
136
136
  zoomEnable: false,
137
137
  activeIndex: 0,
138
+ canLoadImages: false,
138
139
  updateCarouselTime: Date.now(),
139
140
  filters: [{
140
141
  name: 'FRONT / BACK',
@@ -9,6 +9,7 @@
9
9
  @click="toggleSelection(color)">
10
10
  <product-color-image
11
11
  :color="color"
12
+ :lazy="true"
12
13
  class="ProductColorsSelectorOptions__color-inner">
13
14
  </product-color-image>
14
15
  <div
@@ -2,12 +2,14 @@
2
2
  <div
3
3
  class="ProductColorImage"
4
4
  :class="{ zoomedIn }"
5
- :style="style">
5
+ :style="style"
6
+ v-lazy:background-image="pattern">
6
7
  </div>
7
8
  </template>
8
9
 
9
10
  <script>
10
11
  import { getColorBackgroundStyle } from '@lancom/shared/assets/js/utils/colors';
12
+ import { staticLink } from '@lancom/shared/assets/js/utils/filters';
11
13
 
12
14
  export default {
13
15
  name: 'ProductColorImage',
@@ -19,11 +21,18 @@ export default {
19
21
  zoomedIn: {
20
22
  type: Boolean,
21
23
  default: false
24
+ },
25
+ lazy: {
26
+ type: Boolean,
27
+ default: false
22
28
  }
23
29
  },
24
30
  computed: {
31
+ pattern() {
32
+ return this.color.pattern && staticLink(this.color.pattern);
33
+ },
25
34
  style() {
26
- return getColorBackgroundStyle(this.color);
35
+ return getColorBackgroundStyle(this.color, this.lazy);
27
36
  }
28
37
  }
29
38
  };
@@ -6,7 +6,7 @@
6
6
  <div
7
7
  v-if="hasReviews"
8
8
  class="ProductReviews__carousel">
9
- <vue-slick-carousel
9
+ <!-- <vue-slick-carousel
10
10
  :arrows="true"
11
11
  :infinite="false"
12
12
  :speed="800">
@@ -14,7 +14,7 @@
14
14
  v-for="review in reviews"
15
15
  :key="review._id"
16
16
  :review="review" />
17
- </vue-slick-carousel>
17
+ </vue-slick-carousel> -->
18
18
  </div>
19
19
  <div class="ProductReviews__add">
20
20
  <btn
@@ -27,15 +27,15 @@
27
27
  </template>
28
28
 
29
29
  <script>
30
- import VueSlickCarousel from 'vue-slick-carousel';
31
- import 'vue-slick-carousel/dist/vue-slick-carousel.css';
30
+ // import VueSlickCarousel from 'vue-slick-carousel';
31
+ // import 'vue-slick-carousel/dist/vue-slick-carousel.css';
32
32
  import ProductReview from './product_review/product-review';
33
33
  import AddReviewModal from './add_review_modal/add-review-modal';
34
34
 
35
35
  export default {
36
36
  name: 'ProductReviews',
37
37
  components: {
38
- VueSlickCarousel,
38
+ // VueSlickCarousel,
39
39
  ProductReview
40
40
  },
41
41
  mixins: [],
@@ -5,7 +5,9 @@
5
5
  <div class="RelatedProducts__title">
6
6
  Related Products
7
7
  </div>
8
- <product-list :products="products" />
8
+ <product-list
9
+ :products="products"
10
+ :lazy="true" />
9
11
  </div>
10
12
  </template>
11
13
 
@@ -1,4 +1,5 @@
1
1
  import { mapGetters } from 'vuex';
2
+ import { staticLink } from '@lancom/shared/assets/js/utils/filters';
2
3
  import { generateShopHeadScripts } from '@lancom/shared/utils/head';
3
4
 
4
5
  const metaInfo = {
@@ -46,6 +47,12 @@ const metaInfo = {
46
47
  content: pageTitle
47
48
  }];
48
49
 
50
+ const link = [{
51
+ hid: 'canonical',
52
+ rel: 'canonical',
53
+ href: `https://${process.env.HOST_NAME}${this.$route.path === '/' ? '' : this.$route.path}`
54
+ }];
55
+
49
56
  if (hasQueryParams) {
50
57
  metaTags.push({
51
58
  hid: 'robots',
@@ -77,12 +84,22 @@ const metaInfo = {
77
84
  });
78
85
  }
79
86
 
80
- const pageImage = this.pageItem?.image || (this.pageItem?.images && this.pageItem?.images[0]) || image;
87
+ const pageImage = this.pageItemImage || this.pageItem?.image || (this.pageItem?.images && this.pageItem?.images[0]) || image;
81
88
  if (pageImage) {
89
+ const pageImageUrl = staticLink(typeof pageImage === 'string' ? pageImage : (pageImage.medium || pageImage.large));
82
90
  metaTags.push({
83
91
  hid: 'og:image',
84
92
  property: 'og:image',
85
- content: typeof pageImage === 'string' ? pageImage : (pageImage.medium || pageImage.large)
93
+ content: pageImageUrl
94
+ });
95
+
96
+ link.push({
97
+ hid: 'preloadImage',
98
+ rel: 'preload',
99
+ fetchpriority: 'high',
100
+ as: 'image',
101
+ type: 'image/webp',
102
+ href: pageImageUrl
86
103
  });
87
104
  }
88
105
 
@@ -100,11 +117,7 @@ const metaInfo = {
100
117
  return {
101
118
  title: pageTitle,
102
119
  meta: metaTags,
103
- link: [{
104
- hid: 'canonical',
105
- rel: 'canonical',
106
- href: `https://${process.env.HOST_NAME}${this.$route.path === '/' ? '' : this.$route.path}`
107
- }],
120
+ link,
108
121
  ...generateShopHeadScripts(this.shop)
109
122
  };
110
123
  },
package/mixins/modals.js CHANGED
@@ -1,8 +1,3 @@
1
- import CartModal from '@lancom/shared/components/modals/cart_modal/cart-modal';
2
- import OrderModal from '@lancom/shared/components/modals/order_modal/order-modal';
3
- import PaymentModal from '@lancom/shared/components/modals/payment_modal/payment-modal';
4
- import LayersTemplatesModal from '@lancom/shared/components/modals/editor_layers_templates/editor-layers-templates';
5
-
6
1
  const modals = {
7
2
  data() {
8
3
  return {
@@ -30,7 +25,8 @@ const modals = {
30
25
  this.switchModalTo = null;
31
26
  }
32
27
  },
33
- showCartModal(onclose) {
28
+ async showCartModal(onclose) {
29
+ const CartModal = await import('@lancom/shared/components/modals/cart_modal/cart-modal');
34
30
  this.openedModal = 'cart-modal';
35
31
  this.onclose = onclose;
36
32
  this.$modal.show(
@@ -52,7 +48,9 @@ const modals = {
52
48
  }
53
49
  );
54
50
  },
55
- showOrderModal() {
51
+ async showOrderModal() {
52
+ const OrderModal = await import('@lancom/shared/components/modals/order_modal/order-modal');
53
+
56
54
  this.openedModal = 'order-modal';
57
55
  this.$modal.show(
58
56
  OrderModal,
@@ -73,7 +71,8 @@ const modals = {
73
71
  }
74
72
  );
75
73
  },
76
- showPaymentModal() {
74
+ async showPaymentModal() {
75
+ const PaymentModal = await import('@lancom/shared/components/modals/payment_modal/payment-modal');
77
76
  this.openedModal = 'payment-modal';
78
77
  this.$modal.show(
79
78
  PaymentModal,
@@ -97,7 +96,9 @@ const modals = {
97
96
  }
98
97
  );
99
98
  },
100
- openPrintTemplates() {
99
+ async openPrintTemplates() {
100
+ const LayersTemplatesModal = await import('@lancom/shared/components/modals/editor_layers_templates/editor-layers-templates');
101
+
101
102
  this.$modal.show(
102
103
  LayersTemplatesModal,
103
104
  {},
@@ -20,6 +20,10 @@ const productPreview = {
20
20
  toEditor: {
21
21
  type: Boolean,
22
22
  default: true
23
+ },
24
+ lazy: {
25
+ type: Boolean,
26
+ default: true
23
27
  }
24
28
  },
25
29
  data() {
package/nuxt.config.js CHANGED
@@ -107,6 +107,7 @@ module.exports = (config, axios, { raygunClient, publicPath } = {}) => ({
107
107
  config.devtool = 'source-map';
108
108
  }
109
109
  },
110
+ analyze: !config.IS_LOCAL,
110
111
  extractCSS: !config.IS_LOCAL,
111
112
  },
112
113
  hooks: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.216",
3
+ "version": "0.0.218",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
@@ -1,7 +1,7 @@
1
1
  import Vue from 'vue';
2
- import { VueHammer } from 'vue2-hammer';
2
+ // import { VueHammer } from 'vue2-hammer';
3
3
 
4
- VueHammer.config.pan = {
5
- threshold: 5
6
- };
7
- Vue.use(VueHammer);
4
+ // VueHammer.config.pan = {
5
+ // threshold: 5
6
+ // };
7
+ // Vue.use(VueHammer);