19504: Add resource colors to breadcrumbs
authorStephen Smith <stephen@curii.com>
Wed, 16 Nov 2022 18:23:47 +0000 (13:23 -0500)
committerStephen Smith <stephen@curii.com>
Wed, 16 Nov 2022 18:23:47 +0000 (13:23 -0500)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/common/custom-theme.ts
src/components/breadcrumbs/breadcrumbs.tsx

index fc89a4ae216b2790385570f293b74c9ebd3145ba..23fc1fb8353a5324e13da6f38bf18e80ea4991f4 100644 (file)
@@ -5,8 +5,10 @@
 import { createMuiTheme } from '@material-ui/core/styles';
 import { ThemeOptions, Theme } from '@material-ui/core/styles/createMuiTheme';
 import blue from '@material-ui/core/colors/blue';
+import cyan from '@material-ui/core/colors/cyan';
 import grey from '@material-ui/core/colors/grey';
 import green from '@material-ui/core/colors/green';
+import lightGreen from '@material-ui/core/colors/lightGreen';
 import yellow from '@material-ui/core/colors/yellow';
 import red from '@material-ui/core/colors/red';
 import teal from '@material-ui/core/colors/teal';
@@ -22,6 +24,10 @@ export interface ArvadosTheme extends Theme {
 }
 
 interface Colors {
+    cyan100: string;
+    cyan200: string;
+    lightGreen300: string;
+    lightGreen400: string;
     green700: string;
     yellow100: string;
     yellow700: string;
@@ -29,6 +35,8 @@ interface Colors {
     red100: string;
     red900: string;
     blue500: string;
+    grey300: string;
+    grey400: string;
     grey500: string;
     purple: string;
     orange: string;
@@ -46,6 +54,10 @@ export const themeOptions: ArvadosThemeOptions = {
     },
     customs: {
         colors: {
+            lightGreen300: lightGreen["300"],
+            lightGreen400: lightGreen["400"],
+            cyan100: cyan["100"],
+            cyan200: cyan["200"],
             green700: green["700"],
             yellow100: yellow["100"],
             yellow700: yellow["700"],
@@ -53,6 +65,8 @@ export const themeOptions: ArvadosThemeOptions = {
             red100: red["100"],
             red900: red['900'],
             blue500: blue['500'],
+            grey300: grey["300"],
+            grey400: grey["400"],
             grey500: grey500,
             purple: arvadosPurple,
             orange: '#f0ad4e',
@@ -185,4 +199,4 @@ export const themeOptions: ArvadosThemeOptions = {
     },
 };
 
-export const CustomTheme = createMuiTheme(themeOptions);
\ No newline at end of file
+export const CustomTheme = createMuiTheme(themeOptions);
index 0348b8144a5b920e92d8b884ba186229cc8a6917..3237f80063bb8cfc6218b8d08cae51631d2c9f96 100644 (file)
@@ -10,6 +10,10 @@ import { IllegalNamingWarning } from '../warning/warning';
 import { IconType, FreezeIcon } from 'components/icon/icon';
 import grey from '@material-ui/core/colors/grey';
 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;
@@ -17,11 +21,32 @@ export interface Breadcrumb {
     uuid: string;
 }
 
-type CssRules = "item" | "currentItem" | "label" | "icon" | "frozenIcon";
+type CssRules = "item" | "defaultItem" | "processItem" | "collectionItem" | "parentItem" | "currentItem" | "label" | "icon" | "frozenIcon";
 
-const styles: StyleRulesCallback<CssRules> = theme => ({
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
     item: {
-        opacity: 0.6
+        borderRadius: '16px',
+    },
+    defaultItem: {
+        backgroundColor: theme.customs.colors.grey300,
+        '&: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
@@ -48,6 +73,17 @@ export interface BreadcrumbsProps {
     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">
@@ -67,8 +103,11 @@ export const Breadcrumbs = withStyles(styles)(
                                 : isLastItem
                                     ? 'breadcrumb-last'
                                     : false}
-                            color="inherit"
-                            className={isLastItem ? classes.currentItem : classes.item}
+                            className={classNames(
+                                isLastItem ? classes.currentItem : classes.parentItem,
+                                classes.item,
+                                getBreadcrumbClass(item, classes)
+                            )}
                             onClick={() => onClick(item)}
                             onContextMenu={event => onContextMenu(event, item)}>
                             <Icon className={classes.icon} />
@@ -83,7 +122,7 @@ export const Breadcrumbs = withStyles(styles)(
                             }
                         </Button>
                     </Tooltip>
-                    {!isLastItem && <ChevronRightIcon color="inherit" className={classes.item} />}
+                    {!isLastItem && <ChevronRightIcon color="inherit" className={classes.parentItem} />}
                 </React.Fragment>
             );
         })