@gem-sdk/components 2.0.0-dev.612 → 2.0.0-dev.614

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.
@@ -27,9 +27,11 @@ const SEPARATOR = {
27
27
  </svg>
28
28
  `
29
29
  };
30
- const SUPPORT_COMPARE_PRICE_LAYOUTS = [
31
- 'cart-full'
32
- ];
30
+ const PRICE_LAYOUT = {
31
+ PRICE_ONLY: 'price-only',
32
+ PRICE_BEFORE: 'price-before',
33
+ PRICE_AFTER: 'price-after'
34
+ };
33
35
 
36
+ exports.PRICE_LAYOUT = PRICE_LAYOUT;
34
37
  exports.SEPARATOR = SEPARATOR;
35
- exports.SUPPORT_COMPARE_PRICE_LAYOUTS = SUPPORT_COMPARE_PRICE_LAYOUTS;
@@ -56,13 +56,9 @@ const removeColorFromTypo = (typo)=>{
56
56
  }
57
57
  return typo;
58
58
  };
59
- const isLayoutSupportComparePrice = (buttonLayout)=>{
60
- return buttonLayout ? constants.SUPPORT_COMPARE_PRICE_LAYOUTS.includes(buttonLayout) : false;
61
- };
62
59
 
63
60
  exports.checkIconVisibility = checkIconVisibility;
64
61
  exports.getGPProductButtonState = getGPProductButtonState;
65
62
  exports.getRenderComparePriceSettings = getRenderComparePriceSettings;
66
63
  exports.getRenderRegularPriceSettings = getRenderRegularPriceSettings;
67
- exports.isLayoutSupportComparePrice = isLayoutSupportComparePrice;
68
64
  exports.renderSeparator = renderSeparator;
@@ -9,26 +9,41 @@ require('react');
9
9
  var helpers = require('../common/helpers.js');
10
10
  var PriceLayout = require('./PriceLayout.js');
11
11
  var PriceComponent = require('./PriceComponent.js');
12
+ var constants = require('../common/constants.js');
12
13
 
13
14
  const ProductButtonPrice = ({ setting, styles })=>{
14
- const createPriceComponents = ({ includeCompare })=>{
15
- const components = [
16
- /*#__PURE__*/ jsxRuntime.jsx(PriceComponent.default, {
17
- priceType: types.PriceType.Regular,
18
- settings: helpers.getRenderRegularPriceSettings(setting)
19
- }, "regular")
20
- ];
21
- if (includeCompare) {
22
- components.push(/*#__PURE__*/ jsxRuntime.jsx(PriceComponent.default, {
23
- priceType: types.PriceType.Compare,
24
- settings: helpers.getRenderComparePriceSettings(setting)
25
- }, "compare"));
15
+ const regularPriceComponent = /*#__PURE__*/ jsxRuntime.jsx(PriceComponent.default, {
16
+ priceType: types.PriceType.Regular,
17
+ settings: helpers.getRenderRegularPriceSettings(setting)
18
+ }, "regular");
19
+ const comparePriceComponent = /*#__PURE__*/ jsxRuntime.jsx(PriceComponent.default, {
20
+ priceType: types.PriceType.Compare,
21
+ settings: helpers.getRenderComparePriceSettings(setting)
22
+ }, "compare");
23
+ const getComponentsByLayout = ()=>{
24
+ switch(setting?.priceLayout){
25
+ case constants.PRICE_LAYOUT.PRICE_ONLY:
26
+ return [
27
+ regularPriceComponent
28
+ ];
29
+ case constants.PRICE_LAYOUT.PRICE_BEFORE:
30
+ return [
31
+ regularPriceComponent,
32
+ comparePriceComponent
33
+ ];
34
+ case constants.PRICE_LAYOUT.PRICE_AFTER:
35
+ return [
36
+ comparePriceComponent,
37
+ regularPriceComponent
38
+ ];
39
+ default:
40
+ return [
41
+ regularPriceComponent,
42
+ comparePriceComponent
43
+ ];
26
44
  }
27
- return components;
28
45
  };
29
- const components = createPriceComponents({
30
- includeCompare: helpers.isLayoutSupportComparePrice(setting?.buttonLayout)
31
- });
46
+ const components = getComponentsByLayout();
32
47
  return /*#__PURE__*/ jsxRuntime.jsx(PriceLayout.default, {
33
48
  components: components,
34
49
  separator: setting?.separator,
@@ -7,26 +7,41 @@ var types = require('../common/types.js');
7
7
  var helpers = require('../common/helpers.js');
8
8
  var PriceLayout_liquid = require('./PriceLayout.liquid.js');
9
9
  var PriceComponent_liquid = require('./PriceComponent.liquid.js');
10
+ var constants = require('../common/constants.js');
10
11
 
11
12
  const ProductButtonPrice = ({ setting, styles })=>{
12
- const createPriceComponents = ({ includeCompare })=>{
13
- const components = [
14
- ()=>PriceComponent_liquid.default({
15
- priceType: types.PriceType.Regular,
16
- settings: helpers.getRenderRegularPriceSettings(setting)
17
- })
18
- ];
19
- if (includeCompare) {
20
- components.push(()=>PriceComponent_liquid.default({
21
- priceType: types.PriceType.Compare,
22
- settings: helpers.getRenderComparePriceSettings(setting)
23
- }));
13
+ const regularPriceComponent = ()=>PriceComponent_liquid.default({
14
+ priceType: types.PriceType.Regular,
15
+ settings: helpers.getRenderRegularPriceSettings(setting)
16
+ });
17
+ const comparePriceComponent = ()=>PriceComponent_liquid.default({
18
+ priceType: types.PriceType.Compare,
19
+ settings: helpers.getRenderComparePriceSettings(setting)
20
+ });
21
+ const getComponentsByLayout = ()=>{
22
+ switch(setting?.priceLayout){
23
+ case constants.PRICE_LAYOUT.PRICE_ONLY:
24
+ return [
25
+ regularPriceComponent
26
+ ];
27
+ case constants.PRICE_LAYOUT.PRICE_BEFORE:
28
+ return [
29
+ regularPriceComponent,
30
+ comparePriceComponent
31
+ ];
32
+ case constants.PRICE_LAYOUT.PRICE_AFTER:
33
+ return [
34
+ comparePriceComponent,
35
+ regularPriceComponent
36
+ ];
37
+ default:
38
+ return [
39
+ regularPriceComponent,
40
+ comparePriceComponent
41
+ ];
24
42
  }
25
- return components;
26
43
  };
27
- const components = createPriceComponents({
28
- includeCompare: helpers.isLayoutSupportComparePrice(setting?.buttonLayout)
29
- });
44
+ const components = getComponentsByLayout();
30
45
  return PriceLayout_liquid.default({
31
46
  components,
32
47
  separator: setting?.separator,
@@ -100,6 +100,30 @@ const ProductButtonSettings = [
100
100
  }
101
101
  ]
102
102
  },
103
+ {
104
+ id: 'priceLayout',
105
+ type: 'option:illustration',
106
+ enableTooltip: false,
107
+ label: 'Layout',
108
+ options: [
109
+ {
110
+ value: 'price-only',
111
+ type: 'image',
112
+ svgName: 'gp-product-button-price-only-layout'
113
+ },
114
+ {
115
+ value: 'price-before',
116
+ type: 'image',
117
+ svgName: 'gp-product-button-price-before-layout'
118
+ },
119
+ {
120
+ value: 'price-after',
121
+ type: 'image',
122
+ svgName: 'gp-product-button-price-after-layout'
123
+ }
124
+ ],
125
+ default: 'price-only'
126
+ },
103
127
  {
104
128
  id: 'button-text-group',
105
129
  type: 'group',
@@ -580,6 +580,16 @@ const SettingUIV2 = [
580
580
  toggleStyle: 'switch'
581
581
  }
582
582
  },
583
+ {
584
+ label: {
585
+ en: 'Layout'
586
+ },
587
+ conditionDisplay: 'enablePrice === true',
588
+ setting: {
589
+ id: 'priceLayout'
590
+ },
591
+ layout: 'vertical'
592
+ },
583
593
  {
584
594
  label: {
585
595
  en: 'Product price'
@@ -152,7 +152,7 @@ const ProductPriceSettings = [
152
152
  id: 'typo',
153
153
  type: 'typography-v2',
154
154
  default: {
155
- type: 'subheading-2'
155
+ type: 'paragraph-1'
156
156
  },
157
157
  ignoreReRender: true,
158
158
  hiddenSetting: {
@@ -25,8 +25,10 @@ const SEPARATOR = {
25
25
  </svg>
26
26
  `
27
27
  };
