@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.
Files changed (148) hide show
  1. package/dist/cjs/article/components/ArticleReadMore.js +2 -4
  2. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +5 -5
  3. package/dist/cjs/builder.js +17 -21
  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/cart/components/ShopPayButton/ShopPayButton.js +70 -0
  21. package/dist/cjs/cart/components/ShopPayButton/ShopPayButton.liquid.js +71 -0
  22. package/dist/cjs/cart/components/ShopPayButton/common/classes.js +18 -0
  23. package/dist/cjs/cart/components/ShopPayButton/common/helpers.js +31 -0
  24. package/dist/cjs/cart/components/ShopPayButton/common/styles.js +12 -0
  25. package/dist/cjs/cart/components/ShopPayButton/hooks/useShopPayButton.js +70 -0
  26. package/dist/cjs/cart/next.js +1 -1
  27. package/dist/cjs/coupon/components/Coupon.js +1 -3
  28. package/dist/cjs/dialog/setting/Dialog.js +7 -580
  29. package/dist/cjs/dialog/setting/configs/settings.js +325 -0
  30. package/dist/cjs/dialog/setting/configs/uiV1.js +288 -0
  31. package/dist/cjs/dialog/setting/configs/uiV2.js +258 -0
  32. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +4 -4
  33. package/dist/cjs/form/components/submit-button/SubmitButton.js +0 -4
  34. package/dist/cjs/header/components/kind/basic/index.js +1 -1
  35. package/dist/cjs/header/components/kind/modern/index.js +1 -1
  36. package/dist/cjs/index.js +41 -43
  37. package/dist/cjs/index.liquid.js +10 -12
  38. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.js +25 -0
  39. package/dist/cjs/product/components/DynamicCheckout/DynamicCheckout.liquid.js +23 -0
  40. package/dist/cjs/product/components/DynamicCheckout/common/classes.js +32 -0
  41. package/dist/cjs/product/components/DynamicCheckout/common/styles.js +181 -0
  42. package/dist/cjs/product/components/DynamicCheckout/components/Button.liquid.js +58 -0
  43. package/dist/cjs/product/components/DynamicCheckout.js +2 -5
  44. package/dist/cjs/product/components/FileUpload/components/common/index.js +2 -2
  45. package/dist/cjs/product/components/ProductButton.js +2 -3
  46. package/dist/cjs/product/components/ProductButton.liquid.js +3 -3
  47. package/dist/cjs/product/components/ProductDescription/common/const.js +9 -0
  48. package/dist/cjs/product/components/ProductDescription/common/getClasses.js +30 -0
  49. package/dist/cjs/product/components/ProductDescription/common/getStyle.js +81 -0
  50. package/dist/cjs/product/components/ProductDescription/hooks/useGpDescription.js +90 -0
  51. package/dist/cjs/product/components/ProductDescription/index.js +115 -0
  52. package/dist/cjs/product/components/ProductDescription/index.liquid.js +85 -0
  53. package/dist/cjs/product/components/ProductViewMore.js +2 -5
  54. package/dist/cjs/product/components/ProductViewMore.liquid.js +2 -2
  55. package/dist/cjs/product/next.js +1 -1
  56. package/dist/cjs/setting.js +3 -3
  57. package/dist/cjs/text/components/common/getClasses.js +1 -1
  58. package/dist/cjs/third-party/components/PushOwl.js +0 -5
  59. package/dist/esm/article/components/ArticleReadMore.js +1 -3
  60. package/dist/esm/banner/components/HeroBannerItem.liquid.js +5 -5
  61. package/dist/esm/builder.js +4 -8
  62. package/dist/esm/button/components/Button.js +113 -186
  63. package/dist/esm/button/components/Button.liquid.js +109 -172
  64. package/dist/esm/button/components/ButtonIcon.js +13 -0
  65. package/dist/esm/button/components/ButtonIcon.liquid.js +12 -0
  66. package/dist/esm/button/components/ButtonLabel.js +14 -0
  67. package/dist/esm/button/components/ButtonLabel.liquid.js +11 -0
  68. package/dist/esm/button/components/ButtonLoadingIndicator.liquid.js +8 -0
  69. package/dist/esm/button/components/common/attributes.js +13 -0
  70. package/dist/esm/button/components/common/classes.js +49 -0
  71. package/dist/esm/button/components/common/constants.js +24 -0
  72. package/dist/esm/button/components/common/data.js +74 -0
  73. package/dist/esm/button/components/common/helpers.js +118 -0
  74. package/dist/esm/button/components/common/styles.js +148 -0
  75. package/dist/esm/button/next.js +2 -6
  76. package/dist/esm/button/setting/configs/settings.js +5 -1
  77. package/dist/esm/cart/components/CheckoutNow.js +0 -2
  78. package/dist/esm/cart/components/ShopPayButton/ShopPayButton.js +66 -0
  79. package/dist/esm/cart/components/ShopPayButton/ShopPayButton.liquid.js +67 -0
  80. package/dist/esm/cart/components/ShopPayButton/common/classes.js +15 -0
  81. package/dist/esm/cart/components/ShopPayButton/common/helpers.js +27 -0
  82. package/dist/esm/cart/components/ShopPayButton/common/styles.js +10 -0
  83. package/dist/esm/cart/components/ShopPayButton/hooks/useShopPayButton.js +68 -0
  84. package/dist/esm/cart/next.js +1 -1
  85. package/dist/esm/coupon/components/Coupon.js +1 -3
  86. package/dist/esm/dialog/setting/Dialog.js +7 -580
  87. package/dist/esm/dialog/setting/configs/settings.js +323 -0
  88. package/dist/esm/dialog/setting/configs/uiV1.js +286 -0
  89. package/dist/esm/dialog/setting/configs/uiV2.js +256 -0
  90. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +4 -4
  91. package/dist/esm/form/components/submit-button/SubmitButton.js +0 -4
  92. package/dist/esm/header/components/kind/basic/index.js +1 -1
  93. package/dist/esm/header/components/kind/modern/index.js +1 -1
  94. package/dist/esm/index.js +4 -5
  95. package/dist/esm/index.liquid.js +4 -5
  96. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.js +21 -0
  97. package/dist/esm/product/components/DynamicCheckout/DynamicCheckout.liquid.js +19 -0
  98. package/dist/esm/product/components/DynamicCheckout/common/classes.js +30 -0
  99. package/dist/esm/product/components/DynamicCheckout/common/styles.js +179 -0
  100. package/dist/esm/product/components/DynamicCheckout/components/Button.liquid.js +54 -0
  101. package/dist/esm/product/components/DynamicCheckout.js +1 -4
  102. package/dist/esm/product/components/FileUpload/components/common/index.js +2 -2
  103. package/dist/esm/product/components/ProductButton.js +1 -2
  104. package/dist/esm/product/components/ProductButton.liquid.js +1 -1
  105. package/dist/esm/product/components/ProductDescription/common/const.js +6 -0
  106. package/dist/esm/product/components/ProductDescription/common/getClasses.js +27 -0
  107. package/dist/esm/product/components/ProductDescription/common/getStyle.js +77 -0
  108. package/dist/esm/product/components/ProductDescription/hooks/useGpDescription.js +88 -0
  109. package/dist/esm/product/components/ProductDescription/index.js +111 -0
  110. package/dist/esm/product/components/ProductDescription/index.liquid.js +81 -0
  111. package/dist/esm/product/components/ProductViewMore.js +1 -4
  112. package/dist/esm/product/components/ProductViewMore.liquid.js +1 -1
  113. package/dist/esm/product/next.js +1 -1
  114. package/dist/esm/setting.js +3 -3
  115. package/dist/esm/text/components/common/getClasses.js +1 -1
  116. package/dist/esm/third-party/components/PushOwl.js +0 -5
  117. package/dist/types/index.d.ts +200 -360
  118. package/package.json +2 -2
  119. package/dist/cjs/button/components/v2/ButtonIcon.js +0 -18
  120. package/dist/cjs/button/components/v2/ButtonLabel.js +0 -25
  121. package/dist/cjs/button/components/v2/ButtonV2.js +0 -140
  122. package/dist/cjs/button/components/v2/ButtonV2.liquid.js +0 -181
  123. package/dist/cjs/button/hooks/useButtonCustomCss.js +0 -88
  124. package/dist/cjs/button/hooks/useButtonStyles.js +0 -93
  125. package/dist/cjs/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -20
  126. package/dist/cjs/cart/components/ShopPayButton/index.js +0 -113
  127. package/dist/cjs/cart/components/ShopPayButton/index.liquid.js +0 -51
  128. package/dist/cjs/product/components/DynamicCheckout.liquid.js +0 -250
  129. package/dist/cjs/product/components/ProductDescription/const.js +0 -5
  130. package/dist/cjs/product/components/ProductDescription.js +0 -172
  131. package/dist/cjs/product/components/ProductDescription.liquid.js +0 -120
  132. package/dist/esm/button/components/v2/ButtonIcon.js +0 -14
  133. package/dist/esm/button/components/v2/ButtonLabel.js +0 -21
  134. package/dist/esm/button/components/v2/ButtonV2.js +0 -136
  135. package/dist/esm/button/components/v2/ButtonV2.liquid.js +0 -177
  136. package/dist/esm/button/hooks/useButtonCustomCss.js +0 -84
  137. package/dist/esm/button/hooks/useButtonStyles.js +0 -91
  138. package/dist/esm/cart/components/ShopPayButton/ShopPayButtonCommon.js +0 -17
  139. package/dist/esm/cart/components/ShopPayButton/index.js +0 -109
  140. package/dist/esm/cart/components/ShopPayButton/index.liquid.js +0 -47
  141. package/dist/esm/product/components/DynamicCheckout.liquid.js +0 -246
  142. package/dist/esm/product/components/ProductDescription/const.js +0 -3
  143. package/dist/esm/product/components/ProductDescription.js +0 -168
  144. package/dist/esm/product/components/ProductDescription.liquid.js +0 -116
  145. /package/dist/cjs/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
  146. /package/dist/cjs/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
  147. /package/dist/esm/button/components/{v2/ButtonLoadingIndicator.js → ButtonLoadingIndicator.js} +0 -0
  148. /package/dist/esm/product/components/ProductDescription/{common.js → common/getMaxHeight.js} +0 -0
