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