import { ResourcesState } from 'store/resources/resources';
import classNames from 'classnames';
import { ArvadosTheme } from 'common/custom-theme';
-import { extractUuidKind, ResourceKind } from 'models/resource';
-import { ClassNameMap } from '@material-ui/core/styles/withStyles';
export interface Breadcrumb {
label: string;
uuid: string;
}
-type CssRules = "item" | "defaultItem" | "processItem" | "collectionItem" | "parentItem" | "currentItem" | "label" | "icon" | "frozenIcon";
+type CssRules = "item" | "label" | "icon" | "frozenIcon";
const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
item: {
borderRadius: '16px',
- },
- defaultItem: {
+ height: '32px',
backgroundColor: theme.customs.colors.grey300,
+ '&.parentItem': {
+ backgroundColor: `${theme.customs.colors.grey300}99`,
+ },
'&:hover': {
backgroundColor: theme.customs.colors.grey400,
- }
- },
- processItem: {
- backgroundColor: theme.customs.colors.lightGreen300,
- '&:hover': {
- backgroundColor: theme.customs.colors.lightGreen400,
- }
- },
- collectionItem: {
- backgroundColor: theme.customs.colors.cyan100,
- '&:hover': {
- backgroundColor: theme.customs.colors.cyan200,
- }
- },
- parentItem: {
- opacity: 0.75
- },
- currentItem: {
- opacity: 1
+ },
+ '&.parentItem:hover': {
+ backgroundColor: `${theme.customs.colors.grey400}99`,
+ },
},
label: {
textTransform: "none",
paddingRight: '3px',
paddingLeft: '3px',
+ lineHeight: '1.4',
},
icon: {
fontSize: 20,
onContextMenu: (event: React.MouseEvent<HTMLElement>, breadcrumb: Breadcrumb) => void;
}
-const getBreadcrumbClass = (item: Breadcrumb, classes: ClassNameMap<CssRules>): string => {
- switch (extractUuidKind(item.uuid)) {
- case ResourceKind.PROCESS:
- return classes.processItem;
- case ResourceKind.COLLECTION:
- return classes.collectionItem;
- default:
- return classes.defaultItem;
- }
-};
-
export const Breadcrumbs = withStyles(styles)(
({ classes, onClick, onContextMenu, items, resources }: BreadcrumbsProps & WithStyles<CssRules>) =>
- <Grid container data-cy='breadcrumbs' alignItems="center" wrap="nowrap">
+ <Grid container data-cy='breadcrumbs' alignItems="center">
{
items.map((item, index) => {
const isLastItem = index === items.length - 1;
? 'breadcrumb-last'
: false}
className={classNames(
- isLastItem ? classes.currentItem : classes.parentItem,
- classes.item,
- getBreadcrumbClass(item, classes)
+ isLastItem ? null : 'parentItem',
+ classes.item
)}
onClick={() => onClick(item)}
onContextMenu={event => onContextMenu(event, item)}>
}
</Button>
</Tooltip>
- {!isLastItem && <ChevronRightIcon color="inherit" className={classes.parentItem} />}
+ {!isLastItem && <ChevronRightIcon color="inherit" className={'parentItem'} />}
</React.Fragment>
);
})