@gem-sdk/components 2.0.0-staging.145 → 2.0.0-staging.147

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.
@@ -257,7 +257,7 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
257
257
  </div>
258
258
  `;
259
259
  };
260
- helpers.getInsertLinkData('', link);
260
+ const { urlData } = helpers.getInsertLinkData('', link);
261
261
  return core.template`
262
262
  <div class="${core.cls('gp-flex gp-w-full', common.getClassJustify(alignBannerData))}" style="${{
263
263
  ...styleHeight,
@@ -266,6 +266,8 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
266
266
  }}">
267
267
  <gp-hero-banner
268
268
  gp-data='${core.dataStringify({
269
+ href: urlData?.href ?? '',
270
+ target: urlData?.target ?? '_blank',
269
271
  background: backgroundResponsive,
270
272
  uid: builderProps?.uid,
271
273
  enableParallax,
@@ -290,7 +292,6 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
290
292
  }}"
291
293
  data-id="${builderProps?.uid}"
292
294
  >
293
-
294
295
  ${core.RenderIf(!link?.link, renderInnerHeroBanner())}
295
296
  ${core.RenderIf(!!link?.link, core.template /* liquid */ `
296
297
  <div
@@ -78,10 +78,16 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
78
78
  isCapitalize: styles?.typo?.attrs?.transform === 'capitalize',
79
79
  translate
80
80
  });
81
+ const isScrollToElement = ()=>{
82
+ return btnLink?.link?.startsWith('#') && btnLink?.target === '_self';
83
+ };
84
+ const WrapLink = isScrollToElement() ? 'button' : Wrap;
81
85
  return core.template`
82
- <gp-button style="${{
86
+ <gp-button gp-data='${core.dataStringify({
87
+ btnLink: setting?.btnLink
88
+ })}" style="${{
83
89
  ...wrapStyle
84
- }}">
90
+ }}'>
85
91
  <div
86
92
  style="${{
87
93
  ...restStyle,
@@ -90,7 +96,8 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
90
96
  class="${core.cls(wrapClassName, className?.includes('gp-button-atc') ? '' : advanced?.cssClass)}"
91
97
  >
92
98
  <style>${innerBorderCss}</style>
93
- <${Wrap}
99
+ ${core.RenderIf(isScrollToElement(), `<a class="gp-trigger-button-link gp-hidden" href=${urlData.href} target=${urlData.target} ></a>`)}
100
+ <${WrapLink}
94
101
  ${{
95
102
  ...urlData,
96
103
  'data-id': builderProps?.uidInteraction ?? (dataId || builderProps?.uid),
@@ -174,8 +181,9 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
174
181
  </span>
175
182
  </div>
176
183
  ${nodePrice ? nodePrice : ''}
177
- </${Wrap}>
184
+ </${WrapLink}>
178
185
  </div>
186
+ ${core.RenderIf(core.isLocalEnv, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-button.js' | asset_url }}" defer="defer"></script>`, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="${core.baseAssetURL}/assets-v2/gp-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
179
187
  </gp-button>
180
188
  `;
181
189
  };
@@ -253,7 +253,7 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
253
253
  </div>
254
254
  `;
255
255
  };
256
- getInsertLinkData('', link);
256
+ const { urlData } = getInsertLinkData('', link);
257
257
  return template`
258
258
  <div class="${cls('gp-flex gp-w-full', getClassJustify(alignBannerData))}" style="${{
259
259
  ...styleHeight,
@@ -262,6 +262,8 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
262
262
  }}">
263
263
  <gp-hero-banner
264
264
  gp-data='${dataStringify({
265
+ href: urlData?.href ?? '',
266
+ target: urlData?.target ?? '_blank',
265
267
  background: backgroundResponsive,
266
268
  uid: builderProps?.uid,
267
269
  enableParallax,
@@ -286,7 +288,6 @@ const HeroBanner = ({ builderAttrs, builderProps, setting, styles, style, childr
286
288
  }}"
287
289
  data-id="${builderProps?.uid}"
288
290
  >
289
-
290
291
  ${RenderIf(!link?.link, renderInnerHeroBanner())}
291
292
  ${RenderIf(!!link?.link, template /* liquid */ `
292
293
  <div
@@ -1,5 +1,5 @@
1
- import { splitStyle, makeStyleResponsive, makeGlobalSize, composeTypographyClassName, composeTypographyStyle, composeBorderCss, composeCornerCss, getSingleColorVariable, template, cls, getGlobalColorStateClass, getGlobalColorStateStyle, composeRadius, getStyleShadowState, composeSize, getGradientBgrStyleForButton, RenderIf } from '@gem-sdk/core';
2
- import { getInsertLinkData, getDynamicSourceLocales } from '../../helpers.js';
1
+ import { splitStyle, makeStyleResponsive, makeGlobalSize, composeTypographyClassName, composeTypographyStyle, composeBorderCss, composeCornerCss, getSingleColorVariable, template, dataStringify, cls, RenderIf, getGlobalColorStateClass, getGlobalColorStateStyle, composeRadius, getStyleShadowState, composeSize, getGradientBgrStyleForButton, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import { getInsertLinkData, getDynamicSourceLocales, getSettingPreloadData } from '../../helpers.js';
3
3
 
4
4
  const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isForceValue = false })=>{
5
5
  const { align, size, backgroundColor, textColor, roundedBtn, iconSpacing, globalSize } = styles;
@@ -74,10 +74,16 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
74
74
  isCapitalize: styles?.typo?.attrs?.transform === 'capitalize',
75
75
  translate
76
76
  });
77
+ const isScrollToElement = ()=>{
78
+ return btnLink?.link?.startsWith('#') && btnLink?.target === '_self';
79
+ };
80
+ const WrapLink = isScrollToElement() ? 'button' : Wrap;
77
81
  return template`
78
- <gp-button style="${{
82
+ <gp-button gp-data='${dataStringify({
83
+ btnLink: setting?.btnLink
84
+ })}" style="${{
79
85
  ...wrapStyle
80
- }}">
86
+ }}'>
81
87
  <div
82
88
  style="${{
83
89
  ...restStyle,
@@ -86,7 +92,8 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
86
92
  class="${cls(wrapClassName, className?.includes('gp-button-atc') ? '' : advanced?.cssClass)}"
87
93
  >
88
94
  <style>${innerBorderCss}</style>
89
- <${Wrap}
95
+ ${RenderIf(isScrollToElement(), `<a class="gp-trigger-button-link gp-hidden" href=${urlData.href} target=${urlData.target} ></a>`)}
96
+ <${WrapLink}
90
97
  ${{
91
98
  ...urlData,
92
99
  'data-id': builderProps?.uidInteraction ?? (dataId || builderProps?.uid),
@@ -170,8 +177,9 @@ const Button = ({ className, builderProps, customAttrs, pageContext, setting = {
170
177
  </span>
171
178
  </div>
172
179
  ${nodePrice ? nodePrice : ''}
173
- </${Wrap}>
180
+ </${WrapLink}>
174
181
  </div>
182
+ ${RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-button.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
175
183
  </gp-button>
176
184
  `;
177
185
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "2.0.0-staging.145",
3
+ "version": "2.0.0-staging.147",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",