@gem-sdk/components 2.0.0-dev.332 → 2.0.0-dev.334

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 (38) hide show
  1. package/dist/cjs/post-purchase/product/settings/product-image/ProductFeatureImage.js +33 -0
  2. package/dist/cjs/post-purchase/product/settings/product-image/ProductGalleryImage.js +85 -0
  3. package/dist/cjs/post-purchase/product/settings/product-image/ProductImageLayoutSetting.js +69 -0
  4. package/dist/cjs/post-purchase/product/settings/product-image/ProductImages.js +3 -1
  5. package/dist/cjs/post-purchase/product/settings/product-image/uiV1.js +42 -0
  6. package/dist/cjs/product/components/ProductBadge/common/getAttrs.js +74 -0
  7. package/dist/cjs/product/components/ProductBadge/common/getClasses.js +79 -0
  8. package/dist/cjs/product/components/ProductBadge/common/getStyles.js +144 -0
  9. package/dist/cjs/product/components/ProductBadge/constants.js +1 -9
  10. package/dist/cjs/product/components/ProductBadge/index.js +125 -117
  11. package/dist/cjs/product/components/ProductBadge/index.liquid.js +97 -111
  12. package/dist/cjs/product/components/ProductBadge/utils/common.js +11 -0
  13. package/dist/cjs/product/components/ProductBadge/utils/getRotateShape.js +10 -5
  14. package/dist/cjs/product/components/ProductBadge/utils/shape.js +14 -1
  15. package/dist/cjs/product/index.js +1 -1
  16. package/dist/cjs/product/setting/product-badge/configs/settings.js +72 -93
  17. package/dist/cjs/product/setting/product-badge/configs/uiV2.js +93 -15
  18. package/dist/esm/post-purchase/product/settings/product-image/ProductFeatureImage.js +31 -0
  19. package/dist/esm/post-purchase/product/settings/product-image/ProductGalleryImage.js +83 -0
  20. package/dist/esm/post-purchase/product/settings/product-image/ProductImageLayoutSetting.js +67 -0
  21. package/dist/esm/post-purchase/product/settings/product-image/ProductImages.js +3 -1
  22. package/dist/esm/post-purchase/product/settings/product-image/uiV1.js +40 -0
  23. package/dist/esm/product/components/ProductBadge/common/getAttrs.js +67 -0
  24. package/dist/esm/product/components/ProductBadge/common/getClasses.js +70 -0
  25. package/dist/esm/product/components/ProductBadge/common/getStyles.js +137 -0
  26. package/dist/esm/product/components/ProductBadge/constants.js +2 -5
  27. package/dist/esm/product/components/ProductBadge/index.js +128 -120
  28. package/dist/esm/product/components/ProductBadge/index.liquid.js +99 -113
  29. package/dist/esm/product/components/ProductBadge/utils/common.js +12 -2
  30. package/dist/esm/product/components/ProductBadge/utils/getRotateShape.js +10 -5
  31. package/dist/esm/product/components/ProductBadge/utils/shape.js +14 -1
  32. package/dist/esm/product/index.js +1 -1
  33. package/dist/esm/product/setting/product-badge/configs/settings.js +72 -93
  34. package/dist/esm/product/setting/product-badge/configs/uiV2.js +93 -15
  35. package/dist/types/index.d.ts +1 -3
  36. package/package.json +2 -2
  37. package/dist/cjs/product/components/ProductBadge/hooks/useProductBadgeStyles.js +0 -83
  38. package/dist/esm/product/components/ProductBadge/hooks/useProductBadgeStyles.js +0 -81
@@ -4,150 +4,158 @@
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
- var React = require('react');
8
7
  var core = require('@gem-sdk/core');
9
- var constants = require('./constants.js');
10
8
  var common = require('./utils/common.js');
11
- var useProductBadgeStyles = require('./hooks/useProductBadgeStyles.js');
12
- var renderBadgeILP = require('./utils/renderBadgeILP.js');
9
+ require('./constants.js');
13
10
  var NoDataState = require('../../../common/components/NoDataState.js');
14
11
  var TooltipHover = require('../../../common/components/TooltipHover.js');
