@gem-sdk/components 2.0.0-staging.151 → 2.0.0-staging.159
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/banner/components/hero-banner/index.liquid.js +1 -1
- package/dist/cjs/builder.js +4 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.liquid.js +4 -0
- package/dist/cjs/post-purchase/product/components/ProductDiscountTag.js +5 -2
- package/dist/cjs/post-purchase/product/components/ProductOffer.js +16 -3
- package/dist/cjs/post-purchase/product/components/ProductPrice.js +3 -1
- package/dist/cjs/post-purchase/product/components/ProductPriceBreakdown.js +9 -21
- package/dist/cjs/post-purchase/product/constants/ProductOfferPlaceholder.js +149 -0
- package/dist/cjs/post-purchase/product/hooks/useDynamicProduct.js +28 -0
- package/dist/cjs/post-purchase/product/settings/ProductOffer.js +26 -0
- package/dist/cjs/product/components/ProductBundleDiscountItem.liquid.js +3 -3
- package/dist/cjs/product/components/ProductDescription/common.js +28 -0
- package/dist/cjs/product/components/ProductDescription/const.js +5 -0
- package/dist/cjs/product/components/ProductDescription.js +37 -10
- package/dist/cjs/product/components/ProductDescription.liquid.js +3 -1
- package/dist/cjs/third-party/components/EssentialAnnouncementBar.js +33 -0
- package/dist/cjs/third-party/components/EssentialAnnouncementBar.liquid.js +12 -0
- package/dist/cjs/third-party/components/EssentialCountdownTimerBar.js +33 -0
- package/dist/cjs/third-party/components/EssentialCountdownTimerBar.liquid.js +12 -0
- package/dist/cjs/third-party/configs/EssentialAnnouncementBar.js +12 -0
- package/dist/cjs/third-party/configs/EssentialCountdownTimerBar.js +12 -0
- package/dist/cjs/third-party/helpers/thirdParty.js +1 -1
- package/dist/cjs/third-party/next.js +10 -0
- package/dist/cjs/third-party/setting/EssentialAnnouncementBar.js +142 -0
- package/dist/cjs/third-party/setting/EssentialCountdownTimerBar.js +142 -0
- package/dist/cjs/third-party/setting/index.js +4 -0
- package/dist/esm/banner/components/hero-banner/index.liquid.js +1 -1
- package/dist/esm/builder.js +4 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.liquid.js +2 -0
- package/dist/esm/post-purchase/product/components/ProductDiscountTag.js +5 -2
- package/dist/esm/post-purchase/product/components/ProductOffer.js +16 -3
- package/dist/esm/post-purchase/product/components/ProductPrice.js +3 -1
- package/dist/esm/post-purchase/product/components/ProductPriceBreakdown.js +9 -21
- package/dist/esm/post-purchase/product/constants/ProductOfferPlaceholder.js +147 -0
- package/dist/esm/post-purchase/product/hooks/useDynamicProduct.js +26 -0
- package/dist/esm/post-purchase/product/settings/ProductOffer.js +26 -0
- package/dist/esm/product/components/ProductBundleDiscountItem.liquid.js +3 -3
- package/dist/esm/product/components/ProductDescription/common.js +26 -0
- package/dist/esm/product/components/ProductDescription/const.js +3 -0
- package/dist/esm/product/components/ProductDescription.js +37 -10
- package/dist/esm/product/components/ProductDescription.liquid.js +3 -1
- package/dist/esm/third-party/components/EssentialAnnouncementBar.js +29 -0
- package/dist/esm/third-party/components/EssentialAnnouncementBar.liquid.js +8 -0
- package/dist/esm/third-party/components/EssentialCountdownTimerBar.js +29 -0
- package/dist/esm/third-party/components/EssentialCountdownTimerBar.liquid.js +8 -0
- package/dist/esm/third-party/configs/EssentialAnnouncementBar.js +8 -0
- package/dist/esm/third-party/configs/EssentialCountdownTimerBar.js +8 -0
- package/dist/esm/third-party/helpers/thirdParty.js +1 -1
- package/dist/esm/third-party/next.js +10 -0
- package/dist/esm/third-party/setting/EssentialAnnouncementBar.js +138 -0
- package/dist/esm/third-party/setting/EssentialCountdownTimerBar.js +138 -0
- package/dist/esm/third-party/setting/index.js +206 -202
- package/dist/types/index.d.ts +38 -1
- package/package.json +3 -3
|
@@ -4,6 +4,7 @@ import { useCurrentVariant, useProduct, useQuantity, useProductOfferDiscount, us
|
|
|
4
4
|
import { useMemo, useState, useEffect, Fragment as Fragment$1 } from 'react';
|
|
5
5
|
import { postPurchaseSpacing } from '../../utils/helper.js';
|
|
6
6
|
import MoneyLine from './priceBreakdown/MoneyLine.js';
|
|
7
|
+
import { useDynamicProduct } from '../hooks/useDynamicProduct.js';
|
|
7
8
|
|
|
8
9
|
const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, builderAttrs, builderProps, children })=>{
|
|
9
10
|
const currentVariant = useCurrentVariant();
|
|
@@ -18,6 +19,7 @@ const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, b
|
|
|
18
19
|
const discountShopifyFormat = shopifyPriceRounding(discountWithQuantity, 2);
|
|
19
20
|
const totalMoneyFormatted = useFormatMoney(subTotal - parseFloat(discountShopifyFormat), false);
|
|
20
21
|
const currentProductId = currentProduct?.baseID?.replace('gid://shopify/Product/', '');
|
|
22
|
+
const { isDynamicProduct, dynamicPrice, dynamicDiscount, isEnableDynamicDiscount } = useDynamicProduct();
|
|
21
23
|
const { labelStyle, moneyStyle, spacing, width, align, isShowPrice } = styles;
|
|
22
24
|
const itemGap = useMemo(()=>{
|
|
23
25
|
return postPurchaseSpacing[spacing || 'none'];
|
|
@@ -30,19 +32,19 @@ const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, b
|
|
|
30
32
|
}, [
|
|
31
33
|
isShowPrice
|
|
32
34
|
]);
|
|
33
|
-
const
|
|
35
|
+
const getMoneyLines = ()=>{
|
|
34
36
|
const data = [];
|
|
35
37
|
if (styles.isShowSubTotalLabel !== false) {
|
|
36
38
|
data.push({
|
|
37
39
|
title: setting.subTotalLabel,
|
|
38
|
-
money: subTotalMoneyFormatted,
|
|
40
|
+
money: isDynamicProduct ? dynamicPrice : subTotalMoneyFormatted,
|
|
39
41
|
uniqueId: 'subTotalLabel'
|
|
40
42
|
});
|
|
41
43
|
}
|
|
42
44
|
if (styles.isShowDiscountLabel !== false) {
|
|
43
45
|
data.push({
|
|
44
46
|
title: setting.discountLabel,
|
|
45
|
-
money: discount > 0 ? discountMoneyFormatted : 'No discount',
|
|
47
|
+
money: isDynamicProduct && dynamicDiscount && isEnableDynamicDiscount ? `${dynamicDiscount.value}%` : discount > 0 ? discountMoneyFormatted : 'No discount',
|
|
46
48
|
uniqueId: 'discountLabel'
|
|
47
49
|
});
|
|
48
50
|
}
|
|
@@ -68,25 +70,11 @@ const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, b
|
|
|
68
70
|
}
|
|
69
71
|
data.push({
|
|
70
72
|
title: setting.totalLabel,
|
|
71
|
-
money: totalMoneyFormatted,
|
|
73
|
+
money: isDynamicProduct ? dynamicPrice : totalMoneyFormatted,
|
|
72
74
|
uniqueId: 'totalLabel'
|
|
73
75
|
});
|
|
74
76
|
return data;
|
|
75
|
-
}
|
|
76
|
-
discount,
|
|
77
|
-
discountMoneyFormatted,
|
|
78
|
-
setting.discountLabel,
|
|
79
|
-
setting.shippingLabel,
|
|
80
|
-
setting.subTotalLabel,
|
|
81
|
-
setting.taxesLabel,
|
|
82
|
-
setting.totalLabel,
|
|
83
|
-
styles.isShowSubTotalLabel,
|
|
84
|
-
styles.isShowDiscountLabel,
|
|
85
|
-
styles.isShowShippingLabel,
|
|
86
|
-
styles.isShowTaxesLabel,
|
|
87
|
-
subTotalMoneyFormatted,
|
|
88
|
-
totalMoneyFormatted
|
|
89
|
-
]);
|
|
77
|
+
};
|
|
90
78
|
return /*#__PURE__*/ jsxs(Fragment, {
|
|
91
79
|
children: [
|
|
92
80
|
/*#__PURE__*/ jsxs("div", {
|
|
@@ -137,9 +125,9 @@ const PostPurchaseProductPriceBreakdown = ({ setting = {}, styles = {}, style, b
|
|
|
137
125
|
...makeStyleResponsive('w', width),
|
|
138
126
|
gap: itemGap
|
|
139
127
|
},
|
|
140
|
-
children:
|
|
128
|
+
children: getMoneyLines().map((item)=>/*#__PURE__*/ jsxs(Fragment$1, {
|
|
141
129
|
children: [
|
|
142
|
-
item.uniqueId === 'totalLabel' &&
|
|
130
|
+
item.uniqueId === 'totalLabel' && getMoneyLines().length > 1 && /*#__PURE__*/ jsx("hr", {}),
|
|
143
131
|
/*#__PURE__*/ jsx("div", {
|
|
144
132
|
children: /*#__PURE__*/ jsx(MoneyLine, {
|
|
145
133
|
uniqueId: item.uniqueId,
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
const productOfferPlaceholder = {
|
|
2
|
+
id: '',
|
|
3
|
+
title: 'Dynamic product',
|
|
4
|
+
description: 'This is a dynamic product. The actual product will appear here based on your setup',
|
|
5
|
+
descriptionHtml: '<p class="QN2lPu">This is a dynamic product. The actual product will</p>\n<p class="QN2lPu">appear here based on your setup</p>',
|
|
6
|
+
createdAt: '2024-07-01T04:19:51.286753Z',
|
|
7
|
+
handle: 'dynamic-product',
|
|
8
|
+
averageRating: 0,
|
|
9
|
+
isStorefront: true,
|
|
10
|
+
isSample: false,
|
|
11
|
+
baseID: '',
|
|
12
|
+
sku: '',
|
|
13
|
+
options: [
|
|
14
|
+
{
|
|
15
|
+
id: '1',
|
|
16
|
+
name: 'Variant',
|
|
17
|
+
optionType: '',
|
|
18
|
+
values: [
|
|
19
|
+
{
|
|
20
|
+
id: '1',
|
|
21
|
+
label: 'Variant option',
|
|
22
|
+
isDefault: true,
|
|
23
|
+
baseID: ''
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
vendor: '',
|
|
29
|
+
featuredImage: {
|
|
30
|
+
id: '542178560626918105',
|
|
31
|
+
contentType: 'IMAGE',
|
|
32
|
+
previewImage: '',
|
|
33
|
+
src: 'https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png',
|
|
34
|
+
width: 449,
|
|
35
|
+
height: 449,
|
|
36
|
+
alt: ''
|
|
37
|
+
},
|
|
38
|
+
collections: {
|
|
39
|
+
edges: [
|
|
40
|
+
{
|
|
41
|
+
node: {
|
|
42
|
+
id: '502321959132988135',
|
|
43
|
+
title: 'Home page'
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
node: {
|
|
48
|
+
id: '539286505089204764',
|
|
49
|
+
title: 'b'
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
node: {
|
|
54
|
+
id: '539286505089401372',
|
|
55
|
+
title: 'e'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
tags: [],
|
|
61
|
+
medias: {
|
|
62
|
+
edges: [
|
|
63
|
+
{
|
|
64
|
+
cursor: 'gqFpzweGNIc/AALZoXYB',
|
|
65
|
+
node: {
|
|
66
|
+
id: '542178560626918105',
|
|
67
|
+
contentType: 'IMAGE',
|
|
68
|
+
previewImage: '',
|
|
69
|
+
src: 'https://cdn.shopify.com/s/files/1/0858/3168/0279/files/gempages_502328832959710176-312cf60c-d923-4913-9873-66545effe9cc.png',
|
|
70
|
+
width: 449,
|
|
71
|
+
height: 449,
|
|
72
|
+
alt: ''
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
pageInfo: {
|
|
77
|
+
endCursor: 'gqFpzweGNIc/AALZoXYB',
|
|
78
|
+
hasNextPage: true
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
variants: {
|
|
82
|
+
edges: [
|
|
83
|
+
{
|
|
84
|
+
cursor: 'gqFpzwc5ZqRtDAMIoXYC',
|
|
85
|
+
node: {
|
|
86
|
+
id: '520560088328176392',
|
|
87
|
+
title: 'Default Title',
|
|
88
|
+
barcode: '',
|
|
89
|
+
baseID: 'gid://shopify/ProductVariant/49298248925463',
|
|
90
|
+
costPrice: 88,
|
|
91
|
+
height: 0,
|
|
92
|
+
inventoryPolicy: 'DENY',
|
|
93
|
+
inventoryQuantity: 211,
|
|
94
|
+
inventoryStatus: '',
|
|
95
|
+
isDigital: true,
|
|
96
|
+
length: 0,
|
|
97
|
+
lowInventoryAmount: 0,
|
|
98
|
+
manageInventory: false,
|
|
99
|
+
mediaId: '0',
|
|
100
|
+
platform: 'SHOPIFY',
|
|
101
|
+
price: 88,
|
|
102
|
+
salePrice: 88,
|
|
103
|
+
sku: '',
|
|
104
|
+
soldIndividually: false,
|
|
105
|
+
weight: 0,
|
|
106
|
+
width: 0,
|
|
107
|
+
selectedOptions: [],
|
|
108
|
+
media: undefined
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
cursor: 'gqFpzwc5ZqRtDAMIoXYC',
|
|
113
|
+
node: {
|
|
114
|
+
id: '520560088328176392',
|
|
115
|
+
title: 'Default Title',
|
|
116
|
+
barcode: '',
|
|
117
|
+
baseID: 'gid://shopify/ProductVariant/49298248925463',
|
|
118
|
+
costPrice: 88,
|
|
119
|
+
height: 0,
|
|
120
|
+
inventoryPolicy: 'DENY',
|
|
121
|
+
inventoryQuantity: 211,
|
|
122
|
+
inventoryStatus: '',
|
|
123
|
+
isDigital: true,
|
|
124
|
+
length: 0,
|
|
125
|
+
lowInventoryAmount: 0,
|
|
126
|
+
manageInventory: false,
|
|
127
|
+
mediaId: '0',
|
|
128
|
+
platform: 'SHOPIFY',
|
|
129
|
+
price: 88,
|
|
130
|
+
salePrice: 88,
|
|
131
|
+
sku: '',
|
|
132
|
+
soldIndividually: false,
|
|
133
|
+
weight: 0,
|
|
134
|
+
width: 0,
|
|
135
|
+
selectedOptions: [],
|
|
136
|
+
media: undefined
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
],
|
|
140
|
+
pageInfo: {
|
|
141
|
+
hasNextPage: false,
|
|
142
|
+
endCursor: 'gaFpzwc5ZqRtDAMI'
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
export { productOfferPlaceholder };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { usePageStore } from '@gem-sdk/core';
|
|
2
|
+
import { useMemo } from 'react';
|
|
3
|
+
|
|
4
|
+
const useDynamicProduct = ()=>{
|
|
5
|
+
const dynamicDiscountOffer = usePageStore((s)=>s.dynamicDiscountOffer);
|
|
6
|
+
const isDynamicProduct = useMemo(()=>{
|
|
7
|
+
return !!dynamicDiscountOffer;
|
|
8
|
+
}, [
|
|
9
|
+
dynamicDiscountOffer
|
|
10
|
+
]);
|
|
11
|
+
// false = No discount
|
|
12
|
+
const isEnableDynamicDiscount = useMemo(()=>{
|
|
13
|
+
return dynamicDiscountOffer?.isEnabled;
|
|
14
|
+
}, [
|
|
15
|
+
dynamicDiscountOffer
|
|
16
|
+
]);
|
|
17
|
+
const dynamicPrice = '$???';
|
|
18
|
+
return {
|
|
19
|
+
isDynamicProduct,
|
|
20
|
+
dynamicPrice,
|
|
21
|
+
dynamicDiscount: dynamicDiscountOffer,
|
|
22
|
+
isEnableDynamicDiscount
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { useDynamicProduct };
|
|
@@ -180,6 +180,14 @@ const config = {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
},
|
|
183
|
+
{
|
|
184
|
+
id: 'dynamicOfferQuantity',
|
|
185
|
+
type: 'dynamic-offer-quantity',
|
|
186
|
+
min: 1,
|
|
187
|
+
max: 4,
|
|
188
|
+
default: 2,
|
|
189
|
+
isOnlyAcceptInteger: true
|
|
190
|
+
},
|
|
183
191
|
{
|
|
184
192
|
id: 'discountAndShippingFee',
|
|
185
193
|
type: 'discount-and-shipping-fee-product-offer',
|
|
@@ -373,6 +381,24 @@ const config = {
|
|
|
373
381
|
},
|
|
374
382
|
layout: 'vertical'
|
|
375
383
|
},
|
|
384
|
+
{
|
|
385
|
+
type: 'group',
|
|
386
|
+
label: {
|
|
387
|
+
en: 'Product offers'
|
|
388
|
+
},
|
|
389
|
+
controls: [
|
|
390
|
+
{
|
|
391
|
+
type: 'control',
|
|
392
|
+
label: {
|
|
393
|
+
en: 'Quantity'
|
|
394
|
+
},
|
|
395
|
+
setting: {
|
|
396
|
+
id: 'dynamicOfferQuantity'
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
],
|
|
400
|
+
condition: 'false'
|
|
401
|
+
},
|
|
376
402
|
{
|
|
377
403
|
type: 'control',
|
|
378
404
|
label: {
|
|
@@ -44,9 +44,9 @@ const ProductBundleDiscountItem = ({ children, parentSetting, parentStyles, inde
|
|
|
44
44
|
return selected === i;
|
|
45
45
|
};
|
|
46
46
|
return template`
|
|
47
|
-
<
|
|
47
|
+
<gp-product-bundle-discount-item
|
|
48
48
|
${bundleItem}
|
|
49
|
-
class="product-bundle-item cursor-pointer"
|
|
49
|
+
class="product-bundle-item cursor-pointer gp-block"
|
|
50
50
|
style="${{
|
|
51
51
|
...sizeSettings.padding,
|
|
52
52
|
...makeStyleState('bg', parentStyles?.backgroundColor),
|
|
@@ -92,7 +92,7 @@ const ProductBundleDiscountItem = ({ children, parentSetting, parentStyles, inde
|
|
|
92
92
|
${children}
|
|
93
93
|
</div>
|
|
94
94
|
</div>
|
|
95
|
-
</
|
|
95
|
+
</gp-product-bundle-discount-item>
|
|
96
96
|
`;
|
|
97
97
|
};
|
|
98
98
|
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { getResponsiveValueByScreen, makeStyleResponsive } from '@gem-sdk/core';
|
|
2
|
+
import { DESCRIPTION_LINE_HEIGHT_DEFAULT } from './const.js';
|
|
3
|
+
|
|
4
|
+
const getMaxHeightStyleDefault = (setting)=>{
|
|
5
|
+
let result = {
|
|
6
|
+
desktop: 'none'
|
|
7
|
+
};
|
|
8
|
+
const devices = [
|
|
9
|
+
'desktop',
|
|
10
|
+
'mobile',
|
|
11
|
+
'tablet'
|
|
12
|
+
];
|
|
13
|
+
devices.forEach((device)=>{
|
|
14
|
+
const lineClamp = getResponsiveValueByScreen(setting?.lineClamp, device);
|
|
15
|
+
const hasLineClamp = getResponsiveValueByScreen(setting?.hasLineClamp, device);
|
|
16
|
+
const maxHeight = hasLineClamp && lineClamp ? `${lineClamp * DESCRIPTION_LINE_HEIGHT_DEFAULT}px` : 'none';
|
|
17
|
+
result = {
|
|
18
|
+
...result,
|
|
19
|
+
[device]: maxHeight
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
const style = makeStyleResponsive('maxh', result);
|
|
23
|
+
return style;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export { getMaxHeightStyleDefault };
|
|
@@ -3,6 +3,8 @@ import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useProduct, useCurrentDevice, getResponsiveValueByScreen, useProductShopifyEditLink, useEditorMode, isBrowser, composeTypographyClassName, composeTypographyStyle, cls, getGlobalColorClass, getStyleShadow, makeStyleResponsive, makeStyle, getGlobalColorStyle } from '@gem-sdk/core';
|
|
4
4
|
import { useState, useRef, useEffect } from 'react';
|
|
5
5
|
import NoDataState from '../../common/components/NoDataState.js';
|
|
6
|
+
import { getMaxHeightStyleDefault } from './ProductDescription/common.js';
|
|
7
|
+
import { DESCRIPTION_LINE_HEIGHT_DEFAULT } from './ProductDescription/const.js';
|
|
6
8
|
|
|
7
9
|
const ProductDescription = ({ setting, builderProps })=>{
|
|
8
10
|
const [open, setOpen] = useState(false);
|
|
@@ -19,13 +21,17 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
19
21
|
useEffect(()=>{
|
|
20
22
|
const dom = ref.current;
|
|
21
23
|
setOpen(false);
|
|
22
|
-
if (dom
|
|
24
|
+
if (!dom) return;
|
|
25
|
+
const enableShowMore = hasLineClamp && product?.descriptionHtml;
|
|
26
|
+
if (!enableShowMore) dom.style.maxHeight = 'none';
|
|
27
|
+
else {
|
|
23
28
|
const value = lineClamp;
|
|
24
29
|
setTimeout(()=>{
|
|
25
30
|
const scrollHeight = dom?.scrollHeight ?? 0;
|
|
26
31
|
const clientHeight = dom?.clientHeight ?? 0;
|
|
27
|
-
const lineHeight =
|
|
28
|
-
const lineText = Math.round((scrollHeight ?? 0) /
|
|
32
|
+
const lineHeight = getLineHeightFromDom();
|
|
33
|
+
const lineText = Math.round((scrollHeight ?? 0) / lineHeight);
|
|
34
|
+
dom.style.maxHeight = getMaxHeight(lineHeight);
|
|
29
35
|
const conditionCheckLine = isSafari ? value && value < lineText : clientHeight < scrollHeight;
|
|
30
36
|
if (value && conditionCheckLine) {
|
|
31
37
|
allowShowViewMore(()=>true);
|
|
@@ -40,6 +46,16 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
40
46
|
product?.description,
|
|
41
47
|
isSafari
|
|
42
48
|
]);
|
|
49
|
+
const getLineHeightFromDom = ()=>{
|
|
50
|
+
if (!ref.current) return DESCRIPTION_LINE_HEIGHT_DEFAULT;
|
|
51
|
+
const lineHeight = window.getComputedStyle(ref.current).getPropertyValue('line-height');
|
|
52
|
+
return parseInt(lineHeight);
|
|
53
|
+
};
|
|
54
|
+
const getMaxHeight = (lineHeight)=>{
|
|
55
|
+
if (!hasLineClamp || !lineClamp) return 'auto';
|
|
56
|
+
if (lineHeight) return `${lineClamp * lineHeight}px`;
|
|
57
|
+
return 'auto';
|
|
58
|
+
};
|
|
43
59
|
const Tag = htmlTag === 'html' ? 'div' : 'p';
|
|
44
60
|
const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
|
|
45
61
|
const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
|
|
@@ -55,8 +71,8 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
55
71
|
box-shadow: none;
|
|
56
72
|
}
|
|
57
73
|
`;
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
74
|
+
const noDescriptionHtml = !product?.descriptionHtml;
|
|
75
|
+
if (noDescriptionHtml && mode === 'edit') {
|
|
60
76
|
return /*#__PURE__*/ jsx(NoDataState, {
|
|
61
77
|
elementType: "secondary",
|
|
62
78
|
description: "Highlight key benefits with product description.",
|
|
@@ -72,8 +88,18 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
72
88
|
]
|
|
73
89
|
});
|
|
74
90
|
}
|
|
91
|
+
const handleToggleShowMore = ()=>{
|
|
92
|
+
if (!ref.current) return;
|
|
93
|
+
const lineHeight = getLineHeightFromDom();
|
|
94
|
+
if (open) {
|
|
95
|
+
ref.current.style.maxHeight = getMaxHeight(lineHeight);
|
|
96
|
+
} else {
|
|
97
|
+
ref.current.style.maxHeight = 'none';
|
|
98
|
+
}
|
|
99
|
+
setOpen((prev)=>!prev);
|
|
100
|
+
};
|
|
75
101
|
return /*#__PURE__*/ jsx(Fragment, {
|
|
76
|
-
children:
|
|
102
|
+
children: noDescriptionHtml ? null : /*#__PURE__*/ jsxs("div", {
|
|
77
103
|
"data-id": builderProps?.uid,
|
|
78
104
|
children: [
|
|
79
105
|
!isSafari && /*#__PURE__*/ jsx("style", {
|
|
@@ -85,7 +111,7 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
85
111
|
/*#__PURE__*/ jsx(Tag, {
|
|
86
112
|
ref: ref,
|
|
87
113
|
"data-gp-text": true,
|
|
88
|
-
className: cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass,
|
|
114
|
+
className: cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, getGlobalColorClass('text', setting?.color)),
|
|
89
115
|
style: {
|
|
90
116
|
...getStyleShadow({
|
|
91
117
|
value: setting?.textShadow,
|
|
@@ -97,10 +123,11 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
97
123
|
...makeStyle({
|
|
98
124
|
tt: setting?.transform
|
|
99
125
|
}),
|
|
100
|
-
...appendTypoStyle
|
|
126
|
+
...appendTypoStyle,
|
|
127
|
+
...getMaxHeightStyleDefault(setting)
|
|
101
128
|
},
|
|
102
129
|
dangerouslySetInnerHTML: {
|
|
103
|
-
__html: product?.descriptionHtml
|
|
130
|
+
__html: product?.descriptionHtml || ''
|
|
104
131
|
}
|
|
105
132
|
}),
|
|
106
133
|
hasLineClamp && isShowViewMore && /*#__PURE__*/ jsxs("button", {
|
|
@@ -113,7 +140,7 @@ const ProductDescription = ({ setting, builderProps })=>{
|
|
|
113
140
|
...appendTypoStyle,
|
|
114
141
|
...getGlobalColorStyle(setting?.showMoreColor)
|
|
115
142
|
},
|
|
116
|
-
onClick:
|
|
143
|
+
onClick: handleToggleShowMore,
|
|
117
144
|
children: [
|
|
118
145
|
!open ? setting?.viewMoreText : setting?.viewLessText,
|
|
119
146
|
setting?.enableViewMoreIcon && /*#__PURE__*/ jsx("svg", {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { composeTypographyClassName, composeTypographyStyle, getStyleShadow, makeStyleResponsive, getGlobalColorStyle, makeStyle, makeLineClamp, template, cls, getGlobalColorClass, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
2
|
import { getSettingPreloadData } from '../../helpers.js';
|
|
3
|
+
import { getMaxHeightStyleDefault } from './ProductDescription/common.js';
|
|
3
4
|
|
|
4
5
|
const devices = [
|
|
5
6
|
'desktop',
|
|
@@ -31,7 +32,8 @@ const ProductDescription = ({ setting, advanced, builderProps })=>{
|
|
|
31
32
|
...makeStyle({
|
|
32
33
|
tt: setting?.transform
|
|
33
34
|
}),
|
|
34
|
-
...appendTypoStyle
|
|
35
|
+
...appendTypoStyle,
|
|
36
|
+
...getMaxHeightStyleDefault(setting)
|
|
35
37
|
};
|
|
36
38
|
const collapseStyle = {
|
|
37
39
|
...defaultStyle,
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { makeStyleResponsive } from '@gem-sdk/core';
|
|
4
|
+
import ThirdPartyPreview from './ThirdPartyPreview.js';
|
|
5
|
+
import AppConfig from '../configs/EssentialAnnouncementBar.js';
|
|
6
|
+
|
|
7
|
+
const EssentialAnnouncementBarContent = ()=>{
|
|
8
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
9
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
10
|
+
className: "gp-p-2",
|
|
11
|
+
children: /*#__PURE__*/ jsx(ThirdPartyPreview, {
|
|
12
|
+
setting: {
|
|
13
|
+
label: 'Essential Announcement Bar',
|
|
14
|
+
iconSvg: `<img class="gp-w-6 gp-border gp-border-[#494949] gp-rounded-[3px]" src="${AppConfig.logoUrl}">`
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const EssentialAnnouncementBar = ({ setting })=>{
|
|
21
|
+
return /*#__PURE__*/ jsx("div", {
|
|
22
|
+
style: {
|
|
23
|
+
...makeStyleResponsive('ta', setting?.align)
|
|
24
|
+
},
|
|
25
|
+
children: /*#__PURE__*/ jsx(EssentialAnnouncementBarContent, {})
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { EssentialAnnouncementBar as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getLiquidForAppBlock } from '../helpers/thirdParty.js';
|
|
2
|
+
|
|
3
|
+
const EssentialAnnouncementBar = ({ setting, advanced })=>{
|
|
4
|
+
const { align, appBlockId } = setting ?? {};
|
|
5
|
+
return getLiquidForAppBlock(appBlockId, align, `${advanced?.cssClass ?? ''} !gp-block `);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { EssentialAnnouncementBar as default };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
3
|
+
import { makeStyleResponsive } from '@gem-sdk/core';
|
|
4
|
+
import ThirdPartyPreview from './ThirdPartyPreview.js';
|
|
5
|
+
import AppConfig from '../configs/EssentialCountdownTimerBar.js';
|
|
6
|
+
|
|
7
|
+
const EssentialCountdownTimerBarContent = ()=>{
|
|
8
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
9
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
10
|
+
className: "gp-p-2",
|
|
11
|
+
children: /*#__PURE__*/ jsx(ThirdPartyPreview, {
|
|
12
|
+
setting: {
|
|
13
|
+
label: 'Essential Countdown Timer Bar',
|
|
14
|
+
iconSvg: `<img class="gp-w-6 gp-border gp-border-[#494949] gp-rounded-[3px]" src="${AppConfig.logoUrl}">`
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const EssentialCountdownTimerBar = ({ setting })=>{
|
|
21
|
+
return /*#__PURE__*/ jsx("div", {
|
|
22
|
+
style: {
|
|
23
|
+
...makeStyleResponsive('ta', setting?.align)
|
|
24
|
+
},
|
|
25
|
+
children: /*#__PURE__*/ jsx(EssentialCountdownTimerBarContent, {})
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export { EssentialCountdownTimerBar as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getLiquidForAppBlock } from '../helpers/thirdParty.js';
|
|
2
|
+
|
|
3
|
+
const EssentialCountdownTimerBar = ({ setting, advanced })=>{
|
|
4
|
+
const { align, appBlockId } = setting ?? {};
|
|
5
|
+
return getLiquidForAppBlock(appBlockId, align, `${advanced?.cssClass ?? ''} !gp-block `);
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { EssentialCountdownTimerBar as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var AppConfig = {
|
|
2
|
+
id: 'essential-announcement-bar',
|
|
3
|
+
label: 'Essential Announcement Bar',
|
|
4
|
+
logoUrl: 'https://cdn.shopify.com/app-store/listing_images/15e8255158a042a1eab34a4c45c72aa5/icon/CMK1jPv9uoADEAE=.png',
|
|
5
|
+
tag: 'EssentialAnnouncementBar'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { AppConfig as default };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
var AppConfig = {
|
|
2
|
+
id: 'essential-countdown-timer-bar',
|
|
3
|
+
label: 'Essential Countdown Timer Bar',
|
|
4
|
+
logoUrl: 'https://cdn.shopify.com/app-store/listing_images/f84bf9e49eca8bd84c2af7488461363b/icon/CPzKxLTD4_UCEAE=.png',
|
|
5
|
+
tag: 'EssentialCountdownTimerBar'
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { AppConfig as default };
|
|
@@ -37,7 +37,7 @@ const getLiquidForAppBlock = (appBlockId, align, cssClass)=>{
|
|
|
37
37
|
<div
|
|
38
38
|
class="gp-flex gp-w-full gp-items-center ${cssClass}"
|
|
39
39
|
style="${{
|
|
40
|
-
...makeStyleResponsive('
|
|
40
|
+
...makeStyleResponsive('jc', align)
|
|
41
41
|
}}"
|
|
42
42
|
>
|
|
43
43
|
{% for block in app_blocks %}
|
|
@@ -4,6 +4,14 @@ import 'react/jsx-runtime';
|
|
|
4
4
|
import 'react';
|
|
5
5
|
import '@gem-sdk/core';
|
|
6
6
|
|
|
7
|
+
const EssentialAnnouncementBar = dynamic(()=>import('./components/EssentialAnnouncementBar.js'), {
|
|
8
|
+
ssr: false,
|
|
9
|
+
loading: Loading
|
|
10
|
+
});
|
|
11
|
+
const EssentialCountdownTimerBar = dynamic(()=>import('./components/EssentialCountdownTimerBar.js'), {
|
|
12
|
+
ssr: false,
|
|
13
|
+
loading: Loading
|
|
14
|
+
});
|
|
7
15
|
const StellarDeliveryDatePickup = dynamic(()=>import('./components/StellarDeliveryDatePickup.js'), {
|
|
8
16
|
ssr: false,
|
|
9
17
|
loading: Loading
|
|
@@ -409,6 +417,8 @@ const Selleasy = dynamic(()=>import('./components/Selleasy.js'), {
|
|
|
409
417
|
loading: Loading
|
|
410
418
|
});
|
|
411
419
|
var thirdParty = {
|
|
420
|
+
EssentialAnnouncementBar,
|
|
421
|
+
EssentialCountdownTimerBar,
|
|
412
422
|
StellarDeliveryDatePickup,
|
|
413
423
|
TrustshopProductReviews,
|
|
414
424
|
HulkProductOptions,
|