@gem-sdk/components 2.0.0-dev.333 → 2.0.0-dev.335
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/post-purchase/product/helpers/product-quantity/getClasses.js +1 -1
- package/dist/cjs/product/components/ProductBadge/common/getAttrs.js +74 -0
- package/dist/cjs/product/components/ProductBadge/common/getClasses.js +79 -0
- package/dist/cjs/product/components/ProductBadge/common/getStyles.js +144 -0
- package/dist/cjs/product/components/ProductBadge/constants.js +1 -9
- package/dist/cjs/product/components/ProductBadge/index.js +125 -117
- package/dist/cjs/product/components/ProductBadge/index.liquid.js +97 -111
- package/dist/cjs/product/components/ProductBadge/utils/common.js +11 -0
- package/dist/cjs/product/components/ProductBadge/utils/getRotateShape.js +10 -5
- package/dist/cjs/product/components/ProductBadge/utils/shape.js +14 -1
- package/dist/cjs/product/index.js +1 -1
- package/dist/cjs/product/setting/product-badge/configs/settings.js +72 -93
- package/dist/cjs/product/setting/product-badge/configs/uiV2.js +93 -15
- package/dist/esm/post-purchase/product/helpers/product-quantity/getClasses.js +1 -1
- package/dist/esm/product/components/ProductBadge/common/getAttrs.js +67 -0
- package/dist/esm/product/components/ProductBadge/common/getClasses.js +70 -0
- package/dist/esm/product/components/ProductBadge/common/getStyles.js +137 -0
- package/dist/esm/product/components/ProductBadge/constants.js +2 -5
- package/dist/esm/product/components/ProductBadge/index.js +128 -120
- package/dist/esm/product/components/ProductBadge/index.liquid.js +99 -113
- package/dist/esm/product/components/ProductBadge/utils/common.js +12 -2
- package/dist/esm/product/components/ProductBadge/utils/getRotateShape.js +10 -5
- package/dist/esm/product/components/ProductBadge/utils/shape.js +14 -1
- package/dist/esm/product/index.js +1 -1
- package/dist/esm/product/setting/product-badge/configs/settings.js +72 -93
- package/dist/esm/product/setting/product-badge/configs/uiV2.js +93 -15
- package/dist/types/index.d.ts +1 -3
- package/package.json +2 -2
- package/dist/cjs/product/components/ProductBadge/hooks/useProductBadgeStyles.js +0 -83
- package/dist/esm/product/components/ProductBadge/hooks/useProductBadgeStyles.js +0 -81
|
@@ -31,20 +31,68 @@ const ProductBadgeSettings = [
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
|
-
id: '
|
|
35
|
-
type: '
|
|
34
|
+
id: 'shape',
|
|
35
|
+
type: 'badge-style',
|
|
36
36
|
label: 'Content',
|
|
37
|
-
iconViewBox: '0 0
|
|
37
|
+
iconViewBox: '0 0 80 48',
|
|
38
38
|
enableItemBackground: true,
|
|
39
|
-
|
|
39
|
+
itemPerRow: 2,
|
|
40
|
+
itemSpacing: 'large',
|
|
41
|
+
default: 'horizontal_rectangle',
|
|
40
42
|
options: [
|
|
41
43
|
{
|
|
42
|
-
value: '
|
|
43
|
-
|
|
44
|
+
value: 'image',
|
|
45
|
+
label: 'Image',
|
|
46
|
+
type: 'badge-layout',
|
|
47
|
+
iconName: 'gp-product-badge-image'
|
|
44
48
|
},
|
|
45
49
|
{
|
|
46
|
-
value: '
|
|
47
|
-
|
|
50
|
+
value: 'horizontal_rectangle',
|
|
51
|
+
label: 'Text horizontal',
|
|
52
|
+
type: 'badge-layout',
|
|
53
|
+
iconName: 'gp-product-badge-horizontal-rectangle'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
value: 'ribbon',
|
|
57
|
+
label: 'Text corner 1',
|
|
58
|
+
type: 'badge-layout',
|
|
59
|
+
iconName: 'gp-product-badge-ribbon'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
value: 'ribbon_2',
|
|
63
|
+
label: 'Text ribbon 1',
|
|
64
|
+
type: 'badge-layout',
|
|
65
|
+
iconName: 'gp-product-badge-ribbon-2'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
value: 'triangle',
|
|
69
|
+
label: 'Text corner 2',
|
|
70
|
+
type: 'badge-layout',
|
|
71
|
+
iconName: 'gp-product-badge-triangle'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
value: 'ribbon_3',
|
|
75
|
+
label: 'Text ribbon 2',
|
|
76
|
+
type: 'badge-layout',
|
|
77
|
+
iconName: 'gp-product-badge-ribbon-3'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
value: 'square',
|
|
81
|
+
label: 'Text square',
|
|
82
|
+
type: 'badge-layout',
|
|
83
|
+
iconName: 'gp-product-badge-square'
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
value: 'star',
|
|
87
|
+
label: 'Text star',
|
|
88
|
+
type: 'badge-layout',
|
|
89
|
+
iconName: 'gp-product-badge-star'
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
value: 'vertical_rectangle',
|
|
93
|
+
label: 'Text vertical',
|
|
94
|
+
type: 'badge-layout',
|
|
95
|
+
iconName: 'gp-product-badge-vertical-rectangle'
|
|
48
96
|
}
|
|
49
97
|
]
|
|
50
98
|
},
|
|
@@ -78,10 +126,10 @@ const ProductBadgeSettings = [
|
|
|
78
126
|
]
|
|
79
127
|
},
|
|
80
128
|
{
|
|
81
|
-
id: '
|
|
129
|
+
id: 'contentType',
|
|
82
130
|
label: 'Shape',
|
|
83
|
-
type: '
|
|
84
|
-
default: '
|
|
131
|
+
type: 'input',
|
|
132
|
+
default: 'text'
|
|
85
133
|
}
|
|
86
134
|
]
|
|
87
135
|
},
|
|
@@ -104,10 +152,18 @@ const ProductBadgeSettings = [
|
|
|
104
152
|
custom: {
|
|
105
153
|
fontSize: {
|
|
106
154
|
desktop: '15px'
|
|
155
|
+
},
|
|
156
|
+
lineHeight: {
|
|
157
|
+
desktop: '120%'
|
|
158
|
+
},
|
|
159
|
+
fontWeight: '400',
|
|
160
|
+
fontFamily: 'Assistant',
|
|
161
|
+
textShadow: {
|
|
162
|
+
type: 'none'
|
|
107
163
|
}
|
|
108
164
|
},
|
|
109
165
|
attrs: {
|
|
110
|
-
color: '
|
|
166
|
+
color: '#121212'
|
|
111
167
|
}
|
|
112
168
|
},
|
|
113
169
|
hiddenSetting: {
|
|
@@ -360,19 +416,13 @@ const ProductBadgeSettings = [
|
|
|
360
416
|
default: false
|
|
361
417
|
},
|
|
362
418
|
{
|
|
363
|
-
id: '
|
|
419
|
+
id: 'textSizeV2',
|
|
364
420
|
type: 'size-setting',
|
|
365
|
-
label: '',
|
|
366
|
-
disableShapeLinkedTooltip: 'Use other badge shape to resize without proportions',
|
|
367
421
|
devices: {
|
|
368
422
|
desktop: {
|
|
369
423
|
default: {
|
|
370
424
|
width: 'auto',
|
|
371
425
|
height: 'auto',
|
|
372
|
-
shapeLinked: false,
|
|
373
|
-
disableShapeLinked: true,
|
|
374
|
-
hiddenShape: true,
|
|
375
|
-
shape: 'custom',
|
|
376
426
|
padding: {
|
|
377
427
|
top: '8px',
|
|
378
428
|
bottom: '8px',
|
|
@@ -382,41 +432,6 @@ const ProductBadgeSettings = [
|
|
|
382
432
|
}
|
|
383
433
|
}
|
|
384
434
|
},
|
|
385
|
-
settingConfig: {
|
|
386
|
-
width: {
|
|
387
|
-
displayOptions: [
|
|
388
|
-
'auto'
|
|
389
|
-
]
|
|
390
|
-
},
|
|
391
|
-
height: {
|
|
392
|
-
displayOptions: [
|
|
393
|
-
'auto'
|
|
394
|
-
]
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
hiddenSettings: [
|
|
398
|
-
'gap',
|
|
399
|
-
'proportion'
|
|
400
|
-
]
|
|
401
|
-
},
|
|
402
|
-
{
|
|
403
|
-
id: 'textSizeV2',
|
|
404
|
-
type: 'size-setting',
|
|
405
|
-
devices: {
|
|
406
|
-
desktop: {
|
|
407
|
-
default: {
|
|
408
|
-
width: 'Auto',
|
|
409
|
-
height: 'Auto',
|
|
410
|
-
padding: {
|
|
411
|
-
type: 'medium',
|
|
412
|
-
top: '4px',
|
|
413
|
-
bottom: '4px',
|
|
414
|
-
left: '16px',
|
|
415
|
-
right: '16px'
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
},
|
|
420
435
|
settingConfig: {
|
|
421
436
|
width: {
|
|
422
437
|
displayOptions: [
|
|
@@ -452,9 +467,8 @@ const ProductBadgeSettings = [
|
|
|
452
467
|
]
|
|
453
468
|
},
|
|
454
469
|
{
|
|
455
|
-
id: '
|
|
470
|
+
id: 'imageSizeV2',
|
|
456
471
|
type: 'size-setting',
|
|
457
|
-
label: '',
|
|
458
472
|
disableShapeLinkedTooltip: 'Use other badge shape to resize without proportions',
|
|
459
473
|
devices: {
|
|
460
474
|
desktop: {
|
|
@@ -467,42 +481,6 @@ const ProductBadgeSettings = [
|
|
|
467
481
|
}
|
|
468
482
|
}
|
|
469
483
|
},
|
|
470
|
-
settingConfig: {
|
|
471
|
-
width: {
|
|
472
|
-
displayOptions: [
|
|
473
|
-
'auto'
|
|
474
|
-
]
|
|
475
|
-
},
|
|
476
|
-
height: {
|
|
477
|
-
displayOptions: [
|
|
478
|
-
'auto'
|
|
479
|
-
]
|
|
480
|
-
}
|
|
481
|
-
},
|
|
482
|
-
hiddenSettings: [
|
|
483
|
-
'gap',
|
|
484
|
-
'proportion',
|
|
485
|
-
'padding'
|
|
486
|
-
]
|
|
487
|
-
},
|
|
488
|
-
{
|
|
489
|
-
id: 'imageSizeV2',
|
|
490
|
-
type: 'size-setting',
|
|
491
|
-
devices: {
|
|
492
|
-
desktop: {
|
|
493
|
-
default: {
|
|
494
|
-
width: 'Auto',
|
|
495
|
-
height: 'Auto',
|
|
496
|
-
padding: {
|
|
497
|
-
type: 'medium',
|
|
498
|
-
top: '4px',
|
|
499
|
-
bottom: '4px',
|
|
500
|
-
left: '16px',
|
|
501
|
-
right: '16px'
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
}
|
|
505
|
-
},
|
|
506
484
|
settingConfig: {
|
|
507
485
|
width: {
|
|
508
486
|
displayOptions: [
|
|
@@ -534,7 +512,8 @@ const ProductBadgeSettings = [
|
|
|
534
512
|
},
|
|
535
513
|
hiddenSettings: [
|
|
536
514
|
'shape',
|
|
537
|
-
'gap'
|
|
515
|
+
'gap',
|
|
516
|
+
'padding'
|
|
538
517
|
]
|
|
539
518
|
},
|
|
540
519
|
{
|
|
@@ -1,14 +1,45 @@
|
|
|
1
1
|
const SettingUIV2 = [
|
|
2
2
|
{
|
|
3
3
|
label: {
|
|
4
|
-
en: '
|
|
4
|
+
en: 'Style'
|
|
5
5
|
},
|
|
6
6
|
controls: [
|
|
7
7
|
{
|
|
8
8
|
setting: {
|
|
9
|
-
id: '
|
|
9
|
+
id: 'shape'
|
|
10
10
|
},
|
|
11
|
-
layout: 'vertical'
|
|
11
|
+
layout: 'vertical',
|
|
12
|
+
controlChangeTrigger: {
|
|
13
|
+
settings: [
|
|
14
|
+
{
|
|
15
|
+
condition: "shape.includes('image')",
|
|
16
|
+
source: [
|
|
17
|
+
'shape'
|
|
18
|
+
],
|
|
19
|
+
action: {
|
|
20
|
+
controlId: 'contentType',
|
|
21
|
+
newValue: 'image',
|
|
22
|
+
groupType: 'setting',
|
|
23
|
+
controlType: 'setting'
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
condition: "!shape.includes('image')",
|
|
28
|
+
source: [
|
|
29
|
+
'shape'
|
|
30
|
+
],
|
|
31
|
+
action: {
|
|
32
|
+
controlId: 'contentType',
|
|
33
|
+
newValue: 'text',
|
|
34
|
+
groupType: 'setting',
|
|
35
|
+
controlType: 'setting'
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
options: {
|
|
40
|
+
noRecordHistory: true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
12
43
|
}
|
|
13
44
|
]
|
|
14
45
|
},
|
|
@@ -37,12 +68,33 @@ const SettingUIV2 = [
|
|
|
37
68
|
conditionDisplay: 'contentType === "text"',
|
|
38
69
|
controls: [
|
|
39
70
|
{
|
|
40
|
-
id: '
|
|
71
|
+
id: 'content-badge',
|
|
72
|
+
type: 'combo',
|
|
73
|
+
iconName: 'polaris-plus',
|
|
74
|
+
isHideClear: true,
|
|
75
|
+
fixedValue: 'Edit',
|
|
76
|
+
popoverLabel: {
|
|
77
|
+
en: 'Content'
|
|
78
|
+
},
|
|
79
|
+
label: {
|
|
80
|
+
en: 'Content'
|
|
81
|
+
},
|
|
41
82
|
setting: {
|
|
42
83
|
id: 'displayContent'
|
|
43
84
|
},
|
|
44
85
|
layout: 'vertical',
|
|
45
|
-
conditionDisplay: 'contentType == "text"'
|
|
86
|
+
conditionDisplay: 'contentType == "text"',
|
|
87
|
+
controls: [
|
|
88
|
+
{
|
|
89
|
+
label: {
|
|
90
|
+
en: 'Content'
|
|
91
|
+
},
|
|
92
|
+
layout: 'vertical',
|
|
93
|
+
setting: {
|
|
94
|
+
id: 'displayContent'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
46
98
|
},
|
|
47
99
|
{
|
|
48
100
|
id: 'typo',
|
|
@@ -87,15 +139,6 @@ const SettingUIV2 = [
|
|
|
87
139
|
},
|
|
88
140
|
conditionDisplay: 'contentType == "text"',
|
|
89
141
|
controls: [
|
|
90
|
-
{
|
|
91
|
-
label: {
|
|
92
|
-
en: 'Shape'
|
|
93
|
-
},
|
|
94
|
-
setting: {
|
|
95
|
-
id: 'shape'
|
|
96
|
-
},
|
|
97
|
-
conditionDisplay: 'contentType == "text"'
|
|
98
|
-
},
|
|
99
142
|
{
|
|
100
143
|
label: {
|
|
101
144
|
en: 'Color'
|
|
@@ -185,7 +228,7 @@ const SettingUIV2 = [
|
|
|
185
228
|
{
|
|
186
229
|
type: 'control',
|
|
187
230
|
setting: {
|
|
188
|
-
id: '
|
|
231
|
+
id: 'imageSizeV2'
|
|
189
232
|
},
|
|
190
233
|
layout: 'vertical'
|
|
191
234
|
},
|
|
@@ -234,6 +277,11 @@ const SettingUIV2 = [
|
|
|
234
277
|
label: 'Fit content',
|
|
235
278
|
value: 'Auto',
|
|
236
279
|
showValue: true
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
label: 'Default',
|
|
283
|
+
value: 'default',
|
|
284
|
+
showValue: true
|
|
237
285
|
}
|
|
238
286
|
]
|
|
239
287
|
},
|
|
@@ -283,6 +331,36 @@ const SettingUIV2 = [
|
|
|
283
331
|
}
|
|
284
332
|
]
|
|
285
333
|
},
|
|
334
|
+
{
|
|
335
|
+
label: {
|
|
336
|
+
en: 'Position'
|
|
337
|
+
},
|
|
338
|
+
controls: [
|
|
339
|
+
{
|
|
340
|
+
id: 'badge-position',
|
|
341
|
+
type: 'combo',
|
|
342
|
+
iconName: 'polaris-plus',
|
|
343
|
+
isHideClear: true,
|
|
344
|
+
fixedValue: 'Edit',
|
|
345
|
+
popoverLabel: {
|
|
346
|
+
en: 'Position'
|
|
347
|
+
},
|
|
348
|
+
label: {
|
|
349
|
+
en: 'Position'
|
|
350
|
+
},
|
|
351
|
+
layout: 'vertical',
|
|
352
|
+
controls: [
|
|
353
|
+
{
|
|
354
|
+
layout: 'vertical',
|
|
355
|
+
setting: {
|
|
356
|
+
id: 'position'
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
],
|
|
362
|
+
conditionDisplay: 'positionWithImage === "inside"'
|
|
363
|
+
},
|
|
286
364
|
{
|
|
287
365
|
controls: [
|
|
288
366
|
{
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3621,9 +3621,7 @@ type ProductBadgeProps = BasePropsWrap<{
|
|
|
3621
3621
|
wrapperBorder?: Border;
|
|
3622
3622
|
borderRadius?: CornerRadius;
|
|
3623
3623
|
hasShadow?: boolean;
|
|
3624
|
-
textSize?: ObjectDevices<SizeSettingGlobal>;
|
|
3625
3624
|
textSizeV2?: ObjectDevices<SizeSettingGlobal>;
|
|
3626
|
-
imageSize?: ObjectDevices<SizeSettingGlobal>;
|
|
3627
3625
|
imageSizeV2?: ObjectDevices<SizeSettingGlobal>;
|
|
3628
3626
|
align?: ObjectDevices<AlignProp>;
|
|
3629
3627
|
shapeShadow: ShadowProps;
|
|
@@ -6117,7 +6115,7 @@ declare const FileUpload: ({ setting, styles, builderProps, pageContext }: FileU
|
|
|
6117
6115
|
|
|
6118
6116
|
declare const Product: (props: ProductProps) => string;
|
|
6119
6117
|
|
|
6120
|
-
declare const ProductBadge: (
|
|
6118
|
+
declare const ProductBadge: (props: ProductBadgeProps & {
|
|
6121
6119
|
pageContext?: PageContext;
|
|
6122
6120
|
}) => string;
|
|
6123
6121
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.335",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"relationship": "rollup -c ./scripts/rollup.config.settings.mjs && node ./scripts/get-control-relationship.js && node ./scripts/get-element-relationship.js"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@gem-sdk/core": "2.0.0-dev.
|
|
25
|
+
"@gem-sdk/core": "2.0.0-dev.334",
|
|
26
26
|
"@gem-sdk/styles": "2.0.0-dev.324",
|
|
27
27
|
"@gem-sdk/system": "2.0.0-dev.324",
|
|
28
28
|
"@types/react-transition-group": "^4.4.5"
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var core = require('@gem-sdk/core');
|
|
4
|
-
var shape = require('../utils/shape.js');
|
|
5
|
-
var common = require('../utils/common.js');
|
|
6
|
-
var getShapePosition = require('../utils/getShapePosition.js');
|
|
7
|
-
var getRotateShape = require('../utils/getRotateShape.js');
|
|
8
|
-
var getStyleAdvanced = require('../utils/getStyleAdvanced.js');
|
|
9
|
-
var stylesV2 = require('../utils/stylesV2.js');
|
|
10
|
-
var getWhiteSpace = require('../utils/getWhiteSpace.js');
|
|
11
|
-
|
|
12
|
-
const useProductBadgeStyles = ({ setting, styles, style, isInsideProductImage, navigationPosition, imageData, dotData, currentDevice })=>{
|
|
13
|
-
const isTextBadge = setting?.contentType === 'text';
|
|
14
|
-
// currently use imageSize v1, update later
|
|
15
|
-
const badgeSize = isTextBadge ? styles?.textSizeV2 : styles?.imageSize;
|
|
16
|
-
const shape$1 = shape.getShape(setting?.shape);
|
|
17
|
-
const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
|
|
18
|
-
const placementClass = common.getShapePlacementClass(isInsideProductImage, style, currentDevice);
|
|
19
|
-
const shapePosition = getShapePosition.getShapePosition({
|
|
20
|
-
positionType: styles?.position,
|
|
21
|
-
isLiquid: false,
|
|
22
|
-
navigationPosition,
|
|
23
|
-
dataImage: {
|
|
24
|
-
...imageData,
|
|
25
|
-
...dotData
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
const wrapperStyles = common.getWrapperStyle(false);
|
|
29
|
-
const sizeStyles = isTextBadge ? common.getSize(shape$1, badgeSize) : common.getSize(undefined, badgeSize);
|
|
30
|
-
const paddingShape = common.getShapeWrapperPadding(shape$1?.ratio);
|
|
31
|
-
const shadowStyles = stylesV2.getStyleShadowV2('.product-badge-item', isTextBadge ? styles?.textBadgeShadow : styles?.imageBadgeShadow);
|
|
32
|
-
const borderStyles = shape$1?.supportBorder ? isTextBadge ? stylesV2.getStyleBorder(styles?.textBadgeBorder) : stylesV2.getStyleBorder(styles?.imageBadgeBorder) : {};
|
|
33
|
-
const cornerStyles = isTextBadge ? stylesV2.getStyleCornerRadius(styles?.textBadgeCorner, shape$1?.shapeRadius) : stylesV2.getStyleCornerRadius(styles?.imageBadgeCorner, shape$1?.shapeRadius);
|
|
34
|
-
const textBadgePadding = core.makeGlobalSize(styles?.textSizeV2).padding;
|
|
35
|
-
const imageBadgePadding = core.makeGlobalSize(styles?.imageSizeV2).padding;
|
|
36
|
-
const textBadgeStyles = {
|
|
37
|
-
...getWhiteSpace.getWhiteSpaceStyle(styles?.textSizeV2),
|
|
38
|
-
...getRotateShape.composeTextStyleByPosition(shape$1, styles?.position, isDropOutsideProductImage),
|
|
39
|
-
...core.composeTypographyStyle(styles?.typo),
|
|
40
|
-
...core.getStyleShadow({
|
|
41
|
-
value: styles?.typo?.custom?.textShadow,
|
|
42
|
-
styleAppliedFor: 'text-shadow',
|
|
43
|
-
isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
|
|
44
|
-
}),
|
|
45
|
-
...stylesV2.getStyleBackground(!!shape$1?.backgroundColorInText, styles?.badgeColorV2),
|
|
46
|
-
...textBadgePadding
|
|
47
|
-
};
|
|
48
|
-
const textBadgeContainerStyles = {
|
|
49
|
-
...borderStyles,
|
|
50
|
-
...cornerStyles,
|
|
51
|
-
...getRotateShape.composeShapeStyleByPosition(shape$1, styles?.position, isDropOutsideProductImage),
|
|
52
|
-
...stylesV2.getStyleBackground(!shape$1?.backgroundColorInText, styles?.badgeColorV2),
|
|
53
|
-
...paddingShape
|
|
54
|
-
};
|
|
55
|
-
const imageBadgeContainerStyles = {
|
|
56
|
-
...borderStyles,
|
|
57
|
-
...cornerStyles,
|
|
58
|
-
...imageBadgePadding
|
|
59
|
-
};
|
|
60
|
-
const advancedStyles = getStyleAdvanced.getStyleAdvanced(!isDropOutsideProductImage ? {
|
|
61
|
-
...shapePosition,
|
|
62
|
-
...sizeStyles
|
|
63
|
-
} : {}, style);
|
|
64
|
-
return {
|
|
65
|
-
isTextBadge,
|
|
66
|
-
isDropOutsideProductImage,
|
|
67
|
-
placementClass,
|
|
68
|
-
sizeStyles,
|
|
69
|
-
paddingShape,
|
|
70
|
-
shadowStyles,
|
|
71
|
-
borderStyles,
|
|
72
|
-
cornerStyles,
|
|
73
|
-
wrapperStyles,
|
|
74
|
-
advancedStyles,
|
|
75
|
-
textBadgeStyles,
|
|
76
|
-
textBadgeContainerStyles,
|
|
77
|
-
imageBadgeContainerStyles,
|
|
78
|
-
shape: shape$1,
|
|
79
|
-
badgeSize
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
exports.useProductBadgeStyles = useProductBadgeStyles;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { makeGlobalSize, composeTypographyStyle, getStyleShadow } from '@gem-sdk/core';
|
|
2
|
-
import { getShape } from '../utils/shape.js';
|
|
3
|
-
import { getSize, getShapePlacementClass, getWrapperStyle, getShapeWrapperPadding } from '../utils/common.js';
|
|
4
|
-
import { getShapePosition } from '../utils/getShapePosition.js';
|
|
5
|
-
import { composeTextStyleByPosition, composeShapeStyleByPosition } from '../utils/getRotateShape.js';
|
|
6
|
-
import { getStyleAdvanced } from '../utils/getStyleAdvanced.js';
|
|
7
|
-
import { getStyleShadowV2, getStyleBorder, getStyleCornerRadius, getStyleBackground } from '../utils/stylesV2.js';
|
|
8
|
-
import { getWhiteSpaceStyle } from '../utils/getWhiteSpace.js';
|
|
9
|
-
|
|
10
|
-
const useProductBadgeStyles = ({ setting, styles, style, isInsideProductImage, navigationPosition, imageData, dotData, currentDevice })=>{
|
|
11
|
-
const isTextBadge = setting?.contentType === 'text';
|
|
12
|
-
// currently use imageSize v1, update later
|
|
13
|
-
const badgeSize = isTextBadge ? styles?.textSizeV2 : styles?.imageSize;
|
|
14
|
-
const shape = getShape(setting?.shape);
|
|
15
|
-
const isDropOutsideProductImage = setting?.positionWithImage === 'outside';
|
|
16
|
-
const placementClass = getShapePlacementClass(isInsideProductImage, style, currentDevice);
|
|
17
|
-
const shapePosition = getShapePosition({
|
|
18
|
-
positionType: styles?.position,
|
|
19
|
-
isLiquid: false,
|
|
20
|
-
navigationPosition,
|
|
21
|
-
dataImage: {
|
|
22
|
-
...imageData,
|
|
23
|
-
...dotData
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
const wrapperStyles = getWrapperStyle(false);
|
|
27
|
-
const sizeStyles = isTextBadge ? getSize(shape, badgeSize) : getSize(undefined, badgeSize);
|
|
28
|
-
const paddingShape = getShapeWrapperPadding(shape?.ratio);
|
|
29
|
-
const shadowStyles = getStyleShadowV2('.product-badge-item', isTextBadge ? styles?.textBadgeShadow : styles?.imageBadgeShadow);
|
|
30
|
-
const borderStyles = shape?.supportBorder ? isTextBadge ? getStyleBorder(styles?.textBadgeBorder) : getStyleBorder(styles?.imageBadgeBorder) : {};
|
|
31
|
-
const cornerStyles = isTextBadge ? getStyleCornerRadius(styles?.textBadgeCorner, shape?.shapeRadius) : getStyleCornerRadius(styles?.imageBadgeCorner, shape?.shapeRadius);
|
|
32
|
-
const textBadgePadding = makeGlobalSize(styles?.textSizeV2).padding;
|
|
33
|
-
const imageBadgePadding = makeGlobalSize(styles?.imageSizeV2).padding;
|
|
34
|
-
const textBadgeStyles = {
|
|
35
|
-
...getWhiteSpaceStyle(styles?.textSizeV2),
|
|
36
|
-
...composeTextStyleByPosition(shape, styles?.position, isDropOutsideProductImage),
|
|
37
|
-
...composeTypographyStyle(styles?.typo),
|
|
38
|
-
...getStyleShadow({
|
|
39
|
-
value: styles?.typo?.custom?.textShadow,
|
|
40
|
-
styleAppliedFor: 'text-shadow',
|
|
41
|
-
isEnableShadow: styles?.typo?.custom?.textShadow?.type !== 'none'
|
|
42
|
-
}),
|
|
43
|
-
...getStyleBackground(!!shape?.backgroundColorInText, styles?.badgeColorV2),
|
|
44
|
-
...textBadgePadding
|
|
45
|
-
};
|
|
46
|
-
const textBadgeContainerStyles = {
|
|
47
|
-
...borderStyles,
|
|
48
|
-
...cornerStyles,
|
|
49
|
-
...composeShapeStyleByPosition(shape, styles?.position, isDropOutsideProductImage),
|
|
50
|
-
...getStyleBackground(!shape?.backgroundColorInText, styles?.badgeColorV2),
|
|
51
|
-
...paddingShape
|
|
52
|
-
};
|
|
53
|
-
const imageBadgeContainerStyles = {
|
|
54
|
-
...borderStyles,
|
|
55
|
-
...cornerStyles,
|
|
56
|
-
...imageBadgePadding
|
|
57
|
-
};
|
|
58
|
-
const advancedStyles = getStyleAdvanced(!isDropOutsideProductImage ? {
|
|
59
|
-
...shapePosition,
|
|
60
|
-
...sizeStyles
|
|
61
|
-
} : {}, style);
|
|
62
|
-
return {
|
|
63
|
-
isTextBadge,
|
|
64
|
-
isDropOutsideProductImage,
|
|
65
|
-
placementClass,
|
|
66
|
-
sizeStyles,
|
|
67
|
-
paddingShape,
|
|
68
|
-
shadowStyles,
|
|
69
|
-
borderStyles,
|
|
70
|
-
cornerStyles,
|
|
71
|
-
wrapperStyles,
|
|
72
|
-
advancedStyles,
|
|
73
|
-
textBadgeStyles,
|
|
74
|
-
textBadgeContainerStyles,
|
|
75
|
-
imageBadgeContainerStyles,
|
|
76
|
-
shape,
|
|
77
|
-
badgeSize
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export { useProductBadgeStyles };
|