12
+ var system = require('@gem-sdk/system');
13
+ var getAttrs = require('./common/getAttrs.js');
14
+ var getClasses = require('./common/getClasses.js');
15
+ var getStyles = require('./common/getStyles.js');
15
16
 
16
- const ProductBadge = ({ builderAttrs, builderProps, isInsideProductImage, setting, styles, children, style, navigationPosition, imageData, dotData, ...passProps })=>{
17
+ const ProductBadge = (props)=>{
18
+ const { builderAttrs, builderProps, isInsideProductImage, setting, styles, children, style, navigationPosition, imageData, dotData, ...passProps } = props;
17
19
  const product = core.useProduct();
18
20
  const currentVariant = core.useCurrentVariant();
19
21
  const { moneyFormat } = core.useMoneyFormat();
20
22
  const currentDevice = core.useCurrentDevice();
21
23
  const { useProductCompareAtPrice } = core.useProductBundleDiscount();
22
24
  const bundleItem = passProps?.['bundle-item'];
23
- const price = currentVariant?.price ?? 0;
24
- const salePrice = currentVariant?.salePrice ?? 0;
25
- const priceSave = salePrice - price;
26
- const { align } = styles ?? {};
27
- const isDiscountContent = common.checkDiscountContentProductBadge(setting?.displayContent);
28
- const isOpacityBadge = isDiscountContent && priceSave <= 0 && setting?.contentType === 'text';
29
25
  const mode = core.useEditorMode();
30
26
  const isInstant = core.usePageType() === 'STATIC';
31
- const conditionClass = React.useMemo(()=>{
32
- return !mode && isInstant ? renderBadgeILP.toggleBadge(setting?.displayTrigger, product, currentVariant) : '';
33
- }, [
34
- currentVariant,
35
- isInstant,
36
- mode,
37
- product,
38
- setting?.displayTrigger
39
- ]);
40
- const opacityProductBadge = React.useMemo(()=>{
41
- if (bundleItem) return 1;
42
- if (!isOpacityBadge) return 1;
43
- return mode !== 'edit' ? 0 : 0.2;
44
- }, [
45
- bundleItem,
46
- isOpacityBadge,
47
- mode
48
- ]);
49
- const currentProductId = product?.baseID?.replace('gid://shopify/Product/', '');
50
27
  const badgeContent = common.getBadgeContent({
51
28
  detail: product,
52
29
  currentVariant,
53
30
  bundleItem,
54
31
  useProductCompareAtPrice
55
32
  }, setting?.displayContent, moneyFormat);
56
- const isNoDiscountState = isDiscountContent && common.checkNoDiscountState({
57
- detail: product,
33
+ const isNoDiscountState = common.getIsNoDiscountState({
34
+ props,
35
+ product,
58
36
  currentVariant,
59
- bundleItem,
37
+ moneyFormat,
60
38
  useProductCompareAtPrice
61
- }, moneyFormat);
62
- const { isDropOutsideProductImage, placementClass, wrapperStyles, sizeStyles, shadowStyles, textBadgeStyles, textBadgeContainerStyles, imageBadgeContainerStyles, advancedStyles } = useProductBadgeStyles.useProductBadgeStyles({
63
- setting,
64
- styles,
65
- style,
66
- isInsideProductImage,
67
- navigationPosition,
68
- imageData,
69
- dotData,
70
- currentDevice
71
- });
72
- const RenderContent = ()=>{
73
- return /*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
74
- children: [
75
- /*#__PURE__*/ jsxRuntime.jsx("style", {
76
- children: shadowStyles
77
- }),
78
- setting?.contentType === 'text' ? /*#__PURE__*/ jsxRuntime.jsx("div", {
79
- className: core.cls(constants.WRAPPER_CLASS, 'product-badge-item'),
80
- children: /*#__PURE__*/ jsxRuntime.jsx("div", {
81
- className: constants.SHAPE_CLASS,
82
- style: textBadgeContainerStyles,
83
- children: /*#__PURE__*/ jsxRuntime.jsx("pre", {
84
- className: core.cls(constants.CONTENT_CLASS, core.composeTypographyClassName(styles?.typo)),
85
- style: textBadgeStyles,
86
- children: badgeContent
87
- })
88
- })
89
- }) : /*#__PURE__*/ jsxRuntime.jsx("div", {
90
- className: "product-badge-item gp-w-full gp-h-full",
91
- style: imageBadgeContainerStyles,
92
- children: /*#__PURE__*/ jsxRuntime.jsx("img", {
93
- src: setting?.image?.src,
94
- alt: setting?.image?.alt,
95
- className: "gp-object-cover gp-w-full gp-h-full gp-pointer-events-none",
96
- loading: "lazy"
97
- })
98
- })
99
- ]
100
- });
101
- };
39
+ });
40
+ const containerClass = system.createClass({
41
+ ...getClasses.getContainerClasses({
42
+ mode,
43
+ isInstant,
44
+ product,
45
+ currentVariant,
46
+ props
47
+ })
48
+ });
49
+ const containerStyle = system.createStyle({
50
+ ...getStyles.getContainerStyle(props)
51
+ });
52
+ const editTooltipAttrs = system.createAttr({
53
+ ...getAttrs.getEditTooltipAttrs(props)
54
+ });
55
+ const noDataAttrs = system.createAttr({
56
+ ...getAttrs.getNoDataAttrs(props)
57
+ });
58
+ const wrapperClass = system.createClass({
59
+ ...getClasses.getWrapperClasses(props)
60
+ });
61
+ const subWrapperClass = system.createClass({
62
+ ...getClasses.getSubWrapperClass(props, currentDevice)
63
+ });
64
+ const subWrapperStyle = system.createStyle({
65
+ ...getStyles.getSubWrapperStyle(props, currentVariant, mode)
66
+ });
67
+ const subWrapperAttrs = system.createAttr({
68
+ ...getAttrs.getSubWrapperAttrs(props, product)
69
+ });
70
+ const contentStyleInternal = getStyles.getContentStyleInternal(props);
71
+ const textContentContainerClasses = system.createClass({
72
+ ...getClasses.getTextContainerClasses()
73
+ });
74
+ const containerAttrs = system.createAttr({
75
+ ...getAttrs.getContainerAttrs(props)
76
+ });
77
+ const textContentWrapperClasses = system.createClass({
78
+ ...getClasses.getTextWrapperClasses()
79
+ });
80
+ const textContentWrapperStyle = system.createStyle({
81
+ ...getStyles.getTextBadgeWrapperStyles({
82
+ setting,
83
+ styles
84
+ })
85
+ });
86
+ const textContentClasses = system.createClass({
87
+ ...getClasses.getTextContentClasses(styles)
88
+ });
89
+ const textContentStyle = system.createStyle({
90
+ ...getStyles.getTextContentStyle({
91
+ setting,
92
+ styles
93
+ })
94
+ });
95
+ const textContentAttrs = system.createAttr({
96
+ ...getAttrs.getTextContentAttrs()
97
+ });
98
+ const imageContainerClasses = system.createClass({
99
+ ...getClasses.getImageContainerClasses()
100
+ });
101
+ const imageContainerStyles = system.createStyle({
102
+ ...getStyles.getImageContainerStyles({
103
+ setting,
104
+ styles
105
+ })
106
+ });
107
+ const imageClass = system.createClass({
108
+ ...getClasses.getImageClasses()
109
+ });
110
+ const imageAttr = system.createAttr({
111
+ ...getAttrs.getImageAttr({
112
+ setting
113
+ })
114
+ });
102
115
  if (!product) return null;