28
- const SUPPORT_COMPARE_PRICE_LAYOUTS = [
29
- 'cart-full'
30
- ];
28
+ const PRICE_LAYOUT = {
29
+ PRICE_ONLY: 'price-only',
30
+ PRICE_BEFORE: 'price-before',
31
+ PRICE_AFTER: 'price-after'
32
+ };
31
33
 
32
- export { SEPARATOR, SUPPORT_COMPARE_PRICE_LAYOUTS };
34
+ export { PRICE_LAYOUT, SEPARATOR };
@@ -1,4 +1,4 @@
1
- import { SUPPORT_COMPARE_PRICE_LAYOUTS, SEPARATOR } from './constants.js';
1
+ import { SEPARATOR } from './constants.js';
2
2
 
3
3
  const checkIconVisibility = (styles)=>{
4
4
  return styles?.enableIcon === true;
@@ -54,8 +54,5 @@ const removeColorFromTypo = (typo)=>{
54
54
  }
55
55
  return typo;
56
56
  };
57
- const isLayoutSupportComparePrice = (buttonLayout)=>{
58
- return buttonLayout ? SUPPORT_COMPARE_PRICE_LAYOUTS.includes(buttonLayout) : false;
59
- };
60
57
 
61
- export { checkIconVisibility, getGPProductButtonState, getRenderComparePriceSettings, getRenderRegularPriceSettings, isLayoutSupportComparePrice, renderSeparator };
58
+ export { checkIconVisibility, getGPProductButtonState, getRenderComparePriceSettings, getRenderRegularPriceSettings, renderSeparator };
@@ -2,29 +2,44 @@
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { PriceType } from '../common/types.js';
4
4
  import 'react';
