@gem-sdk/components 2.0.0-dev.724 → 2.0.0-dev.725

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.
@@ -56,11 +56,6 @@ const HeroBannerItem = (props)=>{
56
56
  });
57
57
  const backgroundStyle = system.createStyle({
58
58
  ...common.getBackgroundImageHeroBanner(background, enableLazyImage, isNotLiquid),
59
- ...core.getGradientBgrStyleByDevice(background, {
60
- desktop: true,
61
- tablet: true,
62
- mobile: true
63
- }),
64
59
  ...getStyle.getBackgroundStyle(styles, enableParallax, transform)
65
60
  });
66
61
  const containBackgroundClasses = system.createClass({
@@ -68,14 +68,24 @@ const imagePlaceholder = (background)=>{
68
68
  mobile: helpers.createBlurDataURL(srcSet?.mobile?.width ?? srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.mobile?.height ?? srcSet?.tablet?.height ?? srcSet?.desktop?.width ?? 0)
69
69
  };
70
70
  };
71
- const getBackgroundImageHeroBanner = (background, enableLazyImage = false, isNotLiquid = false)=>{
71
+ const getBgImageByScreen = (background, device, enableLazyImage, isNotLiquid)=>{
72
+ if (!background) return '';
72
73
  const srcSet = getBgImage(background);
74
+ const backgroundByDevice = core.getResponsiveValueByScreen(background, device);
75
+ if (enableLazyImage && !isNotLiquid) return `url(${imagePlaceholder(background)[device]})`;
76
+ if (backgroundByDevice?.color?.includes(core.GRADIENT_BGR_KEY)) {
77
+ if (backgroundByDevice.type !== 'image') return `${backgroundByDevice.color}`;
78
+ return `url(${getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, device), device, isNotLiquid)})${backgroundByDevice?.color ? `, ${backgroundByDevice.color}` : ''}`;
79
+ }
80
+ if (backgroundByDevice?.type === 'image') return `url(${getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, device), device, isNotLiquid)})`;
81
+ };
82
+ const getBackgroundImageHeroBanner = (background, enableLazyImage = false, isNotLiquid = false)=>{
83
+ if (!background) return;
73
84
  let result = {};
74
85
  core.DEVICES.forEach((device)=>{
75
- const bg = core.getValueByDevice(background, device);
76
86
  result = {
77
87
  ...result,
78
- [device]: bg?.type === 'color' ? 'url()' : `url('${!enableLazyImage ? getSrcSet.getImageSrc(core.getResponsiveValueByScreen(srcSet, device), device, isNotLiquid) : imagePlaceholder(background)}')`
88
+ [device]: getBgImageByScreen(background, device, enableLazyImage, isNotLiquid)
79
89
  };
80
90
  });
81
91
  return core.makeStyleResponsive('bgi', result);
@@ -96,11 +106,6 @@ const getAttachmentDevice = (background)=>{
96
106
  });
97
107
  return result;
98
108
  };
99
- const bgiEnableByDevice = (background)=>({
100
- desktop: getEnableBgImageByDevice('desktop', background),
101
- tablet: getEnableBgImageByDevice('tablet', background),
102
- mobile: getEnableBgImageByDevice('mobile', background)
103
- });
104
109
  const horizontalAlign = (layout, contentPosition1Col, contentPosition2Col)=>mapContentPositionToHorizontal(getContentPosition(layout, contentPosition1Col, contentPosition2Col));
105
110
  const scrollToContentBanner = (e)=>(e?.target)?.closest('div.gp-hero-banner-row')?.scrollTo(0, 0);
106
111
  const getDataVideoHeroBannerResponsive = (nameDevice, data)=>{
@@ -379,6 +384,17 @@ const getClassSpaceBetween = (setting, contentPosition1Col, contentPosition2Col)
379
384
  'mobile:!gp-content-stretch mobile:[&>*]:!gp-justify-end': settingRes.mobile?.cols?.length === 1 && contentPositionMobile === 'bottom'
380
385
  };
381
386
  };
