@gem-sdk/components 2.0.0-dev.470 → 2.0.0-dev.472

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.
@@ -1,7 +1,8 @@
1
- import { template, RenderIf, getStyleBackgroundByDevice, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
1
+ import { template, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
2
  import { getSettingPreloadData } from '../../helpers.js';
3
- import { createStyle, createStateOrContext } from '@gem-sdk/system';
4
- import { getContainerStyles, filterStyles } from './common/styles.js';
3
+ import { createStyle, createClass, createStateOrContext } from '@gem-sdk/system';
4
+ import { getContainerStyles, getContentStyles } from './common/styles.js';
5
+ import { getContainerClasses } from './common/classes.js';
5
6
 
6
7
  const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced })=>{
7
8
  const { width, position, display, preloadBgImage, background, isScrollToTop } = setting ?? {};
@@ -12,6 +13,17 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced
12
13
  style,
13
14
  display
14
15
  }));
16
+ const computedContentStyles = createStyle(getContentStyles({
17
+ width,
18
+ style,
19
+ background
20
+ }));
21
+ const computedContainerClasses = createClass(getContainerClasses({
22
+ uid: builderProps?.uid,
23
+ isScrollToTop,
24
+ cssClass: advanced?.cssClass,
25
+ isLiquid: true
26
+ }));
15
27
  const createDataState = createStateOrContext({
16
28
  uid: builderProps?.uid,
17
29
  setting: {
@@ -28,14 +40,13 @@ const Sticky = ({ children, builderAttrs, setting, style, builderProps, advanced
28
40
  gp-data='${JSON.stringify(createDataState)}'
29
41
  id="${builderProps?.uid}"
30
42
  data-id="${builderProps?.uid}"
31
- class="${builderProps?.uid} ${getSettingPreloadData('gps-lazy')} ${advanced?.cssClass} ${isScrollToTop ? '!gp-pointer-events-none [&_gp-button_a]:!gp-pointer-events-auto' : ''}"
43
+ class="${computedContainerClasses} ${getSettingPreloadData('gps-lazy')}"
32
44
  style="${computedContainerStyles}"
33
45
  >
34
46
  <div ${{
35
47
  ...builderAttrs
36
48
  }} style="${{
37
- ...filterStyles(style),
38
- ...getStyleBackgroundByDevice(background)
49
+ ...computedContentStyles
39
50
  }}">
40
51
  ${children}
41
52
  </div>
@@ -0,0 +1,9 @@
1
+ import { composeClasses } from '@gem-sdk/core';
2
+
3
+ const getContainerClasses = (args)=>{
4
+ const { uid, isScrollToTop, cssClass, isLiquid } = args;
5
+ const extraClass = isScrollToTop && isLiquid ? '!gp-pointer-events-none [&_gp-button_a]:!gp-pointer-events-auto' : '';
6
+ return composeClasses(`sticky-wrapper gp-w-full ${extraClass} ${uid} ${cssClass}`);
7
+ };
8
+
9
+ export { getContainerClasses };
@@ -1,21 +1,8 @@
1
- import { makeStyleResponsive } from '@gem-sdk/core';
1
+ import { makeStyle, makeStyleResponsive, getGradientBgrStyleByDevice, getStyleBackgroundByDevice } from '@gem-sdk/core';
2
2
  import 'react/jsx-runtime';
3
3
  import 'react';
4
4
  import { ELEMENT_Z_INDEX } from '../../../common/const.js';
5
5
 
6
- const getCSSAlignByDevice = (position, device)=>{
7
- return {
8
- [`--left${device}`]: position == 'top' ? '0' : '50%',
9
- [`--t${device}`]: position == 'top' ? 'unset' : 'translateX(-50%)'
10
- };
11
- };
12
- const getCSSAlign = (position)=>{
13
- return {
14
- ...getCSSAlignByDevice(position?.desktop, ''),
15
- ...getCSSAlignByDevice(position?.tablet ?? position?.desktop, '-tablet'),
16
- ...getCSSAlignByDevice(position?.mobile ?? position?.desktop, '-mobile')
17
- };
18
- };
19
6
  const getDisplayStyle = (device, display, position)=>{
20
7
  const style = {
21
8
  [`--top${device}`]: 'auto',
@@ -36,16 +23,26 @@ const displayConditionStyle = (display, position)=>{
36
23
  };
37
24
  };
38
25
  const getContainerStyles = (args)=>{
39
- const { style, width, position, display } = args;
26
+ const { style, position, display } = args;
40
27
  return {
41
28
  margin: '0 auto',
42
29
  ...getStylePadding(style),
43
- ...makeStyleResponsive('w', width),
44
30
  ...displayConditionStyle(display, position),
45
- ...getCSSAlign(position),
46
31
  'z-index': ELEMENT_Z_INDEX.STICKY
47
32
  };
48
33
  };
34
+ const getContentStyles = (args)=>{
35
+ const { style, width, background } = args;
36
+ return {
37
+ ...makeStyle({
38
+ m: '0 auto'
39
+ }),
40
+ ...makeStyleResponsive('w', width),
41
+ ...filterStyles(style),
42
+ ...getGradientBgrStyleByDevice(background),
43
+ ...getStyleBackgroundByDevice(background)
44
+ };
45
+ };
49
46
  const getStylePadding = (style)=>{
50
47
  const keepList = [
51
48
  '--pt',
@@ -93,4 +90,4 @@ const filterStyles = (style)=>{
93
90
  return cloneStyle;
94
91
  };
95
92
 
96
- export { displayConditionStyle, filterStyles, getContainerStyles, getDisplayStyle, getStylePadding };
93
+ export { displayConditionStyle, filterStyles, getContainerStyles, getContentStyles, getDisplayStyle, getStylePadding };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-dev.470",
3
+ "version": "2.0.0-dev.472",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",