cometchat-react-ui-kit2
Version:
CometChat UI Kit for React App
176 lines (174 loc) • 13.4 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.reactionListStyle = exports.reactionCountStyle = exports.messageReactionsStyle = exports.messageReactionListStyle = exports.messageAddReactionStyle = exports.emojiButtonStyle = 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 messageReactionListStyle = function messageReactionListStyle() {
return {
margin: "5px",
padding: "0px 8px 8px 8px",
display: "flex",
flexDirection: "row",
alignItems: "center"
};
};
exports.messageReactionListStyle = messageReactionListStyle;
var reactionListStyle = function reactionListStyle() {
return {
display: "flex",
alignItems: "center",
justifyContent: "center",
fontSize: "15px",
margin: "0",
padding: "0",
cursor: "pointer"
};
};
exports.reactionListStyle = reactionListStyle;
var messageAddReactionStyle = function messageAddReactionStyle(messageObject, loggedInUser, style, theme) {
var _theme$palette, _theme$palette2, _theme$palette3;
var background = theme === null || theme === void 0 ? void 0 : (_theme$palette = theme.palette) === null || _theme$palette === void 0 ? void 0 : _theme$palette.accent100[theme === null || theme === void 0 ? void 0 : (_theme$palette2 = theme.palette) === null || _theme$palette2 === void 0 ? void 0 : _theme$palette2.mode];
if (messageObject.sender.uid === loggedInUser.uid) {
background = "RGBA(255, 255, 255, 0.23)";
}
return {
padding: "1px 4px",
display: "inline-flex",
alignItems: "center",
justifyContent: "center",
borderRadius: style.borderRadius,
height: "22px",
width: "30px",
cursor: "pointer",
border: "1px solid ".concat(theme === null || theme === void 0 ? void 0 : (_theme$palette3 = theme.palette) === null || _theme$palette3 === void 0 ? void 0 : _theme$palette3.accent100[theme.palette.mode]),
background: background
};
};
exports.messageAddReactionStyle = messageAddReactionStyle;
var emojiButtonStyle = function emojiButtonStyle(style, loggedInUser, messageObject, reactionData, theme) {
var _theme$palette4, _theme$palette5;
var background = theme === null || theme === void 0 ? void 0 : (_theme$palette4 = theme.palette) === null || _theme$palette4 === void 0 ? void 0 : _theme$palette4.accent700[theme === null || theme === void 0 ? void 0 : (_theme$palette5 = theme.palette) === null || _theme$palette5 === void 0 ? void 0 : _theme$palette5.mode];
if ((messageObject === null || messageObject === void 0 ? void 0 : messageObject.type) === "text") {
var _messageObject$sender;
if ((messageObject === null || messageObject === void 0 ? void 0 : (_messageObject$sender = messageObject.sender) === null || _messageObject$sender === void 0 ? void 0 : _messageObject$sender.uid) === (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
if (reactionData !== null && reactionData !== void 0 && reactionData.hasOwnProperty(loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
var _theme$palette6, _theme$palette7;
background = theme === null || theme === void 0 ? void 0 : (_theme$palette6 = theme.palette) === null || _theme$palette6 === void 0 ? void 0 : _theme$palette6.background[theme === null || theme === void 0 ? void 0 : (_theme$palette7 = theme.palette) === null || _theme$palette7 === void 0 ? void 0 : _theme$palette7.mode];
}
}
}
return {
iconHeight: "16px",
iconWidth: "16px",
iconTint: style.iconTint || background,
padding: "0"
};
};
// list item style
exports.emojiButtonStyle = emojiButtonStyle;
var messageReactionsStyle = function messageReactionsStyle(messageObject, loggedInUser, style, reactionData, theme) {
var _theme$palette8, _theme$palette9;
var background = {
background: "transparent"
},
border = {
border: "1px solid ".concat(theme === null || theme === void 0 ? void 0 : (_theme$palette8 = theme.palette) === null || _theme$palette8 === void 0 ? void 0 : _theme$palette8.background[theme === null || theme === void 0 ? void 0 : (_theme$palette9 = theme.palette) === null || _theme$palette9 === void 0 ? void 0 : _theme$palette9.mode])
};
if ((messageObject === null || messageObject === void 0 ? void 0 : messageObject.type) === "text") {
var _messageObject$sender2;
if ((messageObject === null || messageObject === void 0 ? void 0 : (_messageObject$sender2 = messageObject.sender) === null || _messageObject$sender2 === void 0 ? void 0 : _messageObject$sender2.uid) === (loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
if (reactionData !== null && reactionData !== void 0 && reactionData.hasOwnProperty(loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
var _theme$palette10, _theme$palette11;
background = {
background: theme === null || theme === void 0 ? void 0 : (_theme$palette10 = theme.palette) === null || _theme$palette10 === void 0 ? void 0 : _theme$palette10.background[theme === null || theme === void 0 ? void 0 : (_theme$palette11 = theme.palette) === null || _theme$palette11 === void 0 ? void 0 : _theme$palette11.mode]
};
}
} else {
if (reactionData !== null && reactionData !== void 0 && reactionData.hasOwnProperty(loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
var _theme$palette12, _theme$palette13, _theme$palette14, _theme$palette15;
background = {
background: theme === null || theme === void 0 ? void 0 : (_theme$palette12 = theme.palette) === null || _theme$palette12 === void 0 ? void 0 : _theme$palette12.primary[theme === null || theme === void 0 ? void 0 : (_theme$palette13 = theme.palette) === null || _theme$palette13 === void 0 ? void 0 : _theme$palette13.mode]
};
border = {
border: "1 px ".concat(theme === null || theme === void 0 ? void 0 : (_theme$palette14 = theme.palette) === null || _theme$palette14 === void 0 ? void 0 : _theme$palette14.primary[theme === null || theme === void 0 ? void 0 : (_theme$palette15 = theme.palette) === null || _theme$palette15 === void 0 ? void 0 : _theme$palette15.mode])
};
} else {
var _theme$palette16, _theme$palette17;
background = {
background: "transparent"
};
border = {
border: "1px solid ".concat(theme === null || theme === void 0 ? void 0 : (_theme$palette16 = theme.palette) === null || _theme$palette16 === void 0 ? void 0 : _theme$palette16.accent100[theme === null || theme === void 0 ? void 0 : (_theme$palette17 = theme.palette) === null || _theme$palette17 === void 0 ? void 0 : _theme$palette17.mode])
};
}
}
} else {
if (reactionData !== null && reactionData !== void 0 && reactionData.hasOwnProperty(loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
var _theme$palette18, _theme$palette19, _theme$palette20, _theme$palette21;
background = {
background: theme === null || theme === void 0 ? void 0 : (_theme$palette18 = theme.palette) === null || _theme$palette18 === void 0 ? void 0 : _theme$palette18.primary[theme === null || theme === void 0 ? void 0 : (_theme$palette19 = theme.palette) === null || _theme$palette19 === void 0 ? void 0 : _theme$palette19.mode]
};
border = {
border: "1 px ".concat(theme === null || theme === void 0 ? void 0 : (_theme$palette20 = theme.palette) === null || _theme$palette20 === void 0 ? void 0 : _theme$palette20.primary[theme === null || theme === void 0 ? void 0 : (_theme$palette21 = theme.palette) === null || _theme$palette21 === void 0 ? void 0 : _theme$palette21.mode])
};
} else {
var _theme$palette22, _theme$palette23, _theme$palette24, _theme$palette25;
background = {
background: theme === null || theme === void 0 ? void 0 : (_theme$palette22 = theme.palette) === null || _theme$palette22 === void 0 ? void 0 : _theme$palette22.accent100[theme === null || theme === void 0 ? void 0 : (_theme$palette23 = theme.palette) === null || _theme$palette23 === void 0 ? void 0 : _theme$palette23.mode]
};
border = {
border: "1px solid ".concat(theme === null || theme === void 0 ? void 0 : (_theme$palette24 = theme.palette) === null || _theme$palette24 === void 0 ? void 0 : _theme$palette24.accent100[theme === null || theme === void 0 ? void 0 : (_theme$palette25 = theme.palette) === null || _theme$palette25 === void 0 ? void 0 : _theme$palette25.mode])
};
}
}
return _objectSpread(_objectSpread({}, background), {}, {
display: "flex",
alignItems: "center",
justifyContent: "center",
font: style.textFont,
padding: "2px 4px",
margin: "0 0 0 6px",
borderRadius: "11px",
cursor: "pointer"
}, border);
};
exports.messageReactionsStyle = messageReactionsStyle;
var reactionCountStyle = function reactionCountStyle(loggedInUser, messageObject, reactionData, theme) {
var _theme$palette26, _theme$palette27, _theme$palette38;
var color = theme === null || theme === void 0 ? void 0 : (_theme$palette26 = theme.palette) === null || _theme$palette26 === void 0 ? void 0 : _theme$palette26.background[theme === null || theme === void 0 ? void 0 : (_theme$palette27 = theme.palette) === null || _theme$palette27 === void 0 ? void 0 : _theme$palette27.mode];
if (messageObject.type === "text") {
if (messageObject.sender.uid === loggedInUser.uid) {
if (reactionData !== null && reactionData !== void 0 && reactionData.hasOwnProperty(loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
var _theme$palette28, _theme$palette29;
color = theme === null || theme === void 0 ? void 0 : (_theme$palette28 = theme.palette) === null || _theme$palette28 === void 0 ? void 0 : _theme$palette28.primary[theme === null || theme === void 0 ? void 0 : (_theme$palette29 = theme.palette) === null || _theme$palette29 === void 0 ? void 0 : _theme$palette29.mode];
}
} else {
if (reactionData !== null && reactionData !== void 0 && reactionData.hasOwnProperty(loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
var _theme$palette30, _theme$palette31;
color = theme === null || theme === void 0 ? void 0 : (_theme$palette30 = theme.palette) === null || _theme$palette30 === void 0 ? void 0 : _theme$palette30.background[theme === null || theme === void 0 ? void 0 : (_theme$palette31 = theme.palette) === null || _theme$palette31 === void 0 ? void 0 : _theme$palette31.mode];
} else {
var _theme$palette32, _theme$palette33;
color = theme === null || theme === void 0 ? void 0 : (_theme$palette32 = theme.palette) === null || _theme$palette32 === void 0 ? void 0 : _theme$palette32.accent700[theme === null || theme === void 0 ? void 0 : (_theme$palette33 = theme.palette) === null || _theme$palette33 === void 0 ? void 0 : _theme$palette33.mode];
}
}
} else {
if (reactionData !== null && reactionData !== void 0 && reactionData.hasOwnProperty(loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.uid)) {
var _theme$palette34, _theme$palette35;
color = theme === null || theme === void 0 ? void 0 : (_theme$palette34 = theme.palette) === null || _theme$palette34 === void 0 ? void 0 : _theme$palette34.background[theme === null || theme === void 0 ? void 0 : (_theme$palette35 = theme.palette) === null || _theme$palette35 === void 0 ? void 0 : _theme$palette35.mode];
} else {
var _theme$palette36, _theme$palette37;
color = theme === null || theme === void 0 ? void 0 : (_theme$palette36 = theme.palette) === null || _theme$palette36 === void 0 ? void 0 : _theme$palette36.accent700[theme === null || theme === void 0 ? void 0 : (_theme$palette37 = theme.palette) === null || _theme$palette37 === void 0 ? void 0 : _theme$palette37.mode];
}
}
return {
color: color,
font: (0, _Shared.fontHelper)(theme === null || theme === void 0 ? void 0 : (_theme$palette38 = theme.palette) === null || _theme$palette38 === void 0 ? void 0 : _theme$palette38.caption1),
padding: "0px 2px 0px 4px"
};
};
exports.reactionCountStyle = reactionCountStyle;