@gem-sdk/components 2.0.0-staging.146 → 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.
|
@@ -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
|
|
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
|
-
|
|
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
|
-
</${
|
|
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
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { splitStyle, makeStyleResponsive, makeGlobalSize, composeTypographyClassName, composeTypographyStyle, composeBorderCss, composeCornerCss, getSingleColorVariable, template, cls, getGlobalColorStateClass, getGlobalColorStateStyle, composeRadius, getStyleShadowState, composeSize, getGradientBgrStyleForButton,
|
|
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
|
|
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
|
-
|
|
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
|
-
</${
|
|
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
|
};
|