@gem-sdk/components 2.0.0-dev.332 → 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/post-purchase/product/settings/product-image/ProductFeatureImage.js +33 -0
- package/dist/cjs/post-purchase/product/settings/product-image/ProductGalleryImage.js +85 -0
- package/dist/cjs/post-purchase/product/settings/product-image/ProductImageLayoutSetting.js +69 -0
- package/dist/cjs/post-purchase/product/settings/product-image/ProductImages.js +3 -1
- package/dist/cjs/post-purchase/product/settings/product-image/uiV1.js +42 -0
- 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/post-purchase/product/settings/product-image/ProductFeatureImage.js +31 -0
- package/dist/esm/post-purchase/product/settings/product-image/ProductGalleryImage.js +83 -0
- package/dist/esm/post-purchase/product/settings/product-image/ProductImageLayoutSetting.js +67 -0
- package/dist/esm/post-purchase/product/settings/product-image/ProductImages.js +3 -1
- package/dist/esm/post-purchase/product/settings/product-image/uiV1.js +40 -0
- 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,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const productFeatureImageUI = [
|
|
4
|
+
{
|
|
5
|
+
type: 'control',
|
|
6
|
+
setting: {
|
|
7
|
+
id: 'ftAspectRatio'
|
|
8
|
+
},
|
|
9
|
+
label: {
|
|
10
|
+
en: 'Shape'
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: 'control',
|
|
15
|
+
setting: {
|
|
16
|
+
id: 'ftWidth'
|
|
17
|
+
},
|
|
18
|
+
label: {
|
|
19
|
+
en: 'Width'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: 'control',
|
|
24
|
+
label: {
|
|
25
|
+
en: 'Image scale'
|
|
26
|
+
},
|
|
27
|
+
setting: {
|
|
28
|
+
id: 'ftObjectFit'
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
exports.productFeatureImageUI = productFeatureImageUI;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const productGalleryImageUI = [
|
|
4
|
+
{
|
|
5
|
+
type: 'control',
|
|
6
|
+
label: {
|
|
7
|
+
en: 'Display type'
|
|
8
|
+
},
|
|
9
|
+
condition: 'layoutType === "bottom-center"',
|
|
10
|
+
setting: {
|
|
11
|
+
id: 'displayType'
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'control',
|
|
16
|
+
label: {
|
|
17
|
+
en: 'Item per slide'
|
|
18
|
+
},
|
|
19
|
+
condition: '(displayType === "slider" && layoutType === "bottom-center") || layoutType === "left" || layoutType === "right"',
|
|
20
|
+
setting: {
|
|
21
|
+
id: 'ilItemPerSlide'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'control',
|
|
26
|
+
label: {
|
|
27
|
+
en: 'Item per line'
|
|
28
|
+
},
|
|
29
|
+
condition: 'displayType === "grid" && layoutType === "bottom-center"',
|
|
30
|
+
setting: {
|
|
31
|
+
id: 'ilNumberPerRow'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'control',
|
|
36
|
+
label: {
|
|
37
|
+
en: 'Shape'
|
|
38
|
+
},
|
|
39
|
+
setting: {
|
|
40
|
+
id: 'ilAspectRatio'
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
type: 'control',
|
|
45
|
+
label: {
|
|
46
|
+
en: 'Image scale'
|
|
47
|
+
},
|
|
48
|
+
setting: {
|
|
49
|
+
id: 'ilObjectFit'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: 'control',
|
|
54
|
+
label: {
|
|
55
|
+
en: 'Active border'
|
|
56
|
+
},
|
|
57
|
+
setting: {
|
|
58
|
+
id: 'ilBorder'
|
|
59
|
+
},
|
|
60
|
+
isMoreSetting: true
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
type: 'control',
|
|
64
|
+
label: {
|
|
65
|
+
en: 'Spacing'
|
|
66
|
+
},
|
|
67
|
+
setting: {
|
|
68
|
+
id: 'ilSpacing'
|
|
69
|
+
},
|
|
70
|
+
isMoreSetting: true
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
type: 'control',
|
|
74
|
+
label: {
|
|
75
|
+
en: 'Navigation'
|
|
76
|
+
},
|
|
77
|
+
setting: {
|
|
78
|
+
id: 'ilNavigation'
|
|
79
|
+
},
|
|
80
|
+
layout: 'vertical',
|
|
81
|
+
isMoreSetting: true
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
|
|
85
|
+
exports.productGalleryImageUI = productGalleryImageUI;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const productLayoutUI = [
|
|
4
|
+
{
|
|
5
|
+
type: 'control',
|
|
6
|
+
label: {
|
|
7
|
+
en: ''
|
|
8
|
+
},
|
|
9
|
+
setting: {
|
|
10
|
+
id: 'layoutType'
|
|
11
|
+
},
|
|
12
|
+
layout: 'vertical'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'control',
|
|
16
|
+
label: {
|
|
17
|
+
en: 'Ratio'
|
|
18
|
+
},
|
|
19
|
+
setting: {
|
|
20
|
+
id: 'ratioLayoutLeft'
|
|
21
|
+
},
|
|
22
|
+
layout: 'vertical',
|
|
23
|
+
condition: "layoutType === 'left'"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
type: 'control',
|
|
27
|
+
label: {
|
|
28
|
+
en: 'Ratio'
|
|
29
|
+
},
|
|
30
|
+
setting: {
|
|
31
|
+
id: 'ratioLayoutRight'
|
|
32
|
+
},
|
|
33
|
+
layout: 'vertical',
|
|
34
|
+
condition: "layoutType === 'right'"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'control',
|
|
38
|
+
label: {
|
|
39
|
+
en: 'Spacing'
|
|
40
|
+
},
|
|
41
|
+
setting: {
|
|
42
|
+
id: 'spacingHoz'
|
|
43
|
+
},
|
|
44
|
+
condition: "layoutType === 'left' || layoutType === 'right'",
|
|
45
|
+
isMoreSetting: true
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
type: 'control',
|
|
49
|
+
label: {
|
|
50
|
+
en: 'Spacing'
|
|
51
|
+
},
|
|
52
|
+
setting: {
|
|
53
|
+
id: 'spacingVertical'
|
|
54
|
+
},
|
|
55
|
+
condition: "layoutType === 'bottom-center'"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
type: 'control',
|
|
59
|
+
label: {
|
|
60
|
+
en: 'Spacing'
|
|
61
|
+
},
|
|
62
|
+
setting: {
|
|
63
|
+
id: 'ilSpacing'
|
|
64
|
+
},
|
|
65
|
+
condition: "layoutType === 'two-col' || layoutType === 'one-col'"
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
exports.productLayoutUI = productLayoutUI;
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var uiV2 = require('./uiV2.js');
|
|
6
6
|
var settingV2 = require('./setting-v2.js');
|
|
7
|
+
var uiV1 = require('./uiV1.js');
|
|
7
8
|
|
|
8
9
|
const config = {
|
|
9
10
|
tag: 'PostPurchaseProductImages',
|
|
@@ -14,6 +15,7 @@ const config = {
|
|
|
14
15
|
</svg>
|
|
15
16
|
`,
|
|
16
17
|
settings: settingV2.SettingV2,
|
|
18
|
+
ui: uiV1.SettingUIV1,
|
|
17
19
|
uiV2: uiV2.SettingUIV2,
|
|
18
20
|
editorConfigs: {
|
|
19
21
|
placeholder: {
|
|
@@ -36,7 +38,7 @@ const config = {
|
|
|
36
38
|
<rect x="10" y="24" width="10" height="10" rx="3" transform="rotate(90 10 24)" fill="#494949"/>
|
|
37
39
|
<rect x="14" width="56" height="48" rx="3" fill="#494949"/>
|
|
38
40
|
<path d="M34.5 18.766L39.495 17.0288C39.495 17.0288 40.1024 18.4454 42.005 18.4454C43.9076 18.4454 44.5083 17 44.5083 17L49.5 18.766L48.6692 23.1222H46.1642V31H37.825V23.1196H35.3325L34.5 18.766Z" fill="#D6D6D6"/>
|
|
39
|
-
</svg>
|
|
41
|
+
</svg>
|
|
40
42
|
`
|
|
41
43
|
},
|
|
42
44
|
components: [
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ProductImageLayoutSetting = require('./ProductImageLayoutSetting.js');
|
|
4
|
+
var ProductFeatureImage = require('./ProductFeatureImage.js');
|
|
5
|
+
var ProductGalleryImage = require('./ProductGalleryImage.js');
|
|
6
|
+
|
|
7
|
+
const SettingUIV1 = [
|
|
8
|
+
{
|
|
9
|
+
type: 'group',
|
|
10
|
+
label: {
|
|
11
|
+
en: 'Layout'
|
|
12
|
+
},
|
|
13
|
+
controls: ProductImageLayoutSetting.productLayoutUI
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
type: 'group',
|
|
17
|
+
label: {
|
|
18
|
+
en: 'Featured image'
|
|
19
|
+
},
|
|
20
|
+
condition: "layoutType !== 'one-col' && layoutType !== 'two-col'",
|
|
21
|
+
controls: ProductFeatureImage.productFeatureImageUI
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'group',
|
|
25
|
+
label: {
|
|
26
|
+
en: 'Image list'
|
|
27
|
+
},
|
|
28
|
+
condition: "layoutType !== 'only-feature'",
|
|
29
|
+
controls: ProductGalleryImage.productGalleryImageUI
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'control',
|
|
33
|
+
setting: {
|
|
34
|
+
id: 'align'
|
|
35
|
+
},
|
|
36
|
+
label: {
|
|
37
|
+
en: 'Align'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
exports.SettingUIV1 = SettingUIV1;
|
|
@@ -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;
|