@gem-sdk/components 13.1.4 → 13.1.5
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/product/components/product-badge/ProductBadge.liquid.js +19 -19
- package/dist/cjs/product/components/product-badge/common/styles.js +1 -1
- package/dist/cjs/product/components/product-badge/utils/renderBadgeLiquid.js +9 -4
- package/dist/esm/product/components/product-badge/ProductBadge.liquid.js +23 -23
- package/dist/esm/product/components/product-badge/common/styles.js +1 -1
- package/dist/esm/product/components/product-badge/utils/renderBadgeLiquid.js +9 -4
- package/package.json +1 -1
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../../../helpers.js"),generateLiquidContent=require("./utils/generateLiquidContent.js"),renderBadgeLiquid=require("./utils/renderBadgeLiquid.js"),system=require("@gem-sdk/system"),constants=require("./constants.js"),styles=require("./common/styles.js"),classes=require("./common/classes.js"),attrs=require("./common/attrs.js");const ProductBadge=e=>{let{styles:t,setting:s,builderProps:a,pageContext:r}=e,i=s?.shape!=="image",
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var core=require("@gem-sdk/core"),helpers=require("../../../helpers.js"),generateLiquidContent=require("./utils/generateLiquidContent.js"),renderBadgeLiquid=require("./utils/renderBadgeLiquid.js"),system=require("@gem-sdk/system"),constants=require("./constants.js"),styles=require("./common/styles.js"),classes=require("./common/classes.js"),attrs=require("./common/attrs.js"),common=require("./utils/common.js");const ProductBadge=e=>{let{styles:t,setting:s,builderProps:a,pageContext:r}=e,i=s?.shape!=="image",n=i&&s?.displayContent?.trim()==="",c=common.checkDiscountContentProductBadge(s?.displayContent),l=system.createClass({...classes.getContainerClasses({isInstant:!1,props:e})}),o=system.createStyle({...styles.getContainerStyle(e,constants.IS_LIQUID)}),d=system.createClass({...classes.getWrapperClasses(e)}),p=system.createClass({...classes.getSubWrapperClass(e)}),u=system.createStyle({...styles.getSubWrapperStyle({props:e})}),y=system.createAttr({...attrs.getSubWrapperAttrs(e)}),g=styles.getContentStyleInternal(e),m=system.createClass({...classes.getTextContainerClasses()}),C=system.createAttr({...attrs.getContainerAttrs(e)}),v=system.createClass({...classes.getTextWrapperClasses()}),$=system.createStyle({...styles.getTextBadgeWrapperStyles({setting:s,styles:t})}),S=system.createClass({...classes.getTextContentClasses(t)}),q=system.createStyle({...styles.getTextContentStyle({setting:s,styles:t})}),I=system.createAttr({...attrs.getTextContentAttrs()}),j=system.createClass({...classes.getImageContainerClasses()}),D=system.createStyle({...styles.getImageContainerStyles({setting:s,styles:t})}),P=system.createClass({...classes.getImageClasses()}),f=system.createAttr({...attrs.getImageAttr({setting:s})}),A=system.createStateOrContext({minPrice:"{{ minPriceValue | replace: '\"', '\\\"' | escape }}",variantIDs:'{{ product.variants | map: "id" | json | escape }}',variantInventoryQuantities:'{{ product.variants | map: "inventory_quantity" | json | escape }}',amountDiscount:"{{amountDiscountValue | replace: '\"', '\\\"' | escape }}",percentDiscount:"{{percentDiscountValue}}",price:"{{price}}",displayTrigger:JSON.parse(JSON.stringify(s?.displayTrigger).replaceAll("'","'")),uid:e.builderProps?.uid,productCreatedAt:'{{product.created_at | date: "%Y-%m-%d" }}',productTags:"{{ product.tags | join: \",\" | replace: '\"', '\\\"' | escape }}",isTextBadge:i}),{displayContent:L,translate:T}=s??{},b=helpers.getDynamicSourceLocales({val:L?.trim(),uid:a?.uid,settingId:"displayContent",isLiquid:!0,pageContext:r,translate:T});return core.template`
|
|
2
2
|
{% if product %}
|
|
3
|
-
${generateLiquidContent.generateBadgeContent(
|
|
4
|
-
${renderBadgeLiquid.renderBadgeInFirstTime(s?.displayTrigger,!
|
|
3
|
+
${generateLiquidContent.generateBadgeContent(b,r?.isPreviewing)}
|
|
4
|
+
${renderBadgeLiquid.renderBadgeInFirstTime(s?.displayTrigger,!n,c)}
|
|
5
5
|
<gp-product-badge
|
|
6
|
-
${{...
|
|
7
|
-
gp-data='${core.dataStringify(
|
|
8
|
-
class="${
|
|
9
|
-
style="${
|
|
10
|
-
data-display-content="${r?.isPreviewing?
|
|
6
|
+
${{...C}}
|
|
7
|
+
gp-data='${core.dataStringify(A)}'
|
|
8
|
+
class="${l} {{ className }}"
|
|
9
|
+
style="${o}"
|
|
10
|
+
data-display-content="${r?.isPreviewing?b:core.sanitizeLiquid(`{{${b}}}`)}"
|
|
11
11
|
>
|
|
12
12
|
<div class="${d}">
|
|
13
13
|
<div
|
|
14
14
|
${{...y}}
|
|
15
|
-
class="${
|
|
16
|
-
style="${
|
|
15
|
+
class="${p}"
|
|
16
|
+
style="${u}"
|
|
17
17
|
>
|
|
18
|
-
<style>${
|
|
18
|
+
<style>${g}</style>
|
|
19
19
|
${core.RenderIf(i,core.template`
|
|
20
|
-
<div class="${
|
|
20
|
+
<div class="${m}">
|
|
21
21
|
<div
|
|
22
|
-
class="${
|
|
23
|
-
style="${
|
|
22
|
+
class="${v}"
|
|
23
|
+
style="${$}"
|
|
24
24
|
>
|
|
25
25
|
<pre
|
|
26
|
-
${{...
|
|
27
|
-
class="${
|
|
28
|
-
style="${
|
|
26
|
+
${{...I}}
|
|
27
|
+
class="${S}"
|
|
28
|
+
style="${q}"
|
|
29
29
|
>{{ content | replace: percentDiscountKey, percentDiscountValue | replace: amountDiscountKey, amountDiscountValue | replace: inventoryQuantityKey, inventoryQuantityValue | replace: minPriceKey, minPriceValue }}</pre>
|
|
30
30
|
</div>
|
|
31
|
-
</div>`,core.template`<div class="${
|
|
32
|
-
<img ${{...
|
|
31
|
+
</div>`,core.template`<div class="${j}" style="${D}">
|
|
32
|
+
<img ${{...f}} class="${P}" alt="" />
|
|
33
33
|
</div>`)}
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var core=require("@gem-sdk/core"),common=require("../utils/common.js"),getShapePosition=require("../utils/getShapePosition.js"),getRotateShape=require("../utils/getRotateShape.js"),getStyleAdvanced=require("../utils/getStyleAdvanced.js"),getWhiteSpace=require("../utils/getWhiteSpace.js"),stylesV2=require("../utils/stylesV2.js"),shape=require("../utils/shape.js"),renderBadgeILP=require("../utils/renderBadgeILP.js");const getSizeStyles=e=>{let{setting:t,styles:o}=e,r=shape.getShape(t?.shape),a=t?.contentType==="text",i=a?o?.textSizeV2:o?.imageSizeV2;return a?common.getSize(r,i):common.getSize(void 0,i)},getContainerStyle=(e,t=!1)=>{let{setting:o,styles:r,style:a,navigationPosition:i,imageData:s,dotData:n}=e,g=o?.positionWithImage==="outside",l=common.getWrapperStyle(t),p=getShapePosition.getShapePosition({positionType:r?.position,isLiquid:!1,navigationPosition:i,dataImage:{...s,...n}}),S=getSizeStyles(e),d=getStyleAdvanced.getStyleAdvanced(g?{}:{...p,...S},a);return{...!g&&{"--pos":"absolute"},...l,...d}},getTextContentStyle=({styles:e,setting:t})=>{let o=core.makeGlobalSize(e?.textSizeV2).padding,r=shape.getShape(t?.shape),a=t?.positionWithImage==="outside";return{...getWhiteSpace.getWhiteSpaceStyle(e?.textSizeV2),...common.convertToStyle(r?.textStyle),...getRotateShape.composeTextStyleByPosition(r,e?.position,a),...core.composeTypographyStyle(e?.typo),...core.getStyleShadow({value:e?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:e?.typo?.custom?.hasShadowText}),...stylesV2.getStyleBackground(!!r?.backgroundColorInText,e?.badgeColorV2),...o}},getBorderStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?stylesV2.getStyleBorder(e?.textBadgeBorder):stylesV2.getStyleBorder(e?.imageBadgeBorder):{}},getCornerStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?stylesV2.getStyleCornerRadius(e?.textBadgeCorner,o?.shapeRadius):stylesV2.getStyleCornerRadius(e?.imageBadgeCorner,o?.shapeRadius):{}},getTextBadgeWrapperStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=getBorderStyles({setting:t,styles:e}),a=t?.positionWithImage==="outside",i=getCornerStyles({setting:t,styles:e}),s=common.getShapeWrapperPadding(o?.ratio);return{...r,...i,...getRotateShape.composeShapeStyleByPosition(o,e?.position,a),...stylesV2.getStyleBackground(!o?.backgroundColorInText,e?.badgeColorV2),...s,height:o?.ratio===1?"0px":"100%"}},getImageContainerStyles=({styles:e,setting:t})=>{let o=getBorderStyles({setting:t,styles:e}),r=getCornerStyles({setting:t,styles:e}),a=core.makeGlobalSize(e?.imageSizeV2).padding;return{...o,...r,...a}},getOpacityProductBadge=({props:e,currentVariant:t,product:o,isEditMode:r})=>{let{"bundle-item":a,setting:i}=e;if(a)return 1;let s=i?.contentType==="text",n=s&&!i?.displayContent?.trim();if(n)return r?.2:0;let
|
|
1
|
+
"use strict";var core=require("@gem-sdk/core"),common=require("../utils/common.js"),getShapePosition=require("../utils/getShapePosition.js"),getRotateShape=require("../utils/getRotateShape.js"),getStyleAdvanced=require("../utils/getStyleAdvanced.js"),getWhiteSpace=require("../utils/getWhiteSpace.js"),stylesV2=require("../utils/stylesV2.js"),shape=require("../utils/shape.js"),renderBadgeILP=require("../utils/renderBadgeILP.js");const getSizeStyles=e=>{let{setting:t,styles:o}=e,r=shape.getShape(t?.shape),a=t?.contentType==="text",i=a?o?.textSizeV2:o?.imageSizeV2;return a?common.getSize(r,i):common.getSize(void 0,i)},getContainerStyle=(e,t=!1)=>{let{setting:o,styles:r,style:a,navigationPosition:i,imageData:s,dotData:n}=e,g=o?.positionWithImage==="outside",l=common.getWrapperStyle(t),p=getShapePosition.getShapePosition({positionType:r?.position,isLiquid:!1,navigationPosition:i,dataImage:{...s,...n}}),S=getSizeStyles(e),d=getStyleAdvanced.getStyleAdvanced(g?{}:{...p,...S},a);return{...!g&&{"--pos":"absolute"},...l,...d}},getTextContentStyle=({styles:e,setting:t})=>{let o=core.makeGlobalSize(e?.textSizeV2).padding,r=shape.getShape(t?.shape),a=t?.positionWithImage==="outside";return{...getWhiteSpace.getWhiteSpaceStyle(e?.textSizeV2),...common.convertToStyle(r?.textStyle),...getRotateShape.composeTextStyleByPosition(r,e?.position,a),...core.composeTypographyStyle(e?.typo),...core.getStyleShadow({value:e?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:e?.typo?.custom?.hasShadowText}),...stylesV2.getStyleBackground(!!r?.backgroundColorInText,e?.badgeColorV2),...o}},getBorderStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?stylesV2.getStyleBorder(e?.textBadgeBorder):stylesV2.getStyleBorder(e?.imageBadgeBorder):{}},getCornerStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?stylesV2.getStyleCornerRadius(e?.textBadgeCorner,o?.shapeRadius):stylesV2.getStyleCornerRadius(e?.imageBadgeCorner,o?.shapeRadius):{}},getTextBadgeWrapperStyles=({styles:e,setting:t})=>{let o=shape.getShape(t?.shape),r=getBorderStyles({setting:t,styles:e}),a=t?.positionWithImage==="outside",i=getCornerStyles({setting:t,styles:e}),s=common.getShapeWrapperPadding(o?.ratio);return{...r,...i,...getRotateShape.composeShapeStyleByPosition(o,e?.position,a),...stylesV2.getStyleBackground(!o?.backgroundColorInText,e?.badgeColorV2),...s,height:o?.ratio===1?"0px":"100%"}},getImageContainerStyles=({styles:e,setting:t})=>{let o=getBorderStyles({setting:t,styles:e}),r=getCornerStyles({setting:t,styles:e}),a=core.makeGlobalSize(e?.imageSizeV2).padding;return{...o,...r,...a}},getOpacityProductBadge=({props:e,currentVariant:t,product:o,isEditMode:r})=>{let{"bundle-item":a,setting:i}=e;if(a)return 1;let s=i?.contentType==="text",n=s&&!i?.displayContent?.trim(),g=common.checkDiscountContentProductBadge(i?.displayContent);if(n)return r?.2:0;let l=core.convertDecimalToNumber(t?.price)??0,p=core.convertDecimalToNumber(t?.salePrice)??0,S=p-l>0,d=renderBadgeILP.checkShowBadge(i?.displayTrigger,o,t);return(S||!g)&&d?1:r?.2:0},getSubWrapperStyle=({props:e,product:t,currentVariant:o,isEditMode:r})=>{let{setting:a}=e,i=a?.positionWithImage==="outside",s=getSizeStyles(e),n=r&&o?getOpacityProductBadge({props:e,currentVariant:o,product:t,isEditMode:r}):1;return{...i?{...s,"--mb":0}:{},opacity:n}},getContentStyleInternal=e=>{let{styles:t,setting:o,builderProps:r}=e,a=o?.contentType==="text";return stylesV2.generateShadowCSS(`[id="${r?.uid}"] .product-badge-item`,a?t?.textBadgeShadow:t?.imageBadgeShadow)};exports.getContainerStyle=getContainerStyle,exports.getContentStyleInternal=getContentStyleInternal,exports.getImageContainerStyles=getImageContainerStyles,exports.getSubWrapperStyle=getSubWrapperStyle,exports.getTextBadgeWrapperStyles=getTextBadgeWrapperStyles,exports.getTextContentStyle=getTextContentStyle;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var types=require("../types.js");const getMinValueForInventory=e=>e===types.CompareType.ABOVE?0:e===types.CompareType.BELOW?2:1,renderBadgeInFirstTime=(e,i)=>`
|
|
1
|
+
"use strict";var types=require("../types.js");const getMinValueForInventory=e=>e===types.CompareType.ABOVE?0:e===types.CompareType.BELOW?2:1,renderBadgeInFirstTime=(e,i,n)=>`
|
|
2
2
|
{% assign isShow = true %}
|
|
3
3
|
{% assign conditionTriggers = "" %}
|
|
4
4
|
{% assign isInventoryStatus = false %}
|
|
@@ -17,10 +17,15 @@
|
|
|
17
17
|
{% assign salePrice = variant.compare_at_price | times: 1.0 %}
|
|
18
18
|
{% assign priceSave = salePrice | minus: price %}
|
|
19
19
|
{% assign isEmptyBadgeContent = ${!i} %}
|
|
20
|
-
{%
|
|
21
|
-
|
|
20
|
+
{% assign isNotDiscount = false %}
|
|
21
|
+
{% assign isBadgeContentHasDiscount = ${n} %}
|
|
22
|
+
{% if isEmptyBadgeContent == true %}
|
|
23
|
+
{% assign isNotDiscount = true %}
|
|
22
24
|
{% endif %}
|
|
23
|
-
{% if
|
|
25
|
+
{% if isBadgeContentHasDiscount == true and priceSave <= 0 %}
|
|
26
|
+
{% assign isNotDiscount = true %}
|
|
27
|
+
{% endif %}
|
|
28
|
+
{% if isShow and isNotDiscount == false %}
|
|
24
29
|
{% assign className = "" %}
|
|
25
30
|
{% else %}
|
|
26
31
|
{% assign className = "!gp-hidden" %}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import{template as e,dataStringify as t,sanitizeLiquid as s,RenderIf as i,isLocalEnv as r,baseAssetURL as a}from"@gem-sdk/core";import{getDynamicSourceLocales as c,getSettingPreloadData as
|
|
1
|
+
import{template as e,dataStringify as t,sanitizeLiquid as s,RenderIf as i,isLocalEnv as r,baseAssetURL as a}from"@gem-sdk/core";import{getDynamicSourceLocales as c,getSettingPreloadData as o}from"../../../helpers.js";import{generateBadgeContent as n}from"./utils/generateLiquidContent.js";import{renderBadgeInFirstTime as p}from"./utils/renderBadgeLiquid.js";import{createClass as d,createStyle as l,createAttr as u,createStateOrContext as m}from"@gem-sdk/system";import{IS_LIQUID as g}from"./constants.js";import{getContainerStyle as y,getSubWrapperStyle as $,getContentStyleInternal as v,getTextBadgeWrapperStyles as f,getTextContentStyle as j,getImageContainerStyles as P}from"./common/styles.js";import{getContainerClasses as D,getWrapperClasses as V,getSubWrapperClass as S,getTextContainerClasses as b,getTextWrapperClasses as C,getTextContentClasses as I,getImageContainerClasses as T,getImageClasses as k}from"./common/classes.js";import{getSubWrapperAttrs as q,getContainerAttrs as A,getTextContentAttrs as E,getImageAttr as K}from"./common/attrs.js";import{checkDiscountContentProductBadge as N}from"./utils/common.js";let ProductBadge=_=>{let{styles:h,setting:B,builderProps:L,pageContext:O}=_,Q=B?.shape!=="image",w=Q&&B?.displayContent?.trim()==="",G=N(B?.displayContent),J=d({...D({isInstant:!1,props:_})}),x=l({...y(_,g)}),M=d({...V(_)}),R=d({...S(_)}),Y=l({...$({props:_})}),z=u({...q(_)}),F=v(_),H=d({...b()}),U=u({...A(_)}),W=d({...C()}),X=l({...f({setting:B,styles:h})}),Z=d({...I(h)}),ee=l({...j({setting:B,styles:h})}),et=u({...E()}),es=d({...T()}),ei=l({...P({setting:B,styles:h})}),er=d({...k()}),ea=u({...K({setting:B})}),ec=m({minPrice:"{{ minPriceValue | replace: '\"', '\\\"' | escape }}",variantIDs:'{{ product.variants | map: "id" | json | escape }}',variantInventoryQuantities:'{{ product.variants | map: "inventory_quantity" | json | escape }}',amountDiscount:"{{amountDiscountValue | replace: '\"', '\\\"' | escape }}",percentDiscount:"{{percentDiscountValue}}",price:"{{price}}",displayTrigger:JSON.parse(JSON.stringify(B?.displayTrigger).replaceAll("'","'")),uid:_.builderProps?.uid,productCreatedAt:'{{product.created_at | date: "%Y-%m-%d" }}',productTags:"{{ product.tags | join: \",\" | replace: '\"', '\\\"' | escape }}",isTextBadge:Q}),{displayContent:eo,translate:en}=B??{},ep=c({val:eo?.trim(),uid:L?.uid,settingId:"displayContent",isLiquid:!0,pageContext:O,translate:en});return e`
|
|
2
2
|
{% if product %}
|
|
3
|
-
${
|
|
4
|
-
${p(B?.displayTrigger,!
|
|
3
|
+
${n(ep,O?.isPreviewing)}
|
|
4
|
+
${p(B?.displayTrigger,!w,G)}
|
|
5
5
|
<gp-product-badge
|
|
6
|
-
${{...
|
|
7
|
-
gp-data='${t(
|
|
8
|
-
class="${
|
|
9
|
-
style="${
|
|
10
|
-
data-display-content="${
|
|
6
|
+
${{...U}}
|
|
7
|
+
gp-data='${t(ec)}'
|
|
8
|
+
class="${J} {{ className }}"
|
|
9
|
+
style="${x}"
|
|
10
|
+
data-display-content="${O?.isPreviewing?ep:s(`{{${ep}}}`)}"
|
|
11
11
|
>
|
|
12
|
-
<div class="${
|
|
12
|
+
<div class="${M}">
|
|
13
13
|
<div
|
|
14
|
-
${{...
|
|
15
|
-
class="${
|
|
16
|
-
style="${
|
|
14
|
+
${{...z}}
|
|
15
|
+
class="${R}"
|
|
16
|
+
style="${Y}"
|
|
17
17
|
>
|
|
18
|
-
<style>${
|
|
19
|
-
${i(
|
|
20
|
-
<div class="${
|
|
18
|
+
<style>${F}</style>
|
|
19
|
+
${i(Q,e`
|
|
20
|
+
<div class="${H}">
|
|
21
21
|
<div
|
|
22
|
-
class="${
|
|
23
|
-
style="${
|
|
22
|
+
class="${W}"
|
|
23
|
+
style="${X}"
|
|
24
24
|
>
|
|
25
25
|
<pre
|
|
26
|
-
${{...
|
|
27
|
-
class="${
|
|
28
|
-
style="${
|
|
26
|
+
${{...et}}
|
|
27
|
+
class="${Z}"
|
|
28
|
+
style="${ee}"
|
|
29
29
|
>{{ content | replace: percentDiscountKey, percentDiscountValue | replace: amountDiscountKey, amountDiscountValue | replace: inventoryQuantityKey, inventoryQuantityValue | replace: minPriceKey, minPriceValue }}</pre>
|
|
30
30
|
</div>
|
|
31
|
-
</div>`,e`<div class="${
|
|
32
|
-
<img ${{...
|
|
31
|
+
</div>`,e`<div class="${es}" style="${ei}">
|
|
32
|
+
<img ${{...ea}} class="${er}" alt="" />
|
|
33
33
|
</div>`)}
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
</gp-product-badge>
|
|
37
|
-
${i(r,`<script ${
|
|
37
|
+
${i(r,`<script ${o('class="gps-link" delay',"src")}="{{ 'gp-product-badge-v7-5.js' | asset_url }}" defer="defer"></script>`,`<script ${o('class="gps-link" delay',"src")}="${a}/assets-v2/gp-product-badge-v7-5.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}" defer="defer"></script>`)}
|
|
38
38
|
{% endif %}
|
|
39
39
|
`};export{ProductBadge as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{makeGlobalSize as e,composeTypographyStyle as t,getStyleShadow as o,convertDecimalToNumber as r}from"@gem-sdk/core";import{convertToStyle as i,getSize as a,getWrapperStyle as n,getShapeWrapperPadding as s}from"../utils/common.js";import{getShapePosition as
|
|
1
|
+
import{makeGlobalSize as e,composeTypographyStyle as t,getStyleShadow as o,convertDecimalToNumber as r}from"@gem-sdk/core";import{convertToStyle as i,getSize as a,getWrapperStyle as n,getShapeWrapperPadding as s,checkDiscountContentProductBadge as p}from"../utils/common.js";import{getShapePosition as g}from"../utils/getShapePosition.js";import{composeTextStyleByPosition as l,composeShapeStyleByPosition as d}from"../utils/getRotateShape.js";import{getStyleAdvanced as u}from"../utils/getStyleAdvanced.js";import{getWhiteSpaceStyle as S}from"../utils/getWhiteSpace.js";import{getStyleBackground as y,generateShadowCSS as m,getStyleBorder as h,getStyleCornerRadius as x}from"../utils/stylesV2.js";import{getShape as c}from"../utils/shape.js";import{checkShowBadge as C}from"../utils/renderBadgeILP.js";let getSizeStyles=e=>{let{setting:t,styles:o}=e,r=c(t?.shape),i=t?.contentType==="text",n=i?o?.textSizeV2:o?.imageSizeV2;return i?a(r,n):a(void 0,n)},getContainerStyle=(e,t=!1)=>{let{setting:o,styles:r,style:i,navigationPosition:a,imageData:s,dotData:p}=e,l=o?.positionWithImage==="outside",d=n(t),S=g({positionType:r?.position,isLiquid:!1,navigationPosition:a,dataImage:{...s,...p}}),y=getSizeStyles(e),m=u(l?{}:{...S,...y},i);return{...!l&&{"--pos":"absolute"},...d,...m}},getTextContentStyle=({styles:r,setting:a})=>{let n=e(r?.textSizeV2).padding,s=c(a?.shape),p=a?.positionWithImage==="outside";return{...S(r?.textSizeV2),...i(s?.textStyle),...l(s,r?.position,p),...t(r?.typo),...o({value:r?.typo?.custom?.textShadow,styleAppliedFor:"text-shadow",isEnableShadow:r?.typo?.custom?.hasShadowText}),...y(!!s?.backgroundColorInText,r?.badgeColorV2),...n}},getBorderStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=t?.contentType==="text";return o?.supportBorder?r?h(e?.textBadgeBorder):h(e?.imageBadgeBorder):{}},getCornerStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=t?.contentType==="text";return o?.supportCorner?r?x(e?.textBadgeCorner,o?.shapeRadius):x(e?.imageBadgeCorner,o?.shapeRadius):{}},getTextBadgeWrapperStyles=({styles:e,setting:t})=>{let o=c(t?.shape),r=getBorderStyles({setting:t,styles:e}),i=t?.positionWithImage==="outside",a=getCornerStyles({setting:t,styles:e}),n=s(o?.ratio);return{...r,...a,...d(o,e?.position,i),...y(!o?.backgroundColorInText,e?.badgeColorV2),...n,height:o?.ratio===1?"0px":"100%"}},getImageContainerStyles=({styles:t,setting:o})=>{let r=getBorderStyles({setting:o,styles:t}),i=getCornerStyles({setting:o,styles:t}),a=e(t?.imageSizeV2).padding;return{...r,...i,...a}},getOpacityProductBadge=({props:e,currentVariant:t,product:o,isEditMode:i})=>{let{"bundle-item":a,setting:n}=e;if(a)return 1;let s=n?.contentType==="text",g=s&&!n?.displayContent?.trim(),l=p(n?.displayContent);if(g)return i?.2:0;let d=r(t?.price)??0,u=r(t?.salePrice)??0,S=u-d>0,y=C(n?.displayTrigger,o,t);return(S||!l)&&y?1:i?.2:0},getSubWrapperStyle=({props:e,product:t,currentVariant:o,isEditMode:r})=>{let{setting:i}=e,a=i?.positionWithImage==="outside",n=getSizeStyles(e),s=r&&o?getOpacityProductBadge({props:e,currentVariant:o,product:t,isEditMode:r}):1;return{...a?{...n,"--mb":0}:{},opacity:s}},getContentStyleInternal=e=>{let{styles:t,setting:o,builderProps:r}=e,i=o?.contentType==="text";return m(`[id="${r?.uid}"] .product-badge-item`,i?t?.textBadgeShadow:t?.imageBadgeShadow)};export{getContainerStyle,getContentStyleInternal,getImageContainerStyles,getSubWrapperStyle,getTextBadgeWrapperStyles,getTextContentStyle};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{CompareType as e}from"../types.js";let getMinValueForInventory=i=>i===e.ABOVE?0:i===e.BELOW?2:1,renderBadgeInFirstTime=(e,i)=>`
|
|
1
|
+
import{CompareType as e}from"../types.js";let getMinValueForInventory=i=>i===e.ABOVE?0:i===e.BELOW?2:1,renderBadgeInFirstTime=(e,i,n)=>`
|
|
2
2
|
{% assign isShow = true %}
|
|
3
3
|
{% assign conditionTriggers = "" %}
|
|
4
4
|
{% assign isInventoryStatus = false %}
|
|
@@ -17,10 +17,15 @@ import{CompareType as e}from"../types.js";let getMinValueForInventory=i=>i===e.A
|
|
|
17
17
|
{% assign salePrice = variant.compare_at_price | times: 1.0 %}
|
|
18
18
|
{% assign priceSave = salePrice | minus: price %}
|
|
19
19
|
{% assign isEmptyBadgeContent = ${!i} %}
|
|
20
|
-
{%
|
|
21
|
-
|
|
20
|
+
{% assign isNotDiscount = false %}
|
|
21
|
+
{% assign isBadgeContentHasDiscount = ${n} %}
|
|
22
|
+
{% if isEmptyBadgeContent == true %}
|
|
23
|
+
{% assign isNotDiscount = true %}
|
|
22
24
|
{% endif %}
|
|
23
|
-
{% if
|
|
25
|
+
{% if isBadgeContentHasDiscount == true and priceSave <= 0 %}
|
|
26
|
+
{% assign isNotDiscount = true %}
|
|
27
|
+
{% endif %}
|
|
28
|
+
{% if isShow and isNotDiscount == false %}
|
|
24
29
|
{% assign className = "" %}
|
|
25
30
|
{% else %}
|
|
26
31
|
{% assign className = "!gp-hidden" %}
|