1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { Button, Grid, StyleRulesCallback, WithStyles, Typography, Tooltip } from '@material-ui/core';
7 import ChevronRightIcon from '@material-ui/icons/ChevronRight';
8 import { withStyles } from '@material-ui/core';
10 export interface Breadcrumb {
14 interface BreadcrumbsProps {
16 onClick: (breadcrumb: Breadcrumb) => void;
17 onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
20 const Breadcrumbs: React.SFC<BreadcrumbsProps & WithStyles<CssRules>> = ({ classes, onClick, onContextMenu, items }) => {
21 return <Grid container alignItems="center" wrap="nowrap">
23 items.map((item, index) => {
24 const isLastItem = index === items.length - 1;
26 <React.Fragment key={index}>
27 <Tooltip title={item.label}>
30 className={isLastItem ? classes.currentItem : classes.item}
31 onClick={() => onClick(item)}
32 onContextMenu={event => onContextMenu(event, item)}>
36 className={classes.label}>
41 {!isLastItem && <ChevronRightIcon color="inherit" className={classes.item} />}
49 type CssRules = "item" | "currentItem" | "label";
51 const styles: StyleRulesCallback<CssRules> = theme => {
65 export default withStyles(styles)(Breadcrumbs);