@gem-sdk/components 2.0.0-dev.735 → 2.0.0-dev.736

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.
@@ -125,6 +125,11 @@ const ProductVariants = (props)=>{
125
125
  type: el.optionType
126
126
  })).map((el)=>`${el.name}($1)${el.type}`).join('($2)').toString();
127
127
  const renderOptionValues = ()=>{
128
+ return core.template`
129
+ ${system.LiquidIf(` shop.metafields.GEMPAGES.swatches and shop.metafields.GEMPAGES.swatchesJSONFormat != blank`, renderOptionValuesNewFormatSwatches(), renderOptionValuesOld())}
130
+ `;
131
+ };
132
+ const renderOptionValuesOld = ()=>{
128
133
  return core.template /* liquid */ `
129
134
  ${system.Liquid(`{%- assign optionRendered = false -%}`)}
130
135
  ${system.Liquid(`{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}`)}
@@ -202,6 +207,77 @@ const ProductVariants = (props)=>{
202
207
  `)}
203
208
  `)}
204
209
 
210
+ ${system.LiquidIf(`optionRendered == false`, renderVariantItem())}
211
+ `;
212
+ };
213
+ const renderOptionValuesNewFormatSwatches = ()=>{
214
+ return core.template /* liquid */ `
215
+ ${system.Liquid(`{%- assign optionRendered = false -%}`)}
216
+ ${system.Liquid(`{%- assign swatches = shop.metafields.GEMPAGES.swatchesJSONFormat.value -%}`)}
217
+
218
+ ${system.Liquid(`{% for swatch in swatches %}
219
+ {%- assign optionTitle = swatch.optionTitle -%}
220
+ {%- assign optionType = swatch.optionType -%}
221
+ {%- assign labelsString = "" -%}
222
+ {%- assign colorArraysString = "" -%}
223
+ {%- assign imageUrlsString = "" -%}
224
+
225
+ {% for optionValue in swatch.optionValues %}
226
+ {%- assign labelsString = labelsString | append: optionValue.label | append: ',' -%}
227
+ {%- assign colorsJoined = optionValue.colors | join: '#' -%}
228
+ {%- assign colorArraysString = colorArraysString | append: colorsJoined | append: ',' -%}
229
+ {%- assign imageUrlsString = imageUrlsString | append: optionValue.imageUrl | append: ',' -%}
230
+ {% endfor %}
231
+
232
+ {%- assign labels = labelsString | split: ',' | slice: 0, labelsString.size -%}
233
+ {%- assign colorStrings = colorArraysString | split: ',' | slice: 0, colorArraysString.size -%}
234
+ {%- assign imageUrls = imageUrlsString | split: ',' | slice: 0, imageUrlsString.size -%}
235
+
236
+ {% if optionTitle == option.name %}
237
+ {%- assign variantPresetString = "${variantPresetsLiquid}" -%}
238
+ {%- assign optionName = option.name | replace: "'", "'" | replace: '"', '"' -%}
239
+ {%- assign items = variantPresetString | split: '($2)' -%}
240
+ {%- assign type = 'dropdown' -%}
241
+
242
+ {% for item in items %}
243
+ {%- assign itemPreset = item | split: '($1)' -%}
244
+ {% if itemPreset[0] == optionName %}
245
+ {%- assign type = itemPreset[1] -%}
246
+ {% endif %}
247
+ {% if itemPreset[0] == 'base' %}
248
+ {%- assign type = itemPreset[1] -%}
249
+ {% endif %}
250
+ {% endfor %}
251
+ {%- assign optionRendered = true -%}
252
+
253
+ ${system.LiquidFor(`value in values`, index_liquid.default({
254
+ id: `{{option.name | escape}}-{{value | escape}}`,
255
+ variantKey: `{{option.name | escape}}-{{option.position}}-{{ forloop.index }}`,
256
+ showAsSwatches: showAsSwatches,
257
+ uid: uid,
258
+ name: `{{option.name | escape}}`,
259
+ value: {
260
+ label: `{{value | escape}}`
261
+ },
262
+ checked: !hasPreSelected ? 'false' : `{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}`,
263
+ optionPosition: `rootForloop`,
264
+ optionType: 'optionType',
265
+ activeClass: !hasPreSelected ? '' : `{%- if option.selected_value == value -%}option-item-active{%- endif -%}`,
266
+ ...styles$1,
267
+ ...settingMappingStyles,
268
+ swatchAutoWidth: getSwatchAutoWidth(),
269
+ optionTypo: optionTypo
270
+ }))}
271
+
272
+ ${system.LiquidIf(`type == 'dropdown'`, Dropdown_liquid.default({
273
+ ...styles$1,
274
+ ...settingMappingStyles,
275
+ swatchAutoWidth: getSwatchDropdownAutoWidth(),
276
+ optionTypo: optionTypo
277
+ }))}
278
+ {% endif %}
279
+ {% endfor %}`)}
280
+
205
281
  ${system.LiquidIf(`optionRendered == false`, renderVariantItem())}
206
282
  `;
207
283
  };