103
116
  return /*#__PURE__*/ jsxRuntime.jsxs("div", {
104
- ...builderAttrs,
105
- "data-id": builderProps?.uid,
106
- id: builderProps?.uid,
107
- style: {
108
- ...!isDropOutsideProductImage && {
109
- '--pos': 'absolute'
110
- },
111
- ...wrapperStyles,
112
- ...advancedStyles
113
- },
114
- className: core.cls(conditionClass, builderProps?.builderData?.advanced?.cssClass || '', builderProps?.uid, 'gp-shrink-0', 'product-badge', isInsideProductImage ? 'inside-image' : ''),
115
- "gp-data-hidden": "false",
117
+ ...containerAttrs,
118
+ style: containerStyle,
119
+ className: containerClass,
116
120
  children: [
117
- mode === 'edit' && isNoDiscountState ? /*#__PURE__*/ jsxRuntime.jsx(TooltipHover.default, {
118
- enable: true,
119
- text: 'Not be displayed when published',
120
- position: isDropOutsideProductImage ? 'bottom' : 'right',
121
- width: '205px',
121
+ system.If(mode === 'edit' && isNoDiscountState, /*#__PURE__*/ jsxRuntime.jsx(TooltipHover.default, {
122
+ ...editTooltipAttrs,
122
123
  children: /*#__PURE__*/ jsxRuntime.jsx(NoDataState.default, {
123
- builderAttrs: builderAttrs,
124
- elementType: "secondary",
125
- description: "No discount",
126
- rawMode: true
127
- })
128
- }) : isDropOutsideProductImage ? /*#__PURE__*/ jsxRuntime.jsx("div", {
129
- className: core.cls('gp-flex', common.getAlignShape(align, false)),
130
- children: /*#__PURE__*/ jsxRuntime.jsx("div", {
131
- "data-product-id": currentProductId,
132
- className: placementClass,
133
- style: {
134
- ...sizeStyles,
135
- '--mb': 0,
136
- opacity: opacityProductBadge
137
- },
138
- children: /*#__PURE__*/ jsxRuntime.jsx(RenderContent, {})
124
+ ...noDataAttrs
139
125
  })
140
- }) : /*#__PURE__*/ jsxRuntime.jsx("div", {
141
- className: "gp-h-full",
142
- children: /*#__PURE__*/ jsxRuntime.jsx("div", {
143
- "data-product-id": currentProductId,
144
- className: "gp-h-full",
145
- style: {
146
- opacity: opacityProductBadge
147
- },
148
- children: /*#__PURE__*/ jsxRuntime.jsx(RenderContent, {})
126
+ }), /*#__PURE__*/ jsxRuntime.jsx("div", {
127
+ className: wrapperClass,
128
+ children: /*#__PURE__*/ jsxRuntime.jsxs("div", {
129
+ ...subWrapperAttrs,
130
+ className: subWrapperClass,
131
+ style: subWrapperStyle,
132
+ children: [
133
+ /*#__PURE__*/ jsxRuntime.jsx("style", {
134
+ children: contentStyleInternal
135
+ }),
136
+ system.If(setting?.shape !== 'image', /*#__PURE__*/ jsxRuntime.jsx("div", {
137
+ className: textContentContainerClasses,
138
+ children: /*#__PURE__*/ jsxRuntime.jsx("div", {
139
+ className: textContentWrapperClasses,
140
+ style: textContentWrapperStyle,
141
+ children: /*#__PURE__*/ jsxRuntime.jsx("pre", {
142
+ ...textContentAttrs,
143
+ className: textContentClasses,
144
+ style: textContentStyle,
145
+ children: badgeContent
146
+ })
147
+ })
148
+ }), /*#__PURE__*/ jsxRuntime.jsx("div", {
149
+ className: imageContainerClasses,
150
+ style: imageContainerStyles,
151
+ children: /*#__PURE__*/ jsxRuntime.jsx("img", {
152
+ ...imageAttr,
153
+ className: imageClass
154
+ })
155
+ }))
156
+ ]
149
157
  })
150
- }),
158
+ })),
151
159
  core.filterToolbarPreview(children, true)
152
160
  ]
153
161
  });
@@ -4,133 +4,119 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@gem-sdk/core');
6
6
  var helpers = require('../../../helpers.js');
7
- var constants = require('./constants.js');
8
7
  var common = require('./utils/common.js');
9
- var getShapePosition = require('./utils/getShapePosition.js');
10
- var getRotateShape = require('./utils/getRotateShape.js');
11
- var getStyleAdvanced = require('./utils/getStyleAdvanced.js');
12
8
  var generateLiquidContent = require('./utils/generateLiquidContent.js');
13
- var getWhiteSpace = require('./utils/getWhiteSpace.js');
14
9
  var renderBadgeLiquid = require('./utils/renderBadgeLiquid.js');
15
- var shape = require('./utils/shape.js');
16
- var stylesV2 = require('./utils/stylesV2.js');
10
+ var system = require('@gem-sdk/system');
11
+ var getClasses = require('./common/getClasses.js');
12
+ var getStyles = require('./common/getStyles.js');
13
+ var getAttrs = require('./common/getAttrs.js');
17
14
 
18
- const ProductBadge = ({ styles, builderProps, isInsideProductImage, builderAttrs, setting, style, imageData, dotData })=>{
19
- const isTextBadge = setting?.contentType === 'text';
20
- const shape$1 = shape.getShape(setting?.shape);
21
- const shapeAlignClass = common.getAlignShape(styles?.align, isInsideProductImage);
22
- const shapePosition = getShapePosition.getShapePosition({
23
- positionType: styles?.position,
24
- isLiquid: constants.IS_LIQUID,
25
- navigationPosition: undefined,
26
- dataImage: {
27
- ...imageData,
28
- ...dotData
29
- }
30
- });
31
- const wrapperStyles = common.getWrapperStyle(constants.IS_LIQUID);
32
- // currently use imageSize v1, update later
33
- const badgeSize = isTextBadge ? styles?.textSizeV2 : styles?.imageSize;
34
- const sizeStyles = isTextBadge ? common.getSize(shape$1, badgeSize) : common.getSize(undefined, badgeSize);
35
- const getBorderStyles = ()=>{
36
- return isTextBadge ? shape$1?.supportBorder ? stylesV2.getStyleBorder(styles?.textBadgeBorder) : {} : stylesV2.getStyleBorder(styles?.imageBadgeBorder);
37
- };
38
- const getCornerStyles = ()=>isTextBadge ? stylesV2.getStyleCornerRadius(styles?.textBadgeCorner, shape$1?.shapeRadius) : stylesV2.getStyleCornerRadius(styles?.imageBadgeCorner, shape$1?.shapeRadius);
39
- const borderStyles = getBorderStyles();
40
- const cornerStyles = getCornerStyles();
41
- const paddingShape = common.getShapeWrapperPadding(shape$1?.ratio);
42
- const textBadgePadding = core.makeGlobalSize(styles?.textSizeV2).padding;
43
- const imageBadgePadding = core.makeGlobalSize(styles?.imageSizeV2).padding;
44
- const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
15
+ const ProductBadge = (props)=>{
16
+ const { styles, setting } = props;
17
+ const isTextBadge = setting?.shape !== 'image';
45
18
  const isDiscountContent = common.checkDiscountContentProductBadge(setting?.displayContent);
46
- const shadowStyles = stylesV2.getStyleShadowV2('.product-badge-item', isTextBadge ? styles?.textBadgeShadow : styles?.imageBadgeShadow);
19
+ const containerStyle = system.createStyle({
20
+ ...getStyles.getContainerStyle(props)
21
+ });
22
+ const wrapperClass = system.createClass({
23
+ ...getClasses.getWrapperClasses(props)
24
+ });
25
+ const subWrapperClass = system.createClass({
26
+ ...getClasses.getSubWrapperClass(props)
27
+ });
28
+ const subWrapperStyle = system.createStyle({
29
+ ...getStyles.getSubWrapperStyle(props)
30
+ });
31
+ const subWrapperAttrs = system.createAttr({
32
+ ...getAttrs.getSubWrapperAttrs(props)
33
+ });
34
+ const contentStyleInternal = getStyles.getContentStyleInternal(props);
35
+ const textContentContainerClasses = system.createClass({
36
+ ...getClasses.getTextContainerClasses()
37
+ });
38
+ const containerAttrs = system.createAttr({
39
+ ...getAttrs.getContainerAttrs(props)
40
+ });
41
+ const textContentWrapperClasses = system.createClass({
42
+ ...getClasses.getTextWrapperClasses()
43
+ });
44
+ const textContentWrapperStyle = system.createStyle({
45
+ ...getStyles.getTextBadgeWrapperStyles({
46
+ setting,
47
+ styles
48
+ })
49
+ });
50
+ const textContentClasses = system.createClass({
51
+ ...getClasses.getTextContentClasses(styles)
52
+ });
53
+ const textContentStyle = system.createStyle({
54
+ ...getStyles.getTextContentStyle({
55
+ setting,
56
+ styles
57
+ })
58
+ });
59
+ const textContentAttrs = system.createAttr({
60
+ ...getAttrs.getTextContentAttrs()
61
+ });
62
+ const imageContainerClasses = system.createClass({
63
+ ...getClasses.getImageContainerClasses()
64
+ });
65
+ const imageContainerStyles = system.createStyle({
66
+ ...getStyles.getImageContainerStyles({
67
+ setting,
68
+ styles
69
+ })
70
+ });
71
+ const imageClass = system.createClass({
72
+ ...getClasses.getImageClasses()
73
+ });
74
+ const imageAttr = system.createAttr({
75
+ ...getAttrs.getImageAttr({
76
+ setting
77
+ })
78
+ });
47
79
  return core.template`
48
80
  {% if product %}
49
81
  ${generateLiquidContent.generateBadgeContent(setting?.displayContent)}
50
82
  ${renderBadgeLiquid.renderBadgeInFirstTime(setting?.displayTrigger, isDiscountContent, isTextBadge)}
51
83
  <gp-product-badge
52
- data-id="${builderProps?.uid}"
53
- class="gp-product-badge !gp-max-w-none gp-shrink-0 ${builderProps?.uid} ${builderProps?.builderData?.advanced?.cssClass || ''} {{className}}"
54
- id="g-product-badge-${builderProps?.uid}"
55
- gp-data='${core.dataStringify({
56
- displayContent: setting?.displayContent,
57
- minPrice: '{{ minPriceValue }}',
58
- variantIDs: '{{ product.variants | map: "id" | json | escape }}',
59
- variantInventoryQuantities: '{{ product.variants | map: "inventory_quantity" | json | escape }}',
60
- amountDiscount: '{{amountDiscountValue}}',
61
- percentDiscount: '{{percentDiscountValue}}',
62
- price: '{{price}}',
63
- displayTrigger: setting?.displayTrigger,
64
- uid: builderProps?.uid,
65
- productCreatedAt: '{{product.created_at | date: "%Y-%m-%d" }}',
66
- productTags: '{{ product.tags | join: "," }}',
67
- isTextBadge
68
- })}'
69
- style="${{
70
- ...!isDropOutsideProductImage && {
71
- '--pos': 'absolute'
72
- },
73
- ...wrapperStyles,
74
- ...getStyleAdvanced.getStyleAdvanced(!isDropOutsideProductImage ? {
75
- ...shapePosition,
76
- ...sizeStyles
77
- } : {}, style)
78
- }}"
84
+ ${{
85
+ ...containerAttrs
86
+ }}
87
+ class="containerClass"
88
+ style="${containerStyle}"
79
89
  >
80
- <div class="${shapeAlignClass} ${isDropOutsideProductImage && isTextBadge ? '' : 'gp-h-full'}">
81
- <style>${shadowStyles}</style>
90
+ <div class="${wrapperClass}">
82
91
  <div
83
92
  ${{
84
- ...builderAttrs
93
+ ...subWrapperAttrs
85
94
  }}
86
- id=${builderProps?.uid}
87
- class="${!isDropOutsideProductImage && 'gp-h-full'}"
88
- style="${{
89
- ...isDropOutsideProductImage && sizeStyles
90
- }}"
95
+ class="${subWrapperClass}"
96
+ style="${subWrapperStyle}"
91
97
  >
92
- ${core.RenderIf(isTextBadge, core.template`
93
- <div class="${constants.WRAPPER_CLASS} product-badge-item">
94
- <div
95
- class="${constants.SHAPE_CLASS}"
96
- style="
97
- ${{
98
- ...common.convertToStyle(shape$1?.shapeStyle),
99
- ...getRotateShape.composeShapeStyleByPosition(shape$1, styles?.position, isDropOutsideProductImage),
100
- ...stylesV2.getStyleBackground(!shape$1?.backgroundColorInText, styles?.badgeColorV2),
101
- ...paddingShape,
102
- ...borderStyles,
103
- ...cornerStyles
98
+ <style>${contentStyleInternal}</style>
99
+ ${core.RenderIf(isTextBadge, core.template`
100
+ <div class="${textContentContainerClasses}">
101
+ <div
102
+ class="${textContentWrapperClasses}"
103
+ style="${textContentWrapperStyle}"
104
+ >
105
+ <pre
106
+ ${{
107
+ ...textContentAttrs
104
108
  }}
105
- "
106
- >
107
- <pre
108
- id="product-badge-content"
109
- class="${constants.CONTENT_CLASS} ${core.composeTypographyClassName(styles?.typo)}"
110
- style="${{
111
- ...getWhiteSpace.getWhiteSpaceStyle(styles?.textSize),
112
- ...common.convertToStyle(shape$1?.textStyle),
113
- ...getRotateShape.composeTextStyleByPosition(shape$1, styles?.position, isDropOutsideProductImage),
114
- ...core.composeTypographyStyle(styles?.typo),
115
- ...stylesV2.getStyleBackground(!!shape$1?.backgroundColorInText, styles?.badgeColorV2),
116
- ...core.getStyleShadow({
117
- value: styles?.typo?.custom?.textShadow,
118
- styleAppliedFor: 'text-shadow',
119
- isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
120
- }),
121
- ...textBadgePadding
122
- }}"
123
- >{{ content | replace: percentDiscountKey, percentDiscountValue | replace: amountDiscountKey, amountDiscountValue | replace: inventoryQuantityKey, inventoryQuantityValue | replace: minPriceKey, minPriceValue }}</pre>
124
- </div>
125
- </div>`, core.template`<div class="product-badge-item gp-w-full gp-h-full" style="${{
126
- ...imageBadgePadding,
127
- ...borderStyles,
128
- ...cornerStyles
129
- }}">
130
- <img src="${setting?.image?.src}" alt="${setting?.image?.alt}" loading="lazy"
131
- class="gp-object-cover gp-w-full gp-h-full"
132
- />
133
- </div>`)}
109
+ class="${textContentClasses}"
110
+ style="${textContentStyle}"
111
+ >{{ content | replace: percentDiscountKey, percentDiscountValue | replace: amountDiscountKey, amountDiscountValue | replace: inventoryQuantityKey, inventoryQuantityValue | replace: minPriceKey, minPriceValue }}</pre>
112
+ </div>
113
+ </div>`, core.template`<div class="${imageContainerClasses}" style="${imageContainerStyles}">
114
+ <img ${{
115
+ ...imageAttr
116
+ }}>
117
+ class="${imageClass}"
118
+ />
119
+ </div>`)}
134
120
  </div>
135
121
  </div>
136
122
  </gp-product-badge>
@@ -234,6 +234,16 @@ const getDeviceSpecificStyle = (style, currentDevice)=>{
234
234
  }
235
235
  return undefined;
236
236
  };
237
+ const getIsNoDiscountState = ({ props, product, currentVariant, moneyFormat, useProductCompareAtPrice })=>{
238
+ const { setting, 'bundle-item': bundleItem } = props;
239
+ const isDiscountContent = checkDiscountContentProductBadge(setting?.displayContent);
240
+ return isDiscountContent && checkNoDiscountState({
241
+ detail: product,
242
+ currentVariant,
243
+ bundleItem,
244
+ useProductCompareAtPrice
245
+ }, moneyFormat);
246
+ };
237
247
 
238
248
  exports.checkDiscountContentProductBadge = checkDiscountContentProductBadge;
239
249
  exports.checkNoDiscountState = checkNoDiscountState;
@@ -242,6 +252,7 @@ exports.deviceWithSurfix = deviceWithSurfix;
242
252
  exports.getAlignShape = getAlignShape;
243
253
  exports.getBadgeContent = getBadgeContent;
244
254
  exports.getDeviceSpecificStyle = getDeviceSpecificStyle;
255
+ exports.getIsNoDiscountState = getIsNoDiscountState;
245
256
  exports.getShapePlacementClass = getShapePlacementClass;
246
257
  exports.getShapeWrapperPadding = getShapeWrapperPadding;
247
258
  exports.getSize = getSize;
@@ -15,8 +15,11 @@ const composeShapeStyleByPosition = (shape, positionType, isDropOutsideProductIm
15
15
  if (!/\bright\b|\bbottom\b/.test(placement)) return;
16
16
  const key = `--t${device === 'desktop' ? '' : `-${device}`}`;
17
17
  let rotation = '';
18
- if (shape.id === constants.SHAPE_ID.RIBBON && !isDropOutsideProductImage) {
19
- rotation = getRibbonRotation(placement);
18
+ if ([
19
+ constants.SHAPE_ID.RIBBON,
20
+ constants.SHAPE_ID.TRIANGLE
21
+ ].includes(shape.id) && !isDropOutsideProductImage) {
22
+ rotation = getRotation(placement);
20
23
  }
21
24
  if (isRibbon2Or3(shape.id, placement) && !isDropOutsideProductImage) {
22
25
  rotation = 'rotate(180deg)';
@@ -30,7 +33,7 @@ const composeShapeStyleByPosition = (shape, positionType, isDropOutsideProductIm
30
33
  });
31
34
  return result;
32
35
  };
33
- const getRibbonRotation = (placement)=>{
36
+ const getRotation = (placement)=>{
34
37
  switch(true){
35
38
  case placement === 'bottom-left':
36
39
  return 'rotate(-90deg)';
@@ -62,7 +65,9 @@ const composeTextStyleByPosition = (shape, positionType, isDropOutsideProductIma
62
65
  let rotation = '';
63
66
  const key = `--t${device === 'desktop' ? '' : `-${device}`}`;
64
67
  if (shape.id === constants.SHAPE_ID.RIBBON && !isDropOutsideProductImage) {
65
- rotation = `translate(-10%, -30%) ${getTextRibbonRotation(placement)}`;
68
+ rotation = `translate(-10%, -30%) ${getRibbonRotation(placement)}`;
69
+ } else if (shape.id === constants.SHAPE_ID.TRIANGLE && !isDropOutsideProductImage) {
70
+ rotation = `translate(-20%, -75%) ${getRibbonRotation(placement)}`;
66
71
  } else if (shape.id === constants.SHAPE_ID.VERTICAL_RECTANGLE) {
67
72
  rotation = [
68
73
  'bottom',
@@ -80,7 +85,7 @@ const composeTextStyleByPosition = (shape, positionType, isDropOutsideProductIma
80
85
  });
81
86
  return result;
82
87
  };
83
- const getTextRibbonRotation = (placement)=>{
88
+ const getRibbonRotation = (placement)=>{
84
89
  switch(true){
85
90
  case placement.includes('bottom'):
86
91
  return 'rotate(135deg)';
@@ -82,8 +82,21 @@ const productBadgeShape = [
82
82
  wrapperWidth: 'auto',
83
83
  wrapperHeight: 'auto',
84
84
  shapeStyle: {
85
- clipPath: 'polygon( 0% 100%,14.744% 50%,0% 0%,82.051% 0%,100% 50%,82.051% 100%,0% 100% )'
85
+ clipPath: 'polygon( 0% 100%,14.744% 50%,0% 0%,82.051% 0%,100% 50%,82.051% 100%,0% 100%)'
86
86
  }
87
+ },
88
+ {
89
+ id: constants.SHAPE_ID.TRIANGLE,
90
+ wrapperWidth: '132px',
91
+ wrapperHeight: '132px',
92
+ shapeStyle: {
93
+ clipPath: 'polygon(0% 0%, 0% 100%, 100% 0%)'
94
+ },
95
+ textStyle: {
96
+ '--t': 'translate(-20%, -75%) rotate(-45deg)',
97
+ width: 'calc(100% * sqrt(2))'
98
+ },
99
+ ratio: 1
87
100
  }
88
101
  ];
89
102
  const shapeMap = new Map(productBadgeShape.map((shape)=>[
@@ -21,8 +21,8 @@ var ProductList = require('./components/ProductList/ProductList.js');
21
21
  require('./components/ProductBundle/common/styles.js');
22
22
  require('./components/ProductBundle/common/classes.js');
23
23
  require('./components/ProductBadge/constants.js');
24
- require('./components/ProductBadge/utils/shape.js');
25
24
  require('./components/ProductBadge/types.js');
25
+ require('./components/ProductBadge/utils/shape.js');
26
26
  var Product$1 = require('./setting/Product.js');
27
27
  var ProductQuantity$1 = require('./setting/ProductQuantity.js');
28
28
  var ProductTitle = require('./setting/ProductTitle.js');