import * as React from 'react'; import { Breadcrumb } from 'react-bootstrap'; import { Icon } from 'react-fa'; import { RoutingBreadcrumb } from '../../React'; import { CommandButton } from '../CommandButton/CommandButton'; import { ContentTooltip } from '../ContentTooltip/ContentTooltip'; export interface BreadcrumbsProps { id?: string; pinnable?: boolean; items?: RoutingBreadcrumb[]; } export interface BreadcrumbsComponentProps extends React.HTMLProps, BreadcrumbsProps {} export class Breadcrumbs extends React.Component { static defaultProps: Partial = { id: 'breadcrumbs', }; constructor(props: any) { super(props); this.toggleBreadcrumbsPin = this.toggleBreadcrumbsPin.bind(this); } render() { const { className, props, rest } = this.restProps(x => { const { pinnable, items } = x; return { pinnable, items }; }); return this.wxr.renderIterable( props.items, (x, i, a) => { return this.renderCrumb(x, i, i === a.length - 1); }, x => x.length === 0 ? null : (
{x} {this.wxr.renderConditional(props.pinnable, () => ( ))}
), ); } protected renderCrumb( crumb: RoutingBreadcrumb, index: number, active: boolean, ) { const breadcrumb = ( {crumb.content} ); return ( (crumb.tooltip && ( )) || breadcrumb ); } protected toggleBreadcrumbsPin() { const elem = document.getElementById(this.props.id!); if (elem != null) { if (/fixed/.test(elem.className)) { elem.className = 'Breadcrumbs'; } else { elem.className = 'Breadcrumbs fixed'; } } } }