@@ -1,26 +1,5 @@
1
1
  'use strict';
2
2
 
3
- const cartIcon = `<svg
4
- width="20"
5
- height="20"
6
- viewBox="0 0 20 20"
7
- fill="none"
8
- xmlns="http://www.w3.org/2000/svg">
9
- <path
10
- d="M15.6789 4.17725H6.03163C5.29655 4.17725 4.81269 4.94374 5.12886 5.60736L6.96359 9.45836C7.12946 9.80651 7.48073 10.0283 7.86637 10.0283H13.5599C13.9246 10.0283 14.2603 9.82979 14.4361 9.51034L16.5551 5.65933C16.9218 4.99287 16.4396 4.17725 15.6789 4.17725Z"
11
- stroke="#F9F9F9"
12
- stroke-width="1.25" />
13
- <path
14
- d="M3.18465 2.86621C2.83947 2.86621 2.55965 3.14603 2.55965 3.49121C2.55965 3.83639 2.83947 4.11621 3.18465 4.11621V2.86621ZM3.18465 4.11621H3.47436V2.86621H3.18465V4.11621ZM3.8121 4.32823L4.86939 6.51921L5.99516 5.97594L4.93787 3.78497L3.8121 4.32823ZM3.47436 4.11621C3.6183 4.11621 3.74954 4.1986 3.8121 4.32823L4.93787 3.78497C4.66679 3.22322 4.0981 2.86621 3.47436 2.86621V4.11621Z"
15
- fill="#F9F9F9" />
16
- <path
17
- d="M7.11031 9.83643L5.80897 11.8607C5.59505 12.1935 5.83398 12.6311 6.22956 12.6311H15.1832"
18
- stroke="#F9F9F9"
19
- stroke-width="1.25"
20
- stroke-linecap="round" />
21
- <circle cx="6.92627" cy="15.8948" r="1.61255" fill="#F9F9F9" />
22
- <circle cx="14.3094" cy="15.8948" r="1.61255" fill="#F9F9F9" />
23
- </svg>`;
24
3
  const ProductButtonSettings = [
25
4
  {
26
5
  id: 'setting',
@@ -31,38 +10,33 @@ const ProductButtonSettings = [
31
10
  controls: [
32
11
  {
33
12
  id: 'buttonLayout',
34
- type: 'button-layout',
13
+ label: 'Layout',
14
+ type: 'layout-selector',
15
+ iconViewBox: '0 0 72 72',
16
+ enableItemBackground: true,
17
+ itemSpacing: 'large',
18
+ itemPerRow: 1,
35
19
  default: 'cart-icon',
36
20
  options: [
37
21
  {
38
- id: 'cart-full',
39
22
  value: 'cart-full',
40
- name: `<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10 flex items-center justify-center gap-4">${cartIcon} Add to cart - $19 <s>$30<s/></div>`,
41
- icon: true
23
+ iconName: 'gp-product-button-cart-full-layout'
42
24
  },
43
25
  {
44
- id: 'cart-price',
45
26
  value: 'cart-price',
46
- name: '<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10">Add to cart - $19</div>',
47
- icon: false
27
+ iconName: 'gp-product-button-cart-price-layout'
48
28
  },
49
29
  {
50
- id: 'cart-only',
51
30
  value: 'cart-only',
52
- name: '<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10">Add to cart</div>',
53
- icon: false
31
+ iconName: 'gp-product-button-cart-only-layout'
54
32
  },
55
33
  {
56
- id: 'cart-price-icon',
57
34
  value: 'cart-price-icon',
58
- name: `<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10 flex items-center justify-center gap-4">${cartIcon} Add to cart - $19</div>`,
59
- icon: true
35
+ iconName: 'gp-product-button-price-icon-layout'
60
36
  },
61
37
  {
62
- id: 'cart-icon',
63
38
  value: 'cart-icon',
64
- name: `<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10 flex items-center justify-center gap-4">${cartIcon} Add to cart</div>`,
65
- icon: true
39
+ iconName: 'gp-product-button-cart-item-layout'
66
40
  }
67
41
  ]
68
42
  },
@@ -121,6 +121,11 @@ const ProductVariants = (props)=>{
121
121
  type: el.optionType
122
122
  })).map((el)=>`${el.name}($1)${el.type}`).join('($2)').toString();
123
123
  const renderOptionValues = ()=>{
124
+ return template`
125
+ ${LiquidIf(` shop.metafields.GEMPAGES.swatches and shop.metafields.GEMPAGES.swatchesJSONFormat != blank`, renderOptionValuesNewFormatSwatches(), renderOptionValuesOld())}
126
+ `;
127
+ };
128
+ const renderOptionValuesOld = ()=>{
124
129
  return template /* liquid */ `
125
130
  ${Liquid(`{%- assign optionRendered = false -%}`)}
126
131
  ${Liquid(`{%- assign swatches = shop.metafields.GEMPAGES.swatches -%}`)}
@@ -198,6 +203,77 @@ const ProductVariants = (props)=>{
198
203
  `)}
199
204
  `)}
200
205
 
206
+ ${LiquidIf(`optionRendered == false`, renderVariantItem())}
207
+ `;
208
+ };
209
+ const renderOptionValuesNewFormatSwatches = ()=>{
210
+ return template /* liquid */ `
211
+ ${Liquid(`{%- assign optionRendered = false -%}`)}
212
+ ${Liquid(`{%- assign swatches = shop.metafields.GEMPAGES.swatchesJSONFormat.value -%}`)}
213
+
214
+ ${Liquid(`{% for swatch in swatches %}
215
+ {%- assign optionTitle = swatch.optionTitle -%}
216
+ {%- assign optionType = swatch.optionType -%}
217
+ {%- assign labelsString = "" -%}
218
+ {%- assign colorArraysString = "" -%}
219
+ {%- assign imageUrlsString = "" -%}
220
+
221
+ {% for optionValue in swatch.optionValues %}
222
+ {%- assign labelsString = labelsString | append: optionValue.label | append: ',' -%}
223
+ {%- assign colorsJoined = optionValue.colors | join: '#' -%}
224
+ {%- assign colorArraysString = colorArraysString | append: colorsJoined | append: ',' -%}
225
+ {%- assign imageUrlsString = imageUrlsString | append: optionValue.imageUrl | append: ',' -%}
226
+ {% endfor %}
227
+
228
+ {%- assign labels = labelsString | split: ',' | slice: 0, labelsString.size -%}
229
+ {%- assign colorStrings = colorArraysString | split: ',' | slice: 0, colorArraysString.size -%}
230
+ {%- assign imageUrls = imageUrlsString | split: ',' | slice: 0, imageUrlsString.size -%}
231
+
232
+ {% if optionTitle == option.name %}
233
+ {%- assign variantPresetString = "${variantPresetsLiquid}" -%}
234
+ {%- assign optionName = option.name | replace: "'", "'" | replace: '"', '"' -%}
235
+ {%- assign items = variantPresetString | split: '($2)' -%}
236
+ {%- assign type = 'dropdown' -%}
237
+
238
+ {% for item in items %}
239
+ {%- assign itemPreset = item | split: '($1)' -%}
240
+ {% if itemPreset[0] == optionName %}
241
+ {%- assign type = itemPreset[1] -%}
242
+ {% endif %}
243
+ {% if itemPreset[0] == 'base' %}
244
+ {%- assign type = itemPreset[1] -%}
245
+ {% endif %}
246
+ {% endfor %}
247
+ {%- assign optionRendered = true -%}
248
+
249
+ ${LiquidFor(`value in values`, VariantItem({
250
+ id: `{{option.name | escape}}-{{value | escape}}`,
251
+ variantKey: `{{option.name | escape}}-{{option.position}}-{{ forloop.index }}`,
252
+ showAsSwatches: showAsSwatches,
253
+ uid: uid,
254
+ name: `{{option.name | escape}}`,
255
+ value: {
256
+ label: `{{value | escape}}`
257
+ },
258
+ checked: !hasPreSelected ? 'false' : `{%- if option.selected_value == value -%}true{% else %}false{%- endif -%}`,
259
+ optionPosition: `rootForloop`,
260
+ optionType: 'optionType',
261
+ activeClass: !hasPreSelected ? '' : `{%- if option.selected_value == value -%}option-item-active{%- endif -%}`,
262
+ ...styles,
263
+ ...settingMappingStyles,
264
+ swatchAutoWidth: getSwatchAutoWidth(),
265
+ optionTypo: optionTypo
266
+ }))}
267
+
268
+ ${LiquidIf(`type == 'dropdown'`, DropdownVariant({
269
+ ...styles,
270
+ ...settingMappingStyles,
271
+ swatchAutoWidth: getSwatchDropdownAutoWidth(),
272
+ optionTypo: optionTypo
273
+ }))}
274
+ {% endif %}
275
+ {% endfor %}`)}
276
+
201
277
  ${LiquidIf(`optionRendered == false`, renderVariantItem())}
202
278
  `;
203
279
  };
