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.
50 lines
1.1 KiB
50 lines
1.1 KiB
import * as React from 'react';
|
|
import * as PropTypes from 'prop-types';
|
|
|
|
export interface BreadcrumbItemProps {
|
|
prefixCls?: string;
|
|
separator?: React.ReactNode;
|
|
href?: string;
|
|
}
|
|
|
|
export default class BreadcrumbItem extends React.Component<BreadcrumbItemProps, any> {
|
|
static __ANT_BREADCRUMB_ITEM = true;
|
|
|
|
static defaultProps = {
|
|
prefixCls: 'ant-breadcrumb',
|
|
separator: '/',
|
|
};
|
|
|
|
static propTypes = {
|
|
prefixCls: PropTypes.string,
|
|
separator: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
href: PropTypes.string,
|
|
};
|
|
|
|
render() {
|
|
const { prefixCls, separator, children, ...restProps } = this.props;
|
|
let link;
|
|
if ('href' in this.props) {
|
|
link = (
|
|
<a className={`${prefixCls}-link`} {...restProps}>
|
|
{children}
|
|
</a>
|
|
);
|
|
} else {
|
|
link = (
|
|
<span className={`${prefixCls}-link`} {...restProps}>
|
|
{children}
|
|
</span>
|
|
);
|
|
}
|
|
if (children) {
|
|
return (
|
|
<span>
|
|
{link}
|
|
<span className={`${prefixCls}-separator`}>{separator}</span>
|
|
</span>
|
|
);
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
|