@gem-sdk/components 2.0.0-dev.392 → 2.0.0-dev.394

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 (43) hide show
  1. package/dist/cjs/builder.js +4 -4
  2. package/dist/cjs/index.js +30 -30
  3. package/dist/cjs/index.liquid.js +4 -4
  4. package/dist/cjs/product/components/ProductDiscountTag/common/getClasses.js +38 -0
  5. package/dist/cjs/product/components/ProductDiscountTag/common/getStyle.js +42 -0
  6. package/dist/cjs/product/components/ProductDiscountTag/hooks/useGpDiscountTag.js +108 -0
  7. package/dist/cjs/product/components/ProductDiscountTag/index.js +110 -0
  8. package/dist/cjs/product/components/ProductDiscountTag/index.liquid.js +91 -0
  9. package/dist/cjs/product/index.js +4 -4
  10. package/dist/cjs/product/next.js +1 -1
  11. package/dist/cjs/product/setting/ProductTag.js +7 -299
  12. package/dist/cjs/product/setting/product-badge/configs/settings.js +6 -0
  13. package/dist/cjs/product/setting/product-badge/configs/uiV2.js +14 -19
  14. package/dist/cjs/product/setting/product-discount-tag/configs/settings.js +191 -0
  15. package/dist/cjs/product/setting/product-discount-tag/configs/uiV2.js +190 -0
  16. package/dist/cjs/product/setting/product-vendor/configs/settings.js +12 -0
  17. package/dist/cjs/product/setting/product-vendor/configs/uiV2.js +1 -1
  18. package/dist/cjs/sticky/components/Sticky.js +4 -4
  19. package/dist/cjs/sticky/components/hooks/useSticky.js +19 -9
  20. package/dist/esm/builder.js +1 -1
  21. package/dist/esm/index.js +1 -1
  22. package/dist/esm/index.liquid.js +1 -1
  23. package/dist/esm/product/components/ProductDiscountTag/common/getClasses.js +33 -0
  24. package/dist/esm/product/components/ProductDiscountTag/common/getStyle.js +38 -0
  25. package/dist/esm/product/components/ProductDiscountTag/hooks/useGpDiscountTag.js +106 -0
  26. package/dist/esm/product/components/ProductDiscountTag/index.js +106 -0
  27. package/dist/esm/product/components/ProductDiscountTag/index.liquid.js +87 -0
  28. package/dist/esm/product/next.js +1 -1
  29. package/dist/esm/product/setting/ProductTag.js +7 -299
  30. package/dist/esm/product/setting/product-badge/configs/settings.js +6 -0
  31. package/dist/esm/product/setting/product-badge/configs/uiV2.js +14 -19
  32. package/dist/esm/product/setting/product-discount-tag/configs/settings.js +189 -0
  33. package/dist/esm/product/setting/product-discount-tag/configs/uiV2.js +188 -0
  34. package/dist/esm/product/setting/product-vendor/configs/settings.js +12 -0
  35. package/dist/esm/product/setting/product-vendor/configs/uiV2.js +1 -1
  36. package/dist/esm/sticky/components/Sticky.js +4 -4
  37. package/dist/esm/sticky/components/hooks/useSticky.js +20 -10
  38. package/dist/types/index.d.ts +1 -0
  39. package/package.json +2 -2
  40. package/dist/cjs/product/components/ProductTag/ProductTag.js +0 -200
  41. package/dist/cjs/product/components/ProductTag/ProductTag.liquid.js +0 -107
  42. package/dist/esm/product/components/ProductTag/ProductTag.js +0 -196
  43. package/dist/esm/product/components/ProductTag/ProductTag.liquid.js +0 -103
