@gem-sdk/components 2.0.0-dev.275 → 2.0.0-dev.278

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.
Files changed (112) hide show
  1. package/dist/cjs/article/components/ArticleReadMore.js +2 -4
  2. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +4 -4
  3. package/dist/cjs/builder.js +4 -8
  4. package/dist/cjs/button/components/Button.js +111 -184
  5. package/dist/cjs/button/components/Button.liquid.js +108 -171
  6. package/dist/cjs/button/components/ButtonIcon.js +17 -0
  7. package/dist/cjs/button/components/ButtonIcon.liquid.js +16 -0
  8. package/dist/cjs/button/components/ButtonLabel.js +18 -0
  9. package/dist/cjs/button/components/ButtonLabel.liquid.js +15 -0
  10. package/dist/cjs/button/components/ButtonLoadingIndicator.liquid.js +12 -0
  11. package/dist/cjs/button/components/common/attributes.js +15 -0
  12. package/dist/cjs/button/components/common/classes.js +55 -0
  13. package/dist/cjs/button/components/common/constants.js +26 -0
  14. package/dist/cjs/button/components/common/data.js +76 -0
  15. package/dist/cjs/button/components/common/helpers.js +131 -0
  16. package/dist/cjs/button/components/common/styles.js +157 -0
  17. package/dist/cjs/button/next.js +2 -6
  18. package/dist/cjs/button/setting/configs/settings.js +5 -1
  19. package/dist/cjs/cart/components/CheckoutNow.js +0 -2
  20. package/dist/cjs/coupon/components/Coupon.js +1 -3
  21. package/dist/cjs/dialog/setting/Dialog.js +7 -580
  22. package/dist/cjs/dialog/setting/configs/settings.js +325 -0
  23. package/dist/cjs/dialog/setting/configs/uiV1.js +288 -0
  24. package/dist/cjs/dialog/setting/configs/uiV2.js +258 -0
  25. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +3 -3
  26. package/dist/cjs/form/components/submit-button/SubmitButton.js +0 -4
  27. package/dist/cjs/index.js +2 -4
  28. package/dist/cjs/index.liquid.js +1 -3
  29. package/dist/cjs/post-purchase/callout-banner/components/CalloutText.js +1 -2
  30. package/dist/cjs/post-purchase/callout-banner/components/common/getClasses.js +2 -5
  31. package/dist/cjs/post-purchase/callout-banner/components/common/getStyles.js +4 -2
  32. package/dist/cjs/post-purchase/callout-banner/setting/config/callout-text/setting.js +11 -1
  33. package/dist/cjs/post-purchase/product/hooks/product-image/useListCarousel.js +1 -1
  34. package/dist/cjs/post-purchase/product/hooks/product-image/useProductImagePostPurchase.js +4 -1
  35. package/dist/cjs/post-purchase/product/settings/product-image/setting-v2.js +15 -2
  36. package/dist/cjs/post-purchase/product/settings/product-image/uiV2.js +3 -1
  37. package/dist/cjs/post-purchase/utils/constants.js +1 -1
  38. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.js +2 -5
  39. package/dist/cjs/product/components/DynamicCheckout.js +2 -5
  40. package/dist/cjs/product/components/FileUpload/components/common/index.js +1 -1
  41. package/dist/cjs/product/components/ProductButton.js +2 -3
  42. package/dist/cjs/product/components/ProductButton.liquid.js +3 -3
  43. package/dist/cjs/product/components/ProductDescription/index.liquid.js +1 -2
  44. package/dist/cjs/product/components/ProductViewMore.js +2 -5
  45. package/dist/cjs/product/components/ProductViewMore.liquid.js +2 -2
  46. package/dist/cjs/setting.js +2 -2
  47. package/dist/cjs/text/components/common/getClasses.js +1 -1
  48. package/dist/cjs/third-party/components/PushOwl.js +0 -5
  49. package/dist/esm/article/components/ArticleReadMore.js +1 -3
  50. package/dist/esm/banner/components/HeroBannerItem.liquid.js +4 -4
  51. package/dist/esm/builder.js +1 -5
  52. package/dist/esm/button/components/Button.js +113 -186
  53. package/dist/esm/button/components/Button.liquid.js +109 -172
  54. package/dist/esm/button/components/ButtonIcon.js +13 -0
  55. package/dist/esm/button/components/ButtonIcon.liquid.js +12 -0
  56. package/dist/esm/button/components/ButtonLabel.js +14 -0
  57. package/dist/esm/button/components/ButtonLabel.liquid.js +11 -0
  58. package/dist/esm/button/components/ButtonLoadingIndicator.liquid.js +8 -0
  59. package/dist/esm/button/components/common/attributes.js +13 -0
  60. package/dist/esm/button/components/common/classes.js +49 -0
  61. package/dist/esm/button/components/common/constants.js +24 -0
  62. package/dist/esm/button/components/common/data.js +74 -0
  63. package/dist/esm/button/components/common/helpers.js +118 -0
  64. package/dist/esm/button/components/common/styles.js +148 -0
  65. package/dist/esm/button/next.js +2 -6
  66. package/dist/esm/button/setting/configs/settings.js +5 -1
  67. package/dist/esm/cart/components/CheckoutNow.js +0 -2
  68. package/dist/esm/coupon/components/Coupon.js +1 -3
  69. package/dist/esm/dialog/setting/Dialog.js +7 -580
  70. package/dist/esm/dialog/setting/configs/settings.js +323 -0
  71. package/dist/esm/dialog/setting/configs/uiV1.js +286 -0
  72. package/dist/esm/dialog/setting/configs/uiV2.js +256 -0
  73. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +3 -3
  74. package/dist/esm/form/components/submit-button/SubmitButton.js +0 -4
  75. package/dist/esm/index.js +1 -2
  76. package/dist/esm/index.liquid.js +1 -2
  77. package/dist/esm/post-purchase/callout-banner/components/CalloutText.js +1 -2
  78. package/dist/esm/post-purchase/callout-banner/components/common/getClasses.js +2 -5
  79. package/dist/esm/post-purchase/callout-banner/components/common/getStyles.js +4 -2
  80. package/dist/esm/post-purchase/callout-banner/setting/config/callout-text/setting.js +11 -1
  81. package/dist/esm/post-purchase/product/hooks/product-image/useListCarousel.js +1 -1
  82. package/dist/esm/post-purchase/product/hooks/product-image/useProductImagePostPurchase.js +4 -1
  83. package/dist/esm/post-purchase/product/settings/product-image/setting-v2.js +15 -2
  84. package/dist/esm/post-purchase/product/settings/product-image/uiV2.js +3 -1
  85. package/dist/esm/post-purchase/utils/constants.js +1 -1
  86. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.js +1 -4
  87. package/dist/esm/product/components/DynamicCheckout.js +1 -4
  88. package/dist/esm/product/components/FileUpload/components/common/index.js +1 -1
  89. package/dist/esm/product/components/ProductButton.js +1 -2
  90. package/dist/esm/product/components/ProductButton.liquid.js +1 -1
  91. package/dist/esm/product/components/ProductDescription/index.liquid.js +3 -4
  92. package/dist/esm/product/components/ProductViewMore.js +1 -4
  93. package/dist/esm/product/components/ProductViewMore.liquid.js +1 -1
  94. package/dist/esm/setting.js +2 -2
  95. package/dist/esm/text/components/common/getClasses.js +1 -1
  96. package/dist/esm/third-party/components/PushOwl.js +0 -5
  97. package/dist/types/index.d.ts +175 -267
  98. package/package.json +2 -2
  99. package/dist/cjs/button/components/v2/ButtonIcon.js +0 -18
  100. package/dist/cjs/button/components/v2/ButtonLabel.js +0 -25
  101. package/dist/cjs/button/components/v2/ButtonV2.js +0 -140
  102. package/dist/cjs/button/components/v2/ButtonV2.liquid.js +0 -181
  103. package/dist/cjs/button/hooks/useButtonCustomCss.js +0 -88
  104. package/dist/cjs/button/hooks/useButtonStyles.js +0 -93
  105. package/dist/esm/button/components/v2/ButtonIcon.js +0 -14
  106. package/dist/esm/button/components/v2/ButtonLabel.js +0 -21
  107. package/dist/esm/button/components/v2/ButtonV2.js +0 -136
  108. package/dist/esm/button/components/v2/ButtonV2.liquid.js +0 -177
  109. package/dist/esm/button/hooks/useButtonCustomCss.js +0 -84
  110. package/dist/esm/button/hooks/useButtonStyles.js +0 -91
  111. /package/dist/cjs/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
  112. /package/dist/esm/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
@@ -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("'", '&#039;').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 };