@@ -1,24 +1,3 @@
1
- const cartIcon = `<svg
2
- width="20"
3
- height="20"
4
- viewBox="0 0 20 20"
5
- fill="none"
6
- xmlns="http://www.w3.org/2000/svg">
7
- <path
8
- d="M15.6789 4.17725H6.03163C5.29655 4.17725 4.81269 4.94374 5.12886 5.60736L6.96359 9.45836C7.12946 9.80651 7.48073 10.0283 7.86637 10.0283H13.5599C13.9246 10.0283 14.2603 9.82979 14.4361 9.51034L16.5551 5.65933C16.9218 4.99287 16.4396 4.17725 15.6789 4.17725Z"
9
- stroke="#F9F9F9"
10
- stroke-width="1.25" />
11
- <path
12
- d="M3.18465 2.86621C2.83947 2.86621 2.55965 3.14603 2.55965 3.49121C2.55965 3.83639 2.83947 4.11621 3.18465 4.11621V2.86621ZM3.18465 4.11621H3.47436V2.86621H3.18465V4.11621ZM3.8121 4.32823L4.86939 6.51921L5.99516 5.97594L4.93787 3.78497L3.8121 4.32823ZM3.47436 4.11621C3.6183 4.11621 3.74954 4.1986 3.8121 4.32823L4.93787 3.78497C4.66679 3.22322 4.0981 2.86621 3.47436 2.86621V4.11621Z"
13
- fill="#F9F9F9" />
14
- <path
15
- d="M7.11031 9.83643L5.80897 11.8607C5.59505 12.1935 5.83398 12.6311 6.22956 12.6311H15.1832"
16
- stroke="#F9F9F9"
17
- stroke-width="1.25"
18
- stroke-linecap="round" />
19
- <circle cx="6.92627" cy="15.8948" r="1.61255" fill="#F9F9F9" />
20
- <circle cx="14.3094" cy="15.8948" r="1.61255" fill="#F9F9F9" />
21
- </svg>`;
22
1
  const ProductButtonSettings = [
23
2
  {
24
3
  id: 'setting',
@@ -29,38 +8,33 @@ const ProductButtonSettings = [
29
8
  controls: [
30
9
  {
31
10
  id: 'buttonLayout',
32
- type: 'button-layout',
11
+ label: 'Layout',
12
+ type: 'layout-selector',
13
+ iconViewBox: '0 0 72 72',
14
+ enableItemBackground: true,
15
+ itemSpacing: 'large',
16
+ itemPerRow: 1,
33
17
  default: 'cart-icon',
34
18
  options: [
35
19
  {
36
- id: 'cart-full',
37
20
  value: 'cart-full',
38
- name: `<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10 flex items-center justify-center gap-4">${cartIcon} Add to cart - $19 <s>$30<s/></div>`,
39
- icon: true
21
+ iconName: 'gp-product-button-cart-full-layout'
40
22
  },
41
23
  {
42
- id: 'cart-price',
43
24
  value: 'cart-price',
44
- name: '<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10">Add to cart - $19</div>',
45
- icon: false
25
+ iconName: 'gp-product-button-cart-price-layout'
46
26
  },
47
27
  {
48
- id: 'cart-only',
49
28
  value: 'cart-only',
50
- name: '<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10">Add to cart</div>',
51
- icon: false
29
+ iconName: 'gp-product-button-cart-only-layout'
52
30
  },
53
31
  {
54
- id: 'cart-price-icon',
55
32
  value: 'cart-price-icon',
56
- name: `<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10 flex items-center justify-center gap-4">${cartIcon} Add to cart - $19</div>`,
57
- icon: true
33
+ iconName: 'gp-product-button-price-icon-layout'
58
34
  },
59
35
  {
60
- id: 'cart-icon',
61
36
  value: 'cart-icon',
62
- name: `<div class="h-40 w-[200px] rounded-medium bg-dark-200 p-10 flex items-center justify-center gap-4">${cartIcon} Add to cart</div>`,
63
- icon: true
37
+ iconName: 'gp-product-button-cart-item-layout'
64
38
  }
65
39
  ]
66
40
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.735",
3
+ "version": "2.0.0-dev.736",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",