@@ -0,0 +1,188 @@
1
+ const SettingUIV2 = [
2
+ {
3
+ controls: [
4
+ {
5
+ label: {
6
+ en: 'Tag'
7
+ },
8
+ setting: {
9
+ id: 'customContent'
10
+ },
11
+ layout: 'vertical',
12
+ options: {
13
+ labelVariant: 'primary'
14
+ }
15
+ }
16
+ ]
17
+ },
18
+ {
19
+ label: {
20
+ en: 'Size'
21
+ },
22
+ controls: [
23
+ {
24
+ label: {
25
+ en: 'Width'
26
+ },
27
+ controlConfig: {
28
+ id: 'width',
29
+ type: 'dropdown:input',
30
+ units: [
31
+ 'px',
32
+ '%'
33
+ ],
34
+ linkWithSetting: {
35
+ name: 'size',
36
+ field: 'width'
37
+ },
38
+ displayOptions: [
39
+ {
40
+ label: 'Fit content',
41
+ value: 'Auto',
42
+ showValue: true
43
+ },
44
+ {
45
+ label: 'Full',
46
+ value: '100%',
47
+ showValue: true
48
+ },
49
+ {
50
+ label: 'Default',
51
+ value: 'default',
52
+ showValue: true
53
+ }
54
+ ]
55
+ }
56
+ },
57
+ {
58
+ id: 'height',
59
+ label: {
60
+ en: 'Height'
61
+ },
62
+ controlConfig: {
63
+ id: 'height',
64
+ type: 'dropdown:input',
65
+ label: 'Height',
66
+ units: [
67
+ 'px',
68
+ '%'
69
+ ],
70
+ linkWithSetting: {
71
+ name: 'size',
72
+ field: 'height'
73
+ }
74
+ },
75
+ layout: 'horizontal'
76
+ },
77
+ {
78
+ label: {
79
+ en: 'Padding'
80
+ },
81
+ controlConfig: {
82
+ id: 'padding',
83
+ type: 'padding-v2',
84
+ linkWithSetting: {
85
+ name: 'size',
86
+ field: 'padding'
87
+ }
88
+ }
89
+ }
90
+ ]
91
+ },
92
+ {
93
+ label: {
94
+ en: 'Background'
95
+ },
96
+ controls: [
97
+ {
98
+ label: {
99
+ en: 'Color'
100
+ },
101
+ setting: {
102
+ id: 'backgroundColor'
103
+ }
104
+ }
105
+ ]
106
+ },
107
+ {
108
+ label: {
109
+ en: 'Shape'
110
+ },
111
+ controls: [
112
+ {
113
+ label: {
114
+ en: 'Border'
115
+ },
116
+ setting: {
117
+ id: 'borderTag'
118
+ }
119
+ },
120
+ {
121
+ label: {
122
+ en: 'Corner'
123
+ },
124
+ setting: {
125
+ id: 'roundedTag'
126
+ }
127
+ }
128
+ ]
129
+ },
130
+ {
131
+ label: {
132
+ en: 'Text style'
133
+ },
134
+ controls: [
135
+ {
136
+ setting: {
137
+ id: 'typo'
138
+ },
139
+ layout: 'vertical',
140
+ options: {
141
+ hideLabel: true,
142
+ fullWidth: true,
143
+ updateFields: [
144
+ {
145
+ field: 'attrs.textAlign',
146
+ settingId: 'textContentAlign'
147
+ }
148
+ ]
149
+ },
150
+ controlChangeTrigger: {
151
+ settings: [
152
+ {
153
+ action: {
154
+ controlId: 'textContentAlign',
155
+ valueFromField: 'attrs.textAlign',
156
+ groupType: 'style',
157
+ controlType: 'style'
158
+ }
159
+ }
160
+ ],
161
+ options: {
162
+ noRecordHistory: true
163
+ }
164
+ }
165
+ }
166
+ ]
167
+ },
168
+ {
169
+ controls: [
170
+ {
171
+ label: {
172
+ en: 'Align'
173
+ },
174
+ setting: {
175
+ id: 'textAlign'
176
+ },
177
+ conditionEnable: '!(parseInt(size.width) >= 100 && size.width?.includes("%"))',
178
+ options: {
179
+ labelVariant: 'primary',
180
+ fullWidth: true,
181
+ disableMessage: `Align is not supported when width is 100%`
182
+ }
183
+ }
184
+ ]
185
+ }
186
+ ];
187
+
188
+ export { SettingUIV2 };
@@ -99,6 +99,18 @@ const ProductVendorSettings = [
99
99
  },
100
100
  ignoreReRender: true,
