@gem-sdk/components 2.0.0-dev.701 → 2.0.0-dev.702

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.
@@ -3,8 +3,8 @@
3
3
  var core = require('@gem-sdk/core');
4
4
  var getSrcSet = require('../../../image/helpers/getSrcSet.js');
5
5
  var constant = require('../../../constant.js');
6
+ var helpers = require('../../../image/components/common/helpers.js');
6
7
 
7
- const imagePlaceholder = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
8
8
  const getContentPosition = (layout, contentPosition1Col, contentPosition2Col)=>{
9
9
  let result = {};
10
10
  const devices = [
@@ -60,13 +60,24 @@ const getBgImage = (background)=>{
60
60
  };
61
61
  return bgImage;
62
62
  };
63
+ const imagePlaceholder = (background)=>{
64
+ const srcSet = getBgImage(background);
65
+ return {
66
+ desktop: helpers.createBlurDataURL(srcSet?.desktop?.width ?? 0, srcSet?.desktop?.height ?? 0),
67
+ tablet: helpers.createBlurDataURL(srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.tablet?.height ?? srcSet?.desktop?.width ?? 0),
68
+ mobile: helpers.createBlurDataURL(srcSet?.mobile?.width ?? srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.mobile?.height ?? srcSet?.tablet?.height ?? srcSet?.desktop?.width ?? 0)
69
+ };
70
+ };
63
71
  const getBackgroundImageHeroBanner = (background, enableLazyImage = false, isNotLiquid = false)=>{
64
72
  const srcSet = getBgImage(background);
65
- return core.makeStyleResponsive('bgi', {
66
- desktop: `url('${!enableLazyImage ? getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, 'desktop'), 'desktop', isNotLiquid) : imagePlaceholder}')`,
67
- tablet: `url('${!enableLazyImage ? getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, 'tablet'), 'tablet', isNotLiquid) : imagePlaceholder}')`,
68
- mobile: `url('${!enableLazyImage ? getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, 'mobile'), 'mobile', isNotLiquid) : imagePlaceholder}')`
73
+ let result = {};
74
+ core.DEVICES.forEach((device)=>{
75
+ result = {
76
+ ...result,
77
+ [device]: `url('${!enableLazyImage ? getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, device), device, isNotLiquid) : imagePlaceholder(background)}')`
78
+ };
69
79
  });
80
+ return core.makeStyleResponsive('bgi', result);
70
81
  };
71
82
  const getAttachmentDevice = (background)=>{
72
83
  let result = {};
@@ -100,7 +100,7 @@ const getBackgroundStyle = (styles, enableParallax, transform)=>{
100
100
  }),
101
101
  ...core.getGradientBgrStyleByDevice(background, common.bgiEnableByDevice(background)),
102
102
  '--duration': `${hoverEffectDuration ?? 0}s`,
103
- '--scale': hoverEffectScale ?? 1,
103
+ '--scale': `${hoverEffectScale || 100}%`,
104
104
  ...core.makeStyleResponsive('pos', common.getAttachmentDevice(background)),
105
105
  transform,
106
106
  transition: 'transform 300ms cubic-bezier(0,0,0,1)'
@@ -29,7 +29,7 @@ const useHeroBanner = (styles, setting, currentDevice)=>{
29
29
  const enableParallax = Number(setting?.speedParallax || 0) > 0 && backgroundResponsive[currentDevice]?.type === 'image' || false;
30
30
  const onMouseEnterParallax = ()=>{
31
31
  if (hoverEffect && enableParallax) {
32
- setTransform(`${transform} scale(${hoverEffectScale})`);
32
+ setTransform(`${transform} scale(${hoverEffectScale || 100}%)`);
33
33
  }
34
34
  };
35
35
  const onMouseLeaveParallax = ()=>{
@@ -120,6 +120,43 @@ const SettingUIV2 = [
120
120
  controlType: 'setting',
121
121
  removeDevice: true
122
122
  }
123
+ },
124
+ {
125
+ condition: '!background.image.src',
126
+ source: [
127
+ 'background'
128
+ ],
129
+ action: {
130
+ controlId: 'sizeSetting',
131
+ newValue: {
132
+ shapeLinked: false,
133
+ hiddenShape: true
134
+ },
135
+ valueIfNull: {
136
+ width: '100%',
137
+ height: 'fit-content',
138
+ hiddenShape: true
139
+ },
140
+ groupType: 'style',
141
+ controlType: 'size-setting'
142
+ }
143
+ },
144
+ {
145
+ condition: '!!background.image.src',
146
+ source: [
147
+ 'background'
148
+ ],
149
+ action: {
150
+ controlId: 'sizeSetting',
151
+ newValue: {
152
+ hiddenShape: false
153
+ },
154
+ valueIfNull: {
155
+ hiddenShape: false
156
+ },
157
+ groupType: 'style',
158
+ controlType: 'size-setting'
159
+ }
123
160
  }
124
161
  ],
125
162
  options: {
@@ -93,8 +93,12 @@ const FeatureImageWithGallery = ({ builderPropUID, children, enableLazyLoadImage
93
93
  const renderFeaturedImageOnly = (className, hasHoverEffect)=>{
94
94
  return core.template`
95
95
  {% assign src = featureMedia.src %}
96
- ${system.If(hasHoverEffect && setting.hoverEffect == 'other', `{% assign otherImage = product.media[${setting.otherImage}] %}
97
- {% assign src = otherImage.src %}
96
+ ${system.If(hasHoverEffect && setting.hoverEffect == 'other', `{% assign media_length = product.media | size %}
97
+ {% assign other_image_index = ${setting.otherImage} | plus: 0 %}
98
+ {% if other_image_index >= media_length %}
99
+ {% assign other_image_index = media_length | minus: 1 %}
100
+ {% endif %}
101
+ {% assign otherImage = product.media[other_image_index] %}
98
102
  ${system.LiquidIf(`otherImage.media_type != 'image'`, `{% assign src = otherImage.preview_image.src %}`)}
99
103
  `)}
100
104
  ${NextImage_liquid.default({
@@ -36,6 +36,7 @@ const ProductList = (props)=>{
36
36
  endif
37
37
  assign arrayRelatedExclude = relatedExclude | split: ","
38
38
  assign idSelectedList = ''
39
+ assign relatedListProduct = null
39
40
  for collection in collections
40
41
  assign collectionId = collection.id
41
42
  assign isInCollection = false
@@ -50,20 +51,15 @@ const ProductList = (props)=>{
50
51
  break
51
52
  else
52
53
  assign idSelectedList = idSelectedList | append: "," | append: product.id
54
+ assign productSelected = product | sort
55
+ assign relatedListProduct = relatedListProduct | concat: productSelected
53
56
  endif
54
57
  endfor
55
58
  endif
56
59
  endunless
57
60
  endfor
58
61
  endfor
59
- for item in allProductsPaginated
60
- assign handle = item.handle
61
- assign productF = item | sort
62
- if idSelectedList contains item.id
63
- assign products = products | concat: productF
64
- endif
65
- endfor
66
- assign products = products | uniq
62
+ assign products = relatedListProduct | uniq
67
63
  when 'vendor'
68
64
  assign vendorAssignProduct = assignProduct.vendor
69
65
  assign productFilter = allProductsPaginated | where: 'vendor', vendorAssignProduct
@@ -68,27 +68,29 @@ const productFeatureImageSetting = [
68
68
  {
69
69
  id: 'otherImage',
70
70
  label: 'Other image',
71
- type: 'select',
72
- options: [
73
- {
74
- title: 'Image 1',
75
- value: 0
76
- },
71
+ type: 'dropdown:input',
72
+ isNumber: true,
73
+ isIndexValue: true,
74
+ displayOptions: [
77
75
  {
78
- title: 'Image 2',
76
+ label: 'Image 1',
79
77
  value: 1
80
78
  },
81
79
  {
82
- title: 'Image 3',
80
+ label: 'Image 2',
83
81
  value: 2
84
82
  },
85
83
  {
86
- title: 'Image 4',
84
+ label: 'Image 3',
87
85
  value: 3
88
86
  },
89
87
  {
90
- title: 'Last image',
91
- value: -1
88
+ label: 'Image 4',
89
+ value: 4
90
+ },
91
+ {
92
+ label: 'Last image',
93
+ value: 'Last image'
92
94
  }
93
95
  ],
94
96
  default: 0
@@ -1,8 +1,8 @@
1
- import { getResponsiveValueByScreen, getAspectRatioGlobalSize, makeStyleResponsive, getValueByDevice, cls } from '@gem-sdk/core';
1
+ import { getResponsiveValueByScreen, getAspectRatioGlobalSize, makeStyleResponsive, DEVICES, getValueByDevice, cls } from '@gem-sdk/core';
2
2
  import { getImageSrc } from '../../../image/helpers/getSrcSet.js';
3
3
  import { HREF_TO_SALES_PAGE } from '../../../constant.js';
4
+ import { createBlurDataURL } from '../../../image/components/common/helpers.js';
4
5
 
5
- const imagePlaceholder = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=';
6
6
  const getContentPosition = (layout, contentPosition1Col, contentPosition2Col)=>{
7
7
  let result = {};
8
8
  const devices = [
@@ -58,13 +58,24 @@ const getBgImage = (background)=>{
58
58
  };
59
59
  return bgImage;
60
60
  };
61
+ const imagePlaceholder = (background)=>{
62
+ const srcSet = getBgImage(background);
63
+ return {
64
+ desktop: createBlurDataURL(srcSet?.desktop?.width ?? 0, srcSet?.desktop?.height ?? 0),
65
+ tablet: createBlurDataURL(srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.tablet?.height ?? srcSet?.desktop?.width ?? 0),
66
+ mobile: createBlurDataURL(srcSet?.mobile?.width ?? srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.mobile?.height ?? srcSet?.tablet?.height ?? srcSet?.desktop?.width ?? 0)
67
+ };
68
+ };
61
69
  const getBackgroundImageHeroBanner = (background, enableLazyImage = false, isNotLiquid = false)=>{
62
70
  const srcSet = getBgImage(background);
63
- return makeStyleResponsive('bgi', {
64
- desktop: `url('${!enableLazyImage ? getImageSrc(getResponsiveValueByScreen(srcSet, 'desktop'), 'desktop', isNotLiquid) : imagePlaceholder}')`,
65
- tablet: `url('${!enableLazyImage ? getImageSrc(getResponsiveValueByScreen(srcSet, 'tablet'), 'tablet', isNotLiquid) : imagePlaceholder}')`,
66
- mobile: `url('${!enableLazyImage ? getImageSrc(getResponsiveValueByScreen(srcSet, 'mobile'), 'mobile', isNotLiquid) : imagePlaceholder}')`
71
+ let result = {};
72
+ DEVICES.forEach((device)=>{
73
+ result = {
74
+ ...result,
75
+ [device]: `url('${!enableLazyImage ? getImageSrc(getResponsiveValueByScreen(srcSet, device), device, isNotLiquid) : imagePlaceholder(background)}')`
76
+ };
67
77
  });
78
+ return makeStyleResponsive('bgi', result);
68
79
  };
69
80
  const getAttachmentDevice = (background)=>{
70
81
  let result = {};
@@ -98,7 +98,7 @@ const getBackgroundStyle = (styles, enableParallax, transform)=>{
98
98
  }),
99
99
  ...getGradientBgrStyleByDevice(background, bgiEnableByDevice(background)),
100
100
  '--duration': `${hoverEffectDuration ?? 0}s`,
101
- '--scale': hoverEffectScale ?? 1,
101
+ '--scale': `${hoverEffectScale || 100}%`,
102
102
  ...makeStyleResponsive('pos', getAttachmentDevice(background)),
103
103
  transform,
104
104
  transition: 'transform 300ms cubic-bezier(0,0,0,1)'
@@ -25,7 +25,7 @@ const useHeroBanner = (styles, setting, currentDevice)=>{
25
25
  const enableParallax = Number(setting?.speedParallax || 0) > 0 && backgroundResponsive[currentDevice]?.type === 'image' || false;
26
26
  const onMouseEnterParallax = ()=>{
27
27
  if (hoverEffect && enableParallax) {
28
- setTransform(`${transform} scale(${hoverEffectScale})`);
28
+ setTransform(`${transform} scale(${hoverEffectScale || 100}%)`);
29
29
  }
30
30
  };
31
31
  const onMouseLeaveParallax = ()=>{
@@ -118,6 +118,43 @@ const SettingUIV2 = [
118
118
  controlType: 'setting',
119
119
  removeDevice: true
120
120
  }
121
+ },
122
+ {
123
+ condition: '!background.image.src',
124
+ source: [
125
+ 'background'
126
+ ],
127
+ action: {
128
+ controlId: 'sizeSetting',
129
+ newValue: {
130
+ shapeLinked: false,
131
+ hiddenShape: true
132
+ },
133
+ valueIfNull: {
134
+ width: '100%',
135
+ height: 'fit-content',
136
+ hiddenShape: true
137
+ },
138
+ groupType: 'style',
139
+ controlType: 'size-setting'
140
+ }
141
+ },
142
+ {
143
+ condition: '!!background.image.src',
144
+ source: [
145
+ 'background'
146
+ ],
147
+ action: {
148
+ controlId: 'sizeSetting',
149
+ newValue: {
150
+ hiddenShape: false
151
+ },
152
+ valueIfNull: {
153
+ hiddenShape: false
154
+ },
155
+ groupType: 'style',
156
+ controlType: 'size-setting'
157
+ }
121
158
  }
122
159
  ],
123
160
  options: {
@@ -89,8 +89,12 @@ const FeatureImageWithGallery = ({ builderPropUID, children, enableLazyLoadImage
89
89
  const renderFeaturedImageOnly = (className, hasHoverEffect)=>{
90
90
  return template`
91
91
  {% assign src = featureMedia.src %}
92
- ${If(hasHoverEffect && setting.hoverEffect == 'other', `{% assign otherImage = product.media[${setting.otherImage}] %}
93
- {% assign src = otherImage.src %}
92
+ ${If(hasHoverEffect && setting.hoverEffect == 'other', `{% assign media_length = product.media | size %}
93
+ {% assign other_image_index = ${setting.otherImage} | plus: 0 %}
94
+ {% if other_image_index >= media_length %}
95
+ {% assign other_image_index = media_length | minus: 1 %}
96
+ {% endif %}
97
+ {% assign otherImage = product.media[other_image_index] %}
94
98
  ${LiquidIf(`otherImage.media_type != 'image'`, `{% assign src = otherImage.preview_image.src %}`)}
95
99
  `)}
96
100
  ${NextImage({
@@ -32,6 +32,7 @@ const ProductList = (props)=>{
32
32
  endif
33
33
  assign arrayRelatedExclude = relatedExclude | split: ","
34
34
  assign idSelectedList = ''
35
+ assign relatedListProduct = null
35
36
  for collection in collections
36
37
  assign collectionId = collection.id
37
38
  assign isInCollection = false
@@ -46,20 +47,15 @@ const ProductList = (props)=>{
46
47
  break
47
48
  else
48
49
  assign idSelectedList = idSelectedList | append: "," | append: product.id
50
+ assign productSelected = product | sort
51
+ assign relatedListProduct = relatedListProduct | concat: productSelected
49
52
  endif
50
53
  endfor
51
54
  endif
52
55
  endunless
53
56
  endfor
54
57
  endfor
55
- for item in allProductsPaginated
56
- assign handle = item.handle
57
- assign productF = item | sort
58
- if idSelectedList contains item.id
59
- assign products = products | concat: productF
60
- endif
61
- endfor
62
- assign products = products | uniq
58
+ assign products = relatedListProduct | uniq
63
59
  when 'vendor'
64
60
  assign vendorAssignProduct = assignProduct.vendor
65
61
  assign productFilter = allProductsPaginated | where: 'vendor', vendorAssignProduct
@@ -66,27 +66,29 @@ const productFeatureImageSetting = [
66
66
  {
67
67
  id: 'otherImage',
68
68
  label: 'Other image',
69
- type: 'select',
70
- options: [
71
- {
72
- title: 'Image 1',
73
- value: 0
74
- },
69
+ type: 'dropdown:input',
70
+ isNumber: true,
71
+ isIndexValue: true,
72
+ displayOptions: [
75
73
  {
76
- title: 'Image 2',
74
+ label: 'Image 1',
77
75
  value: 1
78
76
  },
79
77
  {
80
- title: 'Image 3',
78
+ label: 'Image 2',
81
79
  value: 2
82
80
  },
83
81
  {
84
- title: 'Image 4',
82
+ label: 'Image 3',
85
83
  value: 3
86
84
  },
87
85
  {
88
- title: 'Last image',
89
- value: -1
86
+ label: 'Image 4',
87
+ value: 4
88
+ },
89
+ {
90
+ label: 'Last image',
91
+ value: 'Last image'
90
92
  }
91
93
  ],
92
94
  default: 0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.701",
3
+ "version": "2.0.0-dev.702",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",