UNPKG

ndla-ui

Version:

UI component library for NDLA.

53 lines (48 loc) 1.2 kB
/** * 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 BEMHelper from 'react-bem-helper'; import { uuid } from 'ndla-util'; import BreadcrumbItem from './BreadcrumbItem'; var classes = BEMHelper({ name: 'breadcrumb-block', prefix: 'c-' }); var BreadcrumbBlock = function BreadcrumbBlock(_ref) { var children = _ref.children, items = _ref.items; return React.createElement( 'div', classes(''), children, React.createElement( 'ol', classes('list'), items.map(function (item, i) { return React.createElement( BreadcrumbItem, { classes: classes, key: uuid(), isCurrent: i === items.length - 1, to: item.to }, item.name ); }) ) ); }; BreadcrumbBlock.propTypes = { children: PropTypes.node, items: PropTypes.arrayOf(PropTypes.shape({ to: PropTypes.string.isRequired, name: PropTypes.string.isRequired })) }; export default BreadcrumbBlock;