@@ -1,109 +0,0 @@
1
- 'use client';
2
- import { jsx } from 'react/jsx-runtime';
3
- import { useShopStore, useCartData, useCurrentVariant, useCurrentVariantInStock, useQuantity, useEditorMode, makeStyleResponsive, cls } from '@gem-sdk/core';
4
- import dynamic from 'next/dynamic';
5
- import { useMemo } from 'react';
6
- import { getStoreUrl, getIdFromGid } from './ShopPayButtonCommon.js';
7
-
8
- const DynamicCheckoutBlack = dynamic(()=>import('./icons/DynamicCheckoutBlack.js'));
9
- const DynamicCheckoutPurple = dynamic(()=>import('./icons/DynamicCheckoutPurple.js'));
10
- const DynamicCheckoutWhite = dynamic(()=>import('./icons/DynamicCheckoutWhite.js'));
11
- const ExpressCheckoutBlack = dynamic(()=>import('./icons/ExpressCheckoutBlack.js'));
12
- const ExpressCheckoutPurple = dynamic(()=>import('./icons/ExpressCheckoutPurple.js'));
13
- const ExpressCheckoutWhite = dynamic(()=>import('./icons/ExpressCheckoutWhite.js'));
14
- /**
15
- * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
16
- */ const ShopPayButton = ({ className, setting, builderAttrs, style, styles })=>{
17
- const storefrontUrl = useShopStore((s)=>s.storefrontUrl);
18
- const storeUrl = getStoreUrl(storefrontUrl);
19
- const { data: cartData } = useCartData();
20
- const currentVariant = useCurrentVariant();
21
- const isCurrentVariantInStock = useCurrentVariantInStock();
22
- const { quantity } = useQuantity();
23
- const mode = useEditorMode();
24
- const idsInCart = useMemo(()=>{
25
- const items = cartData?.lineItems.map((v)=>({
26
- id: v.variantId,
27
- quantity: v.quantity
28
- }))?.reduce((prev, curr)=>{
29
- const bareId = getIdFromGid(curr?.id);
30
- if (bareId) {
31
- prev.push(`${bareId}:${curr?.quantity ?? 1}`);
32
- }
33
- return prev;
34
- }, []);
35
- return items;
36
- }, [
37
- cartData?.lineItems
38
- ]);
39
- const variants = useMemo(()=>{
40
- if (setting?.kind === 'cart-buy') {
41
- return idsInCart;
42
- }
43
- if (currentVariant?.baseID && isCurrentVariantInStock && quantity) {
44
- return [
45
- `${getIdFromGid(currentVariant.baseID)}:${quantity}`
46
- ];
47
- }
48
- return undefined;
49
- }, [
50
- setting?.kind,
51
- currentVariant?.baseID,
52
- isCurrentVariantInStock,
53
- quantity,
54
- idsInCart
55
- ]);
56
- const SPButton = useMemo(()=>{
57
- if (styles?.type === 'dynamic') {
58
- if (styles.color === 'black') return DynamicCheckoutBlack;
59
- if (styles.color === 'purple') return DynamicCheckoutPurple;
60
- return DynamicCheckoutWhite;
61
- } else {
62
- if (styles?.color === 'black') return ExpressCheckoutBlack;
63
- if (styles?.color === 'purple') return ExpressCheckoutPurple;
64
- return ExpressCheckoutWhite;
65
- }
66
- }, [
67
- styles?.type,
68
- styles?.color
69
- ]);
70
- if (!storeUrl) {
71
- return /*#__PURE__*/ jsx("div", {
72
- ...builderAttrs,
73
- children: "URL Not Found"
74
- });
75
- }
76
- const payUrl = `${storeUrl}/cart/${variants?.join(',')}?payment=shop_pay`;
77
- const onClickPay = (w, h)=>{
78
- if (mode === 'edit') return;
79
- if (setting?.openMode === 'popup') {
80
- const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
81
- const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
82
- const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
83
- const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
84
- const systemZoom = width / window.screen.availWidth;
85
- const left = (width - w) / 2 / systemZoom + dualScreenLeft;
86
- const top = (height - h) / 2 / systemZoom + dualScreenTop;
87
- window.open(payUrl, 'shop_pay', `scrollbars=yes, width=${w / systemZoom}, height=${h / systemZoom}, top=${top}, left=${left}`);
88
- } else {
89
- !!payUrl && window.open(payUrl);
90
- }
91
- };
92
- return /*#__PURE__*/ jsx("div", {
93
- ...builderAttrs,
94
- style: {
95
- ...style,
96
- ...makeStyleResponsive('jc', styles?.align)
97
- },
98
- className: cls(className, 'gp-flex'),
99
- children: /*#__PURE__*/ jsx("button", {
100
- disabled: !variants?.length,
101
- className: "disabled:gp-cursor-not-allowed disabled:gp-opacity-50",
102
- "aria-label": "Buy with Shop Pay",
103
- onClick: ()=>onClickPay(600, 600),
104
- children: /*#__PURE__*/ jsx(SPButton, {})
105
- })
106
- });
107
- };
108
-
109
- export { ShopPayButton as default };
@@ -1,47 +0,0 @@
1
- import { template, makeStyleResponsive, cls, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
- import DynamicCheckoutBlack from './icons/DynamicCheckoutBlack.liquid.js';
3
- import DynamicCheckoutPurple from './icons/DynamicCheckoutPurple.liquid.js';
4
- import DynamicCheckoutWhite from './icons/DynamicCheckoutWhite.liquid.js';
5
- import ExpressCheckoutBlack from './icons/ExpressCheckoutBlack.liquid.js';
6
- import ExpressCheckoutPurple from './icons/ExpressCheckoutPurple.liquid.js';
7
- import ExpressCheckoutWhite from './icons/ExpressCheckoutWhite.liquid.js';
8
- import { getSettingPreloadData } from '../../../helpers.js';
9
-
10
- /**
11
- * The `ShopPayButton` component renders a button that redirects to the Shop Pay checkout.
12
- */ const ShopPayButton = ({ className, setting, builderAttrs, style, styles, advanced })=>{
13
- const SPButton = ()=>{
14
- if (styles?.type === 'dynamic') {
15
- if (styles.color === 'black') return DynamicCheckoutBlack;
16
- if (styles.color === 'purple') return DynamicCheckoutPurple;
17
- return DynamicCheckoutWhite;
18
- } else {
19
- if (styles?.color === 'black') return ExpressCheckoutBlack;
20
- if (styles?.color === 'purple') return ExpressCheckoutPurple;
21
- return ExpressCheckoutWhite;
22
- }
23
- };
24
- return template`
25
- <gp-shop-pay-button
26
- ${{
27
- ...builderAttrs
28
- }}
29
- style="${{
30
- ...style,
31
- ...makeStyleResponsive('jc', styles?.align)
32
- }}"
33
- class="${cls(className, 'gp-flex', advanced?.cssClass)}"
34
- gp-data='{"setting":${JSON.stringify(setting)}, "shop_url": "{{shop.url}}" }'
35
- >
36
- <button
37
- class="disabled:gp-cursor-not-allowed disabled:gp-pacity-50 gp-shop-button"
38
- aria-label="Buy with Shop Pay"
39
- >
40
- ${SPButton()({})}
41
- </button>
42
- </gp-shop-pay-button>
43
- ${RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-shop-pay-button.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-shop-pay-button.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
44
- `;
45
- };
46
-
47
- export { ShopPayButton as default };
@@ -1,246 +0,0 @@
1
- import { getWidthHeightGlobalSize, getPaddingGlobalSize, template, cls, genTypoClass, genSizeClass, getGlobalColorStateClassDynamicBtn, composeTypographyV2Css, composeShadowCss, composeCornerCss, composeBorderCss, composeBackgroundCss, composeBackgroundImageCss, composeTextHoverColorCss, RenderIf, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
- import { getDynamicSourceLocales, getSettingPreloadData } from '../../helpers.js';
3
-
4
- const DynamicCheckout = ({ builderProps, styles, advanced, setting, pageContext })=>{
5
- const composeGlobalSize = {
6
- width: getWidthHeightGlobalSize('width', styles?.globalSize),
7
- height: getWidthHeightGlobalSize('height', styles?.globalSize),
8
- padding: getPaddingGlobalSize(styles?.globalSize)
9
- };
10
- const composeSize = (width, height, important = true)=>{
11
- return `
12
- ${width ? `width: ${width}${important ? '!important;' : ''};` : ''}
13
- ${height ? `height: ${height}${important ? '!important;' : ''};` : ''}
14
- `;
15
- };
16
- const composeSpacing = (device)=>{
17
- const suffix = device && device !== 'desktop' ? `-${device}` : '';
18
- const spacingDevice = {
19
- top: composeGlobalSize.padding[`--pt${suffix}`],
20
- bottom: composeGlobalSize.padding[`--pb${suffix}`],
21
- left: composeGlobalSize.padding[`--pl${suffix}`],
22
- right: composeGlobalSize.padding[`--pr${suffix}`]
23
- };
24
- return `padding-top: ${spacingDevice.top ? `${spacingDevice.top} !important;` : ''};
25
- padding-bottom: ${spacingDevice.bottom ? `${spacingDevice.bottom} !important;` : ''};
26
- padding-left: ${spacingDevice.left ? `${spacingDevice.left} !important;` : ''};
27
- padding-right: ${spacingDevice.right ? `${spacingDevice.right} !important;` : ''};
28
- `;
29
- };
30
- const composeFontSize = (fontSize)=>{
31
- return fontSize ? `font-size: ${fontSize} !important;` : '';
32
- };
33
- const composeLineHeight = (lineHeight)=>{
34
- return lineHeight ? `line-height: ${lineHeight} !important;` : '';
35
- };
36
- const composeTextAlign = (align)=>{
37
- return `${align ? `text-align: ${align} !important;` : ''}`;
38
- };
39
- const translatedLabel = getDynamicSourceLocales({
40
- val: setting?.label,
41
- uid: builderProps?.uid,
42
- settingId: 'label',
43
- pageContext,
44
- translate: setting?.translate
45
- });
46
- return template /* liquid */ `
47
- {%- liquid
48
- assign inventory_quantity = variant.inventory_quantity | default: 0
49
- assign supported_payment_methods = shop.enabled_payment_types
50
- -%}
51
- <gp-product-dynamic data-id="${builderProps?.uid}" data-translate-label="${translatedLabel}" class="${advanced?.cssClass}" gp-data='${JSON.stringify({
52
- setting: {
53
- label: setting?.label
54
- },
55
- totalVariant: '{{product.variants.size}}'
56
- }).replaceAll("'", '&#039;')}
57
- '>
58
- <div class="${cls('gp-block', `${'wrap__button--unbranded__' + builderProps?.uid}`, String.raw`[&_.shopify-payment-button\_\_button--unbranded]:gp-min-h-fit`, String.raw`disabled:[&_.shopify-payment-button\_\_button--unbranded]:gp-pointer-events-none`, styles?.typo?.type ? String.raw`[&_.shopify-payment-button\_\_button--unbranded]:!${genTypoClass(styles?.typo?.type)}` : '', styles?.btnSpacing?.type ? String.raw`[&_.shopify-payment-button\_\_button--unbranded]:!${genSizeClass(styles?.btnSpacing?.type)}` : '', getGlobalColorStateClassDynamicBtn('text', styles?.textColor))}">
59
- {{ form | payment_button }}
60
- </div>
61
- {% style %}
62
- .wrap__button--unbranded__${builderProps?.uid} {
63
- ${composeTextAlign(styles?.align?.desktop)}
64
- }
65
-
66
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button {
67
- display: inline-block;
68
- min-height: unset !important;
69
- ${composeSize(composeGlobalSize.width.desktop ?? 'auto', composeGlobalSize.height.desktop ?? 'auto', false)}
70
- }
71
-
72
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button div {
73
- width: 100%;
74
- margin-top: 0px !important;
75
- }
76
-
77
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__more-options {
78
- display: none;
79
- }
80
-
81
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded {
82
- max-width: 100%;
83
- min-width: unset;
84
- min-height: unset !important;
85
- background-color: unset !important;
86
- position: relative;
87
- border: none !important;
88
- margin: 0;
89
- z-index: 0;
90
- border-radius: unset;
91
- width: 100%;
92
- display: inline-flex;
93
- justify-content: center;
94
- align-items: center;
95
- ${composeTypographyV2Css(styles?.typo, true)}
96
- ${composeShadowCss({
97
- boxShadowValue: styles?.boxShadowBtnV2?.desktop?.normal,
98
- hasBoxShadow: styles?.boxShadowBtnV2?.desktop?.normal?.type !== 'none'
99
- })}
100
- ${composeSpacing('desktop')}
101
- ${composeCornerCss(styles?.roundedBtnV2?.desktop?.normal, true)}
102
- ${composeSize(undefined, composeGlobalSize.height.desktop ?? 'auto', false)}
103
- }
104
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::before {
105
- content: "";
106
- height: 100%;
107
- width: 100%;
108
- position: absolute;
109
- top: 0;
110
- left: 0;
111
- pointer-events: none;
112
- z-index: -1;
113
- ${composeBorderCss(styles?.borderBtnV2?.desktop?.normal)}
114
- ${composeCornerCss(styles?.roundedBtnV2?.desktop?.normal)}
115
- ${composeBackgroundCss(styles?.backgroundColorV2?.desktop?.normal)}
116
- ${composeBackgroundImageCss(styles?.backgroundImage, {
117
- device: 'desktop',
118
- state: 'normal'
119
- })}
120
- }
121
-
122
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover {
123
- ${composeShadowCss({
124
- boxShadowValue: styles?.boxShadowBtnV2?.desktop?.hover,
125
- hasBoxShadow: styles?.boxShadowBtnV2?.desktop?.hover?.type !== 'none',
126
- important: true
127
- })}
128
- ${composeTextHoverColorCss('desktop', styles?.textColorHover, true)}
129
- }
130
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover::before {
131
- ${composeBorderCss(styles?.borderBtnV2?.desktop?.hover)}
132
- ${composeCornerCss(styles?.roundedBtnV2?.desktop?.hover)}
133
- ${composeBackgroundCss(styles?.backgroundColorV2?.desktop?.hover)}
134
- }
135
-
136
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::after {
137
- border-radius: 0;
138
- box-shadow: none;
139
- }
140
-
141
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::after:hover {
142
- border-radius: 0;
143
- box-shadow: none;
144
- }
145
-
146
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button > div {
147
- max-width: 100%;
148
- }
149
-
150
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button > div > div {
151
- max-width: 100%;
152
- }
153
-
154
- @media only screen and (max-width: 1024px) and (min-width: 768px) {
155
- .wrap__button--unbranded__${builderProps?.uid} {
156
- ${composeTextAlign(styles?.align?.tablet)}
157
- }
158
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button {
159
- ${composeSize(composeGlobalSize.width.tablet, composeGlobalSize.height.tablet)}
160
- }
161
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover {
162
- ${composeShadowCss({
163
- boxShadowValue: styles?.boxShadowBtnV2?.tablet?.hover,
164
- hasBoxShadow: styles?.boxShadowBtnV2?.tablet?.hover?.type !== 'none',
165
- important: true
166
- })}
167
- ${composeTextHoverColorCss('tablet', styles?.textColorHover, true)}
168
- }
169
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded {
170
- width: 100%;
171
-
172
- ${composeSpacing('tablet')}
173
- ${composeLineHeight(styles?.typo?.custom?.lineHeight?.tablet)}
174
- ${composeFontSize(styles?.typo?.custom?.fontSize?.tablet)}
175
- ${composeSize(composeGlobalSize.width.tablet ?? 'auto', composeGlobalSize.height.tablet ?? 'auto', false)}
176
- ${composeShadowCss({
177
- boxShadowValue: styles?.boxShadowBtnV2?.tablet?.normal,
178
- hasBoxShadow: styles?.boxShadowBtnV2?.tablet?.normal?.type !== 'none'
179
- })}
180
- ${composeCornerCss(styles?.roundedBtnV2?.tablet?.normal, true)}
181
- }
182
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover::before {
183
- ${composeBorderCss(styles?.borderBtnV2?.tablet?.hover)}
184
- ${composeCornerCss(styles?.roundedBtnV2?.tablet?.hover)}
185
- ${composeBackgroundCss(styles?.backgroundColorV2?.tablet?.hover)}
186
- }
187
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::before {
188
- ${composeBorderCss(styles?.borderBtnV2?.tablet?.normal)}
189
- ${composeCornerCss(styles?.roundedBtnV2?.tablet?.normal)}
190
- ${composeBackgroundImageCss(styles?.backgroundImage, {
191
- device: 'tablet',
192
- state: 'normal'
193
- })}
194
- }
195
- }
196
-
197
- @media only screen and (max-width: 767px) {
198
- .wrap__button--unbranded__${builderProps?.uid} {
199
- ${composeTextAlign(styles?.align?.mobile)}
200
- }
201
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button {
202
- ${composeSize(composeGlobalSize.width.mobile, composeGlobalSize.height.mobile)}
203
- }
204
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover {
205
- ${composeShadowCss({
206
- boxShadowValue: styles?.boxShadowBtnV2?.mobile?.hover,
207
- hasBoxShadow: styles?.boxShadowBtnV2?.mobile?.hover?.type !== 'none',
208
- important: true
209
- })}
210
- ${composeTextHoverColorCss('mobile', styles?.textColorHover, true)}
211
- }
212
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded {
213
- width: 100%;
214
- ${composeSpacing('mobile')}
215
- ${composeLineHeight(styles?.typo?.custom?.lineHeight?.mobile)}
216
- ${composeFontSize(styles?.typo?.custom?.fontSize?.mobile)}
217
- ${composeSize(composeGlobalSize.width.mobile ?? 'auto', composeGlobalSize.height.mobile ?? 'auto', false)}
218
- ${composeShadowCss({
219
- boxShadowValue: styles?.boxShadowBtnV2?.mobile?.normal,
220
- hasBoxShadow: styles?.boxShadowBtnV2?.mobile?.normal?.type !== 'none'
221
- })}
222
- ${composeCornerCss(styles?.roundedBtnV2?.mobile?.normal, true)}
223
- }
224
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded:hover::before {
225
- ${composeBorderCss(styles?.borderBtnV2?.mobile?.hover)}
226
- ${composeCornerCss(styles?.roundedBtnV2?.mobile?.hover)}
227
- ${composeBackgroundCss(styles?.backgroundColorV2?.mobile?.hover)}
228
- }
229
- .wrap__button--unbranded__${builderProps?.uid} .shopify-payment-button .shopify-payment-button__button--unbranded::before {
230
- ${composeBorderCss(styles?.borderBtnV2?.mobile?.normal)}
231
- ${composeCornerCss(styles?.roundedBtnV2?.mobile?.normal)}
232
- ${composeBackgroundImageCss(styles?.backgroundImage, {
233
- device: 'mobile',
234
- state: 'normal'
235
- })}
236
- ${composeBackgroundCss(styles?.backgroundColorV2?.mobile?.normal)}
237
- }
238
- }
239
-
240
- {% endstyle %}
241
- </gp-product-dynamic>
242
- ${RenderIf(isLocalEnv, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="{{ 'gp-product-dynamic.js' | asset_url }}" defer="defer"></script>`, `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${baseAssetURL}/assets-v2/gp-product-dynamic.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
243
- `;
244
- };
245
-
246
- export { DynamicCheckout as default };
@@ -1,3 +0,0 @@
1
- const DESCRIPTION_LINE_HEIGHT_DEFAULT = 21;
2
-
3
- export { DESCRIPTION_LINE_HEIGHT_DEFAULT };
@@ -1,168 +0,0 @@
1
- 'use client';
2
- import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
3
- import { useProduct, useCurrentDevice, getResponsiveValueByScreen, useProductShopifyEditLink, useEditorMode, isBrowser, composeTypographyClassName, composeTypographyStyle, cls, getGlobalColorClass, getStyleShadow, makeStyleResponsive, makeStyle, getGlobalColorStyle } from '@gem-sdk/core';
4
- import { useState, useRef, useEffect } from 'react';
5
- import NoDataState from '../../common/components/NoDataState.js';
6
- import { getMaxHeightStyleDefault } from './ProductDescription/common.js';
7
- import { DESCRIPTION_LINE_HEIGHT_DEFAULT } from './ProductDescription/const.js';
8
-
9
- const ProductDescription = ({ setting, builderProps })=>{
10
- const [open, setOpen] = useState(false);
11
- const [isShowViewMore, allowShowViewMore] = useState(false);
12
- const product = useProduct();
13
- const { htmlTag } = setting ?? {};
14
- const ref = useRef(null);
15
- const currentDevice = useCurrentDevice();
16
- const hasLineClamp = getResponsiveValueByScreen(setting?.hasLineClamp, currentDevice);
17
- const lineClamp = getResponsiveValueByScreen(setting?.lineClamp, currentDevice);
18
- const { redirectProductShopifyLink } = useProductShopifyEditLink();
19
- const mode = useEditorMode();
20
- const isSafari = isBrowser() ? navigator?.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1 : false;
21
- useEffect(()=>{
22
- const dom = ref.current;
23
- setOpen(false);
24
- if (!dom) return;
25
- const enableShowMore = hasLineClamp && product?.descriptionHtml;
26
- if (!enableShowMore) dom.style.maxHeight = 'none';
27
- else {
28
- const value = lineClamp;
29
- setTimeout(()=>{
30
- const scrollHeight = dom?.scrollHeight ?? 0;
31
- const clientHeight = dom?.clientHeight ?? 0;
32
- const lineHeight = getLineHeightFromDom();
33
- const lineText = Math.round((scrollHeight ?? 0) / lineHeight);
34
- dom.style.maxHeight = getMaxHeight(lineHeight);
35
- const conditionCheckLine = value && value < lineText || clientHeight < scrollHeight;
36
- if (value && conditionCheckLine) {
37
- allowShowViewMore(()=>true);
38
- } else {
39
- allowShowViewMore(()=>false);
40
- }
41
- }, 100);
42
- }
43
- }, [
44
- hasLineClamp,
45
- lineClamp,
46
- product?.description,
47
- isSafari
48
- ]);
49
- const getLineHeightFromDom = ()=>{
50
- if (!ref.current) return DESCRIPTION_LINE_HEIGHT_DEFAULT;
51
- const lineHeight = window.getComputedStyle(ref.current).getPropertyValue('line-height');
52
- return parseInt(lineHeight);
53
- };
54
- const getMaxHeight = (lineHeight)=>{
55
- if (!hasLineClamp || !lineClamp) return 'auto';
56
- if (lineHeight) return `${lineClamp * lineHeight}px`;
57
- return 'auto';
58
- };
59
- const Tag = htmlTag === 'html' ? 'div' : 'p';
60
- const appendTypoClass = composeTypographyClassName(setting?.typo, setting?.typography);
61
- const appendTypoStyle = composeTypographyStyle(setting?.typo, setting?.typography);
62
- const css = `
63
- .gp-p-description-text > *:not(ol):not(ul):not(table):not(div):not(style):not(script) {
64
- display: inline !important;
65
- }
66
- .gp-p-description-text > *:not(ol):not(ul):not(table):not(div):not(style):not(script)::after {
67
- content: "\\A";
68
- white-space: pre;
69
- }
70
- .gp-p-description-text > table {
71
- box-shadow: none;
72
- }
73
- `;
74
- const noDescriptionHtml = !product?.descriptionHtml;
75
- if (noDescriptionHtml && mode === 'edit') {
76
- return /*#__PURE__*/ jsx(NoDataState, {
77
- elementType: "secondary",
78
- description: "Highlight key benefits with product description.",
79
- descriptionActions: [
80
- {
81
- text: 'Add description',
82
- callback: redirectProductShopifyLink
83
- },
84
- {
85
- text: 'sync data',
86
- callback: 'syncProduct'
87
- }
88
- ]
89
- });
90
- }
91
- const handleToggleShowMore = ()=>{
92
- if (!ref.current) return;
93
- const lineHeight = getLineHeightFromDom();
94
- if (open) {
95
- ref.current.style.maxHeight = getMaxHeight(lineHeight);
96
- } else {
97
- ref.current.style.maxHeight = 'none';
98
- }
99
- setOpen((prev)=>!prev);
100
- };
101
- return /*#__PURE__*/ jsx(Fragment, {
102
- children: noDescriptionHtml ? null : /*#__PURE__*/ jsxs("div", {
103
- "data-id": builderProps?.uid,
104
- children: [
105
- !isSafari && /*#__PURE__*/ jsx("style", {
106
- type: "text/css",
107
- dangerouslySetInnerHTML: {
108
- __html: css
109
- }
110
- }),
111
- /*#__PURE__*/ jsx(Tag, {
112
- ref: ref,
113
- "data-gp-text": true,
114
- className: cls('gp-p-description-text gp-break-words safari:[&_p]:gp-inline safari:[&_p]:after:gp-whitespace-pre', appendTypoClass, getGlobalColorClass('text', setting?.color)),
115
- style: {
116
- ...getStyleShadow({
117
- value: setting?.typo?.custom?.textShadow,
118
- styleAppliedFor: 'text-shadow',
119
- isEnableShadow: setting?.typo?.custom?.textShadow?.type !== 'none'
120
- }),
121
- ...makeStyleResponsive('ta', setting?.textAlign),
122
- ...hasLineClamp && !open ? makeStyleResponsive('line-clamp', setting?.lineClamp) : {},
123
- ...makeStyle({
124
- tt: setting?.transform
125
- }),
126
- ...appendTypoStyle,
127
- ...getMaxHeightStyleDefault(setting)
128
- },
129
- dangerouslySetInnerHTML: {
130
- __html: product?.descriptionHtml || ''
131
- }
132
- }),
133
- hasLineClamp && isShowViewMore && /*#__PURE__*/ jsxs("button", {
134
- className: cls(appendTypoClass, getGlobalColorClass('text', setting?.showMoreColor), 'gp-mt-4 gp-w-full gp-transition-all hover:gp-opacity-80'),
135
- style: {
136
- ...makeStyleResponsive('ta', setting?.textAlign),
137
- ...makeStyle({
138
- tt: setting?.transform
139
- }),
140
- ...appendTypoStyle,
141
- ...getGlobalColorStyle(setting?.showMoreColor)
142
- },
143
- onClick: handleToggleShowMore,
144
- children: [
145
- !open ? setting?.viewMoreText : setting?.viewLessText,
146
- setting?.enableViewMoreIcon && /*#__PURE__*/ jsx("svg", {
147
- className: "gp-ml-1 gp-inline-block",
148
- height: "1em",
149
- width: "1em",
150
- viewBox: "0 0 22 12",
151
- fill: "none",
152
- xmlns: "http://www.w3.org/2000/svg",
153
- children: !open ? /*#__PURE__*/ jsx("path", {
154
- 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",
155
- fill: "currentColor"
156
- }) : /*#__PURE__*/ jsx("path", {
157
- d: "M0.292893 10.2929C-0.0976311 10.6834 -0.0976311 11.3166 0.292893 11.7071C0.683417 12.0976 1.31658 12.0976 1.70711 11.7071L0.292893 10.2929ZM11 1L11.7071 0.292893C11.3166 -0.0976311 10.6834 -0.0976311 10.2929 0.292893L11 1ZM20.2929 11.7071C20.6834 12.0976 21.3166 12.0976 21.7071 11.7071C22.0976 11.3166 22.0976 10.6834 21.7071 10.2929L20.2929 11.7071ZM1.70711 11.7071L11.7071 1.70711L10.2929 0.292893L0.292893 10.2929L1.70711 11.7071ZM10.2929 1.70711L20.2929 11.7071L21.7071 10.2929L11.7071 0.292893L10.2929 1.70711Z",
158
- fill: "currentColor"
159
- })
160
- })
161
- ]
162
- })
163
- ]
164
- })
165
- });
166
- };
167
-
168
- export { ProductDescription as default };