@gem-sdk/components 2.0.0-dev.456 → 2.0.0-dev.458

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.
@@ -422,7 +422,8 @@ const ButtonSettings = [
422
422
  hover: 'text-3'
423
423
  }
424
424
  }
425
- }
425
+ },
426
+ enableGradient: true
426
427
  },
427
428
  {
428
429
  id: 'transform',
@@ -1,3 +1,4 @@
1
+ 'use client';
1
2
  import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
2
3
  import Head from 'next/head';
3
4
  import useCSSCode from '../hooks/useCSSCode.js';
@@ -2,14 +2,29 @@ const SettingCode = [
2
2
  {
3
3
  id: 'setting',
4
4
  controls: [
5
+ {
6
+ id: 'contentBanner',
7
+ type: 'banner',
8
+ message: `You can insert HTML, CSS, JavaScript or Liquid code <a class="no-underline text-primary-250" target="_blank" href="https://help.gempages.net/articles/custom-code-element?utm_source=element-setting-tips#custom-code">Learn more</a>`,
9
+ closable: true
10
+ },
11
+ {
12
+ id: 'name',
13
+ type: 'input',
14
+ default: 'Custom code'
15
+ },
5
16
  {
6
17
  id: 'editorData',
7
18
  type: 'customCodeEditor'
8
19
  },
20
+ {
21
+ id: 'speedParallax',
22
+ type: 'customCodeEditor'
23
+ },
9
24
  {
10
25
  id: 'background',
11
- type: 'background',
12
- label: 'Background',
26
+ type: 'background-media',
27
+ ignoreReRender: true,
13
28
  devices: {
14
29
  desktop: {
15
30
  default: {
@@ -29,6 +44,27 @@ const SettingCode = [
29
44
  attachment: 'scroll'
30
45
  }
31
46
  }
47
+ },
48
+ compoDefaultValue: {
49
+ desktop: {
50
+ default: {
51
+ type: 'color',
52
+ color: '#DDDDDD',
53
+ image: {
54
+ src: 'https://ucarecdn.com/5e27d43d-eb1e-4e71-b7e1-4158f3071bb6/-/format/auto/',
55
+ width: 1200,
56
+ height: 480
57
+ },
58
+ size: 'cover',
59
+ position: {
60
+ x: 50,
61
+ y: 50
62
+ },
63
+ repeat: 'no-repeat',
64
+ attachment: 'scroll',
65
+ preload: false
66
+ }
67
+ }
32
68
  }
33
69
  },
34
70
  {
@@ -1,20 +1,26 @@
1
1
  const SettingUIV2 = [
2
2
  {
3
- messageConfig: {
4
- type: 'info',
5
- message: 'You can insert HTML, CSS, JavaScript or Liquid code.',
6
- link: {
7
- label: 'Learn more',
8
- url: 'https://help.gempages.net/articles/custom-code-element?utm_source=element-setting-tips#custom-code'
3
+ controls: [
4
+ {
5
+ setting: {
6
+ id: 'contentBanner'
7
+ },
8
+ layout: 'vertical'
9
9
  }
10
+ ]
11
+ },
12
+ {
13
+ label: {
14
+ en: 'Custom code'
10
15
  },
11
16
  controls: [
12
17
  {
13
- type: 'control',
14
18
  setting: {
15
19
  id: 'editorData'
16
20
  },
17
- layout: 'vertical'
21
+ label: {
22
+ en: 'Code'
23
+ }
18
24
  }
19
25
  ]
20
26
  },
@@ -42,6 +48,22 @@ const SettingUIV2 = [
42
48
  }
43
49
  ]
44
50
  },
51
+ {
52
+ label: {
53
+ en: 'Configuration'
54
+ },
55
+ controls: [
56
+ {
57
+ type: 'control',
58
+ setting: {
59
+ id: 'name'
60
+ },
61
+ label: {
62
+ en: 'Name'
63
+ }
64
+ }
65
+ ]
66
+ },
45
67
  {
46
68
  controls: [
47
69
  {
@@ -1,7 +1,21 @@
1
1
  import { composeClasses, cls } from '@gem-sdk/core';
2
2
 
3
- const getActiveClasses = (backgroundColorActive, textActive)=>{
4
- return composeClasses(cls('gp-coupon', backgroundColorActive ? `[&_button]:data-[active=true]:!gp-bg-[${backgroundColorActive}]` : '', textActive ? `[&_button]:data-[active=true]:!gp-text-[${textActive}]` : ''));
3
+ const getActiveClasses = (backgroundColor, text)=>{
4
+ const breakpoints = {
5
+ desktop: '',
6
+ tablet: 'tablet:',
7
+ mobile: 'mobile:'
8
+ };
9
+ const generateClass = (type, device, value)=>value ? `${breakpoints[device]}[_&button]:data-[active=true]:!gp-${type}-[${value}]` : '';
10
+ const classes = [
11
+ generateClass('bg', 'desktop', backgroundColor?.desktop?.active),
12
+ generateClass('bg', 'tablet', backgroundColor?.tablet?.active),
13
+ generateClass('bg', 'mobile', backgroundColor?.mobile?.active),
14
+ generateClass('text', 'desktop', text?.desktop?.active),
15
+ generateClass('text', 'tablet', text?.tablet?.active),
16
+ generateClass('text', 'mobile', text?.mobile?.active)
17
+ ].filter(Boolean).join(' ');
18
+ return composeClasses(cls('gp-coupon', classes));
5
19
  };
6
20
 
7
21
  export { getActiveClasses };
@@ -1,11 +1,11 @@
1
1
  const getButtonSetting = (setting, label, htmlType)=>{
2
- const { iconSvg, iconAlign, couponLayout, translate, shouldClearSpace } = setting ?? {};
2
+ const { iconSvg, iconAlign, couponLayout, translate, shouldClearSpace, iconVisible } = setting ?? {};
3
3
  return {
4
4
  label,
5
5
  htmlType,
6
6
  iconAlign,
7
7
  iconSvg,
8
- iconVisible: couponLayout === 'icon',
8
+ iconVisible: couponLayout === 'icon' && iconVisible,
9
9
  translate,
10
10
  shouldClearSpace
11
11
  };
@@ -1,9 +1,8 @@
1
1
  import { makeStyleResponsive, composeBorderCss, composeCornerCss, getStyleShadow } from '@gem-sdk/core';
2
2
 
3
- const getButtonStyles = (styles, removedActiveShadow)=>{
3
+ const getButtonStyles = (styles)=>{
4
4
  return {
5
- ...styles,
6
- hasBoxShadowBtn: removedActiveShadow
5
+ ...styles
7
6
  };
8
7
  };
9
8
  const getButtonStyle = (style, styles)=>{
@@ -12,30 +11,50 @@ const getButtonStyle = (style, styles)=>{
12
11
  ...makeStyleResponsive('ta', styles?.align)
13
12
  };
14
13
  };
15
- const getInnerBorderCornerCss = (data)=>{
16
- const { borderActive, cornerActive, uid, styles } = data;
17
- return `
18
- .gp-coupon[data-active="true"] .${uid}::before {
19
- ${composeBorderCss(borderActive)}
20
- }
21
- .gp-coupon[data-active="true"] .${uid} {
22
- ${composeCornerCss(cornerActive, true)}
23
- }
24
- .gp-coupon[data-active="true"] .${uid} {
25
- box-shadow: ${styles?.hasBoxShadowBtn?.active ? getStyleShadow({
26
- value: styles?.boxShadowBtn?.active,
27
- state: 'active',
28
- styleAppliedFor: 'box-shadow',
29
- isEnableShadow: true
30
- })['--shadow'] : 'none'}
31
- }
32
- `;
33
- };
34
- const removedActiveShadow = (styles)=>{
14
+ const getResponsiveSetting = (setting)=>{
15
+ const desktop = setting.desktop;
16
+ const tablet = setting.tablet ? setting.tablet : desktop;
17
+ const mobile = setting.mobile ? setting.mobile : tablet;
35
18
  return {
36
- hover: styles?.hasBoxShadowBtn?.hover,
37
- normal: styles?.hasBoxShadowBtn?.normal
19
+ desktop,
20
+ tablet,
21
+ mobile
22
+ };
23
+ };
24
+ const getInnerBorderCornerCss = (data)=>{
25
+ const { uid, styles } = data;
26
+ const borderBtnV2 = getResponsiveSetting(styles?.borderBtnV2 || {});
27
+ const roundedBtnV2 = getResponsiveSetting(styles?.roundedBtnV2 || {});
28
+ const boxShadowBtnV2 = getResponsiveSetting(styles?.boxShadowBtnV2 || {});
29
+ const getShadowValue = (value)=>value ? getStyleShadow({
30
+ value,
31
+ state: 'active',
32
+ styleAppliedFor: 'box-shadow',
33
+ isEnableShadow: true
34
+ })['--shadow'] : 'none';
35
+ const breakpoints = {
36
+ desktop: '',
37
+ tablet: '@media only screen and (max-width: 1024px) and (min-width: 768px)',
38
+ mobile: '@media only screen and (max-width: 768px)'
39
+ };
40
+ const generateStyles = (device)=>{
41
+ const mediaQuery = breakpoints[device] ? `${breakpoints[device]} {` : '';
42
+ const closeMediaQuery = mediaQuery ? '}' : '';
43
+ return `
44
+ ${mediaQuery}
45
+ .gp-coupon[data-active="true"] .${uid} {
46
+ ${composeBorderCss(borderBtnV2?.[device]?.active)} !important;
47
+ ${composeCornerCss(roundedBtnV2?.[device]?.active)} !important;
48
+ box-shadow: ${getShadowValue(boxShadowBtnV2?.[device]?.active)} !important;
49
+ }
50
+ ${closeMediaQuery}
51
+ `;
38
52
  };
53
+ return [
54
+ generateStyles('desktop'),
55
+ generateStyles('tablet'),
56
+ generateStyles('mobile')
57
+ ].join('\n').trim();
39
58
  };
40
59
 
41
- export { getButtonStyle, getButtonStyles, getInnerBorderCornerCss, removedActiveShadow };
60
+ export { getButtonStyle, getButtonStyles, getInnerBorderCornerCss };
@@ -1,21 +1,18 @@
1
1
  'use client';
2
2
  import { jsxs, jsx } from 'react/jsx-runtime';
3
- import { createStyle, createClass } from '@gem-sdk/system';
3
+ import { createClass } from '@gem-sdk/system';
4
4
  import Button from '../../button/components/Button.js';
5
5
  import { getButtonSetting } from '../common/index.js';
6
- import { removedActiveShadow, getInnerBorderCornerCss, getButtonStyle, getButtonStyles } from '../common/styles.js';
6
+ import { getInnerBorderCornerCss, getButtonStyle, getButtonStyles } from '../common/styles.js';
7
7
  import useCoupon from '../hooks/useCoupon.js';
8
8
  import { getActiveClasses } from '../common/classes.js';
9
9
 
10
10
  const Coupon = ({ setting, builderProps, builderAttrs, style, styles, advanced, children })=>{
11
- const { borderBtn, roundedBtn, backgroundColor, textColor } = styles ?? {};
11
+ const { backgroundColorV2, textColorHover } = styles ?? {};
12
12
  const { mode, changeStateILP, defaultLabelState, dataActive } = useCoupon(setting);
13
- const computedRemovedActiveShadow = createStyle(removedActiveShadow(styles));
14
- const composeCouponComponentClasses = createClass(getActiveClasses(backgroundColor?.active, textColor?.active));
13
+ const composeCouponComponentClasses = createClass(getActiveClasses(backgroundColorV2, textColorHover));
15
14
  const computedInnerBorderCornerCss = getInnerBorderCornerCss({
16
15
  uid: builderProps?.uid,
17
- borderActive: borderBtn?.active,
18
- cornerActive: roundedBtn?.active,
19
16
  styles
20
17
  });
21
18
  return /*#__PURE__*/ jsxs("div", {
@@ -40,7 +37,7 @@ const Coupon = ({ setting, builderProps, builderAttrs, style, styles, advanced,
40
37
  ...getButtonStyle(style, styles)
41
38
  },
42
39
  styles: {
43
- ...getButtonStyles(styles, computedRemovedActiveShadow)
40
+ ...getButtonStyles(styles)
44
41
  },
45
42
  children: children
46
43
  })
@@ -1,26 +1,23 @@
1
1
  import { template, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
2
  import Button from '../../button/components/Button.liquid.js';
3
3
  import { getSettingPreloadData } from '../../helpers.js';
4
- import { createStyle, createStateOrContext, createClass } from '@gem-sdk/system';
4
+ import { createStateOrContext, createClass } from '@gem-sdk/system';
5
5
  import { getButtonSetting } from '../common/index.js';
6
- import { removedActiveShadow, getInnerBorderCornerCss, getButtonStyle, getButtonStyles } from '../common/styles.js';
6
+ import { getInnerBorderCornerCss, getButtonStyle, getButtonStyles } from '../common/styles.js';
7
7
  import { getActiveClasses } from '../common/classes.js';
8
8
 
9
9
  const Coupon = ({ setting, builderProps, builderAttrs, style, styles, advanced, pageContext })=>{
10
- const { backgroundColor, textColor, borderBtn, roundedBtn } = styles ?? {};
10
+ const { backgroundColorV2, textColorHover } = styles ?? {};
11
11
  const { defaultLabel, clickedLabel, copyContent } = setting ?? {};
12
- const computedRemovedActiveShadow = createStyle(removedActiveShadow(styles));
13
12
  const composeContextState = createStateOrContext({
14
13
  defaultLabel,
15
14
  clickedLabel,
16
15
  copyContent,
17
16
  uid: builderProps?.uid
18
17
  });
19
- const composeCouponComponentClasses = createClass(getActiveClasses(backgroundColor?.active, textColor?.active));
18
+ const composeCouponComponentClasses = createClass(getActiveClasses(backgroundColorV2, textColorHover));
20
19
  const computedInnerBorderCornerCss = getInnerBorderCornerCss({
21
20
  uid: builderProps?.uid,
22
- borderActive: borderBtn?.active,
23
- cornerActive: roundedBtn?.active,
24
21
  styles
25
22
  });
26
23
  const renderScript = ()=>{
@@ -36,13 +33,13 @@ const Coupon = ({ setting, builderProps, builderAttrs, style, styles, advanced,
36
33
  },
37
34
  builderAttrs: builderAttrs,
38
35
  setting: {
39
- ...getButtonSetting(setting, defaultLabel, 'submit')
36
+ ...getButtonSetting(setting, defaultLabel, 'button')
40
37
  },
41
38
  style: {
42
39
  ...getButtonStyle(style, styles)
43
40
  },
44
41
  styles: {
45
- ...getButtonStyles(styles, computedRemovedActiveShadow)
42
+ ...getButtonStyles(styles)
46
43
  },
47
44
  advanced,
48
45
  pageContext