You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.9 KiB

import React from 'react';
9 years ago
import classNames from 'classnames';
import splitObject from '../_util/splitObject';
8 years ago
export interface CardProps {
8 years ago
title?: React.ReactNode;
extra?: React.ReactNode;
bordered?: boolean;
bodyStyle?: React.CSSProperties;
style?: React.CSSProperties;
loading?: boolean;
children?: any;
id?: string;
8 years ago
}
export default (props: CardProps) => {
const [{
prefixCls = 'ant-card', className, extra, bodyStyle,
title, loading, bordered = true,
}, others] = splitObject(props,
['prefixCls', 'className', 'children', 'extra', 'bodyStyle', 'title', 'loading', 'bordered']);
let children = props.children;
9 years ago
const classString = classNames({
[prefixCls]: true,
[className]: !!className,
9 years ago
[`${prefixCls}-loading`]: loading,
[`${prefixCls}-bordered`]: bordered,
9 years ago
});
9 years ago
if (loading) {
children = (
<div>
<p></p>
9 years ago
<p> </p>
<p> </p>
9 years ago
<p>  </p>
<p>  </p>
9 years ago
</div>
);
}
let head;
if (!title) {
head = null;
} else {
head = typeof title === 'string' ? (
<div className={`${prefixCls}-head`}>
<h3 className={`${prefixCls}-head-title`}>{title}</h3>
</div>
) : (
<div className={`${prefixCls}-head`}>
<div className={`${prefixCls}-head-title`}>{title}</div>
</div>
);
}
9 years ago
9 years ago
return (
<div {...others} className={classString}>
{head}
{extra ? <div className={`${prefixCls}-extra`}>{extra}</div> : null}
<div className={`${prefixCls}-body`} style={bodyStyle}>{children}</div>
9 years ago
</div>
);
};