2016-09-21 11:54:53 +08:00
|
|
|
import React from 'react';
|
2016-06-22 13:18:43 +08:00
|
|
|
import splitObject from '../_util/splitObject';
|
2016-03-31 17:46:35 +08:00
|
|
|
|
2016-09-13 15:31:29 +08:00
|
|
|
export interface BreadcrumbItemProps {
|
2016-07-14 13:29:50 +08:00
|
|
|
separator?: React.ReactNode;
|
|
|
|
href?: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default class BreadcrumbItem extends React.Component<BreadcrumbItemProps, any> {
|
2016-03-31 17:46:35 +08:00
|
|
|
static defaultProps = {
|
|
|
|
prefixCls: 'ant-breadcrumb',
|
|
|
|
separator: '/',
|
2016-07-13 11:14:24 +08:00
|
|
|
};
|
2016-03-31 17:46:35 +08:00
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
prefixCls: React.PropTypes.string,
|
|
|
|
separator: React.PropTypes.oneOfType([
|
|
|
|
React.PropTypes.string,
|
|
|
|
React.PropTypes.element,
|
|
|
|
]),
|
|
|
|
href: React.PropTypes.string,
|
2016-07-13 11:14:24 +08:00
|
|
|
};
|
2016-03-31 17:46:35 +08:00
|
|
|
|
|
|
|
render() {
|
2016-07-13 17:22:23 +08:00
|
|
|
const [{ prefixCls, separator, children }, restProps] = splitObject(
|
|
|
|
this.props, ['prefixCls', 'separator', 'children']
|
|
|
|
);
|
2016-03-31 17:46:35 +08:00
|
|
|
let link;
|
|
|
|
if ('href' in this.props) {
|
|
|
|
link = <a className={`${prefixCls}-link`} {...restProps}>{children}</a>;
|
|
|
|
} else {
|
|
|
|
link = <span className={`${prefixCls}-link`} {...restProps}>{children}</span>;
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<span>
|
|
|
|
{link}
|
|
|
|
<span className={`${prefixCls}-separator`}>{separator}</span>
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|