@capillarytech/creatives-library 9.0.41-alpha.1 → 9.0.41-alpha.2

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 (27) hide show
  1. package/package.json +1 -1
  2. package/v2Components/CapDeviceContent/index.scss +1 -1
  3. package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +15 -106
  4. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -139
  5. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +5 -1
  6. package/v2Components/CommonTestAndPreview/index.js +26 -240
  7. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +0 -364
  8. package/v2Components/CommonTestAndPreview/tests/utils.test.js +0 -49
  9. package/v2Components/CommonTestAndPreview/utils.js +0 -20
  10. package/v2Components/FormBuilder/_formBuilder.scss +1 -1
  11. package/v2Containers/Email/_email.scss +4 -0
  12. package/v2Containers/Email/index.js +1 -1
  13. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +14 -10
  14. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +14 -9
  15. package/v2Containers/Templates/_templates.scss +12 -180
  16. package/v2Containers/Templates/index.js +18 -104
  17. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +15 -6
  18. package/v2Containers/Viber/constants.js +0 -21
  19. package/v2Containers/Viber/index.js +49 -719
  20. package/v2Containers/Viber/index.scss +0 -175
  21. package/v2Containers/Viber/messages.js +0 -121
  22. package/v2Containers/Viber/tests/index.test.js +0 -80
  23. package/v2Containers/Whatsapp/index.js +4 -2
  24. package/v2Containers/Whatsapp/index.scss +8 -5
  25. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +280 -224
  26. package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberCarouselPreviewCards.js +0 -126
  27. package/v2Components/CommonTestAndPreview/UnifiedPreview/_viberCarouselPreviewCards.scss +0 -133
