@gem-sdk/components 2.0.0-dev.275 → 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 +4 -4
- package/dist/cjs/builder.js +4 -8
- 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/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 +3 -3
- package/dist/cjs/form/components/submit-button/SubmitButton.js +0 -4
- package/dist/cjs/index.js +2 -4
- package/dist/cjs/index.liquid.js +1 -3
- package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.js +2 -5
- package/dist/cjs/product/components/DynamicCheckout.js +2 -5
- package/dist/cjs/product/components/FileUpload/components/common/index.js +1 -1
- 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/index.liquid.js +1 -2
- package/dist/cjs/product/components/ProductViewMore.js +2 -5
- package/dist/cjs/product/components/ProductViewMore.liquid.js +2 -2
- package/dist/cjs/setting.js +2 -2
- 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 +4 -4
- package/dist/esm/builder.js +1 -5
- 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/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 +3 -3
- package/dist/esm/form/components/submit-button/SubmitButton.js +0 -4
- package/dist/esm/index.js +1 -2
- package/dist/esm/index.liquid.js +1 -2
- package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.js +1 -4
- package/dist/esm/product/components/DynamicCheckout.js +1 -4
- package/dist/esm/product/components/FileUpload/components/common/index.js +1 -1
- 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/index.liquid.js +3 -4
- package/dist/esm/product/components/ProductViewMore.js +1 -4
- package/dist/esm/product/components/ProductViewMore.liquid.js +1 -1
- package/dist/esm/setting.js +2 -2
- 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 +174 -266
- 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/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/cjs/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
- /package/dist/esm/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
|
@@ -1,192 +1,119 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useEditorMode, globalEvent } from '@gem-sdk/core';
|
|
4
|
+
import { createStyle, createClass, createAttr, If } from '@gem-sdk/system';
|
|
5
|
+
import { getButtonAttributes } from './common/attributes.js';
|
|
6
|
+
import { getButtonStyles, getButtonIconStyles, getButtonWrapperStyles } from './common/styles.js';
|
|
7
|
+
import { getButtonClasses, getButtonIconClasses, getButtonLabelClasses, getButtonWrapperClasses, getButtonContentWrapperClasses } from './common/classes.js';
|
|
8
|
+
import ButtonIcon from './ButtonIcon.js';
|
|
9
|
+
import ButtonLabel from './ButtonLabel.js';
|
|
10
|
+
import ButtonLoadingIndicator from './ButtonLoadingIndicator.js';
|
|
11
|
+
import { getData } from './common/data.js';
|
|
12
|
+
import { getInsertLinkData, getButtonWrapper } from './common/helpers.js';
|
|
6
13
|
|
|
7
|
-
const Button = (
|
|
8
|
-
const {
|
|
9
|
-
const { iconSvg, btnLink, htmlType,
|
|
10
|
-
const label = convertHTML(setting?.label);
|
|
11
|
-
const Wrap = btnLink?.link !== undefined && btnLink.link !== '' ? Link : 'button';
|
|
12
|
-
const props = btnLink?.link !== undefined && btnLink.link !== '' ? {
|
|
13
|
-
href: btnLink?.link,
|
|
14
|
-
target: btnLink?.target,
|
|
15
|
-
noFollow: btnLink?.noFollow
|
|
16
|
-
} : {
|
|
17
|
-
type: htmlType
|
|
18
|
-
};
|
|
19
|
-
const iconSpacingStyle = useMemo(()=>{
|
|
20
|
-
const spacing = iconSpacing || {
|
|
21
|
-
desktop: '8px'
|
|
22
|
-
};
|
|
23
|
-
return iconAlign === 'left' ? makeStyleResponsive('mr', spacing) : makeStyleResponsive('ml', spacing);
|
|
24
|
-
}, [
|
|
25
|
-
iconAlign,
|
|
26
|
-
iconSpacing
|
|
27
|
-
]);
|
|
28
|
-
// fix disabled still display hover color
|
|
29
|
-
if (disabled) {
|
|
30
|
-
delete backgroundColor?.hover;
|
|
31
|
-
delete backgroundColor?.focus;
|
|
32
|
-
}
|
|
14
|
+
const Button = (props)=>{
|
|
15
|
+
const { children, advanced, className, nodePrice, customAttrs, styles = {}, setting = {}, builderProps, builderAttrs, wrapClassName = '', onClick } = props;
|
|
16
|
+
const { iconSvg, btnLink, htmlType, loading, disabled, shouldClearSpace } = setting;
|
|
33
17
|
const mode = useEditorMode();
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
children
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
134
|
-
fill: "none",
|
|
135
|
-
viewBox: "0 0 24 24",
|
|
136
|
-
children: [
|
|
137
|
-
/*#__PURE__*/ jsx("circle", {
|
|
138
|
-
className: "gp-opacity-25",
|
|
139
|
-
cx: "12",
|
|
140
|
-
cy: "12",
|
|
141
|
-
r: "10",
|
|
142
|
-
stroke: "currentColor",
|
|
143
|
-
strokeWidth: "4"
|
|
144
|
-
}),
|
|
145
|
-
/*#__PURE__*/ jsx("path", {
|
|
146
|
-
className: "gp-opacity-75",
|
|
147
|
-
fill: "currentColor",
|
|
148
|
-
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"
|
|
149
|
-
})
|
|
150
|
-
]
|
|
151
|
-
}) : '',
|
|
152
|
-
/*#__PURE__*/ jsxs("div", {
|
|
153
|
-
className: cls({
|
|
154
|
-
'gp-flex-row-reverse': iconAlign === 'right'
|
|
155
|
-
}, 'gp-inline-flex'),
|
|
156
|
-
children: [
|
|
157
|
-
!!iconSvg && iconVisible && /*#__PURE__*/ jsx("span", {
|
|
158
|
-
className: `
|
|
159
|
-
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)] ${shouldClearSpace && !label ? '!gp-m-0' : ''}`,
|
|
160
|
-
style: {
|
|
161
|
-
...iconSpacingStyle,
|
|
162
|
-
'--height-desktop': `${size?.desktop}`,
|
|
163
|
-
'--height-tablet': `${size?.desktop || size?.tablet}`,
|
|
164
|
-
'--height-mobile': `${size?.mobile || size?.tablet || size?.desktop}`
|
|
165
|
-
},
|
|
166
|
-
dangerouslySetInnerHTML: {
|
|
167
|
-
__html: iconSvg
|
|
168
|
-
}
|
|
169
|
-
}),
|
|
170
|
-
(!!label || !shouldClearSpace) && /*#__PURE__*/ jsx("div", {
|
|
171
|
-
"data-gp-text": true,
|
|
172
|
-
className: cls(`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`, styles?.typo?.attrs?.italic ? '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]' : '', mode === 'edit' && !options?.isCannotEditing ? 'gp-text button-text' : '', nodePrice ? appendTypoClass : {}),
|
|
173
|
-
style: {
|
|
174
|
-
...makeStyle({
|
|
175
|
-
tt: styles?.transform
|
|
176
|
-
}),
|
|
177
|
-
...nodePrice && appendTypoStyle
|
|
178
|
-
},
|
|
179
|
-
dangerouslySetInnerHTML: {
|
|
180
|
-
__html: styles?.typo?.attrs?.transform === 'capitalize' ? label?.toString().toLocaleLowerCase() : label
|
|
181
|
-
}
|
|
182
|
-
})
|
|
183
|
-
]
|
|
184
|
-
}),
|
|
185
|
-
nodePrice && nodePrice
|
|
186
|
-
]
|
|
187
|
-
}),
|
|
188
|
-
children
|
|
189
|
-
]
|
|
18
|
+
const { customCss, wrapStyle, restStyle, dataState, dataIdAttr, isShowIcon, isScrollToElement, getArialLabel, getLabelToDisplay, checkIsShowLabel, checkIsEditableLabel } = getData(props);
|
|
19
|
+
const { HTMLTag, urlData, shouldRenderLink } = getInsertLinkData({
|
|
20
|
+
htmlType,
|
|
21
|
+
setting: btnLink,
|
|
22
|
+
defaultTag: 'button'
|
|
23
|
+
});
|
|
24
|
+
const ButtonWrapper = getButtonWrapper(HTMLTag, isScrollToElement);
|
|
25
|
+
const buttonStyles = createStyle({
|
|
26
|
+
...getButtonStyles(styles, nodePrice)
|
|
27
|
+
});
|
|
28
|
+
const buttonIconStyles = createStyle({
|
|
29
|
+
...getButtonIconStyles(styles, setting)
|
|
30
|
+
});
|
|
31
|
+
const buttonWrapperStyles = createStyle({
|
|
32
|
+
...getButtonWrapperStyles(restStyle, styles)
|
|
33
|
+
});
|
|
34
|
+
const buttonClasses = createClass({
|
|
35
|
+
...getButtonClasses({
|
|
36
|
+
styles,
|
|
37
|
+
className,
|
|
38
|
+
shouldRenderLink,
|
|
39
|
+
uid: builderProps?.uid
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
const buttonIconClasses = createClass({
|
|
43
|
+
...getButtonIconClasses(getLabelToDisplay(), shouldClearSpace)
|
|
44
|
+
});
|
|
45
|
+
const buttonLabelClasses = createClass({
|
|
46
|
+
...getButtonLabelClasses(styles, checkIsEditableLabel({
|
|
47
|
+
mode
|
|
48
|
+
}))
|
|
49
|
+
});
|
|
50
|
+
const buttonWrapperClasses = createClass({
|
|
51
|
+
...getButtonWrapperClasses(wrapClassName, className, advanced?.cssClass)
|
|
52
|
+
});
|
|
53
|
+
const buttonContentWrapperClasses = createClass({
|
|
54
|
+
...getButtonContentWrapperClasses(setting)
|
|
55
|
+
});
|
|
56
|
+
const buttonWrapperAttrs = createAttr({
|
|
57
|
+
...getButtonAttributes({
|
|
58
|
+
urlData,
|
|
59
|
+
disabled,
|
|
60
|
+
dataState,
|
|
61
|
+
dataId: dataIdAttr,
|
|
62
|
+
arialLabel: getArialLabel()
|
|
63
|
+
})
|
|
64
|
+
});
|
|
65
|
+
const handleClick = (e)=>{
|
|
66
|
+
onClick?.(e);
|
|
67
|
+
if (btnLink?.link?.startsWith('#') && mode !== 'edit') {
|
|
68
|
+
globalEvent.dispatch('onOpenDialog', {
|
|
69
|
+
popupUId: btnLink.link
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
return /*#__PURE__*/ jsx("div", {
|
|
74
|
+
style: wrapStyle,
|
|
75
|
+
children: /*#__PURE__*/ jsxs("div", {
|
|
76
|
+
...builderAttrs,
|
|
77
|
+
style: buttonWrapperStyles,
|
|
78
|
+
className: buttonWrapperClasses,
|
|
79
|
+
children: [
|
|
80
|
+
/*#__PURE__*/ jsx("style", {
|
|
81
|
+
children: customCss
|
|
82
|
+
}),
|
|
83
|
+
If(isScrollToElement, // eslint-disable-next-line jsx-a11y/anchor-has-content
|
|
84
|
+
/*#__PURE__*/ jsx("a", {
|
|
85
|
+
className: "gp-trigger-button-link gp-hidden",
|
|
86
|
+
href: urlData.href,
|
|
87
|
+
target: urlData.target
|
|
88
|
+
})),
|
|
89
|
+
/*#__PURE__*/ jsxs(ButtonWrapper, {
|
|
90
|
+
...buttonWrapperAttrs,
|
|
91
|
+
...customAttrs,
|
|
92
|
+
style: buttonStyles,
|
|
93
|
+
className: buttonClasses,
|
|
94
|
+
onClick: handleClick,
|
|
95
|
+
children: [
|
|
96
|
+
If(loading, /*#__PURE__*/ jsx(ButtonLoadingIndicator, {}), ''),
|
|
97
|
+
/*#__PURE__*/ jsxs("div", {
|
|
98
|
+
className: buttonContentWrapperClasses,
|
|
99
|
+
children: [
|
|
100
|
+
If(isShowIcon, /*#__PURE__*/ jsx(ButtonIcon, {
|
|
101
|
+
iconSvg: iconSvg ?? '',
|
|
102
|
+
styles: buttonIconStyles,
|
|
103
|
+
classes: buttonIconClasses
|
|
104
|
+
})),
|
|
105
|
+
If(checkIsShowLabel(), /*#__PURE__*/ jsx(ButtonLabel, {
|
|
106
|
+
label: getLabelToDisplay(),
|
|
107
|
+
classes: buttonLabelClasses
|
|
108
|
+
}))
|
|
109
|
+
]
|
|
110
|
+
}),
|
|
111
|
+
If(!!nodePrice, nodePrice?.toString() ?? '', '')
|
|
112
|
+
]
|
|
113
|
+
}),
|
|
114
|
+
children
|
|
115
|
+
]
|
|
116
|
+
})
|
|
190
117
|
});
|
|
191
118
|
};
|
|
192
119
|
|
|
@@ -1,182 +1,119 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { template, dataStringify, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
|
+
import { createStyle, createClass, createAttr, createStateOrContext, Liquid, If } from '@gem-sdk/system';
|
|
3
|
+
import { getButtonAttributes } from './common/attributes.js';
|
|
4
|
+
import { getButtonStyles, getButtonIconStyles, getButtonWrapperStyles } from './common/styles.js';
|
|
5
|
+
import { getButtonClasses, getButtonIconClasses, getButtonLabelClasses, getButtonWrapperClasses, getButtonContentWrapperClasses } from './common/classes.js';
|
|
6
|
+
import { getSettingPreloadData } from '../../helpers.js';
|
|
7
|
+
import ButtonIcon from './ButtonIcon.liquid.js';
|
|
8
|
+
import ButtonLabel from './ButtonLabel.liquid.js';
|
|
9
|
+
import ButtonLoadingIndicator from './ButtonLoadingIndicator.liquid.js';
|
|
10
|
+
import { getData } from './common/data.js';
|
|
11
|
+
import { getInsertLinkData, getButtonWrapper } from './common/helpers.js';
|
|
3
12
|
|
|
4
|
-
const Button = (
|
|
5
|
-
const {
|
|
6
|
-
const {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
${composeBorderCss(styles?.borderBtn?.normal)}
|
|
37
|
-
${composeCornerCss(styles?.roundedBtn?.normal)}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
.${builderProps?.uid}:hover::before {
|
|
41
|
-
${composeBorderCss(styles?.borderBtn?.hover)}
|
|
42
|
-
${composeCornerCss(styles?.roundedBtn?.hover)}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.${builderProps?.uid}:hover .gp-button-icon {
|
|
46
|
-
color: ${getSingleColorVariable(styles?.textColor?.hover)};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.${builderProps?.uid} .gp-button-icon {
|
|
50
|
-
color: ${getSingleColorVariable(styles?.textColor?.normal)};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
.${builderProps?.uid}:hover .gp-button-price {
|
|
54
|
-
color: ${getSingleColorVariable(styles?.textColor?.hover)};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.${builderProps?.uid} .gp-button-price {
|
|
58
|
-
color: ${getSingleColorVariable(styles?.textColor?.normal)};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.${builderProps?.uid} .gp-product-dot-price {
|
|
62
|
-
color: ${getSingleColorVariable(styles?.textColor?.normal)};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.${builderProps?.uid}:hover .gp-product-dot-price {
|
|
66
|
-
color: ${getSingleColorVariable(styles?.textColor?.hover)};
|
|
67
|
-
}
|
|
68
|
-
`;
|
|
69
|
-
const labelValDisplay = isForceValue ? label : getDynamicSourceLocales({
|
|
70
|
-
val: label,
|
|
71
|
-
uid: builderProps?.uidTranslate ?? builderProps?.uid,
|
|
72
|
-
settingId: translate ?? 'label',
|
|
73
|
-
pageContext,
|
|
74
|
-
isCapitalize: styles?.typo?.attrs?.transform === 'capitalize',
|
|
75
|
-
translate
|
|
13
|
+
const Button = (props)=>{
|
|
14
|
+
const { advanced, className, nodePrice, customAttrs, styles = {}, setting = {}, builderProps, wrapClassName = '' } = props;
|
|
15
|
+
const { iconSvg, loading, btnLink, htmlType, disabled, shouldClearSpace } = setting;
|
|
16
|
+
const { customCss, wrapStyle, restStyle, dataState, dataIdAttr, isShowIcon, isScrollToElement, getArialLabel, getLabelToDisplay, checkIsShowLabel, checkIsEditableLabel } = getData(props);
|
|
17
|
+
const { HTMLTag, urlData, shouldRenderLink } = getInsertLinkData({
|
|
18
|
+
htmlType,
|
|
19
|
+
setting: btnLink,
|
|
20
|
+
defaultTag: 'button',
|
|
21
|
+
isLiquid: true
|
|
22
|
+
});
|
|
23
|
+
const ButtonWrapper = getButtonWrapper(HTMLTag, isScrollToElement);
|
|
24
|
+
const buttonStyles = createStyle({
|
|
25
|
+
...getButtonStyles(styles, nodePrice)
|
|
26
|
+
});
|
|
27
|
+
const buttonIconStyles = createStyle({
|
|
28
|
+
...getButtonIconStyles(styles, setting)
|
|
29
|
+
});
|
|
30
|
+
const buttonWrapperStyles = createStyle({
|
|
31
|
+
...getButtonWrapperStyles(restStyle, styles)
|
|
32
|
+
});
|
|
33
|
+
const buttonClasses = createClass({
|
|
34
|
+
...getButtonClasses({
|
|
35
|
+
styles,
|
|
36
|
+
className,
|
|
37
|
+
shouldRenderLink,
|
|
38
|
+
uid: builderProps?.uid
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
const buttonIconClasses = createClass({
|
|
42
|
+
...getButtonIconClasses(getLabelToDisplay({
|
|
43
|
+
isLiquid: true
|
|
44
|
+
}), shouldClearSpace)
|
|
76
45
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
...
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
46
|
+
const buttonLabelClasses = createClass({
|
|
47
|
+
...getButtonLabelClasses(styles, checkIsEditableLabel({
|
|
48
|
+
isLiquid: true
|
|
49
|
+
}))
|
|
50
|
+
});
|
|
51
|
+
const buttonWrapperClasses = createClass({
|
|
52
|
+
...getButtonWrapperClasses(wrapClassName, className, advanced?.cssClass)
|
|
53
|
+
});
|
|
54
|
+
const buttonContentWrapperClasses = createClass({
|
|
55
|
+
...getButtonContentWrapperClasses(setting)
|
|
56
|
+
});
|
|
57
|
+
const buttonWrapperAttrs = createAttr({
|
|
58
|
+
...getButtonAttributes({
|
|
59
|
+
urlData,
|
|
60
|
+
disabled,
|
|
61
|
+
dataState,
|
|
62
|
+
dataId: dataIdAttr,
|
|
63
|
+
arialLabel: getArialLabel({
|
|
64
|
+
isLiquid: true
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
});
|
|
68
|
+
const buttonState = createStateOrContext({
|
|
69
|
+
btnLink: setting?.btnLink
|
|
70
|
+
});
|
|
71
|
+
return Liquid(template`
|
|
72
|
+
<gp-button
|
|
73
|
+
gp-data='${dataStringify(buttonState)}'
|
|
74
|
+
style="${{
|
|
75
|
+
wrapStyle
|
|
76
|
+
}}"
|
|
77
|
+
>
|
|
78
|
+
<div style="${buttonWrapperStyles}" class="${buttonWrapperClasses}">
|
|
79
|
+
<style>${customCss}</style>
|
|
80
|
+
${If(isScrollToElement, `<a
|
|
81
|
+
class="gp-trigger-button-link gp-hidden"
|
|
82
|
+
href=${urlData.href}
|
|
83
|
+
target=${urlData.target}
|
|
84
|
+
></a>`)}
|
|
85
|
+
<${ButtonWrapper}
|
|
86
|
+
${{
|
|
87
|
+
...buttonWrapperAttrs
|
|
97
88
|
}}
|
|
98
|
-
|
|
89
|
+
${{
|
|
99
90
|
...customAttrs
|
|
100
91
|
}}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
'gp-animate-bounce': styles?.animation?.normal === 'bounce',
|
|
104
|
-
'hover:gp-animate-bounce': styles?.animation?.hover === 'bounce',
|
|
105
|
-
'gp-scale-[1.1]': styles?.animation?.normal === 'grow',
|
|
106
|
-
'hover:gp-scale-[1.1]': styles?.animation?.hover === 'grow',
|
|
107
|
-
'gp-text-center': shouldRenderLink
|
|
108
|
-
}, className, className?.includes('gp-button-atc') && advanced ? advanced?.cssClass : '', !nodePrice ? appendTypoClass : {})}"
|
|
109
|
-
style="${{
|
|
110
|
-
...getGlobalColorStateStyle('bg', backgroundColor),
|
|
111
|
-
...composeRadius(roundedBtn),
|
|
112
|
-
...getStyleShadowState(styles?.boxShadowBtn, 'box-shadow', {
|
|
113
|
-
normal: styles?.boxShadowBtn?.normal?.type !== 'none',
|
|
114
|
-
hover: styles?.boxShadowBtn?.hover?.type !== 'none'
|
|
115
|
-
}),
|
|
116
|
-
...!styles?.btnSpacing?.type ? composeSize(styles?.btnSpacing?.custom) : {},
|
|
117
|
-
...composeGlobalSize.width,
|
|
118
|
-
...composeGlobalSize.height,
|
|
119
|
-
...composeGlobalSize.padding,
|
|
120
|
-
...getGradientBgrStyleForButton(backgroundColor),
|
|
121
|
-
...getGlobalColorStateStyle('c', textColor),
|
|
122
|
-
'--size': appendTypoStyle['--size'],
|
|
123
|
-
'--size-tablet': appendTypoStyle['--size-tablet'],
|
|
124
|
-
'--size-mobile': appendTypoStyle['--size-mobile'],
|
|
125
|
-
...!nodePrice ? appendTypoStyle : {}
|
|
126
|
-
}}"
|
|
127
|
-
>
|
|
128
|
-
${!disabledLoading ? ` <svg
|
|
129
|
-
class="gp-invisible gp-absolute gp-h-5 gp-w-5 group-data-[state=loading]:gp-animate-spin group-data-[state=loading]:gp-visible"
|
|
130
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
131
|
-
fill="none"
|
|
132
|
-
viewBox="0 0 24 24"
|
|
92
|
+
style="${buttonStyles}"
|
|
93
|
+
class="${buttonClasses}"
|
|
133
94
|
>
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
${RenderIf(!!iconSvg && iconVisible, template`<span
|
|
153
|
-
class="${`gp-inline-flex gp-button-icon gp-transition-colors gp-duration-300 gp-shrink-0 gp-items-center gp-justify-center group-data-[state=loading]:gp-invisible gp-z-1 [&>svg]:!gp-h-[var(--height-desktop)] [&>svg]:!gp-w-auto tablet:[&>svg]:!gp-h-[var(--height-tablet)] mobile:[&>svg]:!gp-h-[var(--height-mobile)]`}"
|
|
154
|
-
style="${{
|
|
155
|
-
...label ? iconSpacingStyle : {},
|
|
156
|
-
'--height-desktop': `${size?.desktop}`,
|
|
157
|
-
'--height-tablet': `${size?.desktop ?? size?.tablet}`,
|
|
158
|
-
'--height-mobile': `${size?.mobile ?? size?.tablet ?? size?.desktop}`
|
|
159
|
-
}}"
|
|
160
|
-
>${iconSvg}</span>`)}
|
|
161
|
-
<span
|
|
162
|
-
data-gp-text
|
|
163
|
-
class="${`gp-content-product-button gp-button-text-only gp-break-words group-data-[state=loading]:gp-invisible [&_p]:gp-whitespace-pre-line gp-z-1 gp-h-full gp-flex gp-items-center gp-overflow-hidden ${nodePrice ? appendTypoClass : ''}
|
|
164
|
-
${styles?.typo?.attrs?.italic ? '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]' : ''}`}"
|
|
165
|
-
style="${{
|
|
166
|
-
...nodePrice && appendTypoStyle,
|
|
167
|
-
'--size': appendTypoStyle['--size'],
|
|
168
|
-
'--size-tablet': appendTypoStyle['--size-tablet'],
|
|
169
|
-
'--size-mobile': appendTypoStyle['--size-mobile']
|
|
170
|
-
}}"
|
|
171
|
-
>
|
|
172
|
-
${labelValDisplay}
|
|
173
|
-
</span>
|
|
95
|
+
${If(loading, ButtonLoadingIndicator, '')}
|
|
96
|
+
<div class="${buttonContentWrapperClasses}">
|
|
97
|
+
${If(isShowIcon, ButtonIcon({
|
|
98
|
+
iconSvg: iconSvg ?? '',
|
|
99
|
+
styles: buttonIconStyles,
|
|
100
|
+
classes: buttonIconClasses
|
|
101
|
+
}))}
|
|
102
|
+
${If(checkIsShowLabel({
|
|
103
|
+
isLiquid: true
|
|
104
|
+
}), ButtonLabel({
|
|
105
|
+
label: getLabelToDisplay({
|
|
106
|
+
isLiquid: true
|
|
107
|
+
}),
|
|
108
|
+
classes: buttonLabelClasses
|
|
109
|
+
}))}
|
|
110
|
+
</div>
|
|
111
|
+
${If(!!nodePrice, nodePrice?.toString() ?? '', '')}
|
|
112
|
+
</${ButtonWrapper}>
|
|
174
113
|
</div>
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
</gp-button>
|
|
179
|
-
`;
|
|
114
|
+
${If(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>`)}
|
|
115
|
+
</gp-button>
|
|
116
|
+
`);
|
|
180
117
|
};
|
|
181
118
|
|
|
182
119
|
export { Button as default };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
const ButtonIcon = ({ iconSvg, classes, styles })=>{
|
|
4
|
+
return /*#__PURE__*/ jsx("span", {
|
|
5
|
+
className: classes,
|
|
6
|
+
style: styles,
|
|
7
|
+
dangerouslySetInnerHTML: {
|
|
8
|
+
__html: iconSvg
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { ButtonIcon as default };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import 'react';
|
|
3
|
+
|
|
4
|
+
const ButtonLabel = ({ label, classes })=>{
|
|
5
|
+
return /*#__PURE__*/ jsx("div", {
|
|
6
|
+
"data-gp-text": true,
|
|
7
|
+
className: classes,
|
|
8
|
+
dangerouslySetInnerHTML: {
|
|
9
|
+
__html: label
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { ButtonLabel as default };
|