@pushwoosh/websdk-common 6.26.0 → 6.27.0
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/inbox/InboxCellPreview.js +62 -14
- package/inbox/types.d.ts +4 -0
- package/package.json +1 -1
|
@@ -46,6 +46,11 @@ const TEXT = {
|
|
|
46
46
|
fontSize: 13,
|
|
47
47
|
lineHeight: 18 / 13,
|
|
48
48
|
fontWeight: 400
|
|
49
|
+
},
|
|
50
|
+
h6: {
|
|
51
|
+
fontSize: 11,
|
|
52
|
+
lineHeight: 13 / 11,
|
|
53
|
+
fontWeight: 600
|
|
49
54
|
}
|
|
50
55
|
};
|
|
51
56
|
const ELLIPSIS = {
|
|
@@ -79,6 +84,23 @@ const TAG_NAME = {
|
|
|
79
84
|
fontWeight: 400,
|
|
80
85
|
color: MAIN
|
|
81
86
|
};
|
|
87
|
+
const PREVIEW_CSS = `
|
|
88
|
+
.pw-inbox-widget--cell .pw-inbox_item--carousel .pw-inbox_hero--placeholder {
|
|
89
|
+
position: relative;
|
|
90
|
+
}
|
|
91
|
+
.pw-inbox-widget--cell .pw-inbox_item--carousel .pw-inbox_hero--placeholder::after {
|
|
92
|
+
content: '';
|
|
93
|
+
position: absolute;
|
|
94
|
+
left: 50%;
|
|
95
|
+
bottom: 9px;
|
|
96
|
+
width: 4px;
|
|
97
|
+
height: 4px;
|
|
98
|
+
margin-left: -10px;
|
|
99
|
+
border-radius: 50%;
|
|
100
|
+
background: ${MAIN};
|
|
101
|
+
box-shadow: 8px 0 0 ${MAIN}, 16px 0 0 ${MAIN};
|
|
102
|
+
}
|
|
103
|
+
`;
|
|
82
104
|
/** Plain text with every `{Tag|modifier}` token drawn as a tag chip. */
|
|
83
105
|
export function renderInboxTags(text) {
|
|
84
106
|
return text.split(TAG_TOKEN).map((part, index) => {
|
|
@@ -109,7 +131,7 @@ const AVATAR = {
|
|
|
109
131
|
},
|
|
110
132
|
android: {
|
|
111
133
|
size: 40,
|
|
112
|
-
radius:
|
|
134
|
+
radius: '50%',
|
|
113
135
|
text: TEXT.h4
|
|
114
136
|
}
|
|
115
137
|
};
|
|
@@ -302,9 +324,28 @@ function IOSCell(props) {
|
|
|
302
324
|
title,
|
|
303
325
|
body,
|
|
304
326
|
dateLabel,
|
|
305
|
-
unread
|
|
327
|
+
unread,
|
|
328
|
+
compactText
|
|
306
329
|
} = props;
|
|
307
330
|
const isClassic = layout === 'classic';
|
|
331
|
+
let titleText = isClassic ? {
|
|
332
|
+
...TEXT.body,
|
|
333
|
+
fontWeight: 500
|
|
334
|
+
} : TEXT.h5;
|
|
335
|
+
let bodyText = isClassic ? {
|
|
336
|
+
...TEXT.body,
|
|
337
|
+
color: '#333333'
|
|
338
|
+
} : {
|
|
339
|
+
...TEXT.footnote,
|
|
340
|
+
color: PHANTOM
|
|
341
|
+
};
|
|
342
|
+
if (compactText) {
|
|
343
|
+
titleText = TEXT.h6;
|
|
344
|
+
bodyText = {
|
|
345
|
+
...TEXT.caption,
|
|
346
|
+
color: PHANTOM
|
|
347
|
+
};
|
|
348
|
+
}
|
|
308
349
|
const texts = _jsxs("div", {
|
|
309
350
|
style: {
|
|
310
351
|
display: 'flex',
|
|
@@ -321,10 +362,7 @@ function IOSCell(props) {
|
|
|
321
362
|
},
|
|
322
363
|
children: [_jsx("div", {
|
|
323
364
|
style: {
|
|
324
|
-
...
|
|
325
|
-
...TEXT.body,
|
|
326
|
-
fontWeight: 500
|
|
327
|
-
} : TEXT.h5),
|
|
365
|
+
...titleText,
|
|
328
366
|
flex: 1,
|
|
329
367
|
minWidth: 0,
|
|
330
368
|
overflowWrap: 'anywhere',
|
|
@@ -342,9 +380,8 @@ function IOSCell(props) {
|
|
|
342
380
|
})]
|
|
343
381
|
}), !!body && _jsx("div", {
|
|
344
382
|
style: {
|
|
345
|
-
...
|
|
346
|
-
overflowWrap: 'anywhere'
|
|
347
|
-
color: isClassic ? '#333333' : PHANTOM
|
|
383
|
+
...bodyText,
|
|
384
|
+
overflowWrap: 'anywhere'
|
|
348
385
|
},
|
|
349
386
|
children: body
|
|
350
387
|
})]
|
|
@@ -506,6 +543,8 @@ export function InboxCellPreview(props) {
|
|
|
506
543
|
emptyDescription = 'Enter text of your inbox message to see the preview',
|
|
507
544
|
renderText = renderInboxTags,
|
|
508
545
|
iconPlaceholder = false,
|
|
546
|
+
appIconUrl,
|
|
547
|
+
compactText = false,
|
|
509
548
|
width = '100%'
|
|
510
549
|
} = props;
|
|
511
550
|
const frame = {
|
|
@@ -542,7 +581,7 @@ export function InboxCellPreview(props) {
|
|
|
542
581
|
return _jsxs("div", {
|
|
543
582
|
style: frame,
|
|
544
583
|
children: [_jsx("style", {
|
|
545
|
-
children: INBOX_WIDGET_CSS
|
|
584
|
+
children: INBOX_WIDGET_CSS + PREVIEW_CSS
|
|
546
585
|
}), _jsx("div", {
|
|
547
586
|
className: widget.className,
|
|
548
587
|
style: {
|
|
@@ -558,8 +597,12 @@ export function InboxCellPreview(props) {
|
|
|
558
597
|
isRead: !unread,
|
|
559
598
|
layout: layout,
|
|
560
599
|
placeholder: isEmpty || (layout === 'classic' ? isIconPending : !hasMedia(picked, layout)),
|
|
561
|
-
timeLabel: formatInboxMessageTime(sendDate || new Date().toISOString()),
|
|
600
|
+
timeLabel: formatInboxMessageTime(sendDate || new Date().toISOString()).replace(/ \d{4},/, ','),
|
|
562
601
|
title: isEmpty ? emptyTitle : picked.title && _jsx("span", {
|
|
602
|
+
style: {
|
|
603
|
+
...ELLIPSIS,
|
|
604
|
+
minWidth: 0
|
|
605
|
+
},
|
|
563
606
|
children: renderText(picked.title)
|
|
564
607
|
})
|
|
565
608
|
})
|
|
@@ -568,6 +611,7 @@ export function InboxCellPreview(props) {
|
|
|
568
611
|
});
|
|
569
612
|
}
|
|
570
613
|
const texts = getInboxMobileTexts(picked, layout);
|
|
614
|
+
const useAppIcon = layout === 'classic' && !picked.iconUrl && !!appIconUrl;
|
|
571
615
|
const Cell = platform === 'android' ? AndroidCell : IOSCell;
|
|
572
616
|
const rtl = !isEmpty && getInboxTextDirection(texts.title, texts.body) === 'rtl';
|
|
573
617
|
return _jsx("div", {
|
|
@@ -575,13 +619,17 @@ export function InboxCellPreview(props) {
|
|
|
575
619
|
style: frame,
|
|
576
620
|
children: _jsx(Cell, {
|
|
577
621
|
body: isEmpty ? emptyDescription : texts.body && renderText(texts.body),
|
|
578
|
-
content:
|
|
622
|
+
content: useAppIcon ? {
|
|
623
|
+
...picked,
|
|
624
|
+
iconUrl: appIconUrl
|
|
625
|
+
} : picked,
|
|
579
626
|
dateLabel: dateLabel,
|
|
580
627
|
isEmpty: isEmpty,
|
|
581
|
-
isIconPending: isIconPending,
|
|
628
|
+
isIconPending: isIconPending && !useAppIcon,
|
|
582
629
|
layout: layout,
|
|
583
630
|
title: isEmpty ? emptyTitle : renderText(texts.title),
|
|
584
|
-
unread: unread
|
|
631
|
+
unread: unread,
|
|
632
|
+
compactText: compactText
|
|
585
633
|
})
|
|
586
634
|
});
|
|
587
635
|
}
|
package/inbox/types.d.ts
CHANGED
|
@@ -123,6 +123,10 @@ export interface InboxCellPreviewProps {
|
|
|
123
123
|
appearance?: Partial<InboxWidgetAppearance>;
|
|
124
124
|
/** Keep the icon placeholder instead of the title's initial while the cell has no icon, as an editor does (default `false`). */
|
|
125
125
|
iconPlaceholder?: boolean;
|
|
126
|
+
/** Application icon the mobile cells draw for a message without its own icon. */
|
|
127
|
+
appIconUrl?: string;
|
|
128
|
+
/** Draw the iOS title at 11px and the text at 10px, as the preset editor's mockup does (default `false`). */
|
|
129
|
+
compactText?: boolean;
|
|
126
130
|
/** CSS width of the preview (default `100%`). */
|
|
127
131
|
width?: string | number;
|
|
128
132
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/websdk-common",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.27.0",
|
|
4
4
|
"description": "Code shared by the Pushwoosh WebSDK and the Control Panel, one entry point per module (web-popups: web popup model and renderer; subscription-widget: push subscription widget model and renderer; inbox: web inbox widget and inbox cell previews)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|