@gem-sdk/components 2.0.0-dev.274 → 2.0.0-dev.277
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.
- package/dist/cjs/article/components/ArticleReadMore.js +2 -4
- package/dist/cjs/banner/components/HeroBannerItem.liquid.js +5 -5
- package/dist/cjs/builder.js +17 -21
- package/dist/cjs/button/components/Button.js +111 -184
- package/dist/cjs/button/components/Button.liquid.js +108 -171
- package/dist/cjs/button/components/ButtonIcon.js +17 -0
- package/dist/cjs/button/components/ButtonIcon.liquid.js +16 -0
- package/dist/cjs/button/components/ButtonLabel.js +18 -0
- package/dist/cjs/button/components/ButtonLabel.liquid.js +15 -0
- package/dist/cjs/button/components/ButtonLoadingIndicator.liquid.js +12 -0
- package/dist/cjs/button/components/common/attributes.js +15 -0
- package/dist/cjs/button/components/common/classes.js +55 -0
- package/dist/cjs/button/components/common/constants.js +26 -0
- package/dist/cjs/button/components/common/data.js +76 -0
- package/dist/cjs/button/components/common/helpers.js +131 -0
- package/dist/cjs/button/components/common/styles.js +157 -0
- package/dist/cjs/button/next.js +2 -6
- package/dist/cjs/button/setting/configs/settings.js +5 -1
- package/dist/cjs/cart/components/CheckoutNow.js +0 -2
- package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.js +70 -0
- package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.liquid.js +71 -0
- package/dist/cjs/cart/components/ShopPayButton/common/classes.js +18 -0
- package/dist/cjs/cart/components/ShopPayButton/common/helpers.js +31 -0
- package/dist/cjs/cart/components/ShopPayButton/common/styles.js +12 -0
- package/dist/cjs/cart/components/ShopPayButton/hooks/useShopPayButton.js +70 -0
- package/dist/cjs/cart/next.js +1 -1
- package/dist/cjs/coupon/components/Coupon.js +1 -3
- package/dist/cjs/dialog/setting/Dialog.js +7 -580
- package/dist/cjs/dialog/setting/configs/settings.js +325 -0
- package/dist/cjs/dialog/setting/configs/uiV1.js +288 -0
- package/dist/cjs/dialog/setting/configs/uiV2.js +258 -0
- package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +4 -4
- package/dist/cjs/form/components/submit-button/SubmitButton.js +0 -4
- package/dist/cjs/header/components/kind/basic/index.js +1 -1
- package/dist/cjs/header/components/kind/modern/index.js +1 -1
- package/dist/cjs/index.js +41 -43
- package/dist/cjs/index.liquid.js +10 -12
- package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.js +25 -0
- package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.liquid.js +23 -0
- package/dist/cjs/product/components/DynamicCheckout/common/classes.js +32 -0
- package/dist/cjs/product/components/DynamicCheckout/common/styles.js +181 -0
- package/dist/cjs/product/components/DynamicCheckout/components/Button.liquid.js +58 -0
- package/dist/cjs/product/components/DynamicCheckout.js +2 -5
- package/dist/cjs/product/components/FileUpload/components/common/index.js +2 -2
- package/dist/cjs/product/components/ProductButton.js +2 -3
- package/dist/cjs/product/components/ProductButton.liquid.js +3 -3
- package/dist/cjs/product/components/ProductDescription/common/const.js +9 -0
- package/dist/cjs/product/components/ProductDescription/common/getClasses.js +30 -0
- package/dist/cjs/product/components/ProductDescription/common/getStyle.js +81 -0
- package/dist/cjs/product/components/ProductDescription/hooks/useGpDescription.js +90 -0
- package/dist/cjs/product/components/ProductDescription/index.js +115 -0
- package/dist/cjs/product/components/ProductDescription/index.liquid.js +85 -0
- package/dist/cjs/product/components/ProductViewMore.js +2 -5
- package/dist/cjs/product/components/ProductViewMore.liquid.js +2 -2
- package/dist/cjs/product/next.js +1 -1
- package/dist/cjs/setting.js +3 -3
- package/dist/cjs/text/components/common/getClasses.js +1 -1
- package/dist/cjs/third-party/components/PushOwl.js +0 -5
- package/dist/esm/article/components/ArticleReadMore.js +1 -3
- package/dist/esm/banner/components/HeroBannerItem.liquid.js +5 -5
- package/dist/esm/builder.js +4 -8
- package/dist/esm/button/components/Button.js +113 -186
- package/dist/esm/button/components/Button.liquid.js +109 -172
- package/dist/esm/button/components/ButtonIcon.js +13 -0
- package/dist/esm/button/components/ButtonIcon.liquid.js +12 -0
- package/dist/esm/button/components/ButtonLabel.js +14 -0
- package/dist/esm/button/components/ButtonLabel.liquid.js +11 -0
- package/dist/esm/button/components/ButtonLoadingIndicator.liquid.js +8 -0
- package/dist/esm/button/components/common/attributes.js +13 -0
- package/dist/esm/button/components/common/classes.js +49 -0
- package/dist/esm/button/components/common/constants.js +24 -0
- package/dist/esm/button/components/common/data.js +74 -0
- package/dist/esm/button/components/common/helpers.js +118 -0
- package/dist/esm/button/components/common/styles.js +148 -0
- package/dist/esm/button/next.js +2 -6
- package/dist/esm/button/setting/configs/settings.js +5 -1
- package/dist/esm/cart/components/CheckoutNow.js +0 -2
- package/dist/esm/cart/components/ShopPayButton/ShopPayButton.js +66 -0
- package/dist/esm/cart/components/ShopPayButton/ShopPayButton.liquid.js +67 -0
- package/dist/esm/cart/components/ShopPayButton/common/classes.js +15 -0
- package/dist/esm/cart/components/ShopPayButton/common/helpers.js +27 -0
- package/dist/esm/cart/components/ShopPayButton/common/styles.js +10 -0
- package/dist/esm/cart/components/ShopPayButton/hooks/useShopPayButton.js +68 -0
- package/dist/esm/cart/next.js +1 -1
- package/dist/esm/coupon/components/Coupon.js +1 -3
- package/dist/esm/dialog/setting/Dialog.js +7 -580
- package/dist/esm/dialog/setting/configs/settings.js +323 -0
- package/dist/esm/dialog/setting/configs/uiV1.js +286 -0
- package/dist/esm/dialog/setting/configs/uiV2.js +256 -0
- package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +4 -4
- package/dist/esm/form/components/submit-button/SubmitButton.js +0 -4
- package/dist/esm/header/components/kind/basic/index.js +1 -1
- package/dist/esm/header/components/kind/modern/index.js +1 -1
- package/dist/esm/index.js +4 -5
- package/dist/esm/index.liquid.js +4 -5
- package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.js +21 -0
- package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.liquid.js +19 -0
- package/dist/esm/product/components/DynamicCheckout/common/classes.js +30 -0
- package/dist/esm/product/components/DynamicCheckout/common/styles.js +179 -0
- package/dist/esm/product/components/DynamicCheckout/components/Button.liquid.js +54 -0
- package/dist/esm/product/components/DynamicCheckout.js +1 -4
- package/dist/esm/product/components/FileUpload/components/common/index.js +2 -2
- package/dist/esm/product/components/ProductButton.js +1 -2
- package/dist/esm/product/components/ProductButton.liquid.js +1 -1
- package/dist/esm/product/components/ProductDescription/common/const.js +6 -0
- package/dist/esm/product/components/ProductDescription/common/getClasses.js +27 -0
- package/dist/esm/product/components/ProductDescription/common/getStyle.js +77 -0
- package/dist/esm/product/components/ProductDescription/hooks/useGpDescription.js +88 -0
- package/dist/esm/product/components/ProductDescription/index.js +111 -0
- package/dist/esm/product/components/ProductDescription/index.liquid.js +81 -0
- package/dist/esm/product/components/ProductViewMore.js +1 -4
- package/dist/esm/product/components/ProductViewMore.liquid.js +1 -1
- package/dist/esm/product/next.js +1 -1
- package/dist/esm/setting.js +3 -3
- package/dist/esm/text/components/common/getClasses.js +1 -1
- package/dist/esm/third-party/components/PushOwl.js +0 -5
- package/dist/types/index.d.ts +200 -360
- package/package.json +2 -2
- package/dist/cjs/button/components/v2/ButtonIcon.js +0 -18
- package/dist/cjs/button/components/v2/ButtonLabel.js +0 -25
- package/dist/cjs/button/components/v2/ButtonV2.js +0 -140
- package/dist/cjs/button/components/v2/ButtonV2.liquid.js +0 -181
- package/dist/cjs/button/hooks/useButtonCustomCss.js +0 -88
- package/dist/cjs/button/hooks/useButtonStyles.js +0 -93
- package/dist/cjs/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -20
- package/dist/cjs/cart/components/ShopPayButton/index.js +0 -113
- package/dist/cjs/cart/components/ShopPayButton/index.liquid.js +0 -51
- package/dist/cjs/product/components/DynamicCheckout.liquid.js +0 -250
- package/dist/cjs/product/components/ProductDescription/const.js +0 -5
- package/dist/cjs/product/components/ProductDescription.js +0 -172
- package/dist/cjs/product/components/ProductDescription.liquid.js +0 -120
- package/dist/esm/button/components/v2/ButtonIcon.js +0 -14
- package/dist/esm/button/components/v2/ButtonLabel.js +0 -21
- package/dist/esm/button/components/v2/ButtonV2.js +0 -136
- package/dist/esm/button/components/v2/ButtonV2.liquid.js +0 -177
- package/dist/esm/button/hooks/useButtonCustomCss.js +0 -84
- package/dist/esm/button/hooks/useButtonStyles.js +0 -91
- package/dist/esm/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -17
- package/dist/esm/cart/components/ShopPayButton/index.js +0 -109
- package/dist/esm/cart/components/ShopPayButton/index.liquid.js +0 -47
- package/dist/esm/product/components/DynamicCheckout.liquid.js +0 -246
- package/dist/esm/product/components/ProductDescription/const.js +0 -3
- package/dist/esm/product/components/ProductDescription.js +0 -168
- package/dist/esm/product/components/ProductDescription.liquid.js +0 -116
- /package/dist/cjs/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
- /package/dist/cjs/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
- /package/dist/esm/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
- /package/dist/esm/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const getButtonAttributes = ({ dataId, disabled, urlData, dataState, arialLabel })=>{
|
|
2
|
+
return {
|
|
3
|
+
...urlData,
|
|
4
|
+
...disabled !== undefined && {
|
|
5
|
+
disabled: disabled
|
|
6
|
+
},
|
|
7
|
+
'data-id': dataId,
|
|
8
|
+
'data-state': dataState,
|
|
9
|
+
'aria-label': arialLabel
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { getButtonAttributes };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { getGlobalColorStateClass } from '@gem-sdk/core';
|
|
2
|
+
|
|
3
|
+
const getButtonClasses = ({ uid, styles, className, shouldRenderLink })=>{
|
|
4
|
+
return {
|
|
5
|
+
...className && {
|
|
6
|
+
[className]: true
|
|
7
|
+
},
|
|
8
|
+
...uid && {
|
|
9
|
+
[uid]: true
|
|
10
|
+
},
|
|
11
|
+
'gp-text-center': shouldRenderLink,
|
|
12
|
+
'gp-max-w-full': styles?.textOverFlow || false,
|
|
13
|
+
'gp-scale-[1.1]': styles?.animation?.normal === 'grow',
|
|
14
|
+
'gp-animate-bounce': styles?.animation?.normal === 'bounce',
|
|
15
|
+
'hover:gp-scale-[1.1]': styles?.animation?.hover === 'grow',
|
|
16
|
+
'hover:gp-animate-bounce': styles?.animation?.hover === 'bounce',
|
|
17
|
+
'gp-button-base gp-group gp-relative gp-inline-flex gp-max-w-full gp-items-center gp-justify-center gp-no-underline gp-transition-colors gp-duration-300 disabled:gp-btn-disabled disabled:gp-opacity-30': true,
|
|
18
|
+
[getGlobalColorStateClass('text', styles?.textColor)]: true
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
const getButtonWrapperClasses = (wrapClassName, className, advancedCssClass)=>{
|
|
22
|
+
return {
|
|
23
|
+
[wrapClassName]: true,
|
|
24
|
+
...className?.includes('gp-button-atc') && advancedCssClass && {
|
|
25
|
+
[advancedCssClass]: true
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
const getButtonContentWrapperClasses = (setting)=>{
|
|
30
|
+
return {
|
|
31
|
+
'gp-inline-flex': true,
|
|
32
|
+
'gp-flex-row-reverse': setting?.iconAlign === 'right'
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
const getButtonLabelClasses = (styles, isEditable)=>{
|
|
36
|
+
return {
|
|
37
|
+
'gp-relative gp-flex gp-h-full gp-items-center gp-overflow-hidden gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line': true,
|
|
38
|
+
'[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]': styles?.typo?.attrs?.italic,
|
|
39
|
+
'gp-text button-text': isEditable
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const getButtonIconClasses = (label, shouldClearSpace)=>{
|
|
43
|
+
return {
|
|
44
|
+
'!gp-m-0': shouldClearSpace && !label,
|
|
45
|
+
'gp-button-icon gp-transition-colors gp-duration-300 gp-z-1 gp-inline-flex gp-shrink-0 gp-items-center gp-justify-center group-data-[state=loading]:gp-invisible [&>svg]:!gp-h-[var(--height-desktop)] [&>svg]:!gp-w-auto tablet:[&>svg]:!gp-h-[var(--height-tablet)] mobile:[&>svg]:!gp-h-[var(--height-mobile)]': true
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { getButtonClasses, getButtonContentWrapperClasses, getButtonIconClasses, getButtonLabelClasses, getButtonWrapperClasses };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const LOADING_INDICATOR = `
|
|
2
|
+
<svg
|
|
3
|
+
class="gp-invisible gp-absolute gp-h-5 gp-w-5 group-data-[state=loading]:gp-animate-spin group-data-[state=loading]:gp-visible"
|
|
4
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
5
|
+
fill="none"
|
|
6
|
+
viewBox="0 0 24 24"
|
|
7
|
+
>
|
|
8
|
+
<circle
|
|
9
|
+
class="gp-opacity-25"
|
|
10
|
+
cx="12"
|
|
11
|
+
cy="12"
|
|
12
|
+
r="10"
|
|
13
|
+
stroke="currentColor"
|
|
14
|
+
stroke-width="4"
|
|
15
|
+
></circle>
|
|
16
|
+
<path
|
|
17
|
+
class="gp-opacity-75"
|
|
18
|
+
fill="currentColor"
|
|
19
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
20
|
+
></path>
|
|
21
|
+
</svg>
|
|
22
|
+
`;
|
|
23
|
+
|
|
24
|
+
export { LOADING_INDICATOR };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { getSplitStyles, getCleanedStyles, checkIsScrollToElement, getDataState, getDataId, handleGetArialLabel, handleGetLabelToDisplay, handleCheckIsShowLabel, handleCheckIsEditableLabel, checkIsShowIcon } from './helpers.js';
|
|
2
|
+
import { getCustomCssStyles } from './styles.js';
|
|
3
|
+
|
|
4
|
+
const getData = (props)=>{
|
|
5
|
+
const { style, dataId, pageContext, styles = {}, setting = {}, builderProps, isForceValue = false } = props;
|
|
6
|
+
const { label, iconSvg, btnLink, loading, options, disabled, translate, iconVisible, shouldClearSpace } = setting;
|
|
7
|
+
const [wrapStyle, restStyle] = getSplitStyles(style);
|
|
8
|
+
const cleanedStyles = getCleanedStyles(styles, disabled);
|
|
9
|
+
const customCss = getCustomCssStyles({
|
|
10
|
+
styles,
|
|
11
|
+
uid: builderProps?.uid
|
|
12
|
+
});
|
|
13
|
+
const dataState = getDataState(loading);
|
|
14
|
+
const dataIdAttr = getDataId(builderProps?.uidInteraction, dataId, builderProps?.uid);
|
|
15
|
+
const getArialLabel = (props)=>{
|
|
16
|
+
const { isLiquid } = props ?? {};
|
|
17
|
+
return handleGetArialLabel({
|
|
18
|
+
label,
|
|
19
|
+
isLiquid
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
const getLabelToDisplay = (props)=>{
|
|
23
|
+
const { isLiquid } = props ?? {};
|
|
24
|
+
return handleGetLabelToDisplay({
|
|
25
|
+
label,
|
|
26
|
+
builderProps,
|
|
27
|
+
styles: cleanedStyles,
|
|
28
|
+
isLiquid,
|
|
29
|
+
...isLiquid && {
|
|
30
|
+
translate
|
|
31
|
+
},
|
|
32
|
+
...isLiquid && {
|
|
33
|
+
pageContext
|
|
34
|
+
},
|
|
35
|
+
...isLiquid && {
|
|
36
|
+
isForceValue
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const checkIsShowLabel = (props)=>{
|
|
41
|
+
const { isLiquid } = props ?? {};
|
|
42
|
+
const labelToDisplay = getLabelToDisplay({
|
|
43
|
+
isLiquid
|
|
44
|
+
});
|
|
45
|
+
return handleCheckIsShowLabel(labelToDisplay, shouldClearSpace);
|
|
46
|
+
};
|
|
47
|
+
const checkIsEditableLabel = (props)=>{
|
|
48
|
+
const { isLiquid, mode } = props ?? {};
|
|
49
|
+
return handleCheckIsEditableLabel({
|
|
50
|
+
options,
|
|
51
|
+
isLiquid,
|
|
52
|
+
...!isLiquid && mode && {
|
|
53
|
+
mode
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const isShowIcon = checkIsShowIcon(iconSvg, iconVisible);
|
|
58
|
+
const isScrollToElement = checkIsScrollToElement(btnLink);
|
|
59
|
+
return {
|
|
60
|
+
customCss,
|
|
61
|
+
wrapStyle,
|
|
62
|
+
restStyle,
|
|
63
|
+
dataState,
|
|
64
|
+
dataIdAttr,
|
|
65
|
+
isShowIcon,
|
|
66
|
+
isScrollToElement,
|
|
67
|
+
getArialLabel,
|
|
68
|
+
getLabelToDisplay,
|
|
69
|
+
checkIsShowLabel,
|
|
70
|
+
checkIsEditableLabel
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { getData };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { splitStyle, convertHTML } from '@gem-sdk/core';
|
|
2
|
+
import { getDynamicSourceLocales } from '../../../helpers.js';
|
|
3
|
+
import Link from '../../../link/components/Link.js';
|
|
4
|
+
|
|
5
|
+
const getCleanedStyles = (styles, disabled)=>{
|
|
6
|
+
if (!disabled) return styles;
|
|
7
|
+
const cleanedStyles = {
|
|
8
|
+
...styles
|
|
9
|
+
};
|
|
10
|
+
const states = [
|
|
11
|
+
'hover',
|
|
12
|
+
'focus'
|
|
13
|
+
];
|
|
14
|
+
const devices = [
|
|
15
|
+
'tablet',
|
|
16
|
+
'mobile',
|
|
17
|
+
'desktop'
|
|
18
|
+
];
|
|
19
|
+
devices.forEach((device)=>{
|
|
20
|
+
states.forEach((state)=>{
|
|
21
|
+
delete cleanedStyles?.backgroundColorV2?.[device]?.[state];
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
return cleanedStyles;
|
|
25
|
+
};
|
|
26
|
+
const handleGetLabelToDisplay = ({ label, styles, translate, pageContext, isForceValue, builderProps, isLiquid = false })=>{
|
|
27
|
+
const liquidLabel = isForceValue ? label : getDynamicSourceLocales({
|
|
28
|
+
translate,
|
|
29
|
+
val: label,
|
|
30
|
+
pageContext,
|
|
31
|
+
settingId: translate ?? 'label',
|
|
32
|
+
uid: builderProps?.uidTranslate ?? builderProps?.uid,
|
|
33
|
+
isCapitalize: styles?.typo?.attrs?.transform === 'capitalize'
|
|
34
|
+
});
|
|
35
|
+
return isLiquid ? liquidLabel?.toString() ?? '' : convertHTML(label);
|
|
36
|
+
};
|
|
37
|
+
const checkIsShowIcon = (iconSvg, iconVisible)=>{
|
|
38
|
+
return !!iconSvg && iconVisible;
|
|
39
|
+
};
|
|
40
|
+
const handleCheckIsShowLabel = (labelToDisplay, shouldClearSpace)=>{
|
|
41
|
+
return !!labelToDisplay || !shouldClearSpace;
|
|
42
|
+
};
|
|
43
|
+
const handleCheckIsEditableLabel = ({ mode, options, isLiquid = false })=>{
|
|
44
|
+
return isLiquid ? !options?.isCannotEditing : mode === 'edit' && !options?.isCannotEditing;
|
|
45
|
+
};
|
|
46
|
+
const checkIsScrollToElement = (btnLink)=>{
|
|
47
|
+
return btnLink?.link?.startsWith('#') && btnLink?.target === '_self';
|
|
48
|
+
};
|
|
49
|
+
const getButtonWrapper = (Wrap, isScrollToElement)=>{
|
|
50
|
+
return isScrollToElement ? 'button' : Wrap;
|
|
51
|
+
};
|
|
52
|
+
const getSplitStyles = (style)=>{
|
|
53
|
+
return splitStyle([
|
|
54
|
+
'pos',
|
|
55
|
+
'top',
|
|
56
|
+
'left',
|
|
57
|
+
'bottom',
|
|
58
|
+
'right',
|
|
59
|
+
'z'
|
|
60
|
+
], style);
|
|
61
|
+
};
|
|
62
|
+
const getDataState = (isLoading)=>{
|
|
63
|
+
return isLoading ? 'loading' : 'idle';
|
|
64
|
+
};
|
|
65
|
+
const getDataId = (uidInteraction, dataId, uid)=>{
|
|
66
|
+
return uidInteraction ?? (dataId || uid) ?? '';
|
|
67
|
+
};
|
|
68
|
+
const handleGetArialLabel = ({ label, isLiquid = false })=>{
|
|
69
|
+
return isLiquid ? label?.toString().replaceAll("'", ''').replaceAll('"', "'") ?? '' : label?.toString() ?? '';
|
|
70
|
+
};
|
|
71
|
+
const getInsertLinkData = ({ setting, htmlType, defaultTag, isLiquid = false })=>{
|
|
72
|
+
const URL_INCLUDES = [
|
|
73
|
+
'product.url'
|
|
74
|
+
];
|
|
75
|
+
const URL_START_WITH = [
|
|
76
|
+
'#',
|
|
77
|
+
'mailto:',
|
|
78
|
+
'tel:'
|
|
79
|
+
];
|
|
80
|
+
const urlHref = setting?.link ?? '';
|
|
81
|
+
const isHomePageHref = urlHref === '/';
|
|
82
|
+
const isHyperlink = setting?.link !== undefined && setting.link !== '';
|
|
83
|
+
const regexHttp = new RegExp(/^https?:\/\//i);
|
|
84
|
+
const isDomain = isHyperlink && regexHttp.test(urlHref);
|
|
85
|
+
const regexPageType = new RegExp(/^\/?(?:collections|pages|products|blogs|checkout|cart)\/?/i);
|
|
86
|
+
const isShopifyDomain = isHyperlink && !regexHttp.test(urlHref) && regexPageType.test(urlHref);
|
|
87
|
+
const isLink = ()=>{
|
|
88
|
+
if (URL_INCLUDES.find((el)=>urlHref.includes(el))) return true;
|
|
89
|
+
if (URL_START_WITH.find((el)=>urlHref.startsWith(el))) return true;
|
|
90
|
+
return false;
|
|
91
|
+
};
|
|
92
|
+
const shouldRenderLink = isDomain || isShopifyDomain || isLink() || isHomePageHref;
|
|
93
|
+
let transformedUrl = urlHref;
|
|
94
|
+
if (isLiquid && (isShopifyDomain || isHomePageHref)) {
|
|
95
|
+
transformedUrl = setting?.isTranslate ? '$locationOrigin' + urlHref : "{{ request.origin }}{{ routes.root_url | split: '/' | join: '/' }}" + urlHref;
|
|
96
|
+
}
|
|
97
|
+
const HTMLTag = shouldRenderLink ? isLiquid ? 'a' : Link : defaultTag;
|
|
98
|
+
const baseUrlData = {
|
|
99
|
+
href: transformedUrl,
|
|
100
|
+
target: setting?.target,
|
|
101
|
+
...setting?.noFollow && {
|
|
102
|
+
rel: 'nofollow'
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
const urlData = shouldRenderLink ? baseUrlData : isHyperlink ? {
|
|
106
|
+
...baseUrlData,
|
|
107
|
+
type: htmlType
|
|
108
|
+
} : {
|
|
109
|
+
type: htmlType
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
HTMLTag,
|
|
113
|
+
urlData,
|
|
114
|
+
shouldRenderLink
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
export { checkIsScrollToElement, checkIsShowIcon, getButtonWrapper, getCleanedStyles, getDataId, getDataState, getInsertLinkData, getSplitStyles, handleCheckIsEditableLabel, handleCheckIsShowLabel, handleGetArialLabel, handleGetLabelToDisplay };
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { makeStyleResponsive, getStyleShadowState, composeRadius, makeGlobalSize, makeStyleResponsiveState, composeTypographyStyle, getGlobalColorStateStyle, getStyleShadow, getStyleBackgroundImageByDevice, getGlobalColorStateResponsiveStyle, composeBorderCss, composeCornerCss, getSingleColorVariable } from '@gem-sdk/core';
|
|
2
|
+
|
|
3
|
+
const MEDIA_QUERIES = {
|
|
4
|
+
TABLET: '@media only screen and (max-width: 1024px) and (min-width: 768px)',
|
|
5
|
+
MOBILE: '@media only screen and (max-width: 767px)'
|
|
6
|
+
};
|
|
7
|
+
const getButtonWrapperStyles = (style, styles)=>({
|
|
8
|
+
...style,
|
|
9
|
+
...makeStyleResponsive('ta', styles?.align)
|
|
10
|
+
});
|
|
11
|
+
const getButtonStyles = (styles, nodePrice)=>({
|
|
12
|
+
...getSizeStyles(styles),
|
|
13
|
+
...getRadiusStyles(styles),
|
|
14
|
+
...getShadowStyles(styles),
|
|
15
|
+
...getBackgroundStyles(styles),
|
|
16
|
+
...getTypoStyles(styles, nodePrice)
|
|
17
|
+
});
|
|
18
|
+
const getButtonIconStyles = (styles, settings)=>({
|
|
19
|
+
...getIconSpacingStyle(styles, settings),
|
|
20
|
+
'--height-desktop': `${styles?.size?.desktop}`,
|
|
21
|
+
'--height-tablet': `${styles?.size?.desktop || styles?.size?.tablet}`,
|
|
22
|
+
'--height-mobile': `${styles?.size?.mobile || styles?.size?.tablet || styles?.size?.desktop}`
|
|
23
|
+
});
|
|
24
|
+
const isEnableShadowStateForDevice = (deviceStyles)=>({
|
|
25
|
+
normal: deviceStyles?.normal?.type !== 'none',
|
|
26
|
+
hover: deviceStyles?.hover?.type !== 'none'
|
|
27
|
+
});
|
|
28
|
+
const getShadowStyles = (styles)=>{
|
|
29
|
+
const { boxShadowBtnV2 } = styles || {};
|
|
30
|
+
return {
|
|
31
|
+
...getStyleShadowState(boxShadowBtnV2?.desktop, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.desktop)),
|
|
32
|
+
...getStyleShadowState(boxShadowBtnV2?.tablet, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.tablet), 'tablet'),
|
|
33
|
+
...getStyleShadowState(boxShadowBtnV2?.mobile, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.mobile), 'mobile')
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const getRadiusStyles = (styles)=>composeRadius(styles?.roundedBtnV2);
|
|
37
|
+
const getIconSpacingStyle = (styles, settings)=>{
|
|
38
|
+
const spacing = styles?.iconSpacing || {
|
|
39
|
+
desktop: '8px'
|
|
40
|
+
};
|
|
41
|
+
return settings?.iconAlign === 'left' ? makeStyleResponsive('mr', spacing) : makeStyleResponsive('ml', spacing);
|
|
42
|
+
};
|
|
43
|
+
const getSizeStyles = (styles)=>{
|
|
44
|
+
const composeGlobalSize = makeGlobalSize(styles?.globalSize);
|
|
45
|
+
return {
|
|
46
|
+
...composeGlobalSize.width,
|
|
47
|
+
...composeGlobalSize.height,
|
|
48
|
+
...composeGlobalSize.padding
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const getTypoStyles = (styles, nodePrice)=>{
|
|
52
|
+
const appendTypoStyle = {
|
|
53
|
+
...makeStyleResponsiveState('c', styles?.textColorHover),
|
|
54
|
+
...composeTypographyStyle(styles?.typo, styles?.typography)
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
...!nodePrice && appendTypoStyle,
|
|
58
|
+
...getGlobalColorStateStyle('c', styles?.textColor),
|
|
59
|
+
...getStyleShadow({
|
|
60
|
+
styleAppliedFor: 'text-shadow',
|
|
61
|
+
value: styles?.typo?.custom?.textShadow,
|
|
62
|
+
isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
const getBackgroundStyles = (styles)=>{
|
|
67
|
+
return {
|
|
68
|
+
...getStyleBackgroundImageByDevice(styles?.backgroundImage),
|
|
69
|
+
...getGlobalColorStateResponsiveStyle('bg', styles?.backgroundColorV2)
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const getCustomCssStyles = ({ styles, uid })=>{
|
|
73
|
+
if (!uid) return '';
|
|
74
|
+
const { borderBtnV2, roundedBtnV2, textColor } = styles ?? {};
|
|
75
|
+
const borderCornerStyles = {
|
|
76
|
+
desktop: generateBorderCornerStyles({
|
|
77
|
+
uid,
|
|
78
|
+
device: 'desktop',
|
|
79
|
+
borderBtn: borderBtnV2,
|
|
80
|
+
roundedBtn: roundedBtnV2
|
|
81
|
+
}),
|
|
82
|
+
tablet: generateBorderCornerStyles({
|
|
83
|
+
uid,
|
|
84
|
+
device: 'tablet',
|
|
85
|
+
borderBtn: borderBtnV2,
|
|
86
|
+
roundedBtn: roundedBtnV2
|
|
87
|
+
}),
|
|
88
|
+
mobile: generateBorderCornerStyles({
|
|
89
|
+
uid,
|
|
90
|
+
device: 'mobile',
|
|
91
|
+
borderBtn: borderBtnV2,
|
|
92
|
+
roundedBtn: roundedBtnV2
|
|
93
|
+
})
|
|
94
|
+
};
|
|
95
|
+
const colorStyles = generateColorStyles(uid, textColor);
|
|
96
|
+
return `
|
|
97
|
+
${borderCornerStyles.desktop.normalStyles}
|
|
98
|
+
${borderCornerStyles.desktop.hoverStyles}
|
|
99
|
+
|
|
100
|
+
${MEDIA_QUERIES.TABLET} {
|
|
101
|
+
${borderCornerStyles.tablet.normalStyles}
|
|
102
|
+
${borderCornerStyles.tablet.hoverStyles}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
${MEDIA_QUERIES.MOBILE} {
|
|
106
|
+
${borderCornerStyles.mobile.normalStyles}
|
|
107
|
+
${borderCornerStyles.mobile.hoverStyles}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
${colorStyles}
|
|
111
|
+
`.trim();
|
|
112
|
+
};
|
|
113
|
+
const generateBorderCornerStyles = ({ uid, device, borderBtn, roundedBtn })=>{
|
|
114
|
+
const normalStyles = `
|
|
115
|
+
.${uid}.gp-button-base::before {
|
|
116
|
+
content: "";
|
|
117
|
+
height: 100%;
|
|
118
|
+
width: 100%;
|
|
119
|
+
position: absolute;
|
|
120
|
+
pointer-events: none;
|
|
121
|
+
${composeBorderCss(borderBtn?.[device]?.normal)}
|
|
122
|
+
${composeCornerCss(roundedBtn?.[device]?.normal)}
|
|
123
|
+
}
|
|
124
|
+
`;
|
|
125
|
+
const hoverStyles = `
|
|
126
|
+
.${uid}:hover::before {
|
|
127
|
+
${composeBorderCss(borderBtn?.[device]?.hover)}
|
|
128
|
+
${composeCornerCss(roundedBtn?.[device]?.hover)}
|
|
129
|
+
}
|
|
130
|
+
`;
|
|
131
|
+
return {
|
|
132
|
+
normalStyles,
|
|
133
|
+
hoverStyles
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
const generateColorStyles = (uid, textColor)=>`
|
|
137
|
+
.${uid}:hover .gp-button-price,
|
|
138
|
+
.${uid}:hover .gp-product-dot-price {
|
|
139
|
+
color: ${getSingleColorVariable(textColor?.hover)};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.${uid} .gp-button-price,
|
|
143
|
+
.${uid} .gp-product-dot-price {
|
|
144
|
+
color: ${getSingleColorVariable(textColor?.normal)};
|
|
145
|
+
}
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
export { generateBorderCornerStyles, generateColorStyles, getButtonIconStyles, getButtonStyles, getButtonWrapperStyles, getCustomCssStyles, getRadiusStyles, getShadowStyles };
|
package/dist/esm/button/next.js
CHANGED
|
@@ -4,15 +4,11 @@ import 'react/jsx-runtime';
|
|
|
4
4
|
import 'react';
|
|
5
5
|
import '@gem-sdk/core';
|
|
6
6
|
|
|
7
|
-
const Button = dynamic(()=>import('./components/
|
|
8
|
-
loading: Loading
|
|
9
|
-
});
|
|
10
|
-
const ButtonV1 = dynamic(()=>import('./components/Button.js'), {
|
|
7
|
+
const Button = dynamic(()=>import('./components/Button.js'), {
|
|
11
8
|
loading: Loading
|
|
12
9
|
});
|
|
13
10
|
var button = {
|
|
14
|
-
Button
|
|
15
|
-
ButtonV1
|
|
11
|
+
Button
|
|
16
12
|
};
|
|
17
13
|
|
|
18
14
|
export { button as default };
|
|
@@ -42,7 +42,11 @@ const ButtonSettings = [
|
|
|
42
42
|
id: 'iconSvg',
|
|
43
43
|
label: 'SVG Icon',
|
|
44
44
|
type: 'icon',
|
|
45
|
-
default:
|
|
45
|
+
default: `
|
|
46
|
+
<svg width="100%" height="100%" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
47
|
+
<path d="M8.90239 3.29786C8.54015 2.53874 7.45959 2.53873 7.09736 3.29786L5.98572 5.62747L3.42662 5.96481C2.59271 6.07473 2.2588 7.1024 2.86883 7.68149L4.74091 9.45861L4.27093 11.9967C4.11778 12.8238 4.99198 13.4589 5.73123 13.0577L7.99987 11.8264L10.2685 13.0577C11.0078 13.4589 11.882 12.8238 11.7288 11.9967L11.2588 9.45861L13.1309 7.68149C13.7409 7.1024 13.407 6.07473 12.5731 5.96481L10.014 5.62747L8.90239 3.29786Z" fill="currentColor"/>
|
|
48
|
+
</svg>
|
|
49
|
+
`
|
|
46
50
|
},
|
|
47
51
|
{
|
|
48
52
|
id: 'iconAlign',
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { useCartData } from '@gem-sdk/core';
|
|
4
4
|
import { useRef } from 'react';
|
|
5
|
-
import 'next/head';
|
|
6
|
-
import 'next/link';
|
|
7
5
|
import Button from '../../button/components/Button.js';
|
|
8
6
|
|
|
9
7
|
const CheckoutNow = ({ setting, builderAttrs, builderProps, style, styles, className })=>{
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { createStyle, createClass, createAttr } from '@gem-sdk/system';
|
|
4
|
+
import dynamic from 'next/dynamic';
|
|
5
|
+
import { getButtonClasses, getButtonWrapperClasses } from './common/classes.js';
|
|
6
|
+
import { getSPButton } from './common/helpers.js';
|
|
7
|
+
import { getButtonWrapperStyles } from './common/styles.js';
|
|
8
|
+
import { useShopPayButton } from './hooks/useShopPayButton.js';
|
|
9
|
+
|
|
10
|
+
const DynamicCheckoutBlack = dynamic(()=>import('./icons/DynamicCheckoutBlack.js'));
|
|
11
|
+
const DynamicCheckoutPurple = dynamic(()=>import('./icons/DynamicCheckoutPurple.js'));
|
|
12
|
+
const DynamicCheckoutWhite = dynamic(()=>import('./icons/DynamicCheckoutWhite.js'));
|
|
13
|
+
const ExpressCheckoutBlack = dynamic(()=>import('./icons/ExpressCheckoutBlack.js'));
|
|
14
|
+
const ExpressCheckoutPurple = dynamic(()=>import('./icons/ExpressCheckoutPurple.js'));
|
|
15
|
+
const ExpressCheckoutWhite = dynamic(()=>import('./icons/ExpressCheckoutWhite.js'));
|
|
16
|
+
/**
|
|
17
|
+
* The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
|
|
18
|
+
*/ const ShopPayButton = ({ style, styles, setting, className, builderAttrs })=>{
|
|
19
|
+
const { variants, storeUrl, handleOnPay } = useShopPayButton(setting);
|
|
20
|
+
if (!storeUrl) {
|
|
21
|
+
return /*#__PURE__*/ jsx("div", {
|
|
22
|
+
...builderAttrs,
|
|
23
|
+
children: "URL Not Found"
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
const SPButton = getSPButton({
|
|
27
|
+
styles,
|
|
28
|
+
buttons: {
|
|
29
|
+
DynamicCheckoutBlack,
|
|
30
|
+
DynamicCheckoutPurple,
|
|
31
|
+
DynamicCheckoutWhite,
|
|
32
|
+
ExpressCheckoutBlack,
|
|
33
|
+
ExpressCheckoutPurple,
|
|
34
|
+
ExpressCheckoutWhite
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const buttonWrapperStyles = createStyle({
|
|
38
|
+
...getButtonWrapperStyles(style, styles)
|
|
39
|
+
});
|
|
40
|
+
const buttonClasses = createClass({
|
|
41
|
+
...getButtonClasses()
|
|
42
|
+
});
|
|
43
|
+
const buttonWrapperClasses = createClass({
|
|
44
|
+
...getButtonWrapperClasses(className)
|
|
45
|
+
});
|
|
46
|
+
const buttonAttributes = createAttr({
|
|
47
|
+
disabled: !variants?.length,
|
|
48
|
+
'aria-label': 'Buy with Shop Pay'
|
|
49
|
+
});
|
|
50
|
+
return /*#__PURE__*/ jsx("div", {
|
|
51
|
+
...builderAttrs,
|
|
52
|
+
style: buttonWrapperStyles,
|
|
53
|
+
className: buttonWrapperClasses,
|
|
54
|
+
children: /*#__PURE__*/ jsx("button", {
|
|
55
|
+
...buttonAttributes,
|
|
56
|
+
className: buttonClasses,
|
|
57
|
+
onClick: ()=>handleOnPay({
|
|
58
|
+
inputWidth: 600,
|
|
59
|
+
inputHeight: 600
|
|
60
|
+
}),
|
|
61
|
+
children: /*#__PURE__*/ jsx(SPButton, {})
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export { ShopPayButton as default };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { template, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
|
+
import { createStyle, createClass, createAttr, createStateOrContext, If } from '@gem-sdk/system';
|
|
3
|
+
import { getSettingPreloadData } from '../../../helpers.js';
|
|
4
|
+
import { getButtonClasses, getButtonWrapperClasses } from './common/classes.js';
|
|
5
|
+
import { getSPButton } from './common/helpers.js';
|
|
6
|
+
import { getButtonWrapperStyles } from './common/styles.js';
|
|
7
|
+
import DynamicCheckoutBlack from './icons/DynamicCheckoutBlack.liquid.js';
|
|
8
|
+
import DynamicCheckoutPurple from './icons/DynamicCheckoutPurple.liquid.js';
|
|
9
|
+
import DynamicCheckoutWhite from './icons/DynamicCheckoutWhite.liquid.js';
|
|
10
|
+
import ExpressCheckoutBlack from './icons/ExpressCheckoutBlack.liquid.js';
|
|
11
|
+
import ExpressCheckoutPurple from './icons/ExpressCheckoutPurple.liquid.js';
|
|
12
|
+
import ExpressCheckoutWhite from './icons/ExpressCheckoutWhite.liquid.js';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
|
|
16
|
+
*/ const ShopPayButton = ({ style, styles, setting, className, builderAttrs })=>{
|
|
17
|
+
const SPButton = getSPButton({
|
|
18
|
+
styles,
|
|
19
|
+
buttons: {
|
|
20
|
+
DynamicCheckoutBlack: DynamicCheckoutBlack({}),
|
|
21
|
+
DynamicCheckoutPurple: DynamicCheckoutPurple({}),
|
|
22
|
+
DynamicCheckoutWhite: DynamicCheckoutWhite({}),
|
|
23
|
+
ExpressCheckoutBlack: ExpressCheckoutBlack({}),
|
|
24
|
+
ExpressCheckoutPurple: ExpressCheckoutPurple({}),
|
|
25
|
+
ExpressCheckoutWhite: ExpressCheckoutWhite({})
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const buttonWrapperStyles = createStyle({
|
|
29
|
+
...getButtonWrapperStyles(style, styles)
|
|
30
|
+
});
|
|
31
|
+
const buttonClasses = createClass({
|
|
32
|
+
...getButtonClasses()
|
|
33
|
+
});
|
|
34
|
+
const buttonWrapperClasses = createClass({
|
|
35
|
+
...getButtonWrapperClasses(className)
|
|
36
|
+
});
|
|
37
|
+
const buttonAttributes = createAttr({
|
|
38
|
+
disabled: false,
|
|
39
|
+
'aria-label': 'Buy with Shop Pay'
|
|
40
|
+
});
|
|
41
|
+
const buttonState = createStateOrContext({
|
|
42
|
+
setting: JSON.stringify(setting),
|
|
43
|
+
shop_url: '{{shop.url}}'
|
|
44
|
+
});
|
|
45
|
+
return template`
|
|
46
|
+
<gp-shop-pay-button
|
|
47
|
+
${{
|
|
48
|
+
...builderAttrs
|
|
49
|
+
}}
|
|
50
|
+
style="${buttonWrapperStyles}"
|
|
51
|
+
class="${buttonWrapperClasses}"
|
|
52
|
+
gp-data='${buttonState}'
|
|
53
|
+
>
|
|
54
|
+
<button
|
|
55
|
+
${{
|
|
56
|
+
...buttonAttributes
|
|
57
|
+
}}
|
|
58
|
+
class="${buttonClasses}"
|
|
59
|
+
>
|
|
60
|
+
${SPButton}
|
|
61
|
+
</button>
|
|
62
|
+
</gp-shop-pay-button>
|
|
63
|
+
${If(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-shop-pay-button.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-shop-pay-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
|
|
64
|
+
`;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export { ShopPayButton as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const getButtonWrapperClasses = (className)=>{
|
|
2
|
+
return {
|
|
3
|
+
...className && {
|
|
4
|
+
[className]: true
|
|
5
|
+
},
|
|
6
|
+
'gp-flex': true
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
const getButtonClasses = ()=>{
|
|
10
|
+
return {
|
|
11
|
+
'disabled:gp-cursor-not-allowed disabled:gp-opacity-50 gp-shop-button': true
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { getButtonClasses, getButtonWrapperClasses };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const getSPButton = ({ styles, buttons })=>{
|
|
2
|
+
const { DynamicCheckoutBlack, DynamicCheckoutWhite, DynamicCheckoutPurple, ExpressCheckoutBlack, ExpressCheckoutWhite, ExpressCheckoutPurple } = buttons;
|
|
3
|
+
if (styles?.type === 'dynamic') {
|
|
4
|
+
if (styles.color === 'black') return DynamicCheckoutBlack;
|
|
5
|
+
if (styles.color === 'purple') return DynamicCheckoutPurple;
|
|
6
|
+
return DynamicCheckoutWhite;
|
|
7
|
+
} else {
|
|
8
|
+
if (styles?.color === 'black') return ExpressCheckoutBlack;
|
|
9
|
+
if (styles?.color === 'purple') return ExpressCheckoutPurple;
|
|
10
|
+
return ExpressCheckoutWhite;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const getIdFromGid = (id)=>{
|
|
14
|
+
if (!id) return;
|
|
15
|
+
return id.split('/').at(-1);
|
|
16
|
+
};
|
|
17
|
+
const getStoreUrl = (url)=>{
|
|
18
|
+
if (!url) return;
|
|
19
|
+
try {
|
|
20
|
+
const data = new URL(url);
|
|
21
|
+
return data.origin;
|
|
22
|
+
} catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { getIdFromGid, getSPButton, getStoreUrl };
|