@gem-sdk/components 2.0.0-dev.333 → 2.0.0-dev.334
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.
- package/dist/cjs/product/components/ProductBadge/common/getAttrs.js +74 -0
- package/dist/cjs/product/components/ProductBadge/common/getClasses.js +79 -0
- package/dist/cjs/product/components/ProductBadge/common/getStyles.js +144 -0
- package/dist/cjs/product/components/ProductBadge/constants.js +1 -9
- package/dist/cjs/product/components/ProductBadge/index.js +125 -117
- package/dist/cjs/product/components/ProductBadge/index.liquid.js +97 -111
- package/dist/cjs/product/components/ProductBadge/utils/common.js +11 -0
- package/dist/cjs/product/components/ProductBadge/utils/getRotateShape.js +10 -5
- package/dist/cjs/product/components/ProductBadge/utils/shape.js +14 -1
- package/dist/cjs/product/index.js +1 -1
- package/dist/cjs/product/setting/product-badge/configs/settings.js +72 -93
- package/dist/cjs/product/setting/product-badge/configs/uiV2.js +93 -15
- package/dist/esm/product/components/ProductBadge/common/getAttrs.js +67 -0
- package/dist/esm/product/components/ProductBadge/common/getClasses.js +70 -0
- package/dist/esm/product/components/ProductBadge/common/getStyles.js +137 -0
- package/dist/esm/product/components/ProductBadge/constants.js +2 -5
- package/dist/esm/product/components/ProductBadge/index.js +128 -120
- package/dist/esm/product/components/ProductBadge/index.liquid.js +99 -113
- package/dist/esm/product/components/ProductBadge/utils/common.js +12 -2
- package/dist/esm/product/components/ProductBadge/utils/getRotateShape.js +10 -5
- package/dist/esm/product/components/ProductBadge/utils/shape.js +14 -1
- package/dist/esm/product/index.js +1 -1
- package/dist/esm/product/setting/product-badge/configs/settings.js +72 -93
- package/dist/esm/product/setting/product-badge/configs/uiV2.js +93 -15
- package/dist/types/index.d.ts +1 -3
- package/package.json +2 -2
- package/dist/cjs/product/components/ProductBadge/hooks/useProductBadgeStyles.js +0 -83
- package/dist/esm/product/components/ProductBadge/hooks/useProductBadgeStyles.js +0 -81
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
|
|
5
|
+
const getImageAttr = ({ setting })=>{
|
|
6
|
+
return {
|
|
7
|
+
src: setting?.image?.src,
|
|
8
|
+
alt: setting?.image?.alt,
|
|
9
|
+
loading: 'lazy'
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const getContainerAttrs = (props)=>{
|
|
13
|
+
const { builderAttrs, builderProps, setting } = props;
|
|
14
|
+
const isTextBadge = setting?.contentType === 'text';
|
|
15
|
+
return {
|
|
16
|
+
...builderAttrs,
|
|
17
|
+
'data-id': builderProps?.uid || '',
|
|
18
|
+
id: `g-product-badge-${builderProps?.uid}`,
|
|
19
|
+
'gp-data-hidden': 'false',
|
|
20
|
+
'gp-data': `${core.dataStringify({
|
|
21
|
+
displayContent: setting?.displayContent,
|
|
22
|
+
minPrice: '{{ minPriceValue }}',
|
|
23
|
+
variantIDs: '{{ product.variants | map: "id" | json | escape }}',
|
|
24
|
+
variantInventoryQuantities: '{{ product.variants | map: "inventory_quantity" | json | escape }}',
|
|
25
|
+
amountDiscount: '{{amountDiscountValue}}',
|
|
26
|
+
percentDiscount: '{{percentDiscountValue}}',
|
|
27
|
+
price: '{{price}}',
|
|
28
|
+
displayTrigger: setting?.displayTrigger,
|
|
29
|
+
uid: builderProps?.uid,
|
|
30
|
+
productCreatedAt: '{{product.created_at | date: "%Y-%m-%d" }}',
|
|
31
|
+
productTags: '{{ product.tags | join: "," }}',
|
|
32
|
+
isTextBadge
|
|
33
|
+
})}`
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const getEditTooltipAttrs = (props)=>{
|
|
37
|
+
const { setting } = props;
|
|
38
|
+
const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
|
|
39
|
+
return {
|
|
40
|
+
enable: true,
|
|
41
|
+
text: 'Not be displayed when published',
|
|
42
|
+
position: isDropOutsideProductImage ? 'bottom' : 'right',
|
|
43
|
+
width: '205px'
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const getNoDataAttrs = (props)=>{
|
|
47
|
+
const { builderAttrs } = props;
|
|
48
|
+
return {
|
|
49
|
+
...builderAttrs,
|
|
50
|
+
elementType: 'secondary',
|
|
51
|
+
description: 'No discount',
|
|
52
|
+
rawMode: true
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
const getSubWrapperAttrs = (props, product)=>{
|
|
56
|
+
const { builderProps } = props;
|
|
57
|
+
const currentProductId = product ? product?.baseID?.replace('gid://shopify/Product/', '') : '';
|
|
58
|
+
return {
|
|
59
|
+
'data-product-id': currentProductId || '',
|
|
60
|
+
id: builderProps?.uid || ''
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const getTextContentAttrs = ()=>{
|
|
64
|
+
return {
|
|
65
|
+
id: 'product-badge-content'
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
exports.getContainerAttrs = getContainerAttrs;
|
|
70
|
+
exports.getEditTooltipAttrs = getEditTooltipAttrs;
|
|
71
|
+
exports.getImageAttr = getImageAttr;
|
|
72
|
+
exports.getNoDataAttrs = getNoDataAttrs;
|
|
73
|
+
exports.getSubWrapperAttrs = getSubWrapperAttrs;
|
|
74
|
+
exports.getTextContentAttrs = getTextContentAttrs;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var renderBadgeILP = require('../utils/renderBadgeILP.js');
|
|
5
|
+
var common = require('../utils/common.js');
|
|
6
|
+
|
|
7
|
+
const getContainerClasses = ({ mode, isInstant, product, currentVariant, props })=>{
|
|
8
|
+
const { setting, builderProps } = props;
|
|
9
|
+
let classList = 'gp-shrink-0 product-badge ';
|
|
10
|
+
const conditionClass = !mode && isInstant ? renderBadgeILP.toggleBadge(setting?.displayTrigger, product, currentVariant) : '{{className}}';
|
|
11
|
+
const advancedClass = builderProps?.builderData?.advanced?.cssClass || '';
|
|
12
|
+
if (conditionClass) classList += `${conditionClass} `;
|
|
13
|
+
if (advancedClass) classList += `${advancedClass} `;
|
|
14
|
+
if (builderProps?.uid) classList += `${builderProps?.uid} `;
|
|
15
|
+
if (setting?.positionWithImage === 'inside') classList += 'inside-image ';
|
|
16
|
+
return {
|
|
17
|
+
...core.composeClasses(classList)
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const getTextContainerClasses = ()=>{
|
|
21
|
+
const classList = 'gp-w-full gp-h-full gp-overflow-hidden product-badge-item';
|
|
22
|
+
return {
|
|
23
|
+
...core.composeClasses(classList)
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
const getTextWrapperClasses = ()=>{
|
|
27
|
+
const classList = 'gp-w-full gp-h-full gp-flex gp-items-center gp-justify-center gp-overflow-hidden';
|
|
28
|
+
return {
|
|
29
|
+
...core.composeClasses(classList)
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
const getTextContentClasses = (styles)=>{
|
|
33
|
+
let classList = 'gp-break-words gp-text-center ';
|
|
34
|
+
const typoClass = core.composeTypographyClassName(styles?.typo);
|
|
35
|
+
if (typoClass) classList += `${typoClass} `;
|
|
36
|
+
return {
|
|
37
|
+
...core.composeClasses(classList)
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
const getImageContainerClasses = ()=>{
|
|
41
|
+
const classList = 'product-badge-item gp-w-full gp-h-full';
|
|
42
|
+
return {
|
|
43
|
+
...core.composeClasses(classList)
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
const getImageClasses = ()=>{
|
|
47
|
+
const classList = 'gp-object-cover gp-w-full gp-h-full gp-pointer-events-none';
|
|
48
|
+
return {
|
|
49
|
+
...core.composeClasses(classList)
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
const getWrapperClasses = (props)=>{
|
|
53
|
+
const { styles, setting } = props;
|
|
54
|
+
const { align } = styles ?? {};
|
|
55
|
+
const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
|
|
56
|
+
let classList = isDropOutsideProductImage ? 'gp-flex ' : 'gp-h-full';
|
|
57
|
+
const alignClass = common.getAlignShape(align, false);
|
|
58
|
+
if (isDropOutsideProductImage && alignClass) classList += `${alignClass} `;
|
|
59
|
+
return {
|
|
60
|
+
...core.composeClasses(classList)
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const getSubWrapperClass = (props, currentDevice)=>{
|
|
64
|
+
const { setting, style } = props;
|
|
65
|
+
const isInsideProductImage = setting?.positionWithImage === 'inside';
|
|
66
|
+
const classList = !isInsideProductImage && currentDevice ? common.getShapePlacementClass(isInsideProductImage, style, currentDevice) : 'gp-h-full';
|
|
67
|
+
return {
|
|
68
|
+
...core.composeClasses(classList)
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
exports.getContainerClasses = getContainerClasses;
|
|
73
|
+
exports.getImageClasses = getImageClasses;
|
|
74
|
+
exports.getImageContainerClasses = getImageContainerClasses;
|
|
75
|
+
exports.getSubWrapperClass = getSubWrapperClass;
|
|
76
|
+
exports.getTextContainerClasses = getTextContainerClasses;
|
|
77
|
+
exports.getTextContentClasses = getTextContentClasses;
|
|
78
|
+
exports.getTextWrapperClasses = getTextWrapperClasses;
|
|
79
|
+
exports.getWrapperClasses = getWrapperClasses;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var core = require('@gem-sdk/core');
|
|
4
|
+
var common = require('../utils/common.js');
|
|
5
|
+
var getShapePosition = require('../utils/getShapePosition.js');
|
|
6
|
+
var getRotateShape = require('../utils/getRotateShape.js');
|
|
7
|
+
var getStyleAdvanced = require('../utils/getStyleAdvanced.js');
|
|
8
|
+
var getWhiteSpace = require('../utils/getWhiteSpace.js');
|
|
9
|
+
var stylesV2 = require('../utils/stylesV2.js');
|
|
10
|
+
var shape = require('../utils/shape.js');
|
|
11
|
+
|
|
12
|
+
const getSizeStyles = (props)=>{
|
|
13
|
+
const { setting, styles } = props;
|
|
14
|
+
const shape$1 = shape.getShape(setting?.shape);
|
|
15
|
+
const isTextBadge = setting?.contentType === 'text';
|
|
16
|
+
const badgeSize = isTextBadge ? styles?.textSizeV2 : styles?.imageSizeV2;
|
|
17
|
+
return isTextBadge ? common.getSize(shape$1, badgeSize) : common.getSize(undefined, badgeSize);
|
|
18
|
+
};
|
|
19
|
+
const getContainerStyle = (props)=>{
|
|
20
|
+
const { setting, styles, style, navigationPosition, imageData, dotData } = props;
|
|
21
|
+
const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
|
|
22
|
+
const wrapperStyles = common.getWrapperStyle(false);
|
|
23
|
+
const shapePosition = getShapePosition.getShapePosition({
|
|
24
|
+
positionType: styles?.position,
|
|
25
|
+
isLiquid: false,
|
|
26
|
+
navigationPosition,
|
|
27
|
+
dataImage: {
|
|
28
|
+
...imageData,
|
|
29
|
+
...dotData
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
const sizeStyles = getSizeStyles(props);
|
|
33
|
+
const advancedStyles = getStyleAdvanced.getStyleAdvanced(!isDropOutsideProductImage ? {
|
|
34
|
+
...shapePosition,
|
|
35
|
+
...sizeStyles
|
|
36
|
+
} : {}, style);
|
|
37
|
+
return {
|
|
38
|
+
...!isDropOutsideProductImage && {
|
|
39
|
+
'--pos': 'absolute'
|
|
40
|
+
},
|
|
41
|
+
...wrapperStyles,
|
|
42
|
+
...advancedStyles
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
const getTextContentStyle = ({ styles, setting })=>{
|
|
46
|
+
const textBadgePadding = core.makeGlobalSize(styles?.textSizeV2).padding;
|
|
47
|
+
const shape$1 = shape.getShape(setting?.shape);
|
|
48
|
+
const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
|
|
49
|
+
return {
|
|
50
|
+
...getWhiteSpace.getWhiteSpaceStyle(styles?.textSizeV2),
|
|
51
|
+
...common.convertToStyle(shape$1?.textStyle),
|
|
52
|
+
...getRotateShape.composeTextStyleByPosition(shape$1, styles?.position, isDropOutsideProductImage),
|
|
53
|
+
...core.composeTypographyStyle(styles?.typo),
|
|
54
|
+
...core.getStyleShadow({
|
|
55
|
+
value: styles?.typo?.custom?.textShadow,
|
|
56
|
+
styleAppliedFor: 'text-shadow',
|
|
57
|
+
isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
|
|
58
|
+
}),
|
|
59
|
+
...stylesV2.getStyleBackground(!!shape$1?.backgroundColorInText, styles?.badgeColorV2),
|
|
60
|
+
...textBadgePadding
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
const getBorderStyles = ({ styles, setting })=>{
|
|
64
|
+
const shape$1 = shape.getShape(setting?.shape);
|
|
65
|
+
const isTextBadge = setting?.contentType === 'text';
|
|
66
|
+
return shape$1?.supportBorder ? isTextBadge ? stylesV2.getStyleBorder(styles?.textBadgeBorder) : stylesV2.getStyleBorder(styles?.imageBadgeBorder) : {};
|
|
67
|
+
};
|
|
68
|
+
const getCornerStyles = ({ styles, setting })=>{
|
|
69
|
+
const shape$1 = shape.getShape(setting?.shape);
|
|
70
|
+
const isTextBadge = setting?.contentType === 'text';
|
|
71
|
+
return isTextBadge ? stylesV2.getStyleCornerRadius(styles?.textBadgeCorner, shape$1?.shapeRadius) : stylesV2.getStyleCornerRadius(styles?.imageBadgeCorner, shape$1?.shapeRadius);
|
|
72
|
+
};
|
|
73
|
+
const getTextBadgeWrapperStyles = ({ styles, setting })=>{
|
|
74
|
+
const shape$1 = shape.getShape(setting?.shape);
|
|
75
|
+
const borderStyles = getBorderStyles({
|
|
76
|
+
setting,
|
|
77
|
+
styles
|
|
78
|
+
});
|
|
79
|
+
const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
|
|
80
|
+
const cornerStyles = getCornerStyles({
|
|
81
|
+
setting,
|
|
82
|
+
styles
|
|
83
|
+
});
|
|
84
|
+
const paddingShape = common.getShapeWrapperPadding(shape$1?.ratio);
|
|
85
|
+
return {
|
|
86
|
+
...borderStyles,
|
|
87
|
+
...cornerStyles,
|
|
88
|
+
...getRotateShape.composeShapeStyleByPosition(shape$1, styles?.position, isDropOutsideProductImage),
|
|
89
|
+
...stylesV2.getStyleBackground(!shape$1?.backgroundColorInText, styles?.badgeColorV2),
|
|
90
|
+
...paddingShape
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
const getImageContainerStyles = ({ styles, setting })=>{
|
|
94
|
+
const borderStyles = getBorderStyles({
|
|
95
|
+
setting,
|
|
96
|
+
styles
|
|
97
|
+
});
|
|
98
|
+
const cornerStyles = getCornerStyles({
|
|
99
|
+
setting,
|
|
100
|
+
styles
|
|
101
|
+
});
|
|
102
|
+
const imageBadgePadding = core.makeGlobalSize(styles?.imageSizeV2).padding;
|
|
103
|
+
return {
|
|
104
|
+
...borderStyles,
|
|
105
|
+
...cornerStyles,
|
|
106
|
+
...imageBadgePadding
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
const getOpacityProductBadge = (props, currentVariant, mode)=>{
|
|
110
|
+
const { 'bundle-item': bundleItem, setting } = props;
|
|
111
|
+
const isDiscountContent = common.checkDiscountContentProductBadge(setting?.displayContent);
|
|
112
|
+
const price = currentVariant?.price ?? 0;
|
|
113
|
+
const salePrice = currentVariant?.salePrice ?? 0;
|
|
114
|
+
const priceSave = salePrice - price;
|
|
115
|
+
const isOpacityBadge = isDiscountContent && priceSave <= 0 && setting?.contentType === 'text';
|
|
116
|
+
if (bundleItem) return 1;
|
|
117
|
+
if (!isOpacityBadge) return 1;
|
|
118
|
+
return mode !== 'edit' ? 0 : 0.2;
|
|
119
|
+
};
|
|
120
|
+
const getSubWrapperStyle = (props, currentVariant, mode)=>{
|
|
121
|
+
const { setting } = props;
|
|
122
|
+
const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
|
|
123
|
+
const sizeStyles = getSizeStyles(props);
|
|
124
|
+
const opacityProductBadge = mode && currentVariant ? getOpacityProductBadge(props, currentVariant, mode) : 1;
|
|
125
|
+
return {
|
|
126
|
+
...isDropOutsideProductImage ? {
|
|
127
|
+
...sizeStyles,
|
|
128
|
+
'--mb': 0
|
|
129
|
+
} : {},
|
|
130
|
+
opacity: opacityProductBadge
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const getContentStyleInternal = (props)=>{
|
|
134
|
+
const { styles, setting } = props;
|
|
135
|
+
const isTextBadge = setting?.contentType === 'text';
|
|
136
|
+
return stylesV2.getStyleShadowV2('.product-badge-item', isTextBadge ? styles?.textBadgeShadow : styles?.imageBadgeShadow);
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
exports.getContainerStyle = getContainerStyle;
|
|
140
|
+
exports.getContentStyleInternal = getContentStyleInternal;
|
|
141
|
+
exports.getImageContainerStyles = getImageContainerStyles;
|
|
142
|
+
exports.getSubWrapperStyle = getSubWrapperStyle;
|
|
143
|
+
exports.getTextBadgeWrapperStyles = getTextBadgeWrapperStyles;
|
|
144
|
+
exports.getTextContentStyle = getTextContentStyle;
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const SHAPE_CLASS = 'gp-w-full gp-h-full gp-flex gp-items-center gp-justify-center gp-overflow-hidden';
|
|
4
|
-
const CONTENT_CLASS = 'gp-break-words gp-text-center';
|
|
5
|
-
const WRAPPER_CLASS = 'gp-w-full gp-h-full gp-overflow-hidden';
|
|
6
|
-
const IS_LIQUID = true;
|
|
7
3
|
exports.SHAPE_ID = void 0;
|
|
8
4
|
(function(SHAPE_ID) {
|
|
9
5
|
SHAPE_ID["SQUARE"] = 'square';
|
|
@@ -14,9 +10,5 @@ exports.SHAPE_ID = void 0;
|
|
|
14
10
|
SHAPE_ID["STAR"] = 'star';
|
|
15
11
|
SHAPE_ID["RIBBON_2"] = 'ribbon_2';
|
|
16
12
|
SHAPE_ID["RIBBON_3"] = 'ribbon_3';
|
|
13
|
+
SHAPE_ID["TRIANGLE"] = 'triangle';
|
|
17
14
|
})(exports.SHAPE_ID || (exports.SHAPE_ID = {}));
|
|
18
|
-
|
|
19
|
-
exports.CONTENT_CLASS = CONTENT_CLASS;
|
|
20
|
-
exports.IS_LIQUID = IS_LIQUID;
|
|
21
|
-
exports.SHAPE_CLASS = SHAPE_CLASS;
|
|
22
|
-
exports.WRAPPER_CLASS = WRAPPER_CLASS;
|
|
@@ -4,150 +4,158 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
-
var React = require('react');
|
|
8
7
|
var core = require('@gem-sdk/core');
|
|
9
|
-
var constants = require('./constants.js');
|
|
10
8
|
var common = require('./utils/common.js');
|
|
11
|
-
|
|
12
|
-
var renderBadgeILP = require('./utils/renderBadgeILP.js');
|
|
9
|
+
require('./constants.js');
|
|
13
10
|
var NoDataState = require('../../../common/components/NoDataState.js');
|
|
14
11
|
var TooltipHover = require('../../../common/components/TooltipHover.js');
|
|
12
|
+
var system = require('@gem-sdk/system');
|
|
13
|
+
var getAttrs = require('./common/getAttrs.js');
|
|
14
|
+
var getClasses = require('./common/getClasses.js');
|
|
15
|
+
var getStyles = require('./common/getStyles.js');
|
|
15
16
|
|
|
16
|
-
const ProductBadge = (
|
|
17
|
+
const ProductBadge = (props)=>{
|
|
18
|
+
const { builderAttrs, builderProps, isInsideProductImage, setting, styles, children, style, navigationPosition, imageData, dotData, ...passProps } = props;
|
|
17
19
|
const product = core.useProduct();
|
|
18
20
|
const currentVariant = core.useCurrentVariant();
|
|
19
21
|
const { moneyFormat } = core.useMoneyFormat();
|
|
20
22
|
const currentDevice = core.useCurrentDevice();
|
|
21
23
|
const { useProductCompareAtPrice } = core.useProductBundleDiscount();
|
|
22
24
|
const bundleItem = passProps?.['bundle-item'];
|
|
23
|
-
const price = currentVariant?.price ?? 0;
|
|
24
|
-
const salePrice = currentVariant?.salePrice ?? 0;
|
|
25
|
-
const priceSave = salePrice - price;
|
|
26
|
-
const { align } = styles ?? {};
|
|
27
|
-
const isDiscountContent = common.checkDiscountContentProductBadge(setting?.displayContent);
|
|
28
|
-
const isOpacityBadge = isDiscountContent && priceSave <= 0 && setting?.contentType === 'text';
|
|
29
25
|
const mode = core.useEditorMode();
|
|
30
26
|
const isInstant = core.usePageType() === 'STATIC';
|
|
31
|
-
const conditionClass = React.useMemo(()=>{
|
|
32
|
-
return !mode && isInstant ? renderBadgeILP.toggleBadge(setting?.displayTrigger, product, currentVariant) : '';
|
|
33
|
-
}, [
|
|
34
|
-
currentVariant,
|
|
35
|
-
isInstant,
|
|
36
|
-
mode,
|
|
37
|
-
product,
|
|
38
|
-
setting?.displayTrigger
|
|
39
|
-
]);
|
|
40
|
-
const opacityProductBadge = React.useMemo(()=>{
|
|
41
|
-
if (bundleItem) return 1;
|
|
42
|
-
if (!isOpacityBadge) return 1;
|
|
43
|
-
return mode !== 'edit' ? 0 : 0.2;
|
|
44
|
-
}, [
|
|
45
|
-
bundleItem,
|
|
46
|
-
isOpacityBadge,
|
|
47
|
-
mode
|
|
48
|
-
]);
|
|
49
|
-
const currentProductId = product?.baseID?.replace('gid://shopify/Product/', '');
|
|
50
27
|
const badgeContent = common.getBadgeContent({
|
|
51
28
|
detail: product,
|
|
52
29
|
currentVariant,
|
|
53
30
|
bundleItem,
|
|
54
31
|
useProductCompareAtPrice
|
|
55
32
|
}, setting?.displayContent, moneyFormat);
|
|
56
|
-
const isNoDiscountState =
|
|
57
|
-
|
|
33
|
+
const isNoDiscountState = common.getIsNoDiscountState({
|
|
34
|
+
props,
|
|
35
|
+
product,
|
|
58
36
|
currentVariant,
|
|
59
|
-
|
|
37
|
+
moneyFormat,
|
|
60
38
|
useProductCompareAtPrice
|
|
61
|
-
}
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
39
|
+
});
|
|
40
|
+
const containerClass = system.createClass({
|
|
41
|
+
...getClasses.getContainerClasses({
|
|
42
|
+
mode,
|
|
43
|
+
isInstant,
|
|
44
|
+
product,
|
|
45
|
+
currentVariant,
|
|
46
|
+
props
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
const containerStyle = system.createStyle({
|
|
50
|
+
...getStyles.getContainerStyle(props)
|
|
51
|
+
});
|
|
52
|
+
const editTooltipAttrs = system.createAttr({
|
|
53
|
+
...getAttrs.getEditTooltipAttrs(props)
|
|
54
|
+
});
|
|
55
|
+
const noDataAttrs = system.createAttr({
|
|
56
|
+
...getAttrs.getNoDataAttrs(props)
|
|
57
|
+
});
|
|
58
|
+
const wrapperClass = system.createClass({
|
|
59
|
+
...getClasses.getWrapperClasses(props)
|
|
60
|
+
});
|
|
61
|
+
const subWrapperClass = system.createClass({
|
|
62
|
+
...getClasses.getSubWrapperClass(props, currentDevice)
|
|
63
|
+
});
|
|
64
|
+
const subWrapperStyle = system.createStyle({
|
|
65
|
+
...getStyles.getSubWrapperStyle(props, currentVariant, mode)
|
|
66
|
+
});
|
|
67
|
+
const subWrapperAttrs = system.createAttr({
|
|
68
|
+
...getAttrs.getSubWrapperAttrs(props, product)
|
|
69
|
+
});
|
|
70
|
+
const contentStyleInternal = getStyles.getContentStyleInternal(props);
|
|
71
|
+
const textContentContainerClasses = system.createClass({
|
|
72
|
+
...getClasses.getTextContainerClasses()
|
|
73
|
+
});
|
|
74
|
+
const containerAttrs = system.createAttr({
|
|
75
|
+
...getAttrs.getContainerAttrs(props)
|
|
76
|
+
});
|
|
77
|
+
const textContentWrapperClasses = system.createClass({
|
|
78
|
+
...getClasses.getTextWrapperClasses()
|
|
79
|
+
});
|
|
80
|
+
const textContentWrapperStyle = system.createStyle({
|
|
81
|
+
...getStyles.getTextBadgeWrapperStyles({
|
|
82
|
+
setting,
|
|
83
|
+
styles
|
|
84
|
+
})
|
|
85
|
+
});
|
|
86
|
+
const textContentClasses = system.createClass({
|
|
87
|
+
...getClasses.getTextContentClasses(styles)
|
|
88
|
+
});
|
|
89
|
+
const textContentStyle = system.createStyle({
|
|
90
|
+
...getStyles.getTextContentStyle({
|
|
91
|
+
setting,
|
|
92
|
+
styles
|
|
93
|
+
})
|
|
94
|
+
});
|
|
95
|
+
const textContentAttrs = system.createAttr({
|
|
96
|
+
...getAttrs.getTextContentAttrs()
|
|
97
|
+
});
|
|
98
|
+
const imageContainerClasses = system.createClass({
|
|
99
|
+
...getClasses.getImageContainerClasses()
|
|
100
|
+
});
|
|
101
|
+
const imageContainerStyles = system.createStyle({
|
|
102
|
+
...getStyles.getImageContainerStyles({
|
|
103
|
+
setting,
|
|
104
|
+
styles
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
const imageClass = system.createClass({
|
|
108
|
+
...getClasses.getImageClasses()
|
|
109
|
+
});
|
|
110
|
+
const imageAttr = system.createAttr({
|
|
111
|
+
...getAttrs.getImageAttr({
|
|
112
|
+
setting
|
|
113
|
+
})
|
|
114
|
+
});
|
|
102
115
|
if (!product) return null;
|
|
103
116
|
return /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
104
|
-
...
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
style: {
|
|
108
|
-
...!isDropOutsideProductImage && {
|
|
109
|
-
'--pos': 'absolute'
|
|
110
|
-
},
|
|
111
|
-
...wrapperStyles,
|
|
112
|
-
...advancedStyles
|
|
113
|
-
},
|
|
114
|
-
className: core.cls(conditionClass, builderProps?.builderData?.advanced?.cssClass || '', builderProps?.uid, 'gp-shrink-0', 'product-badge', isInsideProductImage ? 'inside-image' : ''),
|
|
115
|
-
"gp-data-hidden": "false",
|
|
117
|
+
...containerAttrs,
|
|
118
|
+
style: containerStyle,
|
|
119
|
+
className: containerClass,
|
|
116
120
|
children: [
|
|
117
|
-
mode === 'edit' && isNoDiscountState
|
|
118
|
-
|
|
119
|
-
text: 'Not be displayed when published',
|
|
120
|
-
position: isDropOutsideProductImage ? 'bottom' : 'right',
|
|
121
|
-
width: '205px',
|
|
121
|
+
system.If(mode === 'edit' && isNoDiscountState, /*#__PURE__*/ jsxRuntime.jsx(TooltipHover.default, {
|
|
122
|
+
...editTooltipAttrs,
|
|
122
123
|
children: /*#__PURE__*/ jsxRuntime.jsx(NoDataState.default, {
|
|
123
|
-
|
|
124
|
-
elementType: "secondary",
|
|
125
|
-
description: "No discount",
|
|
126
|
-
rawMode: true
|
|
127
|
-
})
|
|
128
|
-
}) : isDropOutsideProductImage ? /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
129
|
-
className: core.cls('gp-flex', common.getAlignShape(align, false)),
|
|
130
|
-
children: /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
131
|
-
"data-product-id": currentProductId,
|
|
132
|
-
className: placementClass,
|
|
133
|
-
style: {
|
|
134
|
-
...sizeStyles,
|
|
135
|
-
'--mb': 0,
|
|
136
|
-
opacity: opacityProductBadge
|
|
137
|
-
},
|
|
138
|
-
children: /*#__PURE__*/ jsxRuntime.jsx(RenderContent, {})
|
|
124
|
+
...noDataAttrs
|
|
139
125
|
})
|
|
140
|
-
})
|
|
141
|
-
className:
|
|
142
|
-
children: /*#__PURE__*/ jsxRuntime.
|
|
143
|
-
|
|
144
|
-
className:
|
|
145
|
-
style:
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
126
|
+
}), /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
127
|
+
className: wrapperClass,
|
|
128
|
+
children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
|
|
129
|
+
...subWrapperAttrs,
|
|
130
|
+
className: subWrapperClass,
|
|
131
|
+
style: subWrapperStyle,
|
|
132
|
+
children: [
|
|
133
|
+
/*#__PURE__*/ jsxRuntime.jsx("style", {
|
|
134
|
+
children: contentStyleInternal
|
|
135
|
+
}),
|
|
136
|
+
system.If(setting?.shape !== 'image', /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
137
|
+
className: textContentContainerClasses,
|
|
138
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
139
|
+
className: textContentWrapperClasses,
|
|
140
|
+
style: textContentWrapperStyle,
|
|
141
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("pre", {
|
|
142
|
+
...textContentAttrs,
|
|
143
|
+
className: textContentClasses,
|
|
144
|
+
style: textContentStyle,
|
|
145
|
+
children: badgeContent
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
}), /*#__PURE__*/ jsxRuntime.jsx("div", {
|
|
149
|
+
className: imageContainerClasses,
|
|
150
|
+
style: imageContainerStyles,
|
|
151
|
+
children: /*#__PURE__*/ jsxRuntime.jsx("img", {
|
|
152
|
+
...imageAttr,
|
|
153
|
+
className: imageClass
|
|
154
|
+
})
|
|
155
|
+
}))
|
|
156
|
+
]
|
|
149
157
|
})
|
|
150
|
-
}),
|
|
158
|
+
})),
|
|
151
159
|
core.filterToolbarPreview(children, true)
|
|
152
160
|
]
|
|
153
161
|
});
|