ndla-ui
Version:
UI component library for NDLA.
51 lines (45 loc) • 1.19 kB
JavaScript
/**
* Copyright (c) 2016-present, NDLA.
*
* This source code is licensed under the GPLv3 license found in the
* LICENSE file in the root directory of this source tree.
*
*/
import React from 'react';
import PropTypes from 'prop-types';
import { ChevronRight } from 'ndla-icons/common';
import SafeLink from '../common/SafeLink';
var BreadcrumbItem = function BreadcrumbItem(_ref) {
var to = _ref.to,
children = _ref.children,
classes = _ref.classes,
isCurrent = _ref.isCurrent,
home = _ref.home,
name = _ref.name;
return React.createElement(
'li',
classes('item', { home: home }),
isCurrent ? React.createElement(
'span',
null,
children
) : React.createElement(
SafeLink,
{ to: to, 'aria-label': home ? name : null },
children
),
!home && React.createElement(ChevronRight, null)
);
};
BreadcrumbItem.propTypes = {
classes: PropTypes.func.isRequired,
children: PropTypes.node.isRequired,
to: PropTypes.string.isRequired,
isCurrent: PropTypes.bool,
home: PropTypes.bool,
name: PropTypes.string
};
BreadcrumbItem.defaultProps = {
home: false
};
export default BreadcrumbItem;