cometchat-react-ui-kit2
Version:
CometChat UI Kit for React App
148 lines (147 loc) • 10.1 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.messageTextStyle = exports.messageImgStyle = exports.messageContainerStyle = exports.listItemStyle = exports.chatsListStyle = exports.DialogStyle = void 0;
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _Shared = require("../../Shared");
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var chatsListStyle = function chatsListStyle(style, theme) {
var _theme$palette;
return {
width: style === null || style === void 0 ? void 0 : style.width,
height: style === null || style === void 0 ? void 0 : style.height,
border: style === null || style === void 0 ? void 0 : style.border,
background: (style === null || style === void 0 ? void 0 : style.background) || (theme === null || theme === void 0 ? void 0 : (_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.getBackground()),
position: "relative",
flexDirection: "column",
display: "flex",
overflowX: "hidden",
overflowY: "scroll",
margin: "0",
padding: "0",
borderRadius: style === null || style === void 0 ? void 0 : style.borderRadius
};
};
exports.chatsListStyle = chatsListStyle;
var messageContainerStyle = function messageContainerStyle(style) {
return {
overflow: "hidden",
width: style === null || style === void 0 ? void 0 : style.width,
display: "flex",
justifyContent: "center",
alignItems: "center",
position: "absolute",
top: "30%",
zIndex: 1
};
};
exports.messageContainerStyle = messageContainerStyle;
var messageTextStyle = function messageTextStyle(style, theme, message) {
var _theme$palette2, _theme$typography;
var color = {
color: theme === null || theme === void 0 ? void 0 : (_theme$palette2 = theme.palette) === null || _theme$palette2 === void 0 ? void 0 : _theme$palette2.getAccent400()
};
var font = {
font: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$typography = theme.typography) === null || _theme$typography === void 0 ? void 0 : _theme$typography.heading)
};
if (message && (message === null || message === void 0 ? void 0 : message.toLowerCase()) === "no_users_found") {
if (style !== null && style !== void 0 && style.emptyTextColor) {
color = {
color: style === null || style === void 0 ? void 0 : style.emptyTextColor
};
}
if (style !== null && style !== void 0 && style.emptyTextFont) {
font = {
font: style === null || style === void 0 ? void 0 : style.emptyTextFont
};
}
} else if (message && (message === null || message === void 0 ? void 0 : message.toLowerCase()) === "something_wrong") {
var _theme$palette3;
color = {
color: theme === null || theme === void 0 ? void 0 : (_theme$palette3 = theme.palette) === null || _theme$palette3 === void 0 ? void 0 : _theme$palette3.getError()
};
if (style !== null && style !== void 0 && style.errorTextColor) {
color = {
color: style === null || style === void 0 ? void 0 : style.errorTextColor
};
}
if (style !== null && style !== void 0 && style.errorTextFont) {
font = {
font: style === null || style === void 0 ? void 0 : style.errorTextFont
};
}
}
return _objectSpread(_objectSpread({
minHeight: "36px",
lineHeight: "30px",
wordWrap: "break-word",
padding: "0 16px",
width: "calc(100% - 32px)",
display: "flex",
margin: "0",
justifyContent: "center"
}, color), font);
};
exports.messageTextStyle = messageTextStyle;
var messageImgStyle = function messageImgStyle(style, theme, loadingIconURL) {
var _theme$palette4;
var background = {
background: theme === null || theme === void 0 ? void 0 : (_theme$palette4 = theme.palette) === null || _theme$palette4 === void 0 ? void 0 : _theme$palette4.getAccent600()
};
if (style !== null && style !== void 0 && style.loadingIconTint) {
background = {
background: style === null || style === void 0 ? void 0 : style.loadingIconTint
};
}
return _objectSpread(_objectSpread({
WebkitMask: "url(".concat(loadingIconURL, ") center center no-repeat")
}, background), {}, {
margin: "0",
minHeight: "260px",
lineHeight: "30px",
wordWrap: "break-word",
padding: "0 16px",
width: style === null || style === void 0 ? void 0 : style.width
});
};
exports.messageImgStyle = messageImgStyle;
var listItemStyle = function listItemStyle(style, theme) {
var _theme$palette5, _theme$palette6, _theme$palette7, _theme$typography2, _theme$palette8, _theme$typography3, _theme$palette9, _theme$typography4;
return {
background: style === null || style === void 0 ? void 0 : style.background,
activeBackground: theme === null || theme === void 0 ? void 0 : (_theme$palette5 = theme.palette) === null || _theme$palette5 === void 0 ? void 0 : _theme$palette5.getAccent50(),
border: "1px solid ".concat(theme === null || theme === void 0 ? void 0 : (_theme$palette6 = theme.palette) === null || _theme$palette6 === void 0 ? void 0 : _theme$palette6.getAccent200()),
borderRadius: "50%",
titleColor: theme === null || theme === void 0 ? void 0 : (_theme$palette7 = theme.palette) === null || _theme$palette7 === void 0 ? void 0 : _theme$palette7.getAccent(),
titleFont: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$typography2 = theme.typography) === null || _theme$typography2 === void 0 ? void 0 : _theme$typography2.title2),
subtitleColor: theme === null || theme === void 0 ? void 0 : (_theme$palette8 = theme.palette) === null || _theme$palette8 === void 0 ? void 0 : _theme$palette8.getAccent600(),
subtitleFont: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$typography3 = theme.typography) === null || _theme$typography3 === void 0 ? void 0 : _theme$typography3.subtitle2),
typingIndicatorTextColor: theme === null || theme === void 0 ? void 0 : (_theme$palette9 = theme.palette) === null || _theme$palette9 === void 0 ? void 0 : _theme$palette9.getAccent600(),
typingIndicatorTextFont: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$typography4 = theme.typography) === null || _theme$typography4 === void 0 ? void 0 : _theme$typography4.subtitle2)
};
};
exports.listItemStyle = listItemStyle;
var DialogStyle = function DialogStyle(theme) {
var _theme$palette10, _theme$palette11, _theme$typography5, _theme$palette12, _theme$typography6, _theme$palette13, _theme$typography7, _theme$palette14, _theme$palette15, _theme$palette16, _theme$typography8, _theme$palette17;
return {
width: "300px",
height: "225px",
background: theme === null || theme === void 0 ? void 0 : (_theme$palette10 = theme.palette) === null || _theme$palette10 === void 0 ? void 0 : _theme$palette10.getAccent900(),
border: theme === null || theme === void 0 ? void 0 : (_theme$palette11 = theme.palette) === null || _theme$palette11 === void 0 ? void 0 : _theme$palette11.getAccent50(),
borderRadius: "4px",
confirmButtonTextFont: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$typography5 = theme.typography) === null || _theme$typography5 === void 0 ? void 0 : _theme$typography5.title2),
confirmButtonTextColor: theme === null || theme === void 0 ? void 0 : (_theme$palette12 = theme.palette) === null || _theme$palette12 === void 0 ? void 0 : _theme$palette12.getAccent900(),
cancelButtonTextFont: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$typography6 = theme.typography) === null || _theme$typography6 === void 0 ? void 0 : _theme$typography6.title2),
cancelButtonTextColor: theme === null || theme === void 0 ? void 0 : (_theme$palette13 = theme.palette) === null || _theme$palette13 === void 0 ? void 0 : _theme$palette13.getAccent(),
titleTextFont: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$typography7 = theme.typography) === null || _theme$typography7 === void 0 ? void 0 : _theme$typography7.heading),
titleTextColor: theme === null || theme === void 0 ? void 0 : (_theme$palette14 = theme.palette) === null || _theme$palette14 === void 0 ? void 0 : _theme$palette14.getAccent(),
confirmBackground: theme === null || theme === void 0 ? void 0 : (_theme$palette15 = theme.palette) === null || _theme$palette15 === void 0 ? void 0 : _theme$palette15.getError(),
cancelBackground: theme === null || theme === void 0 ? void 0 : (_theme$palette16 = theme.palette) === null || _theme$palette16 === void 0 ? void 0 : _theme$palette16.getAccent500(),
messageTextFont: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$typography8 = theme.typography) === null || _theme$typography8 === void 0 ? void 0 : _theme$typography8.caption1),
messageTextColor: theme === null || theme === void 0 ? void 0 : (_theme$palette17 = theme.palette) === null || _theme$palette17 === void 0 ? void 0 : _theme$palette17.getAccent500()
};
};
exports.DialogStyle = DialogStyle;