5
- import { getRenderRegularPriceSettings, getRenderComparePriceSettings, isLayoutSupportComparePrice } from '../common/helpers.js';
5
+ import { getRenderRegularPriceSettings, getRenderComparePriceSettings } from '../common/helpers.js';
6
6
  import PriceLayout from './PriceLayout.js';
7
7
  import PriceComponent from './PriceComponent.js';
8
+ import { PRICE_LAYOUT } from '../common/constants.js';
8
9
 
9
10
  const ProductButtonPrice = ({ setting, styles })=>{
10
- const createPriceComponents = ({ includeCompare })=>{
11
- const components = [
12
- /*#__PURE__*/ jsx(PriceComponent, {
13
- priceType: PriceType.Regular,
14
- settings: getRenderRegularPriceSettings(setting)
15
- }, "regular")
16
- ];
17
- if (includeCompare) {
18
- components.push(/*#__PURE__*/ jsx(PriceComponent, {
19
- priceType: PriceType.Compare,
20
- settings: getRenderComparePriceSettings(setting)
21
- }, "compare"));
11
+ const regularPriceComponent = /*#__PURE__*/ jsx(PriceComponent, {
12
+ priceType: PriceType.Regular,
13
+ settings: getRenderRegularPriceSettings(setting)
14
+ }, "regular");
15
+ const comparePriceComponent = /*#__PURE__*/ jsx(PriceComponent, {
16
+ priceType: PriceType.Compare,
17
+ settings: getRenderComparePriceSettings(setting)
18
+ }, "compare");
19
+ const getComponentsByLayout = ()=>{
20
+ switch(setting?.priceLayout){
21
+ case PRICE_LAYOUT.PRICE_ONLY:
22
+ return [
23
+ regularPriceComponent
24
+ ];
25
+ case PRICE_LAYOUT.PRICE_BEFORE:
26
+ return [
27
+ regularPriceComponent,
28
+ comparePriceComponent
29
+ ];
30
+ case PRICE_LAYOUT.PRICE_AFTER:
31
+ return [
32
+ comparePriceComponent,
33
+ regularPriceComponent
34
+ ];
35
+ default:
36
+ return [
37
+ regularPriceComponent,
38
+ comparePriceComponent
39
+ ];
22
40
  }
23
- return components;
24
41
  };
25
- const components = createPriceComponents({
26
- includeCompare: isLayoutSupportComparePrice(setting?.buttonLayout)
27
- });
42
+ const components = getComponentsByLayout();
28
43
  return /*#__PURE__*/ jsx(PriceLayout, {
29
44
  components: components,
30
45
  separator: setting?.separator,
@@ -1,28 +1,43 @@
1
1
  'use client';
2
2
  import { PriceType } from '../common/types.js';
3
- import { getRenderComparePriceSettings, isLayoutSupportComparePrice, getRenderRegularPriceSettings } from '../common/helpers.js';
3
+ import { getRenderRegularPriceSettings, getRenderComparePriceSettings } from '../common/helpers.js';
4
4
  import PriceLayout from './PriceLayout.liquid.js';
5
5
  import PriceComponent from './PriceComponent.liquid.js';
6
+ import { PRICE_LAYOUT } from '../common/constants.js';
6
7
 
7
8
  const ProductButtonPrice = ({ setting, styles })=>{
8
- const createPriceComponents = ({ includeCompare })=>{
9
- const components = [
10
- ()=>PriceComponent({
11
- priceType: PriceType.Regular,
12
- settings: getRenderRegularPriceSettings(setting)
13
- })
14
- ];
15
- if (includeCompare) {
16
- components.push(()=>PriceComponent({
17
- priceType: PriceType.Compare,
18
- settings: getRenderComparePriceSettings(setting)
19
- }));
9
+ const regularPriceComponent = ()=>PriceComponent({
10
+ priceType: PriceType.Regular,
11
+ settings: getRenderRegularPriceSettings(setting)
12
+ });
13
+ const comparePriceComponent = ()=>PriceComponent({
14
+ priceType: PriceType.Compare,
15
+ settings: getRenderComparePriceSettings(setting)
16
+ });
17
+ const getComponentsByLayout = ()=>{
18
+ switch(setting?.priceLayout){
19
+ case PRICE_LAYOUT.PRICE_ONLY:
20
+ return [
21
+ regularPriceComponent
22
+ ];
23
+ case PRICE_LAYOUT.PRICE_BEFORE:
24
+ return [
25
+ regularPriceComponent,
26
+ comparePriceComponent
27
+ ];
28
+ case PRICE_LAYOUT.PRICE_AFTER:
29
+ return [
30
+ comparePriceComponent,
31
+ regularPriceComponent
32
+ ];
33
+ default:
34
+ return [
35
+ regularPriceComponent,
36
+ comparePriceComponent
37
+ ];
20
38
  }
21
- return components;
22
39
  };
23
- const components = createPriceComponents({
24
- includeCompare: isLayoutSupportComparePrice(setting?.buttonLayout)
25
- });
40
+ const components = getComponentsByLayout();
26
41
  return PriceLayout({
27
42
  components,
28
43
  separator: setting?.separator,
@@ -98,6 +98,30 @@ const ProductButtonSettings = [
98
98
  }
99
99
  ]
100
100
  },
101
+ {
102
+ id: 'priceLayout',
103
+ type: 'option:illustration',
104
+ enableTooltip: false,
105
+ label: 'Layout',
106
+ options: [
107
+ {
108
+ value: 'price-only',
109
+ type: 'image',
110
+ svgName: 'gp-product-button-price-only-layout'
111
+ },
112
+ {
113
+ value: 'price-before',
114
+ type: 'image',
115
+ svgName: 'gp-product-button-price-before-layout'
116
+ },
117
+ {
118
+ value: 'price-after',
119
+ type: 'image',
120
+ svgName: 'gp-product-button-price-after-layout'
121
+ }
122
+ ],
123
+ default: 'price-only'
124
+ },
101
125
  {
102
126
  id: 'button-text-group',
103
127
  type: 'group',
@@ -578,6 +578,16 @@ const SettingUIV2 = [
578
578
  toggleStyle: 'switch'
579
579
  }
580
580
  },
581
+ {
582
+ label: {
583
+ en: 'Layout'
584
+ },
585
+ conditionDisplay: 'enablePrice === true',
586
+ setting: {
587
+ id: 'priceLayout'
588
+ },
589
+ layout: 'vertical'
590
+ },
581
591
  {
582
592
  label: {
583
593
  en: 'Product price'
@@ -150,7 +150,7 @@ const ProductPriceSettings = [
150
150
  id: 'typo',
151
151
  type: 'typography-v2',
152
152
  default: {
153
- type: 'subheading-2'
153
+ type: 'paragraph-1'
154
154
  },
155
155
  ignoreReRender: true,
156
156
  hiddenSetting: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.612",
3
+ "version": "2.0.0-dev.614",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",