/** * The "stub" component. Used for displaying a placeholder for content. * * @author Brauer Ilya * * @date 2020-05-06 */ import * as React from 'react'; import * as styles from './contentPlaceholder.m.scss'; import {INTENT, SIZE} from '../../constants'; import {getIntentThemeKey} from '../../utils/getIntentThemeKey'; import {joinClassNames} from '../../utils/joinClassNames'; import {systemIconData, SystemIconName} from '@unidata/icon'; import {getSizeThemeKey} from '../../utils/getSizeThemeKey'; interface IProps { iconName: SystemIconName; mainText?: React.ReactNode; mainTextColor?: React.ReactNode; subText?: React.ReactNode; subTextColor?: React.ReactNode; iconSize?: SIZE; // for now only Middle and Large intent?: INTENT; // for now only Primary and Danger onMainClick?: () => void; onSubClick?: () => void; } export class ContentPlaceholder extends React.PureComponent { renderIcon () { let iconName = this.props.iconName || 'search'; const iconSize = this.props.iconSize || SIZE.MIDDLE; const sizeThemeKey = getSizeThemeKey('icon', iconSize); const iconSvgProps = systemIconData[iconName] ? systemIconData[iconName].svg : {}; const svgProps: React.SVGProps = { ...iconSvgProps, className: styles[sizeThemeKey], dangerouslySetInnerHTML: systemIconData[iconName] && systemIconData[iconName].content ? {__html: systemIconData[iconName].content} : undefined }; return ; } override render () { const { mainText = '', mainTextColor = '', subText = '', subTextColor = '', onMainClick, onSubClick, intent = INTENT.PRIMARY } = this.props; const intentKey = getIntentThemeKey('', intent); const containerClassName = joinClassNames( styles.content, styles[intentKey] ); return (
{this.renderIcon()}
{mainText}   {mainTextColor}
{subText}   {subTextColor}
); } }