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