UNPKG

2.05 kBJavaScriptView Raw
1import _extends from 'babel-runtime/helpers/extends';
2import _objectWithoutProperties from 'babel-runtime/helpers/objectWithoutProperties';
3import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
4import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
5import _inherits from 'babel-runtime/helpers/inherits';
6import classNames from 'classnames';
7import React from 'react';
8import PropTypes from 'prop-types';
9
10import SafeAnchor from './SafeAnchor';
11
12var propTypes = {
13 /**
14 * If set to true, renders `span` instead of `a`
15 */
16 active: PropTypes.bool,
17 /**
18 * `href` attribute for the inner `a` element
19 */
20 href: PropTypes.string,
21 /**
22 * `title` attribute for the inner `a` element
23 */
24 title: PropTypes.node,
25 /**
26 * `target` attribute for the inner `a` element
27 */
28 target: PropTypes.string
29};
30
31var defaultProps = {
32 active: false
33};
34
35var BreadcrumbItem = function (_React$Component) {
36 _inherits(BreadcrumbItem, _React$Component);
37
38 function BreadcrumbItem() {
39 _classCallCheck(this, BreadcrumbItem);
40
41 return _possibleConstructorReturn(this, _React$Component.apply(this, arguments));
42 }
43
44 BreadcrumbItem.prototype.render = function render() {
45 var _props = this.props,
46 active = _props.active,
47 href = _props.href,
48 title = _props.title,
49 target = _props.target,
50 className = _props.className,
51 props = _objectWithoutProperties(_props, ['active', 'href', 'title', 'target', 'className']);
52
53 // Don't try to render these props on non-active <span>.
54
55
56 var linkProps = { href: href, title: title, target: target };
57
58 return React.createElement(
59 'li',
60 { className: classNames(className, { active: active }) },
61 active ? React.createElement('span', props) : React.createElement(SafeAnchor, _extends({}, props, linkProps))
62 );
63 };
64
65 return BreadcrumbItem;
66}(React.Component);
67
68BreadcrumbItem.propTypes = propTypes;
69BreadcrumbItem.defaultProps = defaultProps;
70
71export default BreadcrumbItem;
\No newline at end of file