@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
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@gem-sdk/core');
|
|
6
|
-
var helpers = require('../../helpers.js');
|
|
7
|
-
var common = require('./ProductDescription/common.js');
|
|
8
|
-
|
|
9
|
-
const devices = [
|
|
10
|
-
'desktop',
|
|
11
|
-
'mobile',
|
|
12
|
-
'tablet'
|
|
13
|
-
];
|
|
14
|
-
const getDisplayStyle = (fnCondition, defaultValue)=>{
|
|
15
|
-
let result = {};
|
|
16
|
-
devices.forEach((device)=>{
|
|
17
|
-
result = {
|
|
18
|
-
...result,
|
|
19
|
-
[`--d${device === 'desktop' ? '' : `-${device}`}`]: `${fnCondition(device) ? 'none' : defaultValue}`
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
return result;
|
|
23
|
-
};
|
|
24
|
-
const ProductDescription = ({ setting, advanced, builderProps })=>{
|
|
25
|
-
const { htmlTag } = setting ?? {};
|
|
26
|
-
const appendTypoClass = core.composeTypographyClassName(setting?.typo, setting?.typography);
|
|
27
|
-
const appendTypoStyle = core.composeTypographyStyle(setting?.typo, setting?.typography);
|
|
28
|
-
const defaultStyle = {
|
|
29
|
-
...core.getStyleShadow({
|
|
30
|
-
value: setting?.typo?.custom?.textShadow,
|
|
31
|
-
styleAppliedFor: 'text-shadow',
|
|
32
|
-
isEnableShadow: setting?.typo?.custom?.textShadow?.type !== 'none'
|
|
33
|
-
}),
|
|
34
|
-
...core.makeStyleResponsive('ta', setting?.textAlign),
|
|
35
|
-
...core.getGlobalColorStyle(setting?.color),
|
|
36
|
-
...core.makeStyle({
|
|
37
|
-
tt: setting?.transform
|
|
38
|
-
}),
|
|
39
|
-
...appendTypoStyle,
|
|
40
|
-
...common.getMaxHeightStyleDefault(setting)
|
|
41
|
-
};
|
|
42
|
-
const collapseStyle = {
|
|
43
|
-
...defaultStyle,
|
|
44
|
-
...core.makeStyleResponsive('line-clamp', core.makeLineClamp(setting?.lineClamp, setting?.hasLineClamp))
|
|
45
|
-
};
|
|
46
|
-
const getDisplayCollapse = ()=>{
|
|
47
|
-
return getDisplayStyle((device)=>!!setting?.hasLineClamp && setting.hasLineClamp[device] !== undefined && !setting.hasLineClamp[device], 'block');
|
|
48
|
-
};
|
|
49
|
-
const Tag = htmlTag === 'html' ? 'div' : 'p';
|
|
50
|
-
return core.template`
|
|
51
|
-
<gp-product-description data-id="${builderProps?.uid}" class="${advanced?.cssClass} gp-product-description" gp-data='${JSON.stringify({
|
|
52
|
-
setting: {
|
|
53
|
-
lineClamp: setting?.lineClamp,
|
|
54
|
-
hasLineClamp: setting?.hasLineClamp,
|
|
55
|
-
viewMoreText: setting?.viewMoreText,
|
|
56
|
-
viewLessText: setting?.viewLessText,
|
|
57
|
-
enableViewMoreIcon: setting?.enableViewMoreIcon
|
|
58
|
-
},
|
|
59
|
-
defaultStyle,
|
|
60
|
-
collapseStyle
|
|
61
|
-
}).replaceAll("'", ''')}'>
|
|
62
|
-
{%- unless product -%}
|
|
63
|
-
<p>Product not found</p>
|
|
64
|
-
{%- else -%}
|
|
65
|
-
<${Tag}
|
|
66
|
-
data-gp-text
|
|
67
|
-
class="${core.cls('gp-relative p-description-wrapper gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, core.getGlobalColorClass('text', setting?.color), "data-[browser=safari]:after:gp-content-[' '] data-[browser=safari]:after:gp-absolute data-[browser=safari]:after:gp-left-0 data-[browser=safari]:after:gp-right-0 data-[browser=safari]:after:gp-bottom-0 data-[browser=safari]:after:gp-w-full data-[browser=safari]:after:gp-h-1/2 data-[browser=safari]:after:gp-bg-gradient-to-t data-[browser=safari]:after:gp-from-white")}"
|
|
68
|
-
data-gp-text
|
|
69
|
-
style="${collapseStyle}"
|
|
70
|
-
>
|
|
71
|
-
${htmlTag === 'html' ? `{{product.description}}` : `{{product.description | strip_html}}`}
|
|
72
|
-
</${Tag}>
|
|
73
|
-
{% if product.description != blank -%}
|
|
74
|
-
<button
|
|
75
|
-
type="button"
|
|
76
|
-
class="p-description-show-more ${core.cls(appendTypoClass, core.getGlobalColorClass('text', setting?.showMoreColor), 'gp-mt-4 hover:gp-opacity-80 gp-transition-all gp-w-full')}"
|
|
77
|
-
style="${{
|
|
78
|
-
...core.makeStyle({
|
|
79
|
-
tt: setting?.transform
|
|
80
|
-
}),
|
|
81
|
-
...core.makeStyleResponsive('ta', setting?.textAlign),
|
|
82
|
-
...appendTypoStyle,
|
|
83
|
-
...core.getGlobalColorStyle(setting?.showMoreColor),
|
|
84
|
-
...getDisplayCollapse(),
|
|
85
|
-
position: 'absolute',
|
|
86
|
-
visibility: 'hidden'
|
|
87
|
-
}}"
|
|
88
|
-
>
|
|
89
|
-
|
|
90
|
-
${setting?.viewMoreText}
|
|
91
|
-
${setting?.enableViewMoreIcon ? `<svg
|
|
92
|
-
class="gp-ml-1 gp-inline-block"
|
|
93
|
-
style="display: inline-block; margin-left: 1px;"
|
|
94
|
-
height="1em"
|
|
95
|
-
width="1em"
|
|
96
|
-
viewBox="0 0 22 12"
|
|
97
|
-
fill="none"
|
|
98
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
99
|
-
>
|
|
100
|
-
<path
|
|
101
|
-
d="M1.70711 0.292893C1.31658 -0.0976311 0.683417 -0.0976311 0.292893 0.292893C-0.0976311 0.683417 -0.0976311 1.31658 0.292893 1.70711L1.70711 0.292893ZM11 11L10.2929 11.7071C10.6834 12.0976 11.3166 12.0976 11.7071 11.7071L11 11ZM21.7071 1.70711C22.0976 1.31658 22.0976 0.683417 21.7071 0.292893C21.3166 -0.0976311 20.6834 -0.0976311 20.2929 0.292893L21.7071 1.70711ZM0.292893 1.70711L10.2929 11.7071L11.7071 10.2929L1.70711 0.292893L0.292893 1.70711ZM11.7071 11.7071L21.7071 1.70711L20.2929 0.292893L10.2929 10.2929L11.7071 11.7071Z"
|
|
102
|
-
fill="currentColor"
|
|
103
|
-
/>
|
|
104
|
-
</svg>` : ''}
|
|
105
|
-
</button>
|
|
106
|
-
{%- endif -%}
|
|
107
|
-
|
|
108
|
-
{%- endunless -%}
|
|
109
|
-
{% style %}
|
|
110
|
-
.p-description-wrapper.gp-p-description-text * {
|
|
111
|
-
color: inherit;
|
|
112
|
-
line-height: inherit !important;
|
|
113
|
-
}
|
|
114
|
-
{% endstyle %}
|
|
115
|
-
</gp-product-description>
|
|
116
|
-
${core.RenderIf(core.isLocalEnv, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-description.js' | asset_url }}" defer="defer"></script>`, `<script ${helpers.getSettingPreloadData('class="gps-link" delay', 'src')}="${core.baseAssetURL}/assets-v2/gp-product-description.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
|
|
117
|
-
`;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
exports.default = ProductDescription;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
|
|
3
|
-
const ButtonIcon = ({ iconSvg, shouldClearSpace, label, style })=>{
|
|
4
|
-
return /*#__PURE__*/ jsx("span", {
|
|
5
|
-
className: `
|
|
6
|
-
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' : ''}`,
|
|
7
|
-
style: style,
|
|
8
|
-
dangerouslySetInnerHTML: {
|
|
9
|
-
__html: iconSvg
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export { ButtonIcon as default };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import 'react';
|
|
3
|
-
import { useEditorMode, cls, makeStyle } from '@gem-sdk/core';
|
|
4
|
-
|
|
5
|
-
const ButtonLabel = ({ label, styles, options, nodePrice, appendTypoClass })=>{
|
|
6
|
-
const mode = useEditorMode();
|
|
7
|
-
return /*#__PURE__*/ jsx("div", {
|
|
8
|
-
"data-gp-text": true,
|
|
9
|
-
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 : {}),
|
|
10
|
-
style: {
|
|
11
|
-
...makeStyle({
|
|
12
|
-
tt: styles?.transform
|
|
13
|
-
})
|
|
14
|
-
},
|
|
15
|
-
dangerouslySetInnerHTML: {
|
|
16
|
-
__html: styles?.typo?.attrs?.transform === 'capitalize' ? label?.toString().toLocaleLowerCase() : label
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export { ButtonLabel as default };
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
3
|
-
import { convertHTML, useEditorMode, makeStyleResponsive, globalEvent, cls, getGlobalColorStateClass } from '@gem-sdk/core';
|
|
4
|
-
import Head from 'next/head';
|
|
5
|
-
import Link from '../../../link/components/Link.js';
|
|
6
|
-
import { useButtonCustomCss } from '../../hooks/useButtonCustomCss.js';
|
|
7
|
-
import { useButtonStyles } from '../../hooks/useButtonStyles.js';
|
|
8
|
-
import ButtonIcon from './ButtonIcon.js';
|
|
9
|
-
import ButtonLabel from './ButtonLabel.js';
|
|
10
|
-
import ButtonLoadingIndicator from './ButtonLoadingIndicator.js';
|
|
11
|
-
|
|
12
|
-
const Button = (buttonProps)=>{
|
|
13
|
-
const { className, onClick, builderProps, builderAttrs, setting = {}, styles, style, children, nodePrice } = buttonProps;
|
|
14
|
-
const { align, backgroundImage, textColor } = styles ?? {};
|
|
15
|
-
const { iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, options, shouldClearSpace } = setting;
|
|
16
|
-
const label = convertHTML(setting?.label);
|
|
17
|
-
const Wrap = btnLink?.link !== undefined && btnLink.link !== '' ? Link : 'button';
|
|
18
|
-
const props = btnLink?.link !== undefined && btnLink.link !== '' ? {
|
|
19
|
-
setting: {
|
|
20
|
-
href: btnLink?.link,
|
|
21
|
-
target: btnLink?.target,
|
|
22
|
-
noFollow: btnLink?.noFollow
|
|
23
|
-
}
|
|
24
|
-
} : {
|
|
25
|
-
type: htmlType
|
|
26
|
-
};
|
|
27
|
-
const mode = useEditorMode();
|
|
28
|
-
const customCss = useButtonCustomCss({
|
|
29
|
-
styles,
|
|
30
|
-
builderProps
|
|
31
|
-
});
|
|
32
|
-
const { getButtonStyles, getButtonIconStyles, appendTypoClass, appendTypoStyle, isTextOverflow } = useButtonStyles(buttonProps);
|
|
33
|
-
return /*#__PURE__*/ jsxs(Fragment, {
|
|
34
|
-
children: [
|
|
35
|
-
!!styles?.preloadBgImage && /*#__PURE__*/ jsxs(Head, {
|
|
36
|
-
children: [
|
|
37
|
-
!!backgroundImage?.desktop?.normal?.image?.src && /*#__PURE__*/ jsx("link", {
|
|
38
|
-
rel: "preload",
|
|
39
|
-
href: backgroundImage.desktop.normal.image.src,
|
|
40
|
-
as: "image"
|
|
41
|
-
}),
|
|
42
|
-
!!backgroundImage?.tablet?.normal?.image?.src && /*#__PURE__*/ jsx("link", {
|
|
43
|
-
rel: "preload",
|
|
44
|
-
href: backgroundImage?.tablet?.normal?.image?.src,
|
|
45
|
-
as: "image"
|
|
46
|
-
}),
|
|
47
|
-
!!backgroundImage?.mobile?.normal?.image?.src && /*#__PURE__*/ jsx("link", {
|
|
48
|
-
rel: "preload",
|
|
49
|
-
href: backgroundImage?.mobile?.normal?.image?.src,
|
|
50
|
-
as: "image"
|
|
51
|
-
}),
|
|
52
|
-
!!backgroundImage?.desktop?.hover?.image?.src && /*#__PURE__*/ jsx("link", {
|
|
53
|
-
rel: "preload",
|
|
54
|
-
href: backgroundImage.desktop.hover.image.src,
|
|
55
|
-
as: "image"
|
|
56
|
-
}),
|
|
57
|
-
!!backgroundImage?.tablet?.hover?.image?.src && /*#__PURE__*/ jsx("link", {
|
|
58
|
-
rel: "preload",
|
|
59
|
-
href: backgroundImage?.tablet?.hover?.image?.src,
|
|
60
|
-
as: "image"
|
|
61
|
-
}),
|
|
62
|
-
!!backgroundImage?.mobile?.hover?.image?.src && /*#__PURE__*/ jsx("link", {
|
|
63
|
-
rel: "preload",
|
|
64
|
-
href: backgroundImage?.mobile?.hover?.image?.src,
|
|
65
|
-
as: "image"
|
|
66
|
-
})
|
|
67
|
-
]
|
|
68
|
-
}),
|
|
69
|
-
/*#__PURE__*/ jsxs("div", {
|
|
70
|
-
...builderAttrs,
|
|
71
|
-
style: {
|
|
72
|
-
...style,
|
|
73
|
-
...makeStyleResponsive('ta', align)
|
|
74
|
-
},
|
|
75
|
-
children: [
|
|
76
|
-
/*#__PURE__*/ jsx("style", {
|
|
77
|
-
children: customCss
|
|
78
|
-
}),
|
|
79
|
-
/*#__PURE__*/ jsxs(Wrap, {
|
|
80
|
-
...props,
|
|
81
|
-
"data-id": builderProps?.uid,
|
|
82
|
-
"aria-label": setting?.label,
|
|
83
|
-
onClick: (e)=>{
|
|
84
|
-
onClick?.(e);
|
|
85
|
-
if (btnLink?.link?.startsWith('#') && mode !== 'edit') {
|
|
86
|
-
globalEvent.dispatch('onOpenDialog', {
|
|
87
|
-
popupUId: btnLink.link
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
"data-state": loading ? 'loading' : 'idle',
|
|
92
|
-
className: cls(builderProps?.uid, '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', {
|
|
93
|
-
'gp-animate-bounce': styles?.animation?.normal === 'bounce',
|
|
94
|
-
'hover:gp-animate-bounce': styles?.animation?.hover === 'bounce',
|
|
95
|
-
'gp-scale-[1.1]': styles?.animation?.normal === 'grow',
|
|
96
|
-
'hover:gp-scale-[1.1]': styles?.animation?.hover === 'grow',
|
|
97
|
-
'gp-max-w-full': isTextOverflow,
|
|
98
|
-
'gp-text-center': !!btnLink?.link
|
|
99
|
-
}, className, getGlobalColorStateClass('text', textColor), !nodePrice ? appendTypoClass : {}),
|
|
100
|
-
style: getButtonStyles(),
|
|
101
|
-
disabled: disabled,
|
|
102
|
-
children: [
|
|
103
|
-
loading ? /*#__PURE__*/ jsx(ButtonLoadingIndicator, {}) : '',
|
|
104
|
-
/*#__PURE__*/ jsxs("div", {
|
|
105
|
-
className: cls({
|
|
106
|
-
'gp-flex-row-reverse': iconAlign === 'right'
|
|
107
|
-
}, 'gp-inline-flex'),
|
|
108
|
-
children: [
|
|
109
|
-
!!iconSvg && iconVisible && /*#__PURE__*/ jsx(ButtonIcon, {
|
|
110
|
-
iconSvg: iconSvg,
|
|
111
|
-
shouldClearSpace: shouldClearSpace,
|
|
112
|
-
label: label,
|
|
113
|
-
style: getButtonIconStyles()
|
|
114
|
-
}),
|
|
115
|
-
(!!label || !shouldClearSpace) && /*#__PURE__*/ jsx(ButtonLabel, {
|
|
116
|
-
label: label,
|
|
117
|
-
shouldClearSpace: shouldClearSpace,
|
|
118
|
-
appendTypoClass: appendTypoClass,
|
|
119
|
-
appendTypoStyle: appendTypoStyle,
|
|
120
|
-
styles: styles,
|
|
121
|
-
mode: mode,
|
|
122
|
-
options: options
|
|
123
|
-
})
|
|
124
|
-
]
|
|
125
|
-
}),
|
|
126
|
-
nodePrice && nodePrice
|
|
127
|
-
]
|
|
128
|
-
}),
|
|
129
|
-
children
|
|
130
|
-
]
|
|
131
|
-
})
|
|
132
|
-
]
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
export { Button as default };
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { splitStyle, makeStyleResponsive, makeGlobalSize, composeTypographyClassName, makeStyleResponsiveState, composeTypographyStyle, getStyleShadow, template, RenderIf, dataStringify, cls, getGlobalColorStateClass, getStyleBackgroundImageByDevice, getGlobalColorStateResponsiveStyle, composeRadius, getStyleShadowState, composeSize, getGlobalColorStateStyle, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
|
|
2
|
-
import { getInsertLinkData, getDynamicSourceLocales, getSettingPreloadData } from '../../../helpers.js';
|
|
3
|
-
import { useButtonCustomCss } from '../../hooks/useButtonCustomCss.js';
|
|
4
|
-
|
|
5
|
-
const Button = ({ className, builderProps, customAttrs, pageContext, setting = {}, styles = {}, style, wrapClassName = '', advanced, nodePrice, dataId, isForceValue = false })=>{
|
|
6
|
-
const { align, size, backgroundImage, backgroundColorV2, textColor, textColorHover, roundedBtnV2, iconSpacing, globalSize } = styles;
|
|
7
|
-
const { label, iconSvg, btnLink, htmlType, disabled, loading, iconAlign, iconVisible, translate, disabledLoading = true } = setting;
|
|
8
|
-
const [wrapStyle, restStyle] = splitStyle([
|
|
9
|
-
'pos',
|
|
10
|
-
'top',
|
|
11
|
-
'left',
|
|
12
|
-
'bottom',
|
|
13
|
-
'right',
|
|
14
|
-
'z'
|
|
15
|
-
], style);
|
|
16
|
-
const { Wrap, urlData, shouldRenderLink } = getInsertLinkData('button', btnLink, htmlType);
|
|
17
|
-
const spacingDefault = {
|
|
18
|
-
desktop: '8px'
|
|
19
|
-
};
|
|
20
|
-
const iconSpacingStyle = iconAlign === 'left' ? makeStyleResponsive('mr', iconSpacing || spacingDefault) : makeStyleResponsive('ml', iconSpacing || spacingDefault);
|
|
21
|
-
// fix disabled still display hover color
|
|
22
|
-
if (disabled) {
|
|
23
|
-
delete backgroundColorV2?.desktop?.hover;
|
|
24
|
-
delete backgroundColorV2?.tablet?.hover;
|
|
25
|
-
delete backgroundColorV2?.mobile?.hover;
|
|
26
|
-
delete backgroundColorV2?.desktop?.focus;
|
|
27
|
-
delete backgroundColorV2?.tablet?.focus;
|
|
28
|
-
delete backgroundColorV2?.mobile?.focus;
|
|
29
|
-
}
|
|
30
|
-
const composeGlobalSize = makeGlobalSize(globalSize);
|
|
31
|
-
const appendTypoClass = composeTypographyClassName(styles?.typo, styles?.typography);
|
|
32
|
-
const appendTypoStyle = {
|
|
33
|
-
...makeStyleResponsiveState('c', textColorHover),
|
|
34
|
-
...composeTypographyStyle(styles?.typo, styles?.typography),
|
|
35
|
-
...getStyleShadow({
|
|
36
|
-
value: styles?.typo?.custom?.textShadow,
|
|
37
|
-
styleAppliedFor: 'text-shadow',
|
|
38
|
-
isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
|
|
39
|
-
})
|
|
40
|
-
};
|
|
41
|
-
const customCss = useButtonCustomCss({
|
|
42
|
-
styles,
|
|
43
|
-
builderProps
|
|
44
|
-
});
|
|
45
|
-
const labelValDisplay = isForceValue ? label : getDynamicSourceLocales({
|
|
46
|
-
val: label,
|
|
47
|
-
uid: builderProps?.uidTranslate ?? builderProps?.uid,
|
|
48
|
-
settingId: translate ?? 'label',
|
|
49
|
-
pageContext,
|
|
50
|
-
isCapitalize: styles?.typo?.attrs?.transform === 'capitalize',
|
|
51
|
-
translate
|
|
52
|
-
});
|
|
53
|
-
const isScrollToElement = ()=>{
|
|
54
|
-
return btnLink?.link?.startsWith('#') && btnLink?.target === '_self';
|
|
55
|
-
};
|
|
56
|
-
const WrapLink = isScrollToElement() ? 'button' : Wrap;
|
|
57
|
-
return template`
|
|
58
|
-
${RenderIf(!!styles?.preloadBgImage, `${RenderIf(!!backgroundImage?.desktop?.normal?.image?.src, `<link rel="preload" href="${backgroundImage?.desktop?.normal?.image?.src}" as="image" />`)}${RenderIf(!!backgroundImage?.desktop?.hover?.image?.src, `<link rel="preload" href="${backgroundImage?.desktop?.hover?.image?.src}" as="image" />`)}${RenderIf(!!backgroundImage?.tablet?.normal?.image?.src, `<link rel="preload" href="${backgroundImage?.tablet?.normal?.image?.src}" as="image" />`)}${RenderIf(!!backgroundImage?.tablet?.hover?.image?.src, `<link rel="preload" href="${backgroundImage?.tablet?.hover?.image?.src}" as="image" />`)}${RenderIf(!!backgroundImage?.mobile?.normal?.image?.src, `<link rel="preload" href="${backgroundImage?.mobile?.normal?.image?.src}" as="image" />`)}${RenderIf(!!backgroundImage?.mobile?.hover?.image?.src, `<link rel="preload" href="${backgroundImage?.mobile?.hover?.image?.src}" as="image" />`)}`)}
|
|
59
|
-
<gp-button
|
|
60
|
-
gp-data='${dataStringify({
|
|
61
|
-
btnLink: setting?.btnLink
|
|
62
|
-
})}'
|
|
63
|
-
style="${{
|
|
64
|
-
...wrapStyle
|
|
65
|
-
}}"
|
|
66
|
-
>
|
|
67
|
-
<div
|
|
68
|
-
style="${{
|
|
69
|
-
...restStyle,
|
|
70
|
-
...makeStyleResponsive('ta', align)
|
|
71
|
-
}}"
|
|
72
|
-
class="${cls(wrapClassName, className?.includes('gp-button-atc') ? '' : advanced?.cssClass)}"
|
|
73
|
-
>
|
|
74
|
-
<style>${customCss}</style>
|
|
75
|
-
${RenderIf(isScrollToElement(), `<a class="gp-trigger-button-link gp-hidden" href=${urlData.href} target=${urlData.target} ></a>`)}
|
|
76
|
-
<${WrapLink}
|
|
77
|
-
${{
|
|
78
|
-
...urlData,
|
|
79
|
-
'data-id': builderProps?.uidInteraction ?? (dataId || builderProps?.uid),
|
|
80
|
-
'aria-label': setting?.label?.toString().replaceAll("'", ''').replaceAll('"', "'"),
|
|
81
|
-
...disabled && typeof disabled === 'boolean' || disabled ? {
|
|
82
|
-
disabled: 'disabled'
|
|
83
|
-
} : {}
|
|
84
|
-
}}
|
|
85
|
-
${{
|
|
86
|
-
...customAttrs
|
|
87
|
-
}}
|
|
88
|
-
data-state="${loading ? 'loading' : 'idle'}"
|
|
89
|
-
class="${cls(builderProps?.uid, 'gp-button-base gp-rounded-none gp-max-w-full gp-relative gp-group gp-inline-flex gp-items-center gp-justify-center gp-no-underline gp-transition-colors gp-duration-300 disabled:gp-btn-disabled disabled:gp-opacity-30 disabled:gp-pointer-events-none', getGlobalColorStateClass('text', textColor), {
|
|
90
|
-
'gp-animate-bounce': styles?.animation?.normal === 'bounce',
|
|
91
|
-
'hover:gp-animate-bounce': styles?.animation?.hover === 'bounce',
|
|
92
|
-
'gp-scale-[1.1]': styles?.animation?.normal === 'grow',
|
|
93
|
-
'hover:gp-scale-[1.1]': styles?.animation?.hover === 'grow',
|
|
94
|
-
'gp-text-center': shouldRenderLink
|
|
95
|
-
}, className, className?.includes('gp-button-atc') && advanced ? advanced?.cssClass : '', !nodePrice ? appendTypoClass : {})}"
|
|
96
|
-
style="${{
|
|
97
|
-
...getStyleBackgroundImageByDevice(backgroundImage),
|
|
98
|
-
...getGlobalColorStateResponsiveStyle('bg', backgroundColorV2),
|
|
99
|
-
...composeRadius(roundedBtnV2),
|
|
100
|
-
...getStyleShadowState(styles?.boxShadowBtnV2?.desktop, 'box-shadow', {
|
|
101
|
-
normal: styles?.boxShadowBtnV2?.desktop?.normal?.type !== 'none',
|
|
102
|
-
hover: styles?.boxShadowBtnV2?.desktop?.hover?.type !== 'none'
|
|
103
|
-
}),
|
|
104
|
-
...getStyleShadowState(styles?.boxShadowBtnV2?.tablet, 'box-shadow', {
|
|
105
|
-
normal: styles?.boxShadowBtnV2?.tablet?.normal?.type !== 'none',
|
|
106
|
-
hover: styles?.boxShadowBtnV2?.tablet?.hover?.type !== 'none'
|
|
107
|
-
}, 'tablet'),
|
|
108
|
-
...getStyleShadowState(styles?.boxShadowBtnV2?.mobile, 'box-shadow', {
|
|
109
|
-
normal: styles?.boxShadowBtnV2?.mobile?.normal?.type !== 'none',
|
|
110
|
-
hover: styles?.boxShadowBtnV2?.mobile?.hover?.type !== 'none'
|
|
111
|
-
}, 'mobile'),
|
|
112
|
-
...!styles?.btnSpacing?.type ? composeSize(styles?.btnSpacing?.custom) : {},
|
|
113
|
-
...composeGlobalSize.width,
|
|
114
|
-
...composeGlobalSize.height,
|
|
115
|
-
...composeGlobalSize.padding,
|
|
116
|
-
...getGlobalColorStateStyle('c', textColor),
|
|
117
|
-
'--size': appendTypoStyle['--size'],
|
|
118
|
-
'--size-tablet': appendTypoStyle['--size-tablet'],
|
|
119
|
-
'--size-mobile': appendTypoStyle['--size-mobile'],
|
|
120
|
-
...!nodePrice ? appendTypoStyle : {}
|
|
121
|
-
}}"
|
|
122
|
-
>
|
|
123
|
-
${!disabledLoading ? ` <svg
|
|
124
|
-
class="gp-invisible gp-absolute gp-h-5 gp-w-5 group-data-[state=loading]:gp-animate-spin group-data-[state=loading]:gp-visible"
|
|
125
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
126
|
-
fill="none"
|
|
127
|
-
viewBox="0 0 24 24"
|
|
128
|
-
>
|
|
129
|
-
<circle
|
|
130
|
-
class="gp-opacity-25"
|
|
131
|
-
cx="12"
|
|
132
|
-
cy="12"
|
|
133
|
-
r="10"
|
|
134
|
-
stroke="currentColor"
|
|
135
|
-
stroke-width="4"
|
|
136
|
-
></circle>
|
|
137
|
-
<path
|
|
138
|
-
class="gp-opacity-75"
|
|
139
|
-
fill="currentColor"
|
|
140
|
-
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"
|
|
141
|
-
></path>
|
|
142
|
-
</svg>` : ''}
|
|
143
|
-
<div
|
|
144
|
-
class="${cls('gp-inline-flex', {
|
|
145
|
-
'gp-flex-row-reverse': iconAlign === 'right'
|
|
146
|
-
})}">
|
|
147
|
-
${RenderIf(!!iconSvg && iconVisible, template`<span
|
|
148
|
-
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)]`}"
|
|
149
|
-
style="${{
|
|
150
|
-
...label ? iconSpacingStyle : {},
|
|
151
|
-
'--height-desktop': `${size?.desktop}`,
|
|
152
|
-
'--height-tablet': `${size?.desktop ?? size?.tablet}`,
|
|
153
|
-
'--height-mobile': `${size?.mobile ?? size?.tablet ?? size?.desktop}`
|
|
154
|
-
}}"
|
|
155
|
-
>${iconSvg}</span>`)}
|
|
156
|
-
<span
|
|
157
|
-
data-gp-text
|
|
158
|
-
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 ${appendTypoClass}
|
|
159
|
-
${styles?.typo?.attrs?.italic ? '[&:not(:has(p))]:gp-pr-[0.2em] [&_p]:[&:has(p)]:gp-pr-[0.2em]' : ''}`}"
|
|
160
|
-
style="${{
|
|
161
|
-
'--size': appendTypoStyle['--size'],
|
|
162
|
-
'--size-tablet': appendTypoStyle['--size-tablet'],
|
|
163
|
-
'--size-mobile': appendTypoStyle['--size-mobile']
|
|
164
|
-
}}"
|
|
165
|
-
>
|
|
166
|
-
${labelValDisplay}
|
|
167
|
-
</span>
|
|
168
|
-
</div>
|
|
169
|
-
${nodePrice ? nodePrice : ''}
|
|
170
|
-
</${WrapLink}>
|
|
171
|
-
</div>
|
|
172
|
-
${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>`)}
|
|
173
|
-
</gp-button>
|
|
174
|
-
`;
|
|
175
|
-
};
|
|
176
|
-
|
|
177
|
-
export { Button as default };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { 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 generateBorderCornerStyles = ({ uid, device, borderBtn, roundedBtn })=>{
|
|
8
|
-
const normalStyles = `
|
|
9
|
-
.${uid}.gp-button-base::before {
|
|
10
|
-
content: "";
|
|
11
|
-
height: 100%;
|
|
12
|
-
width: 100%;
|
|
13
|
-
position: absolute;
|
|
14
|
-
pointer-events: none;
|
|
15
|
-
${composeBorderCss(borderBtn?.[device]?.normal)}
|
|
16
|
-
${composeCornerCss(roundedBtn?.[device]?.normal)}
|
|
17
|
-
}
|
|
18
|
-
`;
|
|
19
|
-
const hoverStyles = `
|
|
20
|
-
.${uid}:hover::before {
|
|
21
|
-
${composeBorderCss(borderBtn?.[device]?.hover)}
|
|
22
|
-
${composeCornerCss(roundedBtn?.[device]?.hover)}
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
return {
|
|
26
|
-
normalStyles,
|
|
27
|
-
hoverStyles
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
const generateColorStyles = (uid, textColor)=>`
|
|
31
|
-
.${uid}:hover .gp-button-price,
|
|
32
|
-
.${uid}:hover .gp-product-dot-price {
|
|
33
|
-
color: ${getSingleColorVariable(textColor?.hover)};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.${uid} .gp-button-price,
|
|
37
|
-
.${uid} .gp-product-dot-price {
|
|
38
|
-
color: ${getSingleColorVariable(textColor?.normal)};
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
const useButtonCustomCss = ({ styles, builderProps })=>{
|
|
42
|
-
if (!builderProps?.uid) return '';
|
|
43
|
-
const { borderBtnV2, roundedBtnV2, textColor } = styles ?? {};
|
|
44
|
-
const uid = builderProps.uid;
|
|
45
|
-
const borderCornerStyles = {
|
|
46
|
-
desktop: generateBorderCornerStyles({
|
|
47
|
-
uid,
|
|
48
|
-
device: 'desktop',
|
|
49
|
-
borderBtn: borderBtnV2,
|
|
50
|
-
roundedBtn: roundedBtnV2
|
|
51
|
-
}),
|
|
52
|
-
tablet: generateBorderCornerStyles({
|
|
53
|
-
uid,
|
|
54
|
-
device: 'tablet',
|
|
55
|
-
borderBtn: borderBtnV2,
|
|
56
|
-
roundedBtn: roundedBtnV2
|
|
57
|
-
}),
|
|
58
|
-
mobile: generateBorderCornerStyles({
|
|
59
|
-
uid,
|
|
60
|
-
device: 'mobile',
|
|
61
|
-
borderBtn: borderBtnV2,
|
|
62
|
-
roundedBtn: roundedBtnV2
|
|
63
|
-
})
|
|
64
|
-
};
|
|
65
|
-
const colorStyles = generateColorStyles(uid, textColor);
|
|
66
|
-
return `
|
|
67
|
-
${borderCornerStyles.desktop.normalStyles}
|
|
68
|
-
${borderCornerStyles.desktop.hoverStyles}
|
|
69
|
-
|
|
70
|
-
${MEDIA_QUERIES.TABLET} {
|
|
71
|
-
${borderCornerStyles.tablet.normalStyles}
|
|
72
|
-
${borderCornerStyles.tablet.hoverStyles}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
${MEDIA_QUERIES.MOBILE} {
|
|
76
|
-
${borderCornerStyles.mobile.normalStyles}
|
|
77
|
-
${borderCornerStyles.mobile.hoverStyles}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
${colorStyles}
|
|
81
|
-
`.trim();
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export { generateBorderCornerStyles, generateColorStyles, useButtonCustomCss };
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { makeGlobalSize, composeTypographyClassName, makeStyleResponsiveState, composeTypographyStyle, makeStyleResponsive, getGlobalColorStateStyle, getStyleShadowState, getStyleShadow, getStyleBackgroundImageByDevice, getGlobalColorStateResponsiveStyle, composeRadius } from '@gem-sdk/core';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
|
|
4
|
-
const useButtonStyles = (props)=>{
|
|
5
|
-
const { styles, nodePrice, setting = {} } = props;
|
|
6
|
-
const { size, backgroundImage, backgroundColorV2, textColor, roundedBtnV2, iconSpacing, globalSize, textColorHover } = styles ?? {};
|
|
7
|
-
const { iconAlign, disabled } = setting;
|
|
8
|
-
const isTextOverflow = styles?.textOverFlow || false;
|
|
9
|
-
const composeGlobalSize = makeGlobalSize(globalSize);
|
|
10
|
-
const appendTypoClass = composeTypographyClassName(styles?.typo, styles?.typography);
|
|
11
|
-
const appendTypoStyle = {
|
|
12
|
-
...makeStyleResponsiveState('c', textColorHover),
|
|
13
|
-
...composeTypographyStyle(styles?.typo, styles?.typography)
|
|
14
|
-
};
|
|
15
|
-
if (disabled) {
|
|
16
|
-
delete backgroundColorV2?.desktop?.hover;
|
|
17
|
-
delete backgroundColorV2?.tablet?.hover;
|
|
18
|
-
delete backgroundColorV2?.mobile?.hover;
|
|
19
|
-
delete backgroundColorV2?.desktop?.focus;
|
|
20
|
-
delete backgroundColorV2?.tablet?.focus;
|
|
21
|
-
delete backgroundColorV2?.mobile?.focus;
|
|
22
|
-
}
|
|
23
|
-
const iconSpacingStyle = useMemo(()=>{
|
|
24
|
-
const spacing = iconSpacing || {
|
|
25
|
-
desktop: '8px'
|
|
26
|
-
};
|
|
27
|
-
return iconAlign === 'left' ? makeStyleResponsive('mr', spacing) : makeStyleResponsive('ml', spacing);
|
|
28
|
-
}, [
|
|
29
|
-
iconAlign,
|
|
30
|
-
iconSpacing
|
|
31
|
-
]);
|
|
32
|
-
const isEnableShadowStateForDevice = (deviceStyles)=>({
|
|
33
|
-
normal: deviceStyles?.normal?.type !== 'none',
|
|
34
|
-
hover: deviceStyles?.hover?.type !== 'none'
|
|
35
|
-
});
|
|
36
|
-
const getShadowStyles = ()=>{
|
|
37
|
-
const { boxShadowBtnV2 } = styles || {};
|
|
38
|
-
return {
|
|
39
|
-
// Desktop shadows
|
|
40
|
-
...getStyleShadowState(boxShadowBtnV2?.desktop, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.desktop)),
|
|
41
|
-
// Tablet shadows
|
|
42
|
-
...getStyleShadowState(boxShadowBtnV2?.tablet, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.tablet), 'tablet'),
|
|
43
|
-
// Mobile shadows
|
|
44
|
-
...getStyleShadowState(boxShadowBtnV2?.mobile, 'box-shadow', isEnableShadowStateForDevice(boxShadowBtnV2?.mobile), 'mobile')
|
|
45
|
-
};
|
|
46
|
-
};
|
|
47
|
-
const getGlobalSize = ()=>({
|
|
48
|
-
...composeGlobalSize.width,
|
|
49
|
-
...composeGlobalSize.height,
|
|
50
|
-
...composeGlobalSize.padding
|
|
51
|
-
});
|
|
52
|
-
const getTypoStyles = ()=>({
|
|
53
|
-
'--size': appendTypoStyle['--size'],
|
|
54
|
-
'--size-tablet': appendTypoStyle['--size-tablet'],
|
|
55
|
-
'--size-mobile': appendTypoStyle['--size-mobile'],
|
|
56
|
-
...!nodePrice && appendTypoStyle,
|
|
57
|
-
...getStyleShadow({
|
|
58
|
-
value: styles?.typo?.custom?.textShadow,
|
|
59
|
-
styleAppliedFor: 'text-shadow',
|
|
60
|
-
isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
|
|
61
|
-
})
|
|
62
|
-
});
|
|
63
|
-
const getBackgroundStyles = ()=>({
|
|
64
|
-
...getStyleBackgroundImageByDevice(backgroundImage),
|
|
65
|
-
...getGlobalColorStateResponsiveStyle('bg', backgroundColorV2)
|
|
66
|
-
});
|
|
67
|
-
const getRadiusStyles = ()=>composeRadius(roundedBtnV2);
|
|
68
|
-
const getButtonStyles = ()=>({
|
|
69
|
-
...getBackgroundStyles(),
|
|
70
|
-
...getRadiusStyles(),
|
|
71
|
-
...getShadowStyles(),
|
|
72
|
-
...getGlobalSize(),
|
|
73
|
-
...getGlobalColorStateStyle('c', textColor),
|
|
74
|
-
...getTypoStyles()
|
|
75
|
-
});
|
|
76
|
-
const getButtonIconStyles = ()=>({
|
|
77
|
-
...iconSpacingStyle,
|
|
78
|
-
'--height-desktop': `${size?.desktop}`,
|
|
79
|
-
'--height-tablet': `${size?.desktop || size?.tablet}`,
|
|
80
|
-
'--height-mobile': `${size?.mobile || size?.tablet || size?.desktop}`
|
|
81
|
-
});
|
|
82
|
-
return {
|
|
83
|
-
getButtonStyles,
|
|
84
|
-
getButtonIconStyles,
|
|
85
|
-
appendTypoClass,
|
|
86
|
-
appendTypoStyle,
|
|
87
|
-
isTextOverflow
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export { useButtonStyles };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Takes a string in the format of "gid://shopify/ProductVariant/41007289630776" and returns a string of the ID part at the end: "41007289630776"
|
|
3
|
-
*/ function getIdFromGid(id) {
|
|
4
|
-
if (!id) return;
|
|
5
|
-
return id.split('/').at(-1);
|
|
6
|
-
}
|
|
7
|
-
function getStoreUrl(url) {
|
|
8
|
-
if (!url) return;
|
|
9
|
-
try {
|
|
10
|
-
const data = new URL(url);
|
|
11
|
-
return data.origin;
|
|
12
|
-
} catch {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export { getIdFromGid, getStoreUrl };
|