101
101
  hiddenSetting: {
102
+ },
103
+ compoDefaultValue: {
104
+ custom: {
105
+ textShadow: {
106
+ angle: 145,
107
+ distance: '2px',
108
+ blur: '20px',
109
+ color: 'rgba(18, 18, 18, 0.2)',
110
+ type: 'custom',
111
+ enable: true
112
+ }
113
+ }
102
114
  }
103
115
  },
104
116
  {
@@ -105,7 +105,7 @@ const SettingUIV2 = [
105
105
  toggleStyle: 'switch'
106
106
  },
107
107
  help: {
108
- content: `Click to open a collection page with all products from the same vendor.`
108
+ content: `Click to open a collection page with<br> all products from the same vendor.`
109
109
  }
110
110
  },
111
111
  {
@@ -16,9 +16,9 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
16
16
  ...style,
17
17
  ...w,
18
18
  ...getStyleBackgroundByDevice(background),
19
- ...displayStyle(),
20
- ...positionStyle(),
21
- ...getCSSAlign(),
19
+ ...displayStyle,
20
+ ...positionStyle,
21
+ ...getCSSAlign,
22
22
  zIndex: ELEMENT_Z_INDEX.STICKY
23
23
  });
24
24
  const computedMinimizeClasses = createClass(composeClasses('sticky-minimize gp-fixed gp-flex gp-h-[32px] gp-w-[76px] gp-cursor-pointer gp-items-center gp-gap-[4px] gp-border gp-border-[#D8E1FF] gp-bg-white hover:gp-bg-[#D8E1FF]'));
