1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import Typography from '@material-ui/core/Typography';
7 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
8 import { ArvadosTheme } from '~/common/custom-theme';
9 import * as classnames from "classnames";
11 type CssRules = 'attribute' | 'label' | 'value' | 'lowercaseValue' | 'link';
13 const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
16 alignItems: 'flex-start',
17 marginBottom: theme.spacing.unit
20 boxSizing: 'border-box',
21 color: theme.palette.grey["500"],
25 boxSizing: 'border-box',
28 alignItems: 'flex-start',
29 textTransform: 'capitalize'
32 textTransform: 'lowercase'
36 color: theme.palette.primary.main,
37 textDecoration: 'none',
38 overflowWrap: 'break-word',
43 interface DetailsAttributeDataProps {
46 value?: React.ReactNode;
48 lowercaseValue?: boolean;
50 children?: React.ReactNode;
51 onValueClick?: () => void;
54 type DetailsAttributeProps = DetailsAttributeDataProps & WithStyles<CssRules>;
56 export const DetailsAttribute = withStyles(styles)(
57 ({ label, link, value, children, classes, classLabel, classValue, lowercaseValue, onValueClick }: DetailsAttributeProps) =>
58 <Typography component="div" className={classes.attribute}>
59 <Typography component="span" className={classnames([classes.label, classLabel])}>{label}</Typography>
61 ? <a href={link} className={classes.link} target='_blank'>{value}</a>
63 onClick={onValueClick}
65 className={classnames([classes.value, classValue, { [classes.lowercaseValue]: lowercaseValue }])}