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 type CssRules = "item" | "currentItem" | "label";
16 const styles: StyleRulesCallback<CssRules> = theme => ({
28 export interface BreadcrumbsProps {
30 onClick: (breadcrumb: Breadcrumb) => void;
31 onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
34 export const Breadcrumbs = withStyles(styles)(
35 ({ classes, onClick, onContextMenu, items }: BreadcrumbsProps & WithStyles<CssRules>) =>
36 <Grid container alignItems="center" wrap="nowrap">
38 items.map((item, index) => {
39 const isLastItem = index === items.length - 1;
41 <React.Fragment key={index}>
42 <Tooltip title={item.label}>
45 className={isLastItem ? classes.currentItem : classes.item}
46 onClick={() => onClick(item)}
47 onContextMenu={event => onContextMenu(event, item)}>
51 className={classes.label}>
56 {!isLastItem && <ChevronRightIcon color="inherit" className={classes.item} />}