@@ -29,7 +29,7 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps })=>{
29
29
  "data-id": builderProps?.uid,
30
30
  ...builderAttrs,
31
31
  style: {
32
- ...displayStyle(),
32
+ ...displayStyle,
33
33
  zIndex: ELEMENT_Z_INDEX.STICKY
34
34
  },
35
35
  children: [
@@ -1,6 +1,6 @@
1
1
  import { makeStyleResponsive, usePageStore, useCurrentDevice } from '@gem-sdk/core';
2
2
  import { createStyleObject } from '../../../grid/row/commons/helpers.js';
3
- import { useMemo, useCallback } from 'react';
3
+ import { useMemo } from 'react';
4
4
 
5
5
  const minimizeSvg = ` <svg
6
6
  className="gp-ml-[7px]"
@@ -66,13 +66,17 @@ const useSticky = (setting)=>{
66
66
  [`--t${device}`]: position == 'top' ? 'unset' : 'translateX(-50%)'
67
67
  };
68
68
  };
69
- const getCSSAlign = ()=>{
69
+ const getCSSAlign = useMemo(()=>{
70
70
  return {
71
71
  ...getCSSAlignByDevice(position?.desktop, ''),
72
72
  ...getCSSAlignByDevice(position?.tablet ?? position?.desktop, '-tablet'),
73
73
  ...getCSSAlignByDevice(position?.mobile ?? position?.desktop, '-mobile')
74
74
  };
75
- };
75
+ }, [
76
+ position?.desktop,
77
+ position?.mobile,
78
+ position?.tablet
79
+ ]);
76
80
  const gap = useMemo(()=>{
77
81
  if (sidebarMode && position?.[currentDevice] === 'top') {
78
82
  return '40px';
@@ -83,26 +87,32 @@ const useSticky = (setting)=>{
83
87
  sidebarMode,
84
88
  position
85
89
  ]);
86
- const displayStyle = useCallback(()=>{
90
+ const displayStyle = useMemo(()=>{
87
91
  return {
88
92
  [`--top`]: gap ?? 'auto',
89
93
  [`--top-tablet`]: gap ?? 'auto',
90
94
  [`--top-mobile`]: gap ?? 'auto',
91
- [`--${position?.desktop}`]: gap ?? 0,
92
- [`--${position?.tablet ?? position?.desktop}-tablet`]: gap ?? 0,
93
- [`--${position?.mobile ?? position?.desktop}-mobile`]: gap ?? 0
95
+ [`--${position?.desktop}`]: gap ?? '0px',
96
+ [`--${position?.tablet ?? position?.desktop}-tablet`]: gap ?? '0px',
97
+ [`--${position?.mobile ?? position?.desktop}-mobile`]: gap ?? '0px'
94
98
  };
95
99
  }, [
96
100
  gap,
97
- position
101
+ position?.desktop,
102
+ position?.mobile,
103
+ position?.tablet
98
104
  ]);
99
- const positionStyle = ()=>{
105
+ const positionStyle = useMemo(()=>{
100
106
  return {
101
107
  [`--pos`]: getCSSPosition(position?.desktop),
102
108
  [`--pos-tablet`]: getCSSPosition(position?.tablet ?? position?.desktop),
103
109
  [`--pos-mobile`]: getCSSPosition(position?.mobile ?? position?.desktop)
104
110
  };
105
- };
111
+ }, [
112
+ position?.desktop,
113
+ position?.mobile,
114
+ position?.tablet
115
+ ]);
106
116
  return {
107
117
  w,
108
118
  displayStyle,
@@ -3804,6 +3804,7 @@ type ProductBadgeProps = BasePropsWrap<{
3804
3804
  alt?: string;
3805
3805
  src?: string;
3806
3806
  };
3807
+ contentBanner?: string;
3807
3808
  }, {
3808
3809
  typo?: TypographySettingV2;
3809
3810
  position?: ObjectDevices$1<PositionType>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.392",
3
+ "version": "2.0.0-dev.394",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -22,7 +22,7 @@
22
22
  "relationship": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/get-control-relationship.js && node ./scripts/get-element-relationship.js"
23
23
  },
24
24
  "devDependencies": {
25
- "@gem-sdk/core": "2.0.0-dev.392",
25
+ "@gem-sdk/core": "2.0.0-dev.393",
26
26
  "@gem-sdk/styles": "2.0.0-dev.381",
27
27
  "@gem-sdk/system": "2.0.0-dev.371",
28
28
  "@types/react-transition-group": "^4.4.5"
@@ -1,200 +0,0 @@
1
- 'use client';
2
- 'use strict';
3
-
4
- Object.defineProperty(exports, '__esModule', { value: true });
5
-
6
- var jsxRuntime = require('react/jsx-runtime');
7
- var core = require('@gem-sdk/core');
8
- var React = require('react');
9
- var NoDataState = require('../../../common/components/NoDataState.js');
10
- var TooltipHover = require('../../../common/components/TooltipHover.js');
11
- var productBundle = require('../../helpers/product-bundle.js');
12
- var Text = require('../../../text/components/Text.js');
13
- var productBundle$1 = require('../constants/product-bundle.js');
14
-
15
- const ProductTag = ({ setting, styles, builderProps, ...passProps })=>{
16
- const { customContent } = setting ?? {};
17
- const bundleItem = passProps['bundle-item'];
18
- const { textAlign, backgroundColor, roundedTag, borderTag, textColor } = styles ?? {};
19
- const { moneyFormat } = core.useMoneyFormat();
20
- const composeGlobalSize = core.makeGlobalSize(styles?.size);
21
- const mode = core.useEditorMode();
22
- const product = core.useProduct();
23
- const currentVariant = core.useCurrentVariant();
24
- const { quantity, hasUpdatePrice } = core.useQuantity();
25
- const quantityProduct = React.useMemo(()=>{
26
- return hasUpdatePrice && customContent?.unit !== 'percentage' ? quantity ?? 1 : 1;
27
- }, [
28
- hasUpdatePrice,
29
- customContent?.unit,
30
- quantity
31
- ]);
32
- const price = currentVariant?.price ?? 0;
33
- const salePrice = currentVariant?.salePrice ?? 0;
34
- const priceSave = (salePrice - price) * quantityProduct;
35
- const moneyFormatted = core.useFormatMoney(priceSave < 0 ? 0 : priceSave, setting?.moneyWithCurrentFormat || false);
36
- const customDisplayWithUnit = React.useMemo(()=>{
37
- if (!salePrice && salePrice !== 0 || !price && price !== 0) return `${customContent?.unit === 'percentage' ? '0%' : moneyFormatted}`;
38
- if (customContent?.unit === 'percentage') {
39
- const salePercent = Math.round(priceSave / (salePrice / 100));
40
- return `${salePercent < 0 ? 0 : salePercent}%`;
41
- }
42
- return `${moneyFormatted}`;
43
- }, [
44
- customContent?.unit,
45
- moneyFormatted,
46
- price,
47
- priceSave,
48
- salePrice
49
- ]);
50
- const { useProductCompareAtPrice } = core.useProductBundleDiscount();
51
- const { discountPercentAmount } = productBundle.applyBundleDiscountAmount({
52
- currentVariant,
53
- bundleItem,
54
- options: {
55
- moneyFormat,
56
- useProductCompareAtPrice
57
- }
58
- });
59
- const bundleDiscountDisplay = React.useMemo(()=>{
60
- if (!bundleItem) return 0;
61
- const { discountPercentAmount, discountAmount } = productBundle.applyBundleDiscountAmount({
62
- currentVariant,
63
- bundleItem,
64
- options: {
65
- moneyFormat,
66
- useProductCompareAtPrice
67
- }
68
- });
69
- const { discountType } = bundleItem;
70
- const { unit } = customContent || {};
71
- if (discountType === productBundle$1.DiscountType.NoDiscount && !useProductCompareAtPrice) {
72
- return unit === 'percentage' ? '0%' : core.formatMoney('0', moneyFormat);
73
- }
74
- if (unit === 'percentage') {
75
- return `${discountPercentAmount}%`;
76
- }
77
- return discountAmount;
78
- }, [
79
- bundleItem,
80
- currentVariant,
81
- moneyFormat,
82
- useProductCompareAtPrice,
83
- customContent
84
- ]);
85
- const unitCustomDisplay = React.useMemo(()=>{
86
- if (!bundleItem) {
87
- return customDisplayWithUnit;
88
- }
89
- return bundleDiscountDisplay;
90
- }, [
91
- bundleDiscountDisplay,
92
- bundleItem,
93
- customDisplayWithUnit
94
- ]);
95
- const borderColorClass = core.getGlobalColorClass('border', borderTag?.color);
96
- const textColorClass = core.getGlobalColorClass('text', textColor);
97
- const backgroundColorClass = core.getGlobalColorClass('bg', backgroundColor);
98
- const currentProductId = product?.baseID?.replace('gid://shopify/Product/', '');
99
- const shouldPlaceholderNoDiscount = React.useMemo(()=>{
100
- const noDiscount = !bundleItem ? priceSave <= 0 : discountPercentAmount <= 0;
101
- return mode === 'edit' && noDiscount;
102
- }, [
103
- bundleItem,
104
- discountPercentAmount,
105
- mode,
106
- priceSave
107
- ]);
108
- if (shouldPlaceholderNoDiscount) {
109
- return /*#__PURE__*/ jsxRuntime.jsx(TooltipHover.default, {
110
- enable: true,
111
- text: 'Not be displayed when published',
112
- position: 'bottom',
113
- width: '205px',
114
- children: /*#__PURE__*/ jsxRuntime.jsx(NoDataState.default, {
115
- builderAttrs: builderProps?.builderData,
116
- elementType: "secondary",
117
- description: "No discount",
118
- rawMode: true
119
- })
120
- });
121
- }
122
- return /*#__PURE__*/ jsxRuntime.jsx("div", {
123
- className: core.cls({
124
- 'gp-opacity-0 ': mode !== 'edit' && (salePrice <= 0 || Math.ceil(priceSave / (salePrice / 100)) <= 0),
125
- 'gp-opacity-20 ': mode === 'edit' && (salePrice <= 0 || Math.ceil(priceSave / (salePrice / 100)) <= 0) && !bundleItem
126
- }),
127
- style: {
128
- ...core.makeStyleResponsive('ta', textAlign)
129
- },
130
- id: `shopify-text-element-${builderProps?.uid}`,
131
- "data-id": builderProps?.uid,
132
- "data-product-id": currentProductId,
133
- "gp-data-hidden": "false",
134
- children: !product ? null : /*#__PURE__*/ jsxRuntime.jsx("div", {
135
- className: core.cls('gp-inline-flex gp-flex-wrap gp-items-end gp-gap-3'),
136
- style: {
137
- ...composeGlobalSize.width,
138
- ...composeGlobalSize.height
139
- },
140
- children: /*#__PURE__*/ jsxRuntime.jsx("div", {
141
- className: core.cls('gp-flex gp-items-center gp-w-full gp-h-full', borderColorClass, textColorClass, backgroundColorClass),
142
- style: {
143
- ...core.makeStyleResponsive('jc', styles?.textContentAlign),
144
- ...composeGlobalSize.padding,
145
- ...core.makeStyle({
146
- bs: borderTag?.border,
147
- bw: borderTag?.width,
148
- bc: borderColorClass === '' ? borderTag?.color : undefined,
149
- c: textColorClass === '' ? textColor : undefined,
150
- bg: backgroundColorClass === '' ? backgroundColor : undefined
151
- }),
152
- ...roundedTag?.radiusType !== 'custom' ? core.getRadiusCSSFromGlobal('normal', roundedTag?.radiusType) : {},
153
- ...core.getCustomRadius('normal', roundedTag)
154
- },
155
- children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
156
- className: "gp-flex gp-break-all",
157
- children: [
158
- /*#__PURE__*/ jsxRuntime.jsx(Text.default, {
159
- styles: styles,
160
- setting: {
161
- ...setting,
162
- text: customContent?.prefix?.replaceAll(' ', '&nbsp;'),
163
- options: {
164
- useState: true,
165
- uniqueId: `${builderProps?.uid}-prefix`
166
- },
167
- excludeFlex: true
168
- }
169
- }),
170
- /*#__PURE__*/ jsxRuntime.jsx(Text.default, {
171
- styles: styles,
172
- setting: {
173
- ...setting,
174
- text: unitCustomDisplay,
175
- options: {
176
- isCannotEditing: true
177
- },
178
- excludeFlex: true
179
- }
180
- }),
181
- /*#__PURE__*/ jsxRuntime.jsx(Text.default, {
182
- styles: styles,
183
- setting: {
184
- ...setting,
185
- text: customContent?.suffix?.replaceAll(' ', '&nbsp;'),
186
- excludeFlex: true,
187
- options: {
188
- useState: true,
189
- uniqueId: `${builderProps?.uid}-suffix`
190
- }
191
- }
192
- })
193
- ]
194
- })
195
- })
196
- })
197
- });
198
- };
199
-
200
- exports.default = ProductTag;
@@ -1,107 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@gem-sdk/core');
6
- var helpers = require('../../../helpers.js');
7
- var Text_liquid = require('../../../text/components/Text.liquid.js');
8
-
9
- const ProductTag = ({ setting, styles, builderProps, advanced, pageContext })=>{
10
- const { customContent, translate } = setting ?? {};
11
- const { textAlign, backgroundColor, roundedTag, borderTag, textColor } = styles ?? {};
12
- const borderColorClass = core.getGlobalColorClass('border', borderTag?.color);
13
- const textColorClass = core.getGlobalColorClass('text', textColor);
14
- const backgroundColorClass = core.getGlobalColorClass('bg', backgroundColor);
15
- const composeGlobalSize = core.makeGlobalSize(styles?.size);
16
- const moneyFormat = setting?.moneyWithCurrentFormat ? `money_with_currency` : `money`;
17
- const prefixVal = helpers.getDynamicSourceLocales({
18
- val: customContent?.prefix,
19
- uid: builderProps?.uid,
20
- settingId: 'customContent_prefix',
21
- isLiquid: true,
22
- pageContext,
23
- translate
24
- });
25
- const suffixVal = helpers.getDynamicSourceLocales({
26
- val: customContent?.suffix,
27
- uid: builderProps?.uid,
28
- settingId: 'customContent_suffix',
29
- isLiquid: true,
30
- pageContext,
31
- translate
32
- });
33
- return core.template`
34
- {% liquid
35
- assign price = variant.price | times: 1.0
36
- assign salePrice = variant.compare_at_price | times: 1.0
37
- assign priceSave = salePrice | minus: price
38
- assign prefixVal = ${pageContext?.isPreviewing ? JSON.stringify(prefixVal) : prefixVal}
39
- assign suffixVal = ${pageContext?.isPreviewing ? JSON.stringify(suffixVal) : suffixVal}
40
- if salePrice == null or price == null
41
- assign pricePercentage = prefixVal ${customContent?.unit === 'percentage' ? `| append: ' 0% '` : `| ${moneyFormat} | append: ' '`} | append: suffixVal
42
- else
43
- ${customContent?.unit === 'percentage' ? ` assign salePercent = priceSave | divided_by: salePrice | times: 100 | round
44
- assign pricePercentage = prefixVal | append: ' ' | append: salePercent | append: '% ' | append: suffixVal
45
- ` : `
46
- if priceSave > 0
47
- assign priceSaveMoney = priceSave | ${moneyFormat}
48
- assign pricePercentage = prefixVal | append: ' ' | append: priceSaveMoney | append: ' ' | append: suffixVal
49
- else
50
- assign priceSaveMoney = 0 | ${moneyFormat}
51
- assign pricePercentage = prefixVal | append: ' ' | append: priceSaveMoney | append: ' ' | append: suffixVal
52
- endif
53
- `}
54
- endif
55
- %}
56
-
57
- <gp-product-tag
58
- data-id="${builderProps?.uid}"
59
- data-disabled="{%- if priceSave > 0 -%} false {%- else -%} true {%- endif -%}"
60
- gp-data='{"setting":${JSON.stringify(setting).replaceAll("'", '&#039;')}, "id": "${builderProps?.uid}", "locale": "{{shop.locale}}", "currency": "{{shop.currency}}", "moneyFormat": "{{ ${setting?.moneyWithCurrentFormat ? 'shop.money_with_currency_format' : 'shop.money_format'} | replace: '"', '\\"' | escape }}"}'
61
- class="gp-block data-[disabled=true]:gp-hidden ${advanced?.cssClass}"
62
- style="${{
63
- ...core.makeStyleResponsive('ta', textAlign)
64
- }}"
65
- price-save="{{priceSave}}"
66
- data-prefix="${pageContext?.isPreviewing ? prefixVal : `{{${prefixVal}}}`}"
67
- data-suffix="${pageContext?.isPreviewing ? suffixVal : `{{${suffixVal}}}`}"
68
- >
69
- <div class="${core.cls('gp-inline-flex gp-flex-wrap gp-items-end gp-gap-3')}" style="${{
70
- ...composeGlobalSize.width,
71
- ...composeGlobalSize.height
72
- }}">
73
- <div
74
- class="${core.cls('gp-flex gp-items-center gp-w-full gp-h-full', borderColorClass, textColorClass, backgroundColorClass)}"
75
- style="${{
76
- ...core.makeStyleResponsive('jc', styles?.textContentAlign),
77
- ...composeGlobalSize.padding,
78
- ...core.makeStyle({
79
- bs: borderTag?.border,
80
- bw: borderTag?.width,
81
- bc: borderColorClass === '' ? borderTag?.color : undefined,
82
- c: textColorClass === '' ? textColor : undefined,
83
- bg: backgroundColorClass === '' ? backgroundColor : undefined
84
- }),
85
- ...roundedTag?.radiusType !== 'custom' ? core.getRadiusCSSFromGlobal('normal', roundedTag?.radiusType) : {},
86
- ...core.getCustomRadius('normal', roundedTag)
87
- }}"
88
- >
89
- ${Text_liquid.default({
90
- styles,
91
- id: `p-tag-${builderProps?.uid}`,
92
- setting: {
93
- ...setting,
94
- translate: '',
95
- text: '{{pricePercentage}}',
96
- excludeFlex: true
97
- }
98
- })}
99
- </div>
100
- </div>
101
-
102
- </gp-product-tag>
103
- ${core.RenderIf(core.isLocalEnv, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-tag.js' | asset_url }}" defer="defer"></script>`, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="${core.baseAssetURL}/assets-v2/gp-product-tag.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
104
- `;
105
- };
106
-
107
- exports.default = ProductTag;