You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import * as React from 'react';
|
|
import classNames from 'classnames';
|
|
|
|
export interface CommentEditorProps {
|
|
avatar: React.ReactNode;
|
|
children: React.ReactNode;
|
|
className?: string;
|
|
editorStyle?: React.CSSProperties;
|
|
headStyle?: React.CSSProperties;
|
|
innerStyle?: React.CSSProperties;
|
|
prefixCls?: string;
|
|
style?: React.CSSProperties;
|
|
}
|
|
|
|
export default (props: CommentEditorProps) => {
|
|
const {
|
|
avatar,
|
|
children,
|
|
className,
|
|
editorStyle,
|
|
headStyle,
|
|
innerStyle,
|
|
prefixCls = 'ant-comment',
|
|
style,
|
|
...others
|
|
} = props;
|
|
const classString = classNames(`${prefixCls}-editor`, className);
|
|
|
|
const avatarDom = typeof avatar === 'string'
|
|
? <img src={avatar} />
|
|
: avatar;
|
|
|
|
const head = (
|
|
<div className={`${prefixCls}-header`} style={headStyle}>
|
|
<span className={`${prefixCls}-header-avatar`}>
|
|
{avatarDom}
|
|
</span>
|
|
</div>
|
|
);
|
|
|
|
const content = (
|
|
<div className={`${prefixCls}-content`} style={editorStyle}>
|
|
<div className={`${prefixCls}-content-wrapper`}>
|
|
{children}
|
|
</div>
|
|
</div>
|
|
);
|
|
|
|
return (
|
|
<div {...others} className={classString} style={style}>
|
|
<div className={`${prefixCls}-inner`} style={innerStyle}>
|
|
{head}
|
|
{content}
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|