@@ -1,126 +0,0 @@
1
- import React, { useLayoutEffect, useMemo, useRef, useState } from 'react';
2
- import PropTypes from 'prop-types';
3
- import CapRow from '@capillarytech/cap-ui-library/CapRow';
4
- import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
5
- import CapImage from '@capillarytech/cap-ui-library/CapImage';
6
- import {
7
- getTrimmedText,
8
- hasTrimmedText,
9
- getCarouselButtonsWithTitles,
10
- getCarouselButtonSlotCount,
11
- } from '../utils';
12
-
13
- const ViberCarouselPreviewCards = ({ cards = [] }) => {
14
- const previewCards = Array.isArray(cards) && cards.length ? cards : [{}];
15
- const carouselButtonSlotCount = useMemo(
16
- () => getCarouselButtonSlotCount(previewCards),
17
- [previewCards],
18
- );
19
- const carouselTitleRefs = useRef([]);
20
- const [carouselTitleLineCount, setCarouselTitleLineCount] = useState(1);
21
-
22
- carouselTitleRefs.current = previewCards.map(() => null);
23
-
24
- useLayoutEffect(() => {
25
- let maxLines = 1;
26
- carouselTitleRefs.current?.forEach((node) => {
27
- if (!node) {
28
- return;
29
- }
30
- const { lineHeight } = window.getComputedStyle(node);
31
- const parsedLineHeight = parseFloat(lineHeight) || 18;
32
- const lines = Math.min(2, Math.max(1, Math.round(node?.scrollHeight / parsedLineHeight)));
33
- if (lines > maxLines) {
34
- maxLines = lines;
35
- }
36
- });
37
- setCarouselTitleLineCount((prev) => (prev === maxLines ? prev : maxLines));
38
- }, [previewCards]);
39
-
40
- return (
41
- <CapRow type="flex" noWrap className="scroll">
42
- {previewCards?.map((card, index) => {
43
- const cardButtons = getCarouselButtonsWithTitles(card);
44
- const titleLineClass = `text-wrap--${carouselTitleLineCount}-line`;
45
-
46
- return (
47
- <CapRow type="flex-column" className="card" key={`viber-carousel-card-${index}`}>
48
- {hasTrimmedText(card?.mediaUrl) ? (
49
- <CapImage
50
- src={card?.mediaUrl}
51
- className="image"
52
- alt="Viber carousel card"
53
- />
54
- ) : (
55
- <CapRow className="image-placeholder" />
56
- )}
57
- <CapRow className="card-body">
58
- <CapRow className={`text-wrap ${titleLineClass}`}>
59
- {hasTrimmedText(card?.text) ? (
60
- <CapRow
61
- className="text-inner"
62
- ref={(node) => {
63
- carouselTitleRefs.current[index] = node;
64
- }}
65
- >
66
- <CapLabel type="label15" className="text">
67
- {card?.text}
68
- </CapLabel>
69
- </CapRow>
70
- ) : (
71
- <CapLabel type="label15" className="text-placeholder" />
72
- )}
73
- </CapRow>
74
- {carouselButtonSlotCount > 0 && (
75
- <CapRow className="buttons">
76
- {Array.from({ length: carouselButtonSlotCount }).map((_, btnIndex) => {
77
- const cardButton = cardButtons[btnIndex];
78
- const trimmedCardButtonTitle = cardButton
79
- ? getTrimmedText(cardButton?.title)
80
- : '';
81
-
82
- if (!trimmedCardButtonTitle) {
83
- return (
84
- <CapRow
85
- className="button button-placeholder"
86
- key={`viber-carousel-btn-placeholder-${index}-${btnIndex}`}
87
- aria-hidden="true"
88
- />
89
- );
90
- }
91
-
92
- return (
93
- <CapLabel
94
- className={`button ${btnIndex === 1 ? 'button-secondary' : ''}`}
95
- key={`viber-carousel-btn-${index}-${btnIndex}-${trimmedCardButtonTitle}`}
96
- >
97
- {trimmedCardButtonTitle}
98
- </CapLabel>
99
- );
100
- })}
101
- </CapRow>
102
- )}
103
- </CapRow>
104
- </CapRow>
105
- );
106
- })}
107
- </CapRow>
108
- );
109
- };
110
-
111
- ViberCarouselPreviewCards.propTypes = {
112
- cards: PropTypes.arrayOf(PropTypes.shape({
113
- text: PropTypes.string,
114
- mediaUrl: PropTypes.string,
115
- buttons: PropTypes.arrayOf(PropTypes.shape({
116
- title: PropTypes.string,
117
- action: PropTypes.string,
118
- })),
119
- })),
120
- };
121
-
122
- ViberCarouselPreviewCards.defaultProps = {
123
- cards: [],
124
- };
125
-
126
- export default ViberCarouselPreviewCards;
@@ -1,133 +0,0 @@
1
- // Shared Viber carousel card row (Test & Preview device preview)
2
- .viber-carousel-preview {
3
- .scroll {
4
- display: flex;
5
- flex-direction: row;
6
- flex-wrap: nowrap;
7
- align-items: stretch;
8
- width: 100%;
9
- max-width: 100%;
10
- min-width: 0;
11
- overflow-x: auto;
12
- overflow-y: hidden;
13
- padding-right: $CAP_SPACE_12;
14
- scrollbar-width: none;
15
- -webkit-overflow-scrolling: touch;
16
-
17
- &::-webkit-scrollbar {
18
- display: none;
19
- }
20
-
21
- .card {
22
- flex: 0 0 68%;
23
- min-width: 80%;
24
- margin-right: $CAP_SPACE_08;
25
- background: $CAP_G09;
26
- border: 1px solid $CAP_G07;
27
- border-radius: $CAP_SPACE_12;
28
- overflow: hidden;
29
- display: flex;
30
- flex-direction: column;
31
- align-self: stretch;
32
-
33
- &:last-child {
34
- margin-right: 0;
35
- }
36
-
37
- .image {
38
- width: 100%;
39
- height: 10rem;
40
- object-fit: cover;
41
- border-radius: 0;
42
- }
43
-
44
- .image-placeholder {
45
- width: 100%;
46
- height: 10rem;
47
- border-radius: 0;
48
- background: $CAP_G07;
49
- }
50
-
51
- .card-body {
52
- flex: 1;
53
- padding: $CAP_SPACE_08;
54
- display: flex;
55
- flex-direction: column;
56
- min-height: 0;
57
-
58
- .text-wrap {
59
- flex-shrink: 0;
60
- width: 100%;
61
-
62
- &--1-line {
63
- min-height: 1.3em;
64
- }
65
-
66
- &--2-line {
67
- min-height: 2.6em;
68
- }
69
-
70
- .text-inner {
71
- width: 100%;
72
-
73
- .text {
74
- color: $CAP_G01;
75
- line-height: 1.3;
76
- white-space: normal;
77
- word-break: break-word;
78
- display: block;
79
- width: 100%;
80
- margin: 0;
81
- }
82
- }
83
-
84
- .text-placeholder {
85
- width: 100%;
86
- height: 0.875rem;
87
- border-radius: $CAP_SPACE_04;
88
- background: $CAP_G07;
89
- min-height: 0.875rem;
90
- display: block;
91
- }
92
- }
93
-
94
- .buttons {
95
- display: flex;
96
- flex-direction: column;
97
- gap: $CAP_SPACE_06;
98
- width: 100%;
99
- flex-shrink: 0;
100
-
101
- .button {
102
- color: $CAP_WHITE;
103
- background: $CAP_PURPLE01;
104
- border-radius: $CAP_SPACE_12;
105
- text-align: center;
106
- width: 100%;
107
- display: flex;
108
- align-items: center;
109
- justify-content: center;
110
- min-height: 1.5rem;
111
- padding: $CAP_SPACE_06 $CAP_SPACE_08;
112
- white-space: normal;
113
- box-sizing: border-box;
114
- }
115
-
116
- .button-placeholder {
117
- visibility: hidden;
118
- pointer-events: none;
119
- padding: 0;
120
- background: transparent;
121
- border: none;
122
- }
123
-
124
- .button-secondary {
125
- color: $CAP_PURPLE01;
126
- background: transparent;
127
- border: none;
128
- }
129
- }
130
- }
131
- }
132
- }
133
- }