387
+ const getClassSpaceBetweenLeftRight = (settingLayout)=>{
388
+ const settingLayoutResponsive = getResponsiveSetting(settingLayout);
389
+ const isLayoutDistributedDesktop = settingLayoutResponsive?.desktop?.type == 'left-distributed' || settingLayoutResponsive?.desktop?.type == 'right-distributed';
390
+ const isLayoutDistributedTablet = settingLayoutResponsive?.tablet?.type == 'left-distributed' || settingLayoutResponsive?.tablet?.type == 'right-distributed';
391
+ const isLayoutDistributedMobile = settingLayoutResponsive?.mobile?.type == 'left-distributed' || settingLayoutResponsive?.mobile?.type == 'right-distributed';
392
+ return {
393
+ 'gp-h-full [&>*]:!gp-justify-between': isLayoutDistributedDesktop,
394
+ 'tablet:gp-h-full tablet:[&>*]:!gp-justify-between': isLayoutDistributedTablet,
395
+ 'mobile:gp-h-full mobile:[&>*]:!gp-justify-between': isLayoutDistributedMobile
396
+ };
397
+ };
382
398
  const getClassForStretchContent = (verticalAlign)=>{
383
399
  let result = {
384
400
  desktop: 'none',
@@ -482,7 +498,6 @@ const getBannerLink = (setting)=>{
482
498
  return link;
483
499
  };
484
500
 
485
- exports.bgiEnableByDevice = bgiEnableByDevice;
486
501
  exports.debounce = debounce;
487
502
  exports.fallbackImg = fallbackImg;
488
503
  exports.getAspectRatioSettings = getAspectRatioSettings;
@@ -495,6 +510,7 @@ exports.getClassContentPosition = getClassContentPosition;
495
510
  exports.getClassForContentByFitContent = getClassForContentByFitContent;
496
511
  exports.getClassForStretchContent = getClassForStretchContent;
497
512
  exports.getClassSpaceBetween = getClassSpaceBetween;
513
+ exports.getClassSpaceBetweenLeftRight = getClassSpaceBetweenLeftRight;
498
514
  exports.getClipPath = getClipPath;
499
515
  exports.getContentPosition = getContentPosition;
500
516
  exports.getDataVideoHeroBannerResponsive = getDataVideoHeroBannerResponsive;
@@ -46,10 +46,12 @@ const getRowClasses = (styles, setting)=>{
46
46
  const fitContentClass = common.getClassForContentByFitContent(sizeSetting, background);
47
47
  const stretchContentClass = common.getClassForStretchContent(verticalAlign);
48
48
  const layoutClass = common.getClassSpaceBetween(setting?.layout || {}, styles?.contentPosition1Col || {}, styles?.contentPosition2Col || {});
49
+ const layoutDistributedClass = common.getClassSpaceBetweenLeftRight(setting?.layout || {});
49
50
  const classList = `gp-hero-banner-row gp-transition-all gp-duration-300 group-hover/hero:gp-bg-[color:var(--hvr-bgc,_var(--bgc))] group-hover/hero:gp-opacity-[var(--hvr-op,_var(--op))] ${fitContentClass} ${stretchContentClass}`;
50
51
  return {
51
52
  ...composeClasses(classList),
52
- ...layoutClass
53
+ ...layoutClass,
54
+ ...layoutDistributedClass
53
55
  };
54
56
  };
55
57
  const getAdaptiveClasses = ()=>{
@@ -98,7 +98,6 @@ const getBackgroundStyle = (styles, enableParallax, transform)=>{
98
98
  ignoreBgAttachment: true,
99
99
  ignoreBackgroundImage: true
100
100
  }),
101
- ...core.getGradientBgrStyleByDevice(background, common.bgiEnableByDevice(background)),
102
101
  '--duration': `${hoverEffectDuration ?? 0}s`,
103
102
  '--scale': `${hoverEffectScale || 100}%`,
104
103
  ...core.makeStyleResponsive('pos', common.getAttachmentDevice(background)),
@@ -2,7 +2,7 @@
2
2
  import { jsx, jsxs } from 'react/jsx-runtime';
3
3
  import Row from '../../grid/row/Row.js';
4
4
  import { useMemo } from 'react';
5
- import { useEditorMode, getGradientBgrStyleByDevice, filterToolbarPreview, getAspectRatioGlobalSize } from '@gem-sdk/core';
5
+ import { useEditorMode, filterToolbarPreview, getAspectRatioGlobalSize } from '@gem-sdk/core';
6
6
  import { createStyle, createClass } from '@gem-sdk/system';
7
7
  import AdaptiveImage from '../../image/components/AdaptiveImage.js';
8
8
  import HTML5Embed from '../../video/components/HTML5Embed.js';
@@ -52,11 +52,6 @@ const HeroBannerItem = (props)=>{
52
52
  });
53
53
  const backgroundStyle = createStyle({
54
54
  ...getBackgroundImageHeroBanner(background, enableLazyImage, isNotLiquid),
55
- ...getGradientBgrStyleByDevice(background, {
56
- desktop: true,
57
- tablet: true,
58
- mobile: true
59
- }),
60
55
  ...getBackgroundStyle(styles, enableParallax, transform)
61
56
  });
62
57
  const containBackgroundClasses = createClass({
@@ -1,4 +1,4 @@
1
- import { getResponsiveValueByScreen, getAspectRatioGlobalSize, makeStyleResponsive, DEVICES, getValueByDevice, cls } from '@gem-sdk/core';
1
+ import { getResponsiveValueByScreen, getAspectRatioGlobalSize, makeStyleResponsive, DEVICES, getValueByDevice, GRADIENT_BGR_KEY, cls } from '@gem-sdk/core';
2
2
  import { getImageSrc } from '../../../image/helpers/getSrcSet.js';
3
3
  import { HREF_TO_SALES_PAGE } from '../../../constant.js';
4
4
  import { createBlurDataURL } from '../../../image/components/common/helpers.js';
@@ -66,14 +66,24 @@ const imagePlaceholder = (background)=>{
66
66
  mobile: createBlurDataURL(srcSet?.mobile?.width ?? srcSet?.tablet?.width ?? srcSet?.desktop?.width ?? 0, srcSet?.mobile?.height ?? srcSet?.tablet?.height ?? srcSet?.desktop?.width ?? 0)
67
67
  };
68
68
  };
69
- const getBackgroundImageHeroBanner = (background, enableLazyImage = false, isNotLiquid = false)=>{
69
+ const getBgImageByScreen = (background, device, enableLazyImage, isNotLiquid)=>{
70
+ if (!background) return '';
70
71
  const srcSet = getBgImage(background);
72
+ const backgroundByDevice = getResponsiveValueByScreen(background, device);
73
+ if (enableLazyImage && !isNotLiquid) return `url(${imagePlaceholder(background)[device]})`;
74
+ if (backgroundByDevice?.color?.includes(GRADIENT_BGR_KEY)) {
75
+ if (backgroundByDevice.type !== 'image') return `${backgroundByDevice.color}`;
76
+ return `url(${getImageSrc(getResponsiveValueByScreen(srcSet, device), device, isNotLiquid)})${backgroundByDevice?.color ? `, ${backgroundByDevice.color}` : ''}`;
77
+ }
78
+ if (backgroundByDevice?.type === 'image') return `url(${getImageSrc(getResponsiveValueByScreen(srcSet, device), device, isNotLiquid)})`;
79
+ };
80
+ const getBackgroundImageHeroBanner = (background, enableLazyImage = false, isNotLiquid = false)=>{
81
+ if (!background) return;
71
82
  let result = {};
72
83
  DEVICES.forEach((device)=>{
73
- const bg = getValueByDevice(background, device);
74
84
  result = {
75
85
  ...result,
76
- [device]: bg?.type === 'color' ? 'url()' : `url('${!enableLazyImage ? getImageSrc(getResponsiveValueByScreen(srcSet, device), device, isNotLiquid) : imagePlaceholder(background)}')`
86
+ [device]: getBgImageByScreen(background, device, enableLazyImage, isNotLiquid)
77
87
  };
78
88
  });
79
89
  return makeStyleResponsive('bgi', result);
@@ -94,11 +104,6 @@ const getAttachmentDevice = (background)=>{
94
104
  });
95
105
  return result;
96
106
  };
97
- const bgiEnableByDevice = (background)=>({
98
- desktop: getEnableBgImageByDevice('desktop', background),
99
- tablet: getEnableBgImageByDevice('tablet', background),
100
- mobile: getEnableBgImageByDevice('mobile', background)
101
- });
102
107
  const horizontalAlign = (layout, contentPosition1Col, contentPosition2Col)=>mapContentPositionToHorizontal(getContentPosition(layout, contentPosition1Col, contentPosition2Col));
103
108
  const scrollToContentBanner = (e)=>(e?.target)?.closest('div.gp-hero-banner-row')?.scrollTo(0, 0);
104
109
  const getDataVideoHeroBannerResponsive = (nameDevice, data)=>{
@@ -377,6 +382,17 @@ const getClassSpaceBetween = (setting, contentPosition1Col, contentPosition2Col)
377
382
  'mobile:!gp-content-stretch mobile:[&>*]:!gp-justify-end': settingRes.mobile?.cols?.length === 1 && contentPositionMobile === 'bottom'
378
383
  };
379
384
  };
385
+ const getClassSpaceBetweenLeftRight = (settingLayout)=>{
386
+ const settingLayoutResponsive = getResponsiveSetting(settingLayout);
387
+ const isLayoutDistributedDesktop = settingLayoutResponsive?.desktop?.type == 'left-distributed' || settingLayoutResponsive?.desktop?.type == 'right-distributed';
388
+ const isLayoutDistributedTablet = settingLayoutResponsive?.tablet?.type == 'left-distributed' || settingLayoutResponsive?.tablet?.type == 'right-distributed';
389
+ const isLayoutDistributedMobile = settingLayoutResponsive?.mobile?.type == 'left-distributed' || settingLayoutResponsive?.mobile?.type == 'right-distributed';
390
+ return {
391
+ 'gp-h-full [&>*]:!gp-justify-between': isLayoutDistributedDesktop,
392
+ 'tablet:gp-h-full tablet:[&>*]:!gp-justify-between': isLayoutDistributedTablet,
393
+ 'mobile:gp-h-full mobile:[&>*]:!gp-justify-between': isLayoutDistributedMobile
394
+ };
395
+ };
380
396
  const getClassForStretchContent = (verticalAlign)=>{
381
397
  let result = {
382
398
  desktop: 'none',
@@ -480,4 +496,4 @@ const getBannerLink = (setting)=>{
480
496
  return link;
481
497
  };
482
498
 
483
- export { bgiEnableByDevice, debounce, fallbackImg, getAspectRatioSettings, getAttachmentDevice, getBackgroundImageHeroBanner, getBannerLink, getBgImage, getClassAlignBanner, getClassContentPosition, getClassForContentByFitContent, getClassForStretchContent, getClassSpaceBetween, getClipPath, getContentPosition, getDataVideoHeroBannerResponsive, getDisplayStyleByFitContent, getEnableBgImageByDevice, getPercentageVisible, getResponsiveSetting, getStyleAspectRatioHeroBannerCustom, getStyleHeroBannerBg, getVisibilityStyle, getWidth, horizontalAlign, imagePlaceholder, isScaleImage, mapContentPositionToHorizontal, scrollToContentBanner, showVideoType };
499
+ export { debounce, fallbackImg, getAspectRatioSettings, getAttachmentDevice, getBackgroundImageHeroBanner, getBannerLink, getBgImage, getClassAlignBanner, getClassContentPosition, getClassForContentByFitContent, getClassForStretchContent, getClassSpaceBetween, getClassSpaceBetweenLeftRight, getClipPath, getContentPosition, getDataVideoHeroBannerResponsive, getDisplayStyleByFitContent, getEnableBgImageByDevice, getPercentageVisible, getResponsiveSetting, getStyleAspectRatioHeroBannerCustom, getStyleHeroBannerBg, getVisibilityStyle, getWidth, horizontalAlign, imagePlaceholder, isScaleImage, mapContentPositionToHorizontal, scrollToContentBanner, showVideoType };
@@ -1,5 +1,5 @@
1
1
  import { getGlobalColorStateClass, getValueByDevice } from '@gem-sdk/core';
2
- import { getClassAlignBanner, getResponsiveSetting, getClassContentPosition, getContentPosition, getClassForContentByFitContent, getClassForStretchContent, getClassSpaceBetween } from './common.js';
2
+ import { getClassAlignBanner, getResponsiveSetting, getClassContentPosition, getContentPosition, getClassForContentByFitContent, getClassForStretchContent, getClassSpaceBetween, getClassSpaceBetweenLeftRight } from './common.js';
3
3
 
4
4
  function composeClasses(classList) {
5
5
  return classList.split(' ').reduce((acc, item)=>{
@@ -44,10 +44,12 @@ const getRowClasses = (styles, setting)=>{
44
44
  const fitContentClass = getClassForContentByFitContent(sizeSetting, background);
45
45
  const stretchContentClass = getClassForStretchContent(verticalAlign);
46
46
  const layoutClass = getClassSpaceBetween(setting?.layout || {}, styles?.contentPosition1Col || {}, styles?.contentPosition2Col || {});
47
+ const layoutDistributedClass = getClassSpaceBetweenLeftRight(setting?.layout || {});
47
48
  const classList = `gp-hero-banner-row gp-transition-all gp-duration-300 group-hover/hero:gp-bg-[color:var(--hvr-bgc,_var(--bgc))] group-hover/hero:gp-opacity-[var(--hvr-op,_var(--op))] ${fitContentClass} ${stretchContentClass}`;
48
49
  return {
49
50
  ...composeClasses(classList),
50
- ...layoutClass
51
+ ...layoutClass,
52
+ ...layoutDistributedClass
51
53
  };
52
54
  };
53
55
  const getAdaptiveClasses = ()=>{
@@ -1,5 +1,5 @@
1
- import { makeStyleResponsive, getHeightByShapeGlobalSize, makeStyleWithDefault, getWidthByShapeGlobalSize, makeStyle, getSingleColorVariable, getRadiusStyleActiveState, getStyleShadow, getGlobalColorStateStyle, makeStyleState, getResponsiveStylePadding, getStyleBackgroundByDevice, getGradientBgrStyleByDevice } from '@gem-sdk/core';
2
- import { getVisibilityStyle, getStyleAspectRatioHeroBannerCustom, getAspectRatioSettings, getDisplayStyleByFitContent, getStyleHeroBannerBg, bgiEnableByDevice, getAttachmentDevice, getClipPath, getResponsiveSetting } from './common.js';
1
+ import { makeStyleResponsive, getHeightByShapeGlobalSize, makeStyleWithDefault, getWidthByShapeGlobalSize, makeStyle, getSingleColorVariable, getRadiusStyleActiveState, getStyleShadow, getGlobalColorStateStyle, makeStyleState, getResponsiveStylePadding, getStyleBackgroundByDevice } from '@gem-sdk/core';
2
+ import { getVisibilityStyle, getStyleAspectRatioHeroBannerCustom, getAspectRatioSettings, getDisplayStyleByFitContent, getStyleHeroBannerBg, getAttachmentDevice, getClipPath, getResponsiveSetting } from './common.js';
3
3
 
4
4
  function filterTruthyStyles(styles) {
5
5
  return Object.fromEntries(Object.entries(styles || {}).filter(([, value])=>!!value));
@@ -96,7 +96,6 @@ const getBackgroundStyle = (styles, enableParallax, transform)=>{
96
96
  ignoreBgAttachment: true,
97
97
  ignoreBackgroundImage: true
98
98
  }),
99
- ...getGradientBgrStyleByDevice(background, bgiEnableByDevice(background)),
100
99
  '--duration': `${hoverEffectDuration ?? 0}s`,
101
100
  '--scale': `${hoverEffectScale || 100}%`,
102
101
  ...makeStyleResponsive('pos', getAttachmentDevice(background)),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.724",
3
+ "version": "2.0.0-dev.725",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",
@@ -25,7 +25,7 @@
25
25
  "scan-all-text": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/scan-all-text && node ./scripts/scan-all-text"
26
26
  },
27
27
  "devDependencies": {
28
- "@gem-sdk/core": "2.0.0-dev.724",
28
+ "@gem-sdk/core": "2.0.0-dev.725",
29
29
  "@gem-sdk/styles": "2.0.0-dev.703",
30
30
  "@gem-sdk/system": "2.0.0-dev.695",
31
31
  "@types/react-transition-group": "^4.4.5",