@pushwoosh/dumb-components 0.0.9 → 0.0.10
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/PushPreview/PushPreview.d.ts +3 -0
- package/PushPreview/PushPreview.js +34 -0
- package/PushPreview/constants/urls.d.ts +2 -0
- package/PushPreview/constants/urls.js +2 -0
- package/PushPreview/helpers/helpers.d.ts +2 -0
- package/PushPreview/helpers/helpers.js +10 -0
- package/PushPreview/index.d.ts +1 -0
- package/PushPreview/index.js +1 -0
- package/PushPreview/styled.d.ts +24 -0
- package/PushPreview/styled.js +39 -0
- package/PushPreview/types.d.ts +14 -0
- package/PushPreview/types.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +2 -1
- package/package.json +4 -3
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Columns } from '@pushwoosh/kit-helpers';
|
|
3
|
+
import { Spinner } from '@pushwoosh/kit-spinner';
|
|
4
|
+
import { PREVIEW_ICON_URL } from './constants/urls';
|
|
5
|
+
import { getLocalizedContent } from './helpers/helpers';
|
|
6
|
+
import { LoadingBox, PushBox, AppIcon, PushContent, PushTitleBox, PushTitleText, PushDate, PushDescription } from './styled';
|
|
7
|
+
export function PushPreview(props) {
|
|
8
|
+
const {
|
|
9
|
+
pushPreset,
|
|
10
|
+
language,
|
|
11
|
+
isLoading,
|
|
12
|
+
appTitle,
|
|
13
|
+
appIcon,
|
|
14
|
+
width
|
|
15
|
+
} = props;
|
|
16
|
+
const title = getLocalizedContent(pushPreset === null || pushPreset === void 0 ? void 0 : pushPreset.title, language) || appTitle;
|
|
17
|
+
const subTitle = getLocalizedContent(pushPreset === null || pushPreset === void 0 ? void 0 : pushPreset.subTitle, language);
|
|
18
|
+
const content = getLocalizedContent(pushPreset === null || pushPreset === void 0 ? void 0 : pushPreset.content, language);
|
|
19
|
+
const renderIcon = content ? (pushPreset === null || pushPreset === void 0 ? void 0 : pushPreset.icon) || appIcon || PREVIEW_ICON_URL : PREVIEW_ICON_URL;
|
|
20
|
+
return React.createElement(PushBox, {
|
|
21
|
+
"$width": width
|
|
22
|
+
}, isLoading && React.createElement(LoadingBox, null, React.createElement(Spinner, {
|
|
23
|
+
size: "medium"
|
|
24
|
+
})), !isLoading && React.createElement(Columns, {
|
|
25
|
+
"$sizes": "30px 1fr",
|
|
26
|
+
"$alignItems": "center",
|
|
27
|
+
"$gap": 10
|
|
28
|
+
}, React.createElement(AppIcon, {
|
|
29
|
+
alt: appTitle,
|
|
30
|
+
src: renderIcon
|
|
31
|
+
}), React.createElement(PushContent, null, React.createElement(PushTitleBox, null, React.createElement(PushTitleText, null, title), React.createElement(PushDate, null, "5m\u00A0ago")), subTitle && React.createElement(PushTitleText, null, subTitle), React.createElement(PushDescription, {
|
|
32
|
+
"$isLocked": !content
|
|
33
|
+
}, content || 'Please, create or select push content'))));
|
|
34
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const getDefaultLanguage = properties => {
|
|
2
|
+
if (properties.default) {
|
|
3
|
+
return 'default';
|
|
4
|
+
}
|
|
5
|
+
if (properties.en) {
|
|
6
|
+
return 'en';
|
|
7
|
+
}
|
|
8
|
+
return Object.keys(properties)[0];
|
|
9
|
+
};
|
|
10
|
+
export const getLocalizedContent = (value, language) => (value === null || value === void 0 ? void 0 : value[language || getDefaultLanguage(value)]) || '';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PushPreview';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './PushPreview';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const PushBox: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
$width?: string;
|
|
3
|
+
}, never>;
|
|
4
|
+
export declare const AppIcon: import("styled-components").StyledComponent<"img", any, {}, never>;
|
|
5
|
+
export declare const PushContent: import("styled-components").StyledComponent<"div", any, {
|
|
6
|
+
$alignContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
7
|
+
$alignItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
8
|
+
$gap?: string | number | undefined;
|
|
9
|
+
$gridAutoFlow?: "row" | "column" | "dense" | "row dense" | "column dense" | undefined;
|
|
10
|
+
$justifyContent?: "end" | "start" | "center" | "space-between" | "space-around" | "space-evenly" | "stretch" | undefined;
|
|
11
|
+
$justifyItems?: "end" | "start" | "center" | "stretch" | "baseline" | undefined;
|
|
12
|
+
$margin?: string | number | undefined;
|
|
13
|
+
$padding?: string | number | undefined;
|
|
14
|
+
$placeItems?: "end" | "start" | "center" | "stretch" | undefined;
|
|
15
|
+
} & {
|
|
16
|
+
$gridAutoFlow: string;
|
|
17
|
+
}, "$gridAutoFlow">;
|
|
18
|
+
export declare const PushTitleBox: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
19
|
+
export declare const PushTitleText: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
20
|
+
export declare const PushDate: import("styled-components").StyledComponent<"span", any, {}, never>;
|
|
21
|
+
export declare const PushDescription: import("styled-components").StyledComponent<"div", any, {
|
|
22
|
+
$isLocked: boolean;
|
|
23
|
+
}, never>;
|
|
24
|
+
export declare const LoadingBox: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Color, FontWeight, FontSize, Shadow, ShapeRadius, Spacing } from '@pushwoosh/kit-constants';
|
|
3
|
+
import { Vertical } from '@pushwoosh/kit-helpers';
|
|
4
|
+
export const PushBox = styled.div.withConfig({
|
|
5
|
+
displayName: "PushBox",
|
|
6
|
+
componentId: "sc-13jvrn7-0"
|
|
7
|
+
})(["display:grid;width:", ";min-height:50px;padding:10px;background:", ";box-shadow:", ";border-radius:10px;"], ({
|
|
8
|
+
$width
|
|
9
|
+
}) => $width || '100%', Color.CLEAR, Shadow.LARGE);
|
|
10
|
+
export const AppIcon = styled.img.withConfig({
|
|
11
|
+
displayName: "AppIcon",
|
|
12
|
+
componentId: "sc-13jvrn7-1"
|
|
13
|
+
})(["width:30px;height:30px;border-radius:", ";"], ShapeRadius.CONTROL);
|
|
14
|
+
export const PushContent = styled(Vertical).withConfig({
|
|
15
|
+
displayName: "PushContent",
|
|
16
|
+
componentId: "sc-13jvrn7-2"
|
|
17
|
+
})(["max-width:240px;"]);
|
|
18
|
+
export const PushTitleBox = styled.span.withConfig({
|
|
19
|
+
displayName: "PushTitleBox",
|
|
20
|
+
componentId: "sc-13jvrn7-3"
|
|
21
|
+
})(["display:grid;grid-template-columns:1fr min-content;grid-gap:", ";"], Spacing.S3);
|
|
22
|
+
export const PushTitleText = styled.span.withConfig({
|
|
23
|
+
displayName: "PushTitleText",
|
|
24
|
+
componentId: "sc-13jvrn7-4"
|
|
25
|
+
})(["font-weight:", ";font-size:13px;line-height:140%;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;"], FontWeight.MEDIUM);
|
|
26
|
+
export const PushDate = styled.span.withConfig({
|
|
27
|
+
displayName: "PushDate",
|
|
28
|
+
componentId: "sc-13jvrn7-5"
|
|
29
|
+
})(["color:#555;font-weight:", ";font-size:", ";letter-spacing:0;"], FontWeight.REGULAR, FontSize.SMALL);
|
|
30
|
+
export const PushDescription = styled.div.withConfig({
|
|
31
|
+
displayName: "PushDescription",
|
|
32
|
+
componentId: "sc-13jvrn7-6"
|
|
33
|
+
})(["color:", ";font-weight:", ";font-size:13px;line-height:140%;"], ({
|
|
34
|
+
$isLocked
|
|
35
|
+
}) => $isLocked ? Color.LOCKED : Color.MAIN, FontWeight.REGULAR);
|
|
36
|
+
export const LoadingBox = styled.div.withConfig({
|
|
37
|
+
displayName: "LoadingBox",
|
|
38
|
+
componentId: "sc-13jvrn7-7"
|
|
39
|
+
})(["display:flex;align-items:center;justify-content:center;flex:1;"]);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PushBasicData {
|
|
2
|
+
title?: Record<string, string>;
|
|
3
|
+
subTitle?: Record<string, string>;
|
|
4
|
+
content?: Record<string, string>;
|
|
5
|
+
icon?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PushPreviewProps<T> {
|
|
8
|
+
pushPreset?: T | null;
|
|
9
|
+
language?: string;
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
appTitle: string;
|
|
12
|
+
appIcon?: string;
|
|
13
|
+
width?: string;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { ProgressBar } from './ProgressBar';
|
|
2
2
|
export * from './Tabs';
|
|
3
|
-
export { EmailTemplatePreview } from './EmailTemplatePreview/EmailTemplatePreview';
|
|
3
|
+
export { EmailTemplatePreview } from './EmailTemplatePreview/EmailTemplatePreview';
|
|
4
|
+
export { PushPreview } from './PushPreview';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/dumb-components",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "React components to build Pushwoosh products",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
},
|
|
17
17
|
"pre-commit": "check",
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@pushwoosh/frontend-builder-engine": "^1.0.
|
|
20
|
-
"@pushwoosh/kit-constants": "^1.6.
|
|
19
|
+
"@pushwoosh/frontend-builder-engine": "^1.0.6",
|
|
20
|
+
"@pushwoosh/kit-constants": "^1.6.6",
|
|
21
21
|
"@types/lodash": "^4.17.13",
|
|
22
22
|
"@types/react": "^18.2.69",
|
|
23
23
|
"@types/react-dom": "^18.2.22",
|
|
@@ -38,6 +38,7 @@
|
|
|
38
38
|
"npm": ">= 7"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
+
"@pushwoosh/kit-helpers": "^4.6.2",
|
|
41
42
|
"@pushwoosh/kit-icons": "^2.0.25",
|
|
42
43
|
"@pushwoosh/kit-spinner": "^1.5.1",
|
|
43
44
|
"@pushwoosh/kit-typography": "^1.7.1",
|