@expressms/smartapp-ui 1.0.7 → 1.1.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/build/main/assets/icons/refresh.svg +3 -0
- package/build/main/constants/constants.d.ts +16 -0
- package/build/main/constants/constants.js +18 -0
- package/build/main/helpers/index.d.ts +3 -0
- package/build/main/helpers/index.js +4 -0
- package/build/main/styles/stories.module.scss +96 -21
- package/build/main/styles/styles.min.css +1 -1
- package/build/main//321/201omponents/Avatar/Avatar.d.ts +1 -1
- package/build/main//321/201omponents/Avatar/Avatar.js +16 -16
- package/build/main//321/201omponents/Avatar/types.d.ts +4 -2
- package/build/main//321/201omponents/Avatar/types.js +1 -0
- package/build/main//321/201omponents/Chips/Chips.js +1 -1
- package/build/main//321/201omponents/CustomSelectProfiles/CustomSelectProfiles.js +3 -3
- package/build/main//321/201omponents/Header/Header.d.ts +1 -1
- package/build/main//321/201omponents/Header/Header.js +17 -3
- package/build/main//321/201omponents/Header/types.d.ts +11 -0
- package/build/main//321/201omponents/Loader/Loader.d.ts +1 -1
- package/build/main//321/201omponents/Loader/Loader.js +17 -2
- package/build/main//321/201omponents/Loader/types.d.ts +6 -0
- package/build/main//321/201omponents/Stories/Stories.js +91 -38
- package/build/main//321/201omponents/Stories/types.d.ts +24 -7
- package/build/main//321/201omponents/Stories/types.js +5 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IAvatarProps } from './types';
|
|
2
2
|
import '../../styles/stories.module.scss';
|
|
3
|
-
declare const Avatar: ({ username, onClick,
|
|
3
|
+
declare const Avatar: ({ username, avatar, onClick, size }: IAvatarProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default Avatar;
|
|
@@ -14,26 +14,26 @@ import { AvatarFontSizes } from './types';
|
|
|
14
14
|
import '../../styles/stories.module.scss';
|
|
15
15
|
var Avatar = function (_a) {
|
|
16
16
|
var _b, _c, _d;
|
|
17
|
-
var username = _a.username, _e = _a.onClick, onClick = _e === void 0 ? function () { return undefined; } : _e, _f = _a.
|
|
18
|
-
var initials =
|
|
19
|
-
? (_d = (_c = (_b = username === null || username === void 0 ? void 0 : username.split(' ')) === null || _b === void 0 ? void 0 : _b.map(function (n) { return n[0]; })) === null || _c === void 0 ? void 0 : _c.join('
|
|
17
|
+
var username = _a.username, avatar = _a.avatar, _e = _a.onClick, onClick = _e === void 0 ? function () { return undefined; } : _e, _f = _a.size, size = _f === void 0 ? 44 : _f;
|
|
18
|
+
var initials = username.split(' ').length <= 2
|
|
19
|
+
? (_d = (_c = (_b = username === null || username === void 0 ? void 0 : username.split(' ')) === null || _b === void 0 ? void 0 : _b.map(function (n) { return n[0]; })) === null || _c === void 0 ? void 0 : _c.join('')) === null || _d === void 0 ? void 0 : _d.toUpperCase()
|
|
20
20
|
: username[0].toUpperCase();
|
|
21
21
|
var getFontSizeAvatar = function () {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
22
|
+
switch (size) {
|
|
23
|
+
case (size = 24): {
|
|
24
|
+
return AvatarFontSizes.small;
|
|
25
|
+
}
|
|
26
|
+
case (size = 32): {
|
|
27
|
+
return AvatarFontSizes.average;
|
|
28
|
+
}
|
|
29
|
+
case (size = 44): {
|
|
30
|
+
return AvatarFontSizes.high;
|
|
31
|
+
}
|
|
32
|
+
case (size = 100): {
|
|
33
|
+
return AvatarFontSizes.greatest;
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
|
-
return AvatarFontSizes.high;
|
|
36
36
|
};
|
|
37
|
-
return (_jsx("div", __assign({ style: { width: "".concat(
|
|
37
|
+
return (_jsx("div", __assign({ style: { width: "".concat(size, "px"), height: "".concat(size, "px"), fontSize: getFontSizeAvatar() }, onClick: onClick, className: "smartapp-avatar" }, { children: avatar ? _jsx("img", { src: avatar, alt: "avatar" }) : initials })));
|
|
38
38
|
};
|
|
39
39
|
export default Avatar;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
export interface IAvatarProps {
|
|
2
2
|
username: string;
|
|
3
|
+
avatar?: string;
|
|
3
4
|
onClick?: () => void;
|
|
4
|
-
|
|
5
|
+
size?: 24 | 32 | 44 | 100;
|
|
5
6
|
}
|
|
6
7
|
export declare enum AvatarFontSizes {
|
|
7
8
|
small = "12px",
|
|
8
9
|
average = "14px",
|
|
9
|
-
high = "18px"
|
|
10
|
+
high = "18px",
|
|
11
|
+
greatest = "42px"
|
|
10
12
|
}
|
|
@@ -17,6 +17,6 @@ import { DEFAULT_GRAY_ICON_COLOR } from '../../constants';
|
|
|
17
17
|
import '../../styles/stories.module.scss';
|
|
18
18
|
var Chips = function (_a) {
|
|
19
19
|
var name = _a.name, iconColor = _a.iconColor, _b = _a.onCancelFunction, onCancelFunction = _b === void 0 ? function () { return undefined; } : _b;
|
|
20
|
-
return (_jsxs("div", __assign({ className: "smartapp-chips" }, { children: [_jsxs("div", __assign({ className: "smartapp-chips__info" }, { children: [_jsx(Avatar, { username: name,
|
|
20
|
+
return (_jsxs("div", __assign({ className: "smartapp-chips" }, { children: [_jsxs("div", __assign({ className: "smartapp-chips__info" }, { children: [_jsx(Avatar, { username: name, size: 24 }), _jsx("p", __assign({ className: "smartapp-chips__info--name" }, { children: name }))] })), _jsx("div", __assign({ onClick: function () { return onCancelFunction(name); }, className: "smartapp-chips__cancel-icon" }, { children: _jsx(CancelIcon, { style: { color: getIconColor(iconColor, DEFAULT_GRAY_ICON_COLOR) } }) }))] })));
|
|
21
21
|
};
|
|
22
22
|
export default Chips;
|
|
@@ -27,14 +27,14 @@ import '../../styles/stories.module.scss';
|
|
|
27
27
|
var Control = function (_a) {
|
|
28
28
|
var _b, _c, _d;
|
|
29
29
|
var children = _a.children, props = __rest(_a, ["children"]);
|
|
30
|
-
return (_jsxs(components.Control, __assign({}, props, { children: [((_b = props.selectProps) === null || _b === void 0 ? void 0 : _b.value) && (_jsx("div", __assign({ className: "smartapp-custom-select__control" }, { children: _jsx("span", { children: _jsx(Avatar, {
|
|
30
|
+
return (_jsxs(components.Control, __assign({}, props, { children: [((_b = props.selectProps) === null || _b === void 0 ? void 0 : _b.value) && (_jsx("div", __assign({ className: "smartapp-custom-select__control" }, { children: _jsx("span", { children: _jsx(Avatar, { size: 32, username: (_d = (_c = props === null || props === void 0 ? void 0 : props.selectProps) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.username }) }) }))), children] })));
|
|
31
31
|
};
|
|
32
32
|
var Option = function (_a) {
|
|
33
33
|
var _b, _c, _d;
|
|
34
34
|
var props = __rest(_a, []);
|
|
35
|
-
return (_jsx(components.Option, __assign({}, props, { children: _jsxs("div", __assign({ className: "smartapp-custom-select__option" }, { children: [_jsx("div", __assign({ className: "smartapp-custom-select__option--avatar" }, { children: _jsx(Avatar, {
|
|
35
|
+
return (_jsx(components.Option, __assign({}, props, { children: _jsxs("div", __assign({ className: "smartapp-custom-select__option" }, { children: [_jsx("div", __assign({ className: "smartapp-custom-select__option--avatar" }, { children: _jsx(Avatar, { size: 32, username: (_b = props === null || props === void 0 ? void 0 : props.data) === null || _b === void 0 ? void 0 : _b.username }) })), _jsxs("div", __assign({ className: "smartapp-custom-select__option--info" }, { children: [_jsxs("p", __assign({ className: "smartapp-custom-select__option--info__title" }, { children: [(_c = props === null || props === void 0 ? void 0 : props.data) === null || _c === void 0 ? void 0 : _c.username, " "] })), _jsxs("p", __assign({ className: "smartapp-custom-select__option--info__email" }, { children: [(_d = props === null || props === void 0 ? void 0 : props.data) === null || _d === void 0 ? void 0 : _d.email, " "] }))] }))] })) })));
|
|
36
36
|
};
|
|
37
|
-
var DropdownIndicator = function (props) { return
|
|
37
|
+
var DropdownIndicator = function (props) { return _jsx(components.DropdownIndicator, __assign({}, props)); };
|
|
38
38
|
var IndicatorSeparator = function () { return null; };
|
|
39
39
|
var CustomSelectPriority = function (_a) {
|
|
40
40
|
var options = _a.options, defaultValue = _a.defaultValue, placeholder = _a.placeholder, onChange = _a.onChange, _b = _a.width, width = _b === void 0 ? 100 : _b;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IHeaderProps } from './types';
|
|
2
2
|
import '../../styles/stories.module.scss';
|
|
3
|
-
declare const Header: ({ title, isBack, isRemove, onClickBack, onClickRemove, arrowColor, trashColor, }: IHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare const Header: ({ title, isBack, isRemove, refreshIcon, onClickBack, onClickRemove, arrowColor, trashColor, platform, headerHeight, textSize, textColor, backgroundColor, }: IHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default Header;
|
|
@@ -10,13 +10,27 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import classNames from 'classnames';
|
|
13
14
|
import { ReactComponent as ArrowBackIcon } from '../../assets/icons/arrow-back.svg';
|
|
14
15
|
import { ReactComponent as TrashIcon } from '../../assets/icons/trash.svg';
|
|
16
|
+
import { ReactComponent as RefreshIcon } from '../../assets/icons/refresh.svg';
|
|
15
17
|
import { getIconColor } from '../../helpers';
|
|
16
|
-
import { DEFAULT_BLACK_ICON_COLOR, DEFAULT_RED_ICON_COLOR } from '../../constants';
|
|
18
|
+
import { DEFAULT_BLACK_ICON_COLOR, DEFAULT_HEADER_BACKGROUND_COLOR, DEFAULT_HEADER_TEXT_COLOR, DEFAULT_RED_ICON_COLOR, FONT_SIZE, LINE_HEIGHT, PLATFORM, } from '../../constants';
|
|
17
19
|
import '../../styles/stories.module.scss';
|
|
18
20
|
var Header = function (_a) {
|
|
19
|
-
var _b
|
|
20
|
-
|
|
21
|
+
var _b;
|
|
22
|
+
var _c = _a.title, title = _c === void 0 ? '' : _c, _d = _a.isBack, isBack = _d === void 0 ? false : _d, _e = _a.isRemove, isRemove = _e === void 0 ? false : _e, refreshIcon = _a.refreshIcon, _f = _a.onClickBack, onClickBack = _f === void 0 ? function () { return undefined; } : _f, _g = _a.onClickRemove, onClickRemove = _g === void 0 ? function () { return undefined; } : _g, arrowColor = _a.arrowColor, trashColor = _a.trashColor, _h = _a.platform, platform = _h === void 0 ? PLATFORM.web : _h, headerHeight = _a.headerHeight, _j = _a.textSize, textSize = _j === void 0 ? 'default' : _j, textColor = _a.textColor, backgroundColor = _a.backgroundColor;
|
|
23
|
+
var getHeaderStyles = function () { return ({
|
|
24
|
+
height: headerHeight && "".concat(headerHeight - 29, "px"),
|
|
25
|
+
fontSize: FONT_SIZE[textSize],
|
|
26
|
+
lineHeight: LINE_HEIGHT[textSize],
|
|
27
|
+
color: getIconColor(textColor, DEFAULT_HEADER_TEXT_COLOR),
|
|
28
|
+
background: getIconColor(backgroundColor, DEFAULT_HEADER_BACKGROUND_COLOR),
|
|
29
|
+
}); };
|
|
30
|
+
var renderRefreshIcon = function (_a) {
|
|
31
|
+
var isEnabled = _a.isEnabled, onClick = _a.onClick;
|
|
32
|
+
return (_jsx(RefreshIcon, { className: classNames({ 'smartapp-header__icons--refresh': isEnabled }), onClick: !isEnabled ? onClick : function () { } }));
|
|
33
|
+
};
|
|
34
|
+
return (_jsxs("div", __assign({ className: classNames((_b = { 'smartapp-header': true }, _b["smartapp-header__".concat(platform)] = true, _b)), style: getHeaderStyles() }, { children: [_jsxs("div", __assign({ className: "smartapp-header__info" }, { children: [isBack && (_jsx(ArrowBackIcon, { style: { color: getIconColor(arrowColor, DEFAULT_BLACK_ICON_COLOR) }, onClick: onClickBack, className: "smartapp-header__info--arrow-back" })), title && _jsx("p", __assign({ className: "smartapp-header__info--title" }, { children: title }))] })), _jsxs("div", __assign({ className: "smartapp-header__icons" }, { children: [isRemove && (_jsx("div", __assign({ onClick: onClickRemove, className: "smartapp-header__icons--trash" }, { children: _jsx(TrashIcon, { style: { color: getIconColor(trashColor, DEFAULT_RED_ICON_COLOR) } }) }))), refreshIcon && renderRefreshIcon(refreshIcon)] }))] })));
|
|
21
35
|
};
|
|
22
36
|
export default Header;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
+
import { PLATFORM } from '../../constants';
|
|
2
|
+
export type TRefreshIcon = {
|
|
3
|
+
isEnabled: boolean;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
};
|
|
1
6
|
export interface IHeaderProps {
|
|
2
7
|
title?: string;
|
|
3
8
|
isBack?: boolean;
|
|
4
9
|
isRemove?: boolean;
|
|
10
|
+
refreshIcon?: TRefreshIcon;
|
|
5
11
|
onClickBack?: () => void;
|
|
6
12
|
onClickRemove?: () => void;
|
|
7
13
|
arrowColor?: string;
|
|
8
14
|
trashColor?: string;
|
|
15
|
+
platform?: PLATFORM;
|
|
16
|
+
headerHeight?: number;
|
|
17
|
+
textSize?: 'small' | 'default' | 'large';
|
|
18
|
+
textColor?: string;
|
|
19
|
+
backgroundColor?: string;
|
|
9
20
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ILoaderProps } from './types';
|
|
2
2
|
import '../../styles/stories.module.scss';
|
|
3
|
-
declare const Loader: ({ isLoader, title }: ILoaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare const Loader: ({ isLoader, isFullScreen, isTextItalic, title, textSize, width, iconSize, backgroundColor, }: ILoaderProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default Loader;
|
|
@@ -11,9 +11,24 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import { ColorRing } from 'react-loader-spinner';
|
|
14
|
+
import classNames from 'classnames';
|
|
15
|
+
import { DEFAULT_GRAY_LOADER_BACKGROUND_COLOR, DEFAULT_WHITE_LOADER_BACKGROUND_COLOR, FONT_SIZE, LINE_HEIGHT, } from '../../constants';
|
|
16
|
+
import { getIconColor } from '../../helpers';
|
|
14
17
|
import '../../styles/stories.module.scss';
|
|
15
18
|
var Loader = function (_a) {
|
|
16
|
-
var _b = _a.isLoader, isLoader = _b === void 0 ? false : _b, title = _a.title;
|
|
17
|
-
|
|
19
|
+
var _b = _a.isLoader, isLoader = _b === void 0 ? false : _b, _c = _a.isFullScreen, isFullScreen = _c === void 0 ? true : _c, _d = _a.isTextItalic, isTextItalic = _d === void 0 ? false : _d, title = _a.title, _e = _a.textSize, textSize = _e === void 0 ? 'small' : _e, _f = _a.width, width = _f === void 0 ? 150 : _f, _g = _a.iconSize, iconSize = _g === void 0 ? 32 : _g, backgroundColor = _a.backgroundColor;
|
|
20
|
+
var getTextStyles = function () { return ({
|
|
21
|
+
fontSize: FONT_SIZE[textSize],
|
|
22
|
+
fontStyle: isTextItalic ? 'italic' : 'normal',
|
|
23
|
+
lineHeight: LINE_HEIGHT[textSize],
|
|
24
|
+
}); };
|
|
25
|
+
var getBackgroundColor = function () {
|
|
26
|
+
var defaultColor = isFullScreen ? DEFAULT_GRAY_LOADER_BACKGROUND_COLOR : DEFAULT_WHITE_LOADER_BACKGROUND_COLOR;
|
|
27
|
+
return getIconColor(backgroundColor, defaultColor);
|
|
28
|
+
};
|
|
29
|
+
return (_jsx("div", __assign({ className: classNames({
|
|
30
|
+
'smartapp-loader-wrapper': true,
|
|
31
|
+
'smartapp-loader-wrapper__full-screen': isFullScreen,
|
|
32
|
+
}), style: { background: getBackgroundColor() } }, { children: _jsxs("div", __assign({ className: "smartapp-loader", style: { width: "".concat(width, "px") } }, { children: [_jsx(ColorRing, { visible: isLoader, height: iconSize, width: iconSize, ariaLabel: "blocks-loading", wrapperStyle: {}, wrapperClass: "blocks-wrapper", colors: ['#4799E3', '#4799E3', '#4799E3', '#4799E3', '#4799E3'] }), title && _jsx("p", __assign({ className: "smartapp-loader__title", style: getTextStyles() }, { children: title }))] })) })));
|
|
18
33
|
};
|
|
19
34
|
export default Loader;
|
|
@@ -16,9 +16,11 @@ import { isNull, sortBy } from 'lodash';
|
|
|
16
16
|
import Stories from 'react-insta-stories';
|
|
17
17
|
import Popup from 'reactjs-popup';
|
|
18
18
|
import { useSwipeable } from 'react-swipeable';
|
|
19
|
+
import { isEmpty } from 'lodash';
|
|
19
20
|
import { ReactComponent as CloseStoriesIcon } from '../../assets/icons/close-stories.svg';
|
|
20
|
-
import { STORY_BACKGROUND_TYPES } from './types';
|
|
21
|
-
import { BUTTON_PADDING, DEFAULT_FONT_FAMILY, MAX_PADDING_FOR_IMAGE, PLATFORM, } from '../../constants';
|
|
21
|
+
import { STORY_BACKGROUND_TYPES, STORY_TYPE, } from './types';
|
|
22
|
+
import { BUTTON_PADDING, DEFAULT_BACKGROUND_BUTTON_COLOR, DEFAULT_FONT_FAMILY, DEFAULT_TEXT_BUTTON_COLOR, MAX_PADDING_FOR_IMAGE, PLATFORM, } from '../../constants';
|
|
23
|
+
import { getIconColor, isAndroidPlatform, isIosPlatform, isWebPlatform } from '../../helpers';
|
|
22
24
|
import '../../styles/stories.module.scss';
|
|
23
25
|
var storyItemBaseStyles = {
|
|
24
26
|
height: '100%',
|
|
@@ -27,9 +29,9 @@ var storyItemBaseStyles = {
|
|
|
27
29
|
var progressContainerStyles = function (platform) { return ({
|
|
28
30
|
gap: '12px',
|
|
29
31
|
width: '100%',
|
|
30
|
-
maxWidth: platform
|
|
32
|
+
maxWidth: isIosPlatform(platform) || isAndroidPlatform(platform) ? '139px' : '198px',
|
|
31
33
|
filter: 'none',
|
|
32
|
-
paddingTop: platform
|
|
34
|
+
paddingTop: isWebPlatform(platform) ? '22px' : isIosPlatform(platform) ? '21px' : '26px',
|
|
33
35
|
paddingLeft: '0',
|
|
34
36
|
paddingRight: '0',
|
|
35
37
|
paddingBottom: '0',
|
|
@@ -63,12 +65,10 @@ var StoriesComponent = function (_a) {
|
|
|
63
65
|
var id = _a.id;
|
|
64
66
|
return id === activeStoryId;
|
|
65
67
|
});
|
|
66
|
-
var getStoryStyles = function (
|
|
67
|
-
var _a,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
return __assign(__assign({}, storyItemBaseStyles), { backgroundImage: "url(".concat((_b = story === null || story === void 0 ? void 0 : story.backgroundSource) === null || _b === void 0 ? void 0 : _b.value, ")"), backgroundSize: 'cover' });
|
|
68
|
+
var getStoryStyles = function (_a) {
|
|
69
|
+
var type = _a.type, value = _a.value;
|
|
70
|
+
return type === STORY_BACKGROUND_TYPES.color
|
|
71
|
+
? __assign(__assign({}, storyItemBaseStyles), { background: value }) : __assign(__assign({}, storyItemBaseStyles), { backgroundImage: "url(".concat(value, ")"), backgroundSize: 'cover' });
|
|
72
72
|
};
|
|
73
73
|
var changeActiveGroupStories = function (groupStoriesItem) {
|
|
74
74
|
setActiveGroupStories(groupStoriesItem);
|
|
@@ -99,10 +99,12 @@ var StoriesComponent = function (_a) {
|
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
var onPrevious = function () { return activeStoryId === stories[0].id && handlePrevious(); };
|
|
102
|
-
var onStoryStart = function () {
|
|
102
|
+
var onStoryStart = function (storyIndex) {
|
|
103
|
+
var isVideoStory = stories[storyIndex].type === STORY_TYPE.video;
|
|
104
|
+
isVideoStory && setActiveStoryId(stories[storyIndex].id);
|
|
103
105
|
var story = stories.find(function (_a) {
|
|
104
106
|
var id = _a.id;
|
|
105
|
-
return id ===
|
|
107
|
+
return id === stories[storyIndex].id;
|
|
106
108
|
});
|
|
107
109
|
var isLastStory = stories.at(-1).id === story.id;
|
|
108
110
|
if (!story.viewed && changeStoryToViewed) {
|
|
@@ -112,44 +114,94 @@ var StoriesComponent = function (_a) {
|
|
|
112
114
|
changeGroupStoriesToViewed(activeGroupStories);
|
|
113
115
|
}
|
|
114
116
|
};
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
117
|
+
var getImageContent = function (_a) {
|
|
118
|
+
var id = _a.id, title = _a.title, body = _a.body, backgroundSource = _a.backgroundSource, button = _a.button, image = _a.image;
|
|
119
|
+
return ({
|
|
120
|
+
content: function () {
|
|
121
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
122
|
+
useEffect(function () {
|
|
123
|
+
setActiveStoryId(id);
|
|
124
|
+
var storyWrapper = document.querySelector('.smartapp-stories');
|
|
125
|
+
var storyWrapperHeight = (storyWrapper === null || storyWrapper === void 0 ? void 0 : storyWrapper.getBoundingClientRect().height) || 0;
|
|
126
|
+
var storyContent = document.querySelector('.smartapp-stories__story');
|
|
127
|
+
var storyContentHeight = (storyContent === null || storyContent === void 0 ? void 0 : storyContent.getBoundingClientRect().height) || 0;
|
|
128
|
+
var buttonElement = document.querySelector('.smartapp-stories__story--button');
|
|
129
|
+
var buttonElementHeight = buttonElement ? (buttonElement.getBoundingClientRect().height + BUTTON_PADDING) : 0;
|
|
130
|
+
var padding = (storyWrapperHeight - storyContentHeight - buttonElementHeight) / 2;
|
|
131
|
+
var paddingTop = (padding > MAX_PADDING_FOR_IMAGE && image) ? "".concat(MAX_PADDING_FOR_IMAGE, "px") : "".concat(padding, "px");
|
|
132
|
+
storyContent === null || storyContent === void 0 ? void 0 : storyContent.style.setProperty('--padding', paddingTop);
|
|
133
|
+
}, []);
|
|
134
|
+
return (_jsx("div", __assign({ style: getStoryStyles(backgroundSource) }, { children: _jsxs("div", __assign({ style: { fontFamily: "".concat(fontFamily, ", sans-serif") }, className: "smartapp-stories__story" }, { children: [image && _jsx("div", __assign({ className: "smartapp-stories__story--image" }, { children: _jsx("img", { src: image, alt: "" }) })), title && _jsx("div", __assign({ className: "smartapp-stories__story--title" }, { children: title })), body && _jsx("div", __assign({ className: "smartapp-stories__story--body" }, { children: body })), button && (_jsx("div", __assign({ style: {
|
|
135
|
+
color: getIconColor(button.textColor, DEFAULT_TEXT_BUTTON_COLOR),
|
|
136
|
+
background: getIconColor(button.backgroundColor, DEFAULT_BACKGROUND_BUTTON_COLOR),
|
|
137
|
+
}, className: classNames('smartapp-stories__story--button', "smartapp-stories__story--button__".concat(platform)), onClick: button.action }, { children: button.text })))] })) }), id));
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
};
|
|
141
|
+
var getVideoContent = function (_a) {
|
|
142
|
+
var url = _a.url;
|
|
143
|
+
return ({
|
|
144
|
+
type: STORY_TYPE.video,
|
|
145
|
+
url: url,
|
|
146
|
+
});
|
|
147
|
+
};
|
|
148
|
+
var getStories = function () { return stories.map(function (story) { return story.type === STORY_TYPE.image ? getImageContent(story) : getVideoContent(story); }); };
|
|
133
149
|
var swipeableHandlers = useSwipeable({
|
|
134
150
|
trackMouse: true,
|
|
135
151
|
onSwipedLeft: function () { return handleNext(); },
|
|
136
152
|
onSwipedRight: function () { return handlePrevious(); },
|
|
137
153
|
});
|
|
138
154
|
useEffect(function () {
|
|
139
|
-
var _a;
|
|
140
155
|
var sortedStories = sortStoriesByOrder((groupStories === null || groupStories === void 0 ? void 0 : groupStories.stories) || []);
|
|
141
156
|
setActiveGroupStories(groupStories);
|
|
142
157
|
setStories(sortedStories);
|
|
143
|
-
setActiveStoryId((groupStories === null || groupStories === void 0 ? void 0 : groupStories.stories) ? (_a = sortedStories[0]) === null || _a === void 0 ? void 0 : _a.id : null);
|
|
144
158
|
}, [groupStories]);
|
|
145
159
|
useEffect(function () {
|
|
146
|
-
var
|
|
160
|
+
var video = document.querySelector('video');
|
|
161
|
+
var pauseVideosOnBackground = function () {
|
|
162
|
+
var backgroundVideos = document.querySelectorAll("#background_video_".concat(activeStoryId));
|
|
163
|
+
backgroundVideos.forEach(function (video) { return video.pause(); });
|
|
164
|
+
};
|
|
165
|
+
var playVideosOnBackground = function () {
|
|
166
|
+
var backgroundVideos = document.querySelectorAll("#background_video_".concat(activeStoryId));
|
|
167
|
+
backgroundVideos.forEach(function (video) { return video.play(); });
|
|
168
|
+
};
|
|
169
|
+
video === null || video === void 0 ? void 0 : video.addEventListener("play", playVideosOnBackground);
|
|
170
|
+
video === null || video === void 0 ? void 0 : video.addEventListener("pause", pauseVideosOnBackground);
|
|
171
|
+
return function () {
|
|
172
|
+
video === null || video === void 0 ? void 0 : video.removeEventListener("play", playVideosOnBackground);
|
|
173
|
+
video === null || video === void 0 ? void 0 : video.removeEventListener("pause", pauseVideosOnBackground);
|
|
174
|
+
};
|
|
175
|
+
}, [activeStoryId]);
|
|
176
|
+
useEffect(function () {
|
|
147
177
|
var popupElement = document.querySelector('.smartapp-stories-content');
|
|
148
|
-
var
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
178
|
+
var videoWrapper = document.querySelector('.smartapp-stories-content > div > div > div:nth-child(2) > div');
|
|
179
|
+
if (activeStory) {
|
|
180
|
+
if (activeStory.type === STORY_TYPE.image) {
|
|
181
|
+
var _a = activeStory.backgroundSource, type = _a.type, value = _a.value;
|
|
182
|
+
var prevBackgroundVideos = document.querySelectorAll(".smartapp-stories-content__background-video");
|
|
183
|
+
var background = type === STORY_BACKGROUND_TYPES.color ? value : "url(".concat(value, ")");
|
|
184
|
+
!isEmpty(prevBackgroundVideos) && prevBackgroundVideos.forEach(function (video) { return video.remove(); });
|
|
185
|
+
isWebPlatform(platform) && (popupElement === null || popupElement === void 0 ? void 0 : popupElement.style.setProperty('--background', background));
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
var prevBackgroundVideos = document.querySelectorAll(".smartapp-stories-content__background-video");
|
|
189
|
+
!isEmpty(prevBackgroundVideos) && prevBackgroundVideos.forEach(function (video) { return video.remove(); });
|
|
190
|
+
var video = document.createElement('video');
|
|
191
|
+
video.id = "background_video_".concat(activeStory.id);
|
|
192
|
+
video.src = activeStory.url;
|
|
193
|
+
video.playsInline = true;
|
|
194
|
+
video.autoplay = true;
|
|
195
|
+
video.muted = true;
|
|
196
|
+
video.classList.add('smartapp-stories-content__background-video');
|
|
197
|
+
if (isWebPlatform(platform)) {
|
|
198
|
+
popupElement === null || popupElement === void 0 ? void 0 : popupElement.style.removeProperty('--background');
|
|
199
|
+
popupElement === null || popupElement === void 0 ? void 0 : popupElement.appendChild(video);
|
|
200
|
+
}
|
|
201
|
+
videoWrapper === null || videoWrapper === void 0 ? void 0 : videoWrapper.appendChild(video.cloneNode(true));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}, [platform, activeStory]);
|
|
153
205
|
if (isNull(activeGroupStories)) {
|
|
154
206
|
return null;
|
|
155
207
|
}
|
|
@@ -157,6 +209,7 @@ var StoriesComponent = function (_a) {
|
|
|
157
209
|
'smartapp-stories': true
|
|
158
210
|
},
|
|
159
211
|
_b["smartapp-stories__".concat(platform)] = true,
|
|
212
|
+
_b['smartapp-stories__video'] = (activeStory === null || activeStory === void 0 ? void 0 : activeStory.type) === STORY_TYPE.video,
|
|
160
213
|
_b['smartapp-stories__animate-right'] = isAnimateToRight,
|
|
161
214
|
_b['smartapp-stories__animate-left'] = isAnimateToLeft,
|
|
162
215
|
_b)) }, swipeableHandlers, { children: _jsx(Stories, { defaultInterval: 6000, width: "100%", height: "100%", stories: getStories(), onStoryStart: onStoryStart, onPrevious: onPrevious, onAllStoriesEnd: handleNext, progressContainerStyles: progressContainerStyles(platform), progressWrapperStyles: progressWrapperStyles, progressStyles: progressStyles }, activeGroupStories.id) })), _jsx(CloseStoriesIcon, { className: classNames((_c = {
|
|
@@ -1,30 +1,46 @@
|
|
|
1
|
+
import { PLATFORM } from '../../constants';
|
|
1
2
|
export declare enum STORY_BACKGROUND_TYPES {
|
|
2
3
|
color = "color",
|
|
3
4
|
image = "image"
|
|
4
5
|
}
|
|
5
|
-
export
|
|
6
|
+
export declare enum STORY_TYPE {
|
|
7
|
+
image = "image",
|
|
8
|
+
video = "video"
|
|
9
|
+
}
|
|
10
|
+
export type TBackgroundSource = {
|
|
11
|
+
type: 'color' | 'image';
|
|
12
|
+
value: string;
|
|
13
|
+
};
|
|
14
|
+
type TCommonStoryItem = {
|
|
6
15
|
id: number;
|
|
7
16
|
order: number;
|
|
8
17
|
viewed?: boolean;
|
|
18
|
+
};
|
|
19
|
+
export interface TImageStoryItem extends TCommonStoryItem {
|
|
20
|
+
type: 'image';
|
|
9
21
|
title: string | null;
|
|
10
22
|
body: string | null;
|
|
11
|
-
backgroundSource:
|
|
12
|
-
type: STORY_BACKGROUND_TYPES;
|
|
13
|
-
value: string;
|
|
14
|
-
};
|
|
23
|
+
backgroundSource: TBackgroundSource;
|
|
15
24
|
button: {
|
|
16
25
|
text: string;
|
|
26
|
+
textColor?: string;
|
|
27
|
+
backgroundColor?: string;
|
|
17
28
|
action: () => void;
|
|
18
29
|
} | null;
|
|
19
30
|
image: string | null;
|
|
20
|
-
}
|
|
31
|
+
}
|
|
32
|
+
export interface TVideoStoryItem extends TCommonStoryItem {
|
|
33
|
+
type: 'video';
|
|
34
|
+
url: string;
|
|
35
|
+
}
|
|
36
|
+
export type TStoryItem = TImageStoryItem | TVideoStoryItem;
|
|
21
37
|
export type TGroupStories = {
|
|
22
38
|
id: number;
|
|
23
39
|
viewed: boolean;
|
|
24
40
|
stories: TStoryItem[];
|
|
25
41
|
};
|
|
26
42
|
export interface IStoriesProps {
|
|
27
|
-
platform?:
|
|
43
|
+
platform?: PLATFORM;
|
|
28
44
|
fontFamily?: string;
|
|
29
45
|
groupStories: TGroupStories | null;
|
|
30
46
|
allGroupsStories: TGroupStories[];
|
|
@@ -32,3 +48,4 @@ export interface IStoriesProps {
|
|
|
32
48
|
changeGroupStoriesToViewed?: (groupStories: TGroupStories) => void;
|
|
33
49
|
handleCloseGroupStories: () => void;
|
|
34
50
|
}
|
|
51
|
+
export {};
|
|
@@ -3,3 +3,8 @@ export var STORY_BACKGROUND_TYPES;
|
|
|
3
3
|
STORY_BACKGROUND_TYPES["color"] = "color";
|
|
4
4
|
STORY_BACKGROUND_TYPES["image"] = "image";
|
|
5
5
|
})(STORY_BACKGROUND_TYPES || (STORY_BACKGROUND_TYPES = {}));
|
|
6
|
+
export var STORY_TYPE;
|
|
7
|
+
(function (STORY_TYPE) {
|
|
8
|
+
STORY_TYPE["image"] = "image";
|
|
9
|
+
STORY_TYPE["video"] = "video";
|
|
10
|
+
})(STORY_TYPE || (STORY_TYPE = {}));
|