@gem-sdk/components 2.1.13-staging.2 → 2.1.13-staging.21
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/article/components/ArticleImage.js +2 -1
- package/dist/cjs/article/components/ArticleList.js +1 -1
- package/dist/cjs/banner/components/hero-banner/index.liquid.js +12 -10
- package/dist/cjs/banner/components/hero-banner/utils/index.js +5 -3
- package/dist/cjs/builder.js +21 -1
- package/dist/cjs/collection/components/CollectionDescription.js +101 -7
- package/dist/cjs/collection/components/CollectionDescription.liquid.js +102 -9
- package/dist/cjs/collection/setting/CollectionDescription.js +128 -0
- package/dist/cjs/common/const.js +1 -1
- package/dist/cjs/form/components/textarea/TextArea.liquid.js +2 -2
- package/dist/cjs/image/components/AdaptiveImage.liquid.js +6 -5
- package/dist/cjs/image/components/Image.js +22 -3
- package/dist/cjs/image/components/Image.liquid.js +6 -5
- package/dist/cjs/image/components/NextImage.liquid.js +4 -3
- package/dist/cjs/image/components/NoDataImage.js +133 -0
- package/dist/cjs/image-comparison/components/CompareImage.liquid.js +7 -3
- package/dist/cjs/index.js +20 -0
- package/dist/cjs/index.liquid.js +22 -2
- package/dist/cjs/marquee/components/MarqueeBase.liquid.js +7 -26
- package/dist/cjs/product/components/ProductImagesV2/jsx/ProductImages.js +2 -9
- package/dist/cjs/product/components/ProductImagesV2/liquid/ProductFeaturedImageCarousel.liquid.js +4 -4
- package/dist/cjs/product/components/ProductImagesV2/liquid/ProductGalleryCarousel.liquid.js +2 -2
- package/dist/cjs/product/components/ProductImagesV2/liquid/ProductGalleryGrid.liquid.js +4 -4
- package/dist/cjs/product/components/ProductImagesV2/liquid/ProductImages.liquid.js +4 -4
- package/dist/cjs/tab/hooks/useTabInteraction.js +13 -9
- package/dist/cjs/text/components/Text.js +0 -1
- package/dist/cjs/third-party/components/AlsoBoughtCbb.js +32 -0
- package/dist/cjs/third-party/components/AlsoBoughtCbb.liquid.js +21 -0
- package/dist/cjs/third-party/components/BfSizeChartSizeGuide.js +32 -0
- package/dist/cjs/third-party/components/BfSizeChartSizeGuide.liquid.js +12 -0
- package/dist/cjs/third-party/components/EssentialAnnouncementBar.js +32 -0
- package/dist/cjs/third-party/components/EssentialAnnouncementBar.liquid.js +12 -0
- package/dist/cjs/third-party/components/EssentialCountdownTimerBar.js +32 -0
- package/dist/cjs/third-party/components/EssentialCountdownTimerBar.liquid.js +12 -0
- package/dist/cjs/third-party/components/EstimatedDeliveryDatePlus.js +32 -0
- package/dist/cjs/third-party/components/EstimatedDeliveryDatePlus.liquid.js +12 -0
- package/dist/cjs/third-party/components/GloColorSwatchvariantImage.js +32 -0
- package/dist/cjs/third-party/components/GloColorSwatchvariantImage.liquid.js +12 -0
- package/dist/cjs/third-party/components/HextomFreeShippingBar.js +32 -0
- package/dist/cjs/third-party/components/HextomFreeShippingBar.liquid.js +12 -0
- package/dist/cjs/third-party/components/OkendoReviewsLoyalty.js +32 -0
- package/dist/cjs/third-party/components/OkendoReviewsLoyalty.liquid.js +12 -0
- package/dist/cjs/third-party/components/QikifyUpsell.liquid.js +3 -46
- package/dist/cjs/third-party/components/StellarDeliveryDatePickup.js +32 -0
- package/dist/cjs/third-party/components/StellarDeliveryDatePickup.liquid.js +21 -0
- package/dist/cjs/third-party/components/TrustedsiteTrustBadges.js +32 -0
- package/dist/cjs/third-party/components/TrustedsiteTrustBadges.liquid.js +12 -0
- package/dist/cjs/third-party/configs/AlsoBoughtCbb.js +12 -0
- package/dist/cjs/third-party/configs/BfSizeChartSizeGuide.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/configs/EstimatedDeliveryDatePlus.js +12 -0
- package/dist/cjs/third-party/configs/GloColorSwatchvariantImage.js +12 -0
- package/dist/cjs/third-party/configs/HextomFreeShippingBar.js +12 -0
- package/dist/cjs/third-party/configs/OkendoReviewsLoyalty.js +12 -0
- package/dist/cjs/third-party/configs/StellarDeliveryDatePickup.js +12 -0
- package/dist/cjs/third-party/configs/TrustedsiteTrustBadges.js +12 -0
- package/dist/cjs/third-party/helpers/thirdParty.js +1 -1
- package/dist/cjs/third-party/next.js +51 -1
- package/dist/cjs/third-party/setting/AlsoBoughtCbb.js +127 -0
- package/dist/cjs/third-party/setting/BfSizeChartSizeGuide.js +131 -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/EstimatedDeliveryDatePlus.js +128 -0
- package/dist/cjs/third-party/setting/GloColorSwatchvariantImage.js +152 -0
- package/dist/cjs/third-party/setting/HextomFreeShippingBar.js +128 -0
- package/dist/cjs/third-party/setting/OkendoReviewsLoyalty.js +171 -0
- package/dist/cjs/third-party/setting/QikifyUpsell.js +11 -1
- package/dist/cjs/third-party/setting/StellarDeliveryDatePickup.js +127 -0
- package/dist/cjs/third-party/setting/TrustedsiteTrustBadges.js +177 -0
- package/dist/cjs/third-party/setting/index.js +21 -1
- package/dist/cjs/video/components/HTML5Embed.js +2 -2
- package/dist/cjs/video/components/HTML5Embed.liquid.js +6 -3
- package/dist/cjs/video/components/LiteYouTubeEmbed.liquid.js +5 -3
- package/dist/esm/article/components/ArticleImage.js +2 -1
- package/dist/esm/article/components/ArticleList.js +1 -1
- package/dist/esm/banner/components/hero-banner/index.liquid.js +12 -10
- package/dist/esm/banner/components/hero-banner/utils/index.js +5 -3
- package/dist/esm/builder.js +21 -1
- package/dist/esm/collection/components/CollectionDescription.js +103 -9
- package/dist/esm/collection/components/CollectionDescription.liquid.js +103 -10
- package/dist/esm/collection/setting/CollectionDescription.js +128 -0
- package/dist/esm/common/const.js +1 -1
- package/dist/esm/form/components/textarea/TextArea.liquid.js +2 -2
- package/dist/esm/image/components/AdaptiveImage.liquid.js +6 -5
- package/dist/esm/image/components/Image.js +23 -4
- package/dist/esm/image/components/Image.liquid.js +6 -5
- package/dist/esm/image/components/NextImage.liquid.js +4 -3
- package/dist/esm/image/components/NoDataImage.js +129 -0
- package/dist/esm/image-comparison/components/CompareImage.liquid.js +7 -3
- package/dist/esm/index.js +10 -0
- package/dist/esm/index.liquid.js +11 -1
- package/dist/esm/marquee/components/MarqueeBase.liquid.js +7 -26
- package/dist/esm/product/components/ProductImagesV2/jsx/ProductImages.js +2 -9
- package/dist/esm/product/components/ProductImagesV2/liquid/ProductFeaturedImageCarousel.liquid.js +4 -4
- package/dist/esm/product/components/ProductImagesV2/liquid/ProductGalleryCarousel.liquid.js +2 -2
- package/dist/esm/product/components/ProductImagesV2/liquid/ProductGalleryGrid.liquid.js +4 -4
- package/dist/esm/product/components/ProductImagesV2/liquid/ProductImages.liquid.js +4 -4
- package/dist/esm/tab/hooks/useTabInteraction.js +14 -10
- package/dist/esm/text/components/Text.js +0 -1
- package/dist/esm/third-party/components/AlsoBoughtCbb.js +28 -0
- package/dist/esm/third-party/components/AlsoBoughtCbb.liquid.js +17 -0
- package/dist/esm/third-party/components/BfSizeChartSizeGuide.js +28 -0
- package/dist/esm/third-party/components/BfSizeChartSizeGuide.liquid.js +8 -0
- package/dist/esm/third-party/components/EssentialAnnouncementBar.js +28 -0
- package/dist/esm/third-party/components/EssentialAnnouncementBar.liquid.js +8 -0
- package/dist/esm/third-party/components/EssentialCountdownTimerBar.js +28 -0
- package/dist/esm/third-party/components/EssentialCountdownTimerBar.liquid.js +8 -0
- package/dist/esm/third-party/components/EstimatedDeliveryDatePlus.js +28 -0
- package/dist/esm/third-party/components/EstimatedDeliveryDatePlus.liquid.js +8 -0
- package/dist/esm/third-party/components/GloColorSwatchvariantImage.js +28 -0
- package/dist/esm/third-party/components/GloColorSwatchvariantImage.liquid.js +8 -0
- package/dist/esm/third-party/components/HextomFreeShippingBar.js +28 -0
- package/dist/esm/third-party/components/HextomFreeShippingBar.liquid.js +8 -0
- package/dist/esm/third-party/components/OkendoReviewsLoyalty.js +28 -0
- package/dist/esm/third-party/components/OkendoReviewsLoyalty.liquid.js +8 -0
- package/dist/esm/third-party/components/QikifyUpsell.liquid.js +3 -46
- package/dist/esm/third-party/components/StellarDeliveryDatePickup.js +28 -0
- package/dist/esm/third-party/components/StellarDeliveryDatePickup.liquid.js +17 -0
- package/dist/esm/third-party/components/TrustedsiteTrustBadges.js +28 -0
- package/dist/esm/third-party/components/TrustedsiteTrustBadges.liquid.js +8 -0
- package/dist/esm/third-party/configs/AlsoBoughtCbb.js +8 -0
- package/dist/esm/third-party/configs/BfSizeChartSizeGuide.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/configs/EstimatedDeliveryDatePlus.js +8 -0
- package/dist/esm/third-party/configs/GloColorSwatchvariantImage.js +8 -0
- package/dist/esm/third-party/configs/HextomFreeShippingBar.js +8 -0
- package/dist/esm/third-party/configs/OkendoReviewsLoyalty.js +8 -0
- package/dist/esm/third-party/configs/StellarDeliveryDatePickup.js +8 -0
- package/dist/esm/third-party/configs/TrustedsiteTrustBadges.js +8 -0
- package/dist/esm/third-party/helpers/thirdParty.js +1 -1
- package/dist/esm/third-party/next.js +51 -1
- package/dist/esm/third-party/setting/AlsoBoughtCbb.js +123 -0
- package/dist/esm/third-party/setting/BfSizeChartSizeGuide.js +127 -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/EstimatedDeliveryDatePlus.js +124 -0
- package/dist/esm/third-party/setting/GloColorSwatchvariantImage.js +148 -0
- package/dist/esm/third-party/setting/HextomFreeShippingBar.js +124 -0
- package/dist/esm/third-party/setting/OkendoReviewsLoyalty.js +167 -0
- package/dist/esm/third-party/setting/QikifyUpsell.js +11 -1
- package/dist/esm/third-party/setting/StellarDeliveryDatePickup.js +123 -0
- package/dist/esm/third-party/setting/TrustedsiteTrustBadges.js +173 -0
- package/dist/esm/third-party/setting/index.js +224 -204
- package/dist/esm/video/components/HTML5Embed.js +2 -2
- package/dist/esm/video/components/HTML5Embed.liquid.js +6 -3
- package/dist/esm/video/components/LiteYouTubeEmbed.liquid.js +5 -3
- package/dist/types/index.d.ts +184 -8
- package/package.json +2 -2
|
@@ -10,7 +10,7 @@ import NextImage from '../../../image/components/NextImage.liquid.js';
|
|
|
10
10
|
import { getImageSrc, DEVICES } from '../../../image/helpers/getSrcSet.js';
|
|
11
11
|
import { createBlurDataURL } from '../../../image/components/helpers.js';
|
|
12
12
|
|
|
13
|
-
const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, children, rawChildren, advanced,
|
|
13
|
+
const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, children, rawChildren, advanced, enableLazyLoadImage = true })=>{
|
|
14
14
|
const { link, layout, verticalAlign, order, alignBanner, alt, title } = setting ?? {};
|
|
15
15
|
const { background, overlayEnable, overlayColor, overlayOpacity, verticalGutter, contentWidth, hoverEffect, hoverEffectDuration, hoverEffectScale, cornerBg, borderBg, hasActiveShadow, shadowBg, sizeSetting, contentPadding } = styles ?? {};
|
|
16
16
|
const enableParallax = setting?.enableParallax || false;
|
|
@@ -130,6 +130,7 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
|
|
|
130
130
|
tablet: createBlurDataURL(srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.tablet?.height ?? srcSet?.desktop?.width ?? 0),
|
|
131
131
|
mobile: createBlurDataURL(srcSet?.mobile?.width ?? srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.mobile?.height ?? srcSet?.tablet?.height ?? srcSet?.desktop?.width ?? 0)
|
|
132
132
|
};
|
|
133
|
+
const enableLazyLoad = !setting?.preload && enableLazyLoadImage;
|
|
133
134
|
const renderInnerHeroBanner = ()=>{
|
|
134
135
|
return template /* liquid */ `
|
|
135
136
|
<div
|
|
@@ -179,7 +180,7 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
|
|
|
179
180
|
alt,
|
|
180
181
|
title,
|
|
181
182
|
imagePlaceholder,
|
|
182
|
-
|
|
183
|
+
enableLazyLoadImage
|
|
183
184
|
})}
|
|
184
185
|
<div class="${cls('gp-absolute gp-w-full gp-h-full')}">
|
|
185
186
|
<div
|
|
@@ -193,9 +194,10 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
|
|
|
193
194
|
'clip-path': getClipPath(borderBg?.width, cornerBg)
|
|
194
195
|
}}"
|
|
195
196
|
>
|
|
196
|
-
<div class="${cls('hero-banner-bg-parallax gp-hero-banner-image-background
|
|
197
|
+
<div class="${cls('hero-banner-bg-parallax gp-hero-banner-image-background', {
|
|
197
198
|
'gp-duration-[var(--duration)] group-hover/hero:gp-scale-[var(--scale)]': hoverEffect,
|
|
198
|
-
'gp-transition-transform': hoverEffect
|
|
199
|
+
'gp-transition-transform': hoverEffect,
|
|
200
|
+
gp_lazybg: enableLazyLoad
|
|
199
201
|
})}"
|
|
200
202
|
style="${{
|
|
201
203
|
...getStyleBackgroundByDevice(background, {
|
|
@@ -204,9 +206,9 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
|
|
|
204
206
|
liquid: true
|
|
205
207
|
}),
|
|
206
208
|
...makeStyleResponsive('bgi', {
|
|
207
|
-
desktop: `url('${bgiEnableByDevice['desktop'] ?
|
|
208
|
-
tablet: `url('${bgiEnableByDevice['tablet'] ?
|
|
209
|
-
mobile: `url('${bgiEnableByDevice['mobile'] ?
|
|
209
|
+
desktop: `url('${bgiEnableByDevice['desktop'] ? !enableLazyLoad ? getImageSrc(getResponsiveValueByScreen(srcSet, 'desktop'), 'desktop') : imagePlaceholder['desktop'] : ''}')`,
|
|
210
|
+
tablet: `url('${bgiEnableByDevice['tablet'] ? !enableLazyLoad ? getImageSrc(getResponsiveValueByScreen(srcSet, 'tablet'), 'tablet') : imagePlaceholder['tablet'] : ''}')`,
|
|
211
|
+
mobile: `url('${bgiEnableByDevice['mobile'] ? !enableLazyLoad ? getImageSrc(getResponsiveValueByScreen(srcSet, 'mobile'), 'mobile') : imagePlaceholder['mobile'] : ''}')`
|
|
210
212
|
}),
|
|
211
213
|
'--duration': `${hoverEffectDuration ?? 0}s`,
|
|
212
214
|
'--scale': hoverEffectScale ?? 1,
|
|
@@ -214,17 +216,17 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
|
|
|
214
216
|
...getStyleHeroBannerBg(backgroundResponsive || {}, enableParallax)
|
|
215
217
|
}}"
|
|
216
218
|
>
|
|
219
|
+
${embed()}
|
|
217
220
|
${!setting?.preload ? DEVICES.map((device)=>{
|
|
218
221
|
return RenderIf(getEnableBgImageByDevice(device), NextImage({
|
|
219
222
|
src: getImageSrc(getResponsiveValueByScreen(srcSet, device), device),
|
|
220
223
|
alt: `lazy image ${device}`,
|
|
221
224
|
className: `gp-absolute gp-top-0 gp-invisible gp-w-full gp_lazyload gp-h-full gp_lazyforbg ${device === 'tablet' ? 'gp_lazybg_tl' : ''} ${device === 'mobile' ? 'gp_lazybg_mb' : ''}`,
|
|
222
225
|
isDisableAspectStyle: true,
|
|
223
|
-
|
|
226
|
+
enableLazyLoadImage
|
|
224
227
|
}));
|
|
225
228
|
}).join('') : ''}
|
|
226
|
-
</div>
|
|
227
|
-
${embed()} </div>
|
|
229
|
+
</div></div>
|
|
228
230
|
</div>
|
|
229
231
|
${RenderIf(overlayEnable, template`<div
|
|
230
232
|
aria-label="Overlay"
|
|
@@ -25,13 +25,14 @@ const getHeightHeroBanner = (background, enableParallax)=>{
|
|
|
25
25
|
'tablet'
|
|
26
26
|
];
|
|
27
27
|
DEVICES.forEach((device)=>{
|
|
28
|
+
const enableParallaxDevice = background?.[device]?.type === 'image' ? enableParallax : false;
|
|
28
29
|
const isScale = isScaleImage({
|
|
29
|
-
enableParallax,
|
|
30
|
+
enableParallax: enableParallaxDevice,
|
|
30
31
|
attachment: background[device]?.attachment
|
|
31
32
|
});
|
|
32
33
|
result = {
|
|
33
34
|
...result,
|
|
34
|
-
[device]:
|
|
35
|
+
[device]: enableParallaxDevice ? '150%' : isScale ? '100vh' : '100%'
|
|
35
36
|
};
|
|
36
37
|
});
|
|
37
38
|
return makeStyleResponsive('h', result);
|
|
@@ -44,8 +45,9 @@ const getWidthHeroBanner = (background, enableParallax)=>{
|
|
|
44
45
|
'tablet'
|
|
45
46
|
];
|
|
46
47
|
DEVICES.forEach((device)=>{
|
|
48
|
+
const enableParallaxDevice = background?.[device]?.type === 'image' ? enableParallax : false;
|
|
47
49
|
const isScale = isScaleImage({
|
|
48
|
-
enableParallax,
|
|
50
|
+
enableParallax: enableParallaxDevice,
|
|
49
51
|
attachment: background[device]?.attachment
|
|
50
52
|
});
|
|
51
53
|
result = {
|
package/dist/esm/builder.js
CHANGED
|
@@ -107,8 +107,18 @@ import TrustreviewsProductReviews from './third-party/components/TrustreviewsPro
|
|
|
107
107
|
import MyappgurusProductReviews from './third-party/components/MyappgurusProductReviews.js';
|
|
108
108
|
import HulkProductOptions from './third-party/components/HulkProductOptions.js';
|
|
109
109
|
import TrustshopProductReviews from './third-party/components/TrustshopProductReviews.js';
|
|
110
|
+
import StellarDeliveryDatePickup from './third-party/components/StellarDeliveryDatePickup.js';
|
|
111
|
+
import EssentialCountdownTimerBar from './third-party/components/EssentialCountdownTimerBar.js';
|
|
112
|
+
import EssentialAnnouncementBar from './third-party/components/EssentialAnnouncementBar.js';
|
|
113
|
+
import OkendoReviewsLoyalty from './third-party/components/OkendoReviewsLoyalty.js';
|
|
114
|
+
import EstimatedDeliveryDatePlus from './third-party/components/EstimatedDeliveryDatePlus.js';
|
|
110
115
|
import HextomCountdownTimerBar from './third-party/components/HextomCountdownTimerBar.js';
|
|
111
116
|
import TrustBadgesBear from './third-party/components/TrustBadgesBear.js';
|
|
117
|
+
import TrustedsiteTrustBadges from './third-party/components/TrustedsiteTrustBadges.js';
|
|
118
|
+
import GloColorSwatchvariantImage from './third-party/components/GloColorSwatchvariantImage.js';
|
|
119
|
+
import BfSizeChartSizeGuide from './third-party/components/BfSizeChartSizeGuide.js';
|
|
120
|
+
import AlsoBoughtCbb from './third-party/components/AlsoBoughtCbb.js';
|
|
121
|
+
import HextomFreeShippingBar from './third-party/components/HextomFreeShippingBar.js';
|
|
112
122
|
import CartLineVariant from './cart/components/CartLineVariant.js';
|
|
113
123
|
import Cart from './cart/components/Cart.js';
|
|
114
124
|
import CartList from './cart/components/CartList.js';
|
|
@@ -243,6 +253,11 @@ import PostPurchaseCountdownTimer from './post-purchase/countdown-timer/componen
|
|
|
243
253
|
import Text$1 from './post-purchase/text/Text.js';
|
|
244
254
|
|
|
245
255
|
var builder = {
|
|
256
|
+
EstimatedDeliveryDatePlus,
|
|
257
|
+
OkendoReviewsLoyalty,
|
|
258
|
+
EssentialAnnouncementBar,
|
|
259
|
+
EssentialCountdownTimerBar,
|
|
260
|
+
StellarDeliveryDatePickup,
|
|
246
261
|
TrustshopProductReviews,
|
|
247
262
|
HulkProductOptions,
|
|
248
263
|
TrustreviewsProductReviews,
|
|
@@ -479,7 +494,12 @@ var builder = {
|
|
|
479
494
|
MarqueeItem,
|
|
480
495
|
ProductBadge,
|
|
481
496
|
HextomCountdownTimerBar,
|
|
482
|
-
TrustBadgesBear
|
|
497
|
+
TrustBadgesBear,
|
|
498
|
+
TrustedsiteTrustBadges,
|
|
499
|
+
GloColorSwatchvariantImage,
|
|
500
|
+
BfSizeChartSizeGuide,
|
|
501
|
+
AlsoBoughtCbb,
|
|
502
|
+
HextomFreeShippingBar
|
|
483
503
|
};
|
|
484
504
|
|
|
485
505
|
export { builder as default };
|
|
@@ -1,15 +1,109 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useCollection } from '@gem-sdk/core';
|
|
3
|
-
import
|
|
1
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { useCurrentDevice, useCollection, getResponsiveValueByScreen, composeTypographyClassName, composeTypographyStyle, isSafari, cls, getGlobalColorClass, getStyleShadow, makeStyleResponsive, makeStyle, getGlobalColorStyle } from '@gem-sdk/core';
|
|
3
|
+
import { useState, useRef, useEffect } from 'react';
|
|
4
4
|
|
|
5
|
-
const CollectionDescription = ({ setting })=>{
|
|
5
|
+
const CollectionDescription = ({ setting, builderProps })=>{
|
|
6
|
+
const [open, setOpen] = useState(false);
|
|
7
|
+
const [isShowViewMore, allowShowViewMore] = useState(false);
|
|
8
|
+
const ref = useRef(null);
|
|
9
|
+
const currentDevice = useCurrentDevice();
|
|
6
10
|
const collection = useCollection();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const hasLineClamp = getResponsiveValueByScreen(setting?.hasLineClamp, currentDevice);
|
|
12
|
+
const lineClamp = getResponsiveValueByScreen(setting?.lineClamp, currentDevice);
|
|
13
|
+
const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
|
|
14
|
+
const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
|
|
15
|
+
useEffect(()=>{
|
|
16
|
+
const dom = ref.current;
|
|
17
|
+
setOpen(false);
|
|
18
|
+
if (dom && hasLineClamp && collection?.description) {
|
|
19
|
+
const value = lineClamp;
|
|
20
|
+
setTimeout(()=>{
|
|
21
|
+
const scrollHeight = dom?.scrollHeight ?? 0;
|
|
22
|
+
const clientHeight = dom?.clientHeight ?? 0;
|
|
23
|
+
const lineHeight = window.getComputedStyle(dom).getPropertyValue('line-height');
|
|
24
|
+
const lineText = Math.round((scrollHeight ?? 0) / parseInt(lineHeight));
|
|
25
|
+
const conditionCheckLine = isSafari() ? value && value < lineText : clientHeight < scrollHeight;
|
|
26
|
+
if (value && conditionCheckLine) {
|
|
27
|
+
allowShowViewMore(()=>true);
|
|
28
|
+
} else {
|
|
29
|
+
allowShowViewMore(()=>false);
|
|
30
|
+
}
|
|
31
|
+
}, 100);
|
|
12
32
|
}
|
|
33
|
+
}, [
|
|
34
|
+
hasLineClamp,
|
|
35
|
+
lineClamp,
|
|
36
|
+
collection?.description
|
|
37
|
+
]);
|
|
38
|
+
const css = `
|
|
39
|
+
.gp-p-description-text > *:not(ol):not(ul):not(table):not(div) {
|
|
40
|
+
display: inline !important;
|
|
41
|
+
}
|
|
42
|
+
.gp-p-description-text > *:not(ol):not(ul):not(table):not(div)::after {
|
|
43
|
+
content: "\\A";
|
|
44
|
+
white-space: pre;
|
|
45
|
+
}
|
|
46
|
+
.gp-p-description-text > table {
|
|
47
|
+
box-shadow: none;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const hasDescription = collection?.description && collection.description?.trim() != '';
|
|
51
|
+
return /*#__PURE__*/ jsxs("div", {
|
|
52
|
+
"data-id": builderProps?.uid,
|
|
53
|
+
children: [
|
|
54
|
+
!isSafari() && /*#__PURE__*/ jsx("style", {
|
|
55
|
+
children: css
|
|
56
|
+
}),
|
|
57
|
+
/*#__PURE__*/ jsx("div", {
|
|
58
|
+
ref: ref,
|
|
59
|
+
"data-gp-text": true,
|
|
60
|
+
className: cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, !hasDescription ? 'gp-p-2 gp-text-center gp-text-sm gp-font-semibold gp-text-gray-500 gp-py-2 !gp-text-center' : '', getGlobalColorClass('text', setting?.color)),
|
|
61
|
+
style: {
|
|
62
|
+
...getStyleShadow({
|
|
63
|
+
styleAppliedFor: 'text-shadow'
|
|
64
|
+
}),
|
|
65
|
+
...makeStyleResponsive('ta', setting?.textAlign),
|
|
66
|
+
...hasLineClamp && !open ? makeStyleResponsive('line-clamp', setting?.lineClamp) : {},
|
|
67
|
+
...makeStyle({
|
|
68
|
+
tt: setting?.transform
|
|
69
|
+
}),
|
|
70
|
+
...appendTypoStyle
|
|
71
|
+
},
|
|
72
|
+
dangerouslySetInnerHTML: {
|
|
73
|
+
__html: collection?.descriptionHtml && hasDescription ? collection.descriptionHtml : ``
|
|
74
|
+
}
|
|
75
|
+
}),
|
|
76
|
+
hasLineClamp && isShowViewMore && /*#__PURE__*/ jsxs("button", {
|
|
77
|
+
className: cls(appendTypoClass, getGlobalColorClass('text', setting?.showMoreColor), 'gp-mt-4 gp-w-full gp-transition-all hover:gp-opacity-80'),
|
|
78
|
+
style: {
|
|
79
|
+
...makeStyleResponsive('ta', setting?.textAlign),
|
|
80
|
+
...makeStyle({
|
|
81
|
+
tt: setting?.transform
|
|
82
|
+
}),
|
|
83
|
+
...appendTypoStyle,
|
|
84
|
+
...getGlobalColorStyle(setting?.showMoreColor)
|
|
85
|
+
},
|
|
86
|
+
onClick: ()=>setOpen((prev)=>!prev),
|
|
87
|
+
children: [
|
|
88
|
+
!open ? setting?.viewMoreText : setting?.viewLessText,
|
|
89
|
+
setting?.enableViewMoreIcon && /*#__PURE__*/ jsx("svg", {
|
|
90
|
+
className: "gp-ml-1 gp-inline-block",
|
|
91
|
+
height: "1em",
|
|
92
|
+
width: "1em",
|
|
93
|
+
viewBox: "0 0 22 12",
|
|
94
|
+
fill: "none",
|
|
95
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
96
|
+
children: !open ? /*#__PURE__*/ jsx("path", {
|
|
97
|
+
d: "M1.70711 0.292893C1.31658 -0.0976311 0.683417 -0.0976311 0.292893 0.292893C-0.0976311 0.683417 -0.0976311 1.31658 0.292893 1.70711L1.70711 0.292893ZM11 11L10.2929 11.7071C10.6834 12.0976 11.3166 12.0976 11.7071 11.7071L11 11ZM21.7071 1.70711C22.0976 1.31658 22.0976 0.683417 21.7071 0.292893C21.3166 -0.0976311 20.6834 -0.0976311 20.2929 0.292893L21.7071 1.70711ZM0.292893 1.70711L10.2929 11.7071L11.7071 10.2929L1.70711 0.292893L0.292893 1.70711ZM11.7071 11.7071L21.7071 1.70711L20.2929 0.292893L10.2929 10.2929L11.7071 11.7071Z",
|
|
98
|
+
fill: "currentColor"
|
|
99
|
+
}) : /*#__PURE__*/ jsx("path", {
|
|
100
|
+
d: "M0.292893 10.2929C-0.0976311 10.6834 -0.0976311 11.3166 0.292893 11.7071C0.683417 12.0976 1.31658 12.0976 1.70711 11.7071L0.292893 10.2929ZM11 1L11.7071 0.292893C11.3166 -0.0976311 10.6834 -0.0976311 10.2929 0.292893L11 1ZM20.2929 11.7071C20.6834 12.0976 21.3166 12.0976 21.7071 11.7071C22.0976 11.3166 22.0976 10.6834 21.7071 10.2929L20.2929 11.7071ZM1.70711 11.7071L11.7071 1.70711L10.2929 0.292893L0.292893 10.2929L1.70711 11.7071ZM10.2929 1.70711L20.2929 11.7071L21.7071 10.2929L11.7071 0.292893L10.2929 1.70711Z",
|
|
101
|
+
fill: "currentColor"
|
|
102
|
+
})
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
]
|
|
13
107
|
});
|
|
14
108
|
};
|
|
15
109
|
|
|
@@ -1,16 +1,109 @@
|
|
|
1
|
-
import { template } from '@gem-sdk/core';
|
|
2
|
-
import
|
|
1
|
+
import { composeTypographyStyle, composeTypographyClassName, getStyleShadow, makeStyleResponsive, getGlobalColorStyle, makeStyle, makeLineClamp, template, cls, getGlobalColorClass, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
|
+
import { getDynamicSourceLocales, getSettingPreloadData } from '../../helpers.js';
|
|
3
|
+
import { getDisplayStyle } from '../../product/components/ProductImages/common/common.js';
|
|
3
4
|
|
|
4
|
-
const CollectionDescription = ({ setting })=>{
|
|
5
|
+
const CollectionDescription = ({ setting, advanced, builderProps, pageContext })=>{
|
|
6
|
+
const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
|
|
7
|
+
const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
|
|
8
|
+
const defaultStyle = {
|
|
9
|
+
...getStyleShadow({
|
|
10
|
+
styleAppliedFor: 'text-shadow'
|
|
11
|
+
}),
|
|
12
|
+
...makeStyleResponsive('ta', setting?.textAlign),
|
|
13
|
+
...getGlobalColorStyle(setting?.color),
|
|
14
|
+
...makeStyle({
|
|
15
|
+
tt: setting?.transform
|
|
16
|
+
}),
|
|
17
|
+
...appendTypoStyle
|
|
18
|
+
};
|
|
19
|
+
const collapseStyle = {
|
|
20
|
+
...defaultStyle,
|
|
21
|
+
...makeStyleResponsive('line-clamp', makeLineClamp(setting?.lineClamp, setting?.hasLineClamp))
|
|
22
|
+
};
|
|
23
|
+
const getDisplayCollapse = ()=>{
|
|
24
|
+
return getDisplayStyle((device)=>!!setting?.hasLineClamp && setting.hasLineClamp[device] !== undefined && !setting.hasLineClamp[device], 'block');
|
|
25
|
+
};
|
|
26
|
+
const moreIcon = `<svg
|
|
27
|
+
class="gp-ml-1 gp-inline-block"
|
|
28
|
+
style="display: inline-block; margin-left: 1px;"
|
|
29
|
+
height="1em"
|
|
30
|
+
width="1em"
|
|
31
|
+
viewBox="0 0 22 12"
|
|
32
|
+
fill="none"
|
|
33
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
34
|
+
>
|
|
35
|
+
<path
|
|
36
|
+
d="M1.70711 0.292893C1.31658 -0.0976311 0.683417 -0.0976311 0.292893 0.292893C-0.0976311 0.683417 -0.0976311 1.31658 0.292893 1.70711L1.70711 0.292893ZM11 11L10.2929 11.7071C10.6834 12.0976 11.3166 12.0976 11.7071 11.7071L11 11ZM21.7071 1.70711C22.0976 1.31658 22.0976 0.683417 21.7071 0.292893C21.3166 -0.0976311 20.6834 -0.0976311 20.2929 0.292893L21.7071 1.70711ZM0.292893 1.70711L10.2929 11.7071L11.7071 10.2929L1.70711 0.292893L0.292893 1.70711ZM11.7071 11.7071L21.7071 1.70711L20.2929 0.292893L10.2929 10.2929L11.7071 11.7071Z"
|
|
37
|
+
fill="currentColor"
|
|
38
|
+
/>
|
|
39
|
+
</svg>`;
|
|
40
|
+
const viewMoreTextTranslate = getDynamicSourceLocales({
|
|
41
|
+
val: setting?.viewMoreText,
|
|
42
|
+
uid: builderProps?.uid,
|
|
43
|
+
settingId: 'viewMoreText',
|
|
44
|
+
isLiquid: true,
|
|
45
|
+
pageContext,
|
|
46
|
+
translate: setting?.translate
|
|
47
|
+
});
|
|
48
|
+
const viewLessTextTranslate = getDynamicSourceLocales({
|
|
49
|
+
val: setting?.viewLessText,
|
|
50
|
+
uid: builderProps?.uid,
|
|
51
|
+
settingId: 'viewLessText',
|
|
52
|
+
isLiquid: true,
|
|
53
|
+
pageContext,
|
|
54
|
+
translate: setting?.translate
|
|
55
|
+
});
|
|
5
56
|
return template`
|
|
6
|
-
|
|
7
|
-
styles: setting,
|
|
57
|
+
<gp-collection-description data-id="${builderProps?.uid}" class="${advanced?.cssClass} gp-collection-description" gp-data='${JSON.stringify({
|
|
8
58
|
setting: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
59
|
+
lineClamp: setting?.lineClamp,
|
|
60
|
+
hasLineClamp: setting?.hasLineClamp,
|
|
61
|
+
viewMoreText: viewMoreTextTranslate,
|
|
62
|
+
viewLessText: viewLessTextTranslate,
|
|
63
|
+
enableViewMoreIcon: setting?.enableViewMoreIcon
|
|
64
|
+
},
|
|
65
|
+
defaultStyle,
|
|
66
|
+
collapseStyle
|
|
67
|
+
}).replaceAll("'", ''')}'
|
|
68
|
+
view-more-text="${pageContext?.isPreviewing ? viewMoreTextTranslate : `{{${viewMoreTextTranslate}}}`}"
|
|
69
|
+
view-less-text="${pageContext?.isPreviewing ? viewLessTextTranslate : `{{${viewLessTextTranslate}}}`}"
|
|
70
|
+
>
|
|
71
|
+
<div></div>
|
|
72
|
+
<div
|
|
73
|
+
data-gp-text
|
|
74
|
+
class="${cls('gp-relative p-description-wrapper gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, getGlobalColorClass('text', setting?.color), "data-[browser=safari]:after:gp-content-[' '] data-[browser=safari]:after:gp-absolute data-[browser=safari]:after:gp-left-0 data-[browser=safari]:after:gp-right-0 data-[browser=safari]:after:gp-bottom-0 data-[browser=safari]:after:gp-w-full data-[browser=safari]:after:gp-h-1/2 data-[browser=safari]:after:gp-bg-gradient-to-t data-[browser=safari]:after:gp-from-white")}"
|
|
75
|
+
data-gp-text
|
|
76
|
+
style="${collapseStyle}"
|
|
77
|
+
>
|
|
78
|
+
{{collection.description}}
|
|
79
|
+
</div>
|
|
80
|
+
{% if collection.description != blank -%}
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
class="p-description-show-more ${cls(appendTypoClass, getGlobalColorClass('text', setting?.showMoreColor), 'gp-mt-4 hover:gp-opacity-80 gp-transition-all gp-w-full')}"
|
|
84
|
+
style="${{
|
|
85
|
+
...makeStyle({
|
|
86
|
+
tt: setting?.transform
|
|
87
|
+
}),
|
|
88
|
+
...makeStyleResponsive('ta', setting?.textAlign),
|
|
89
|
+
...appendTypoStyle,
|
|
90
|
+
...getGlobalColorStyle(setting?.showMoreColor),
|
|
91
|
+
...getDisplayCollapse(),
|
|
92
|
+
position: 'absolute',
|
|
93
|
+
visibility: 'hidden'
|
|
94
|
+
}}"
|
|
95
|
+
>
|
|
96
|
+
${pageContext?.isPreviewing ? viewMoreTextTranslate : `{{${viewMoreTextTranslate}}}`}
|
|
97
|
+
${setting?.enableViewMoreIcon ? moreIcon : ''}
|
|
98
|
+
</button>
|
|
99
|
+
{%- endif -%}
|
|
100
|
+
{% style %}
|
|
101
|
+
.p-description-wrapper.gp-p-description-text * {
|
|
102
|
+
color: inherit
|
|
103
|
+
}
|
|
104
|
+
{% endstyle %}
|
|
105
|
+
</gp-collection-description>
|
|
106
|
+
${RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-collection-description.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-collection-description.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
|
|
14
107
|
`;
|
|
15
108
|
};
|
|
16
109
|
|
|
@@ -35,6 +35,59 @@ const config = {
|
|
|
35
35
|
}
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
|
+
{
|
|
39
|
+
id: 'hasLineClamp',
|
|
40
|
+
label: 'Enable View More',
|
|
41
|
+
type: 'toggle',
|
|
42
|
+
devices: {
|
|
43
|
+
desktop: {
|
|
44
|
+
default: true
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: 'lineClamp',
|
|
50
|
+
label: 'Maximum Row(s) To Show',
|
|
51
|
+
type: 'input:number',
|
|
52
|
+
min: 1,
|
|
53
|
+
hide: true,
|
|
54
|
+
devices: {
|
|
55
|
+
desktop: {
|
|
56
|
+
default: 12
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'viewMoreText',
|
|
62
|
+
label: 'View More Text',
|
|
63
|
+
type: 'input',
|
|
64
|
+
default: 'Show more',
|
|
65
|
+
hide: true
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
id: 'showMoreColor',
|
|
69
|
+
type: 'colorpicker',
|
|
70
|
+
default: 'text-1'
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
id: 'viewLessText',
|
|
74
|
+
label: 'View Less Text',
|
|
75
|
+
type: 'input',
|
|
76
|
+
default: 'Show less',
|
|
77
|
+
hide: true
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
id: 'enableViewMoreIcon',
|
|
81
|
+
label: 'Enable Icon',
|
|
82
|
+
type: 'toggle',
|
|
83
|
+
default: true,
|
|
84
|
+
hide: true
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
id: 'translate',
|
|
88
|
+
type: 'input',
|
|
89
|
+
default: 'viewLessText,viewMoreText'
|
|
90
|
+
},
|
|
38
91
|
{
|
|
39
92
|
id: 'textAlign',
|
|
40
93
|
label: 'Align',
|
|
@@ -70,11 +123,86 @@ const config = {
|
|
|
70
123
|
default: 'center'
|
|
71
124
|
}
|
|
72
125
|
}
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
id: 'color',
|
|
129
|
+
type: 'colorpicker',
|
|
130
|
+
default: 'text-1'
|
|
73
131
|
}
|
|
74
132
|
]
|
|
75
133
|
}
|
|
76
134
|
],
|
|
77
135
|
ui: [
|
|
136
|
+
{
|
|
137
|
+
type: 'group',
|
|
138
|
+
label: {
|
|
139
|
+
en: ''
|
|
140
|
+
},
|
|
141
|
+
controls: [
|
|
142
|
+
{
|
|
143
|
+
type: 'control',
|
|
144
|
+
label: {
|
|
145
|
+
en: 'Show more'
|
|
146
|
+
},
|
|
147
|
+
options: {
|
|
148
|
+
label: 'large'
|
|
149
|
+
},
|
|
150
|
+
setting: {
|
|
151
|
+
id: 'hasLineClamp'
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
type: 'control',
|
|
156
|
+
label: {
|
|
157
|
+
en: 'Text color'
|
|
158
|
+
},
|
|
159
|
+
setting: {
|
|
160
|
+
id: 'showMoreColor'
|
|
161
|
+
},
|
|
162
|
+
condition: 'hasLineClamp == true'
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
type: 'control',
|
|
166
|
+
label: {
|
|
167
|
+
en: 'Max lines'
|
|
168
|
+
},
|
|
169
|
+
setting: {
|
|
170
|
+
id: 'lineClamp'
|
|
171
|
+
},
|
|
172
|
+
condition: 'hasLineClamp == true'
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: 'control',
|
|
176
|
+
label: {
|
|
177
|
+
en: 'Show more label'
|
|
178
|
+
},
|
|
179
|
+
setting: {
|
|
180
|
+
id: 'viewMoreText'
|
|
181
|
+
},
|
|
182
|
+
condition: 'hasLineClamp == true'
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
type: 'control',
|
|
186
|
+
label: {
|
|
187
|
+
en: 'Show less label'
|
|
188
|
+
},
|
|
189
|
+
setting: {
|
|
190
|
+
id: 'viewLessText'
|
|
191
|
+
},
|
|
192
|
+
condition: 'hasLineClamp == true'
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
type: 'control',
|
|
196
|
+
label: {
|
|
197
|
+
en: 'Icon'
|
|
198
|
+
},
|
|
199
|
+
setting: {
|
|
200
|
+
id: 'enableViewMoreIcon'
|
|
201
|
+
},
|
|
202
|
+
condition: 'hasLineClamp == true'
|
|
203
|
+
}
|
|
204
|
+
]
|
|
205
|
+
},
|
|
78
206
|
{
|
|
79
207
|
label: {
|
|
80
208
|
en: 'Text'
|
package/dist/esm/common/const.js
CHANGED
|
@@ -2,10 +2,10 @@ import { makeStyleResponsive, makeWidth, composeAdvanceStyle, composeTypographyC
|
|
|
2
2
|
import { getDynamicSourceLocales } from '../../../helpers.js';
|
|
3
3
|
|
|
4
4
|
const FormTextarea = ({ setting, builderProps, className, builderAttrs, advanced, pageContext })=>{
|
|
5
|
-
const { text, name, placeholder, required, width, fullWidth, typography } = setting ?? {};
|
|
5
|
+
const { text, name, placeholder, required, width, fullWidth, typography, translate } = setting ?? {};
|
|
6
6
|
const textAreaWidth = makeStyleResponsive('w', makeWidth(width, fullWidth));
|
|
7
7
|
const defaultName = name === '' || name === undefined ? 'contact[note]' : name;
|
|
8
|
-
const { border, rounded, hasBoxShadow, boxShadow, pos, d, op, right, top, left, bottom, z, margin, padding
|
|
8
|
+
const { border, rounded, hasBoxShadow, boxShadow, pos, d, op, right, top, left, bottom, z, margin, padding } = advanced ?? {};
|
|
9
9
|
const spacingSetting = advanced?.['spacing-setting'];
|
|
10
10
|
const inputStyle = composeAdvanceStyle({
|
|
11
11
|
border,
|
|
@@ -2,7 +2,7 @@ import { template, cls, RenderIf, makeStyleResponsive } from '@gem-sdk/core';
|
|
|
2
2
|
import { getImageSrc } from '../helpers/getSrcSet.js';
|
|
3
3
|
import { createBlurDataURL } from './helpers.js';
|
|
4
4
|
|
|
5
|
-
const AdaptiveImage = ({ srcSet, priority, alt, aspectRatio, layout, className, pictureClass, style, imagePlaceholder,
|
|
5
|
+
const AdaptiveImage = ({ srcSet, priority, alt, aspectRatio, layout, className, pictureClass, style, imagePlaceholder, enableLazyLoadImage = true, pageContext, ...props })=>{
|
|
6
6
|
const fallBackImage = 'https://cdn.shopify.com/s/assets/no-image-2048-5e88c1b20e087fb7bbe9a3771824e743c244f437e4f8ba93bbf7b11b53f7824c_large.gif';
|
|
7
7
|
const srcDesktop = getImageSrc(srcSet?.desktop, 'desktop') || fallBackImage;
|
|
8
8
|
const srcTablet = (getImageSrc(srcSet?.tablet, 'tablet') ?? getImageSrc(srcSet?.desktop, 'tablet')) || fallBackImage;
|
|
@@ -27,16 +27,17 @@ const AdaptiveImage = ({ srcSet, priority, alt, aspectRatio, layout, className,
|
|
|
27
27
|
}}"
|
|
28
28
|
/>
|
|
29
29
|
`, template`
|
|
30
|
-
${srcMobile ? `<source media="(max-width: 767px)" data-srcSet="${srcMobile}" srcset="${
|
|
31
|
-
${srcTablet ? `<source media="(max-width: 1024px)" data-srcSet="${srcTablet}" srcset="${
|
|
30
|
+
${srcMobile ? `<source media="(max-width: 767px)" data-srcSet="${srcMobile}" srcset="${enableLazyLoadImage ? imagePlaceholder?.['mobile'] ?? createBlurDataURL(srcSet?.mobile?.width ?? srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.mobile?.height ?? srcSet?.tablet?.height ?? srcSet?.desktop?.height ?? 0) : srcMobile}" />` : ''}
|
|
31
|
+
${srcTablet ? `<source media="(max-width: 1024px)" data-srcSet="${srcTablet}" srcset="${enableLazyLoadImage ? imagePlaceholder?.['tablet'] ?? createBlurDataURL(srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.tablet?.height ?? srcSet?.desktop?.height ?? 0) : srcTablet}" />` : ''}
|
|
32
32
|
<img
|
|
33
33
|
${{
|
|
34
34
|
...props
|
|
35
35
|
}}
|
|
36
36
|
class="${cls(className, {
|
|
37
|
-
gp_lazyload:
|
|
37
|
+
gp_lazyload: enableLazyLoadImage,
|
|
38
|
+
gp_force_load: pageContext?.isOptimizePlan
|
|
38
39
|
})}"
|
|
39
|
-
src="${
|
|
40
|
+
src="${enableLazyLoadImage ? imagePlaceholder?.['desktop'] ?? createBlurDataURL(srcSet?.desktop?.width ?? 0, srcSet?.desktop?.height ?? 0) : srcDesktop}"
|
|
40
41
|
data-src="${srcDesktop}"
|
|
41
42
|
width="100%"
|
|
42
43
|
alt="${alt}"
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { makeStyleResponsive, getWidthByShapeGlobalSize, makeWidth, getHeightByShapeGlobalSize, cls, getStyleShadowState, handleConvertClassColor, getBorderStyle, getBorderRadiusStyle, getStyleShadow, getAspectRatioGlobalSize, getGlobalColorStateClass, getGlobalColorStateStyle, makeStyleState, getCornerCSSFromGlobal } from '@gem-sdk/core';
|
|
2
|
+
import { useCurrentDevice, makeStyleResponsive, getWidthByShapeGlobalSize, makeWidth, getHeightByShapeGlobalSize, cls, getStyleShadowState, handleConvertClassColor, getBorderStyle, getBorderRadiusStyle, getStyleShadow, getAspectRatioGlobalSize, getGlobalColorStateClass, getGlobalColorStateStyle, makeStyleState, getCornerCSSFromGlobal } from '@gem-sdk/core';
|
|
3
3
|
import Link from '../../link/components/Link.js';
|
|
4
4
|
import AdaptiveImage from './AdaptiveImage.js';
|
|
5
5
|
import NextImage from './NextImage.js';
|
|
6
6
|
import { composeAspectRatio } from './helpers.js';
|
|
7
|
+
import NoDataImage from './NoDataImage.js';
|
|
8
|
+
import { useMemo } from 'react';
|
|
7
9
|
|
|
8
10
|
const Image = ({ styles, className, setting, builderAttrs, builderProps, style, children, onClick, onLoad })=>{
|
|
9
11
|
const { image, imageLink, srcSet, isNotLazyload } = setting ?? {};
|
|
10
12
|
const { customAspectRadio } = styles ?? {};
|
|
13
|
+
const currentDevice = useCurrentDevice();
|
|
11
14
|
const { shape } = styles ?? {};
|
|
12
15
|
const WrapLink = imageLink?.link ? Link : 'div';
|
|
13
16
|
const opacity = {
|
|
@@ -52,6 +55,18 @@ const Image = ({ styles, className, setting, builderAttrs, builderProps, style,
|
|
|
52
55
|
custom: customAspectRadio
|
|
53
56
|
})
|
|
54
57
|
};
|
|
58
|
+
const isShowNoDataState = useMemo(()=>{
|
|
59
|
+
if (setting?.disableNoDataState) return false;
|
|
60
|
+
if (currentDevice === 'mobile') return !setting?.srcSet?.mobile?.src && !setting?.srcSet?.tablet?.src && !setting?.srcSet?.desktop?.src;
|
|
61
|
+
if (currentDevice === 'tablet') return !setting?.srcSet?.tablet?.src && !setting?.srcSet?.desktop?.src;
|
|
62
|
+
return !setting?.srcSet?.desktop?.src;
|
|
63
|
+
}, [
|
|
64
|
+
currentDevice,
|
|
65
|
+
setting?.disableNoDataState,
|
|
66
|
+
setting?.srcSet?.desktop?.src,
|
|
67
|
+
setting?.srcSet?.mobile?.src,
|
|
68
|
+
setting?.srcSet?.tablet?.src
|
|
69
|
+
]);
|
|
55
70
|
return /*#__PURE__*/ jsxs("div", {
|
|
56
71
|
...builderAttrs,
|
|
57
72
|
"data-id": builderProps?.uid,
|
|
@@ -76,14 +91,18 @@ const Image = ({ styles, className, setting, builderAttrs, builderProps, style,
|
|
|
76
91
|
style: {
|
|
77
92
|
...getStyleShadowState(styles?.boxShadowImg, 'box-shadow', styles?.hasBoxShadowImg),
|
|
78
93
|
borderRadius: 'inherit',
|
|
79
|
-
overflow: 'hidden',
|
|
80
94
|
...makeStyleResponsive('jc', styles?.align)
|
|
81
95
|
},
|
|
82
96
|
children: [
|
|
83
|
-
|
|
97
|
+
isShowNoDataState ? /*#__PURE__*/ jsx(NoDataImage, {
|
|
98
|
+
style: {
|
|
99
|
+
...imageWidth,
|
|
100
|
+
...imageHeight
|
|
101
|
+
}
|
|
102
|
+
}) : setting?.isAdaptive ? /*#__PURE__*/ jsx(AdaptiveImage, {
|
|
84
103
|
srcSet: setting.srcSet,
|
|
85
104
|
pictureClass: "gp-contents",
|
|
86
|
-
className: cls(className, 'gp-w-full gp-max-w-full', handleConvertClassColor(styles?.borderImg)),
|
|
105
|
+
className: cls(className, 'gp-inline-block gp-w-full gp-max-w-full', handleConvertClassColor(styles?.borderImg)),
|
|
87
106
|
alt: setting.alt,
|
|
88
107
|
style: {
|
|
89
108
|
...imageWidth,
|