Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | 11x 11x 11x 11x 11x 11x 5x 6x 11x 3x 3x | 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 (
<span className={style.container} data-selector-id={dataSelectorId}>
{customizedChannelName ? (
<Avatar
name={customizedChannelName}
size={size}
palette={palette}
textPalette={textPalette}
customClass={customTextClass}
dataId={dataId}
needTitle={title}
title={title}
{...avatarProps}
/>
) : !renderIconOnly ? (
iconName ? (
<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}
/>
) : (
<Avatar
name={name}
size={size}
palette={palette}
textPalette={textPalette}
customClass={customTextClass}
dataId={dataId}
needTitle={title}
title={title}
{...avatarProps}
/>
)
) : (
<Icon
name={iconName}
size={iconSize}
iconClass={`${iconClass ? iconClass : ''} ${style.iconStyle} ${
name && action ? style[`${name.toLowerCase()}_${action.toLowerCase()}`] : ''
}`}
title={iconTitle}
dataId={dataId}
{...iconProps}
/>
)}
{topicIcon ? (
<span
className={`${style.thread} ${needTopicBorder ? style.threadBorder : ''} ${topicClass ? topicClass : ''}`}
data-title={topicIconTitle}
>
<Icon
name={topicIcon}
size={topicIconSize}
iconClass={
style[`topic_${topicIconColor}`] ? `${style.topicIcon} ${style[`topic_${topicIconColor}`]}` : ''
}
dataId={dataId}
/>
</span>
) : null}
</span>
);
}
}
ChannelIcon.defaultProps = defaultProps;
ChannelIcon.propTypes = propTypes;
// if (__DOCS__) {
// ChannelIcon.docs = {
// componentGroup: 'Atom'
// };
// }
|