1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
7 import { ArvadosTheme } from '~/common/custom-theme';
8 import { ListItemIcon, ListItemText, Typography } from '@material-ui/core';
9 import { IconType } from '../icon/icon';
10 import * as classnames from "classnames";
12 type CssRules = 'root' | 'listItemText' | 'hasMargin' | 'active';
14 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
23 color: theme.palette.primary.main,
26 marginLeft: `${theme.spacing.unit}px`,
30 export interface ListItemTextIconDataProps {
36 nameDecorator?: JSX.Element;
39 type ListItemTextIconProps = ListItemTextIconDataProps & WithStyles<CssRules>;
41 export const ListItemTextIcon = withStyles(styles)(
42 class extends React.Component<ListItemTextIconProps, {}> {
44 const { classes, isActive, hasMargin, name, icon: Icon, iconSize, nameDecorator } = this.props;
46 <Typography component='span' className={classes.root}>
47 <ListItemIcon className={classnames({
48 [classes.hasMargin]: hasMargin,
49 [classes.active]: isActive
52 <Icon style={{ fontSize: `${iconSize}rem` }} />
54 {nameDecorator || null}
55 <ListItemText primary={
56 <Typography className={classnames(classes.listItemText, {
57 [classes.active]: isActive