UNPKG

@zohodesk/dot

Version:

In this Library, we Provide Some Basic Components to Build Your Application

109 lines (104 loc) 3.75 kB
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } import React, { Component } from 'react'; import { defaultProps } from "./props/defaultProps"; import { propTypes } from "./props/propTypes"; import { Icon } from '@zohodesk/icons'; import Avatar from '@zohodesk/components/es/Avatar/Avatar'; import AvatarIcon from "../avatar/AvatarIcon/AvatarIcon"; import { getChannelMappingObj } from "../utils/ChannelIconMapping"; import style from "./ChannelIcon.module.css"; export default class ChannelIcon extends Component { constructor(props) { super(props); } render() { let { name, action, iconSize, iconTitle, size, topicIcon, topicIconTitle, topicIconSize, topicIconColor, iconClass, dataId, className, palette, textPalette, customTextClass, iconColor, needTopicBorder, topicClass, renderIconOnly, iconName, title, dataSelectorId, customProps } = this.props; const { avatarProps = {}, avatarIconProps = {}, iconProps = {} } = customProps; let defaultChannelObj = name && !iconName && getChannelMappingObj()[name.toUpperCase()]; let customizedChannelName = null; if (!defaultChannelObj) { customizedChannelName = name; } else { iconName = defaultChannelObj[action]; } return /*#__PURE__*/React.createElement("span", { className: style.container, "data-selector-id": dataSelectorId }, customizedChannelName ? /*#__PURE__*/React.createElement(Avatar, _extends({ name: customizedChannelName, size: size, palette: palette, textPalette: textPalette, customClass: customTextClass, dataId: dataId, needTitle: title, title: title }, avatarProps)) : !renderIconOnly ? iconName ? /*#__PURE__*/React.createElement(AvatarIcon, _extends({ name: iconName, iconSize: iconSize, size: size, iconClass: `${style.iconStyle} ${name && action ? style[`${name.toLowerCase()}_${action.toLowerCase()}`] : ''} ${iconClass ? iconClass : ''} `, dataId: dataId, className: className, iconColor: iconColor, title: iconTitle }, avatarIconProps)) : /*#__PURE__*/React.createElement(Avatar, _extends({ name: name, size: size, palette: palette, textPalette: textPalette, customClass: customTextClass, dataId: dataId, needTitle: title, title: title }, avatarProps)) : /*#__PURE__*/React.createElement(Icon, _extends({ name: iconName, size: iconSize, iconClass: `${iconClass ? iconClass : ''} ${style.iconStyle} ${name && action ? style[`${name.toLowerCase()}_${action.toLowerCase()}`] : ''}`, title: iconTitle, dataId: dataId }, iconProps)), topicIcon ? /*#__PURE__*/React.createElement("span", { className: `${style.thread} ${needTopicBorder ? style.threadBorder : ''} ${topicClass ? topicClass : ''}`, "data-title": topicIconTitle }, /*#__PURE__*/React.createElement(Icon, { name: topicIcon, size: topicIconSize, iconClass: style[`topic_${topicIconColor}`] ? `${style.topicIcon} ${style[`topic_${topicIconColor}`]}` : '', dataId: dataId })) : null); } } ChannelIcon.defaultProps = defaultProps; ChannelIcon.propTypes = propTypes; // if (__DOCS__) { // ChannelIcon.docs = { // componentGroup: 'Atom' // }; // }