2016-07-07 20:25:03 +08:00
|
|
|
|
import * as React from 'react';
|
2016-02-19 19:35:49 +08:00
|
|
|
|
import classNames from 'classnames';
|
2016-06-22 13:18:43 +08:00
|
|
|
|
import splitObject from '../_util/splitObject';
|
2016-07-14 13:29:50 +08:00
|
|
|
|
|
2016-09-13 15:31:29 +08:00
|
|
|
|
export interface CardProps {
|
2016-07-14 13:29:50 +08:00
|
|
|
|
title?: React.ReactNode;
|
|
|
|
|
extra?: React.ReactNode;
|
|
|
|
|
bordered?: boolean;
|
|
|
|
|
bodyStyle?: React.CSSProperties;
|
|
|
|
|
style?: React.CSSProperties;
|
|
|
|
|
loading?: boolean;
|
|
|
|
|
children?: any;
|
2016-09-21 09:27:58 +08:00
|
|
|
|
id?: string;
|
2016-07-14 13:29:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default (props: CardProps) => {
|
2016-06-22 13:18:43 +08:00
|
|
|
|
const [{
|
|
|
|
|
prefixCls = 'ant-card', className, extra, bodyStyle,
|
2016-07-13 17:22:23 +08:00
|
|
|
|
title, loading, bordered = true,
|
2016-06-22 13:18:43 +08:00
|
|
|
|
}, others] = splitObject(props,
|
|
|
|
|
['prefixCls', 'className', 'children', 'extra', 'bodyStyle', 'title', 'loading', 'bordered']);
|
|
|
|
|
let children = props.children;
|
2016-02-19 19:35:49 +08:00
|
|
|
|
const classString = classNames({
|
|
|
|
|
[prefixCls]: true,
|
|
|
|
|
[className]: !!className,
|
2016-02-22 16:25:13 +08:00
|
|
|
|
[`${prefixCls}-loading`]: loading,
|
2016-04-10 15:38:52 +08:00
|
|
|
|
[`${prefixCls}-bordered`]: bordered,
|
2016-02-19 19:35:49 +08:00
|
|
|
|
});
|
2016-02-22 16:25:13 +08:00
|
|
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
|
children = (
|
|
|
|
|
<div>
|
2016-03-30 19:06:05 +08:00
|
|
|
|
<p>████████████████████████</p>
|
2016-02-22 16:25:13 +08:00
|
|
|
|
<p>██████ ███████████████████</p>
|
2016-03-30 19:06:05 +08:00
|
|
|
|
<p>██████████████ ██████████</p>
|
2016-02-22 16:25:13 +08:00
|
|
|
|
<p>█████ ██████ █████████████</p>
|
2016-03-30 19:06:05 +08:00
|
|
|
|
<p>███████████ ██████████ ███</p>
|
2016-02-22 16:25:13 +08:00
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-20 16:40:18 +08:00
|
|
|
|
const head = title ? (
|
|
|
|
|
<div className={`${prefixCls}-head`}>
|
|
|
|
|
<h3 className={`${prefixCls}-head-title`}>{title}</h3>
|
|
|
|
|
</div>
|
|
|
|
|
) : null;
|
2016-02-22 16:25:13 +08:00
|
|
|
|
|
2016-02-19 19:35:49 +08:00
|
|
|
|
return (
|
2016-06-22 13:18:43 +08:00
|
|
|
|
<div {...others} className={classString}>
|
2016-02-20 16:40:18 +08:00
|
|
|
|
{head}
|
|
|
|
|
{extra ? <div className={`${prefixCls}-extra`}>{extra}</div> : null}
|
|
|
|
|
<div className={`${prefixCls}-body`} style={bodyStyle}>{children}</div>
|
2016-02-19 19:35:49 +08:00
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|