UNPKG

@zohodesk/dot

Version:

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

111 lines (107 loc) 3.4 kB
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/lib/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, { name: customizedChannelName, size: size, palette: palette, textPalette: textPalette, customClass: customTextClass, dataId: dataId, needTitle: title, title: title, ...avatarProps }) : !renderIconOnly ? iconName ? /*#__PURE__*/React.createElement(AvatarIcon, { 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, { name: name, size: size, palette: palette, textPalette: textPalette, customClass: customTextClass, dataId: dataId, needTitle: title, title: title, ...avatarProps }) : /*#__PURE__*/React.createElement(Icon, { 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' // }; // }