|
1 |
| -import { Divider, Grid, makeStyles } from "@material-ui/core"; |
2 |
| -import FileCopyOutlinedIcon from "@material-ui/icons/FileCopyOutlined"; |
| 1 | +import { Grid, makeStyles } from "@material-ui/core"; |
3 | 2 | import React, { ReactElement } from "react";
|
4 | 3 | import { copyToClipboard } from "../../utils/appUtil";
|
5 |
| -import IconButton from "../input/buttons/IconButton"; |
| 4 | +import { copyIcon } from "../../../common/utils/svgIcons"; |
| 5 | +import ButtonBase from "@material-ui/core/ButtonBase"; |
6 | 6 |
|
7 | 7 | type LabeledRowProps = {
|
8 | 8 | label: string;
|
9 | 9 | value: string | number;
|
10 | 10 | paddingSpacing?: number;
|
11 | 11 | showCopyIcon?: boolean;
|
12 | 12 | reserveSpaceForCopyIcon?: boolean;
|
| 13 | + statusIcon?: string; |
13 | 14 | };
|
14 | 15 |
|
15 | 16 | const useStyles = makeStyles((theme) => ({
|
16 | 17 | cell: (props: LabeledRowProps) => ({
|
17 | 18 | padding: theme.spacing(props.paddingSpacing ?? 2),
|
18 |
| - textAlign: "center", |
19 | 19 | wordWrap: "break-word",
|
20 | 20 | whiteSpace: "pre-wrap",
|
| 21 | + fontSize: "16px", |
21 | 22 | }),
|
| 23 | + textLabel: { |
| 24 | + color: "#979797", |
| 25 | + }, |
| 26 | + textValue: { |
| 27 | + color: "#f2f2f2", |
| 28 | + }, |
| 29 | + copyIcon: { |
| 30 | + paddingRight: "5px", |
| 31 | + }, |
| 32 | + copyContainer: { |
| 33 | + cursor: "pointer", |
| 34 | + color: "#f15a24", |
| 35 | + fontSize: "14px", |
| 36 | + display: "flex", |
| 37 | + justifyContent: "flex-end", |
| 38 | + }, |
| 39 | + statusContainer: { |
| 40 | + display: "flex", |
| 41 | + alignItems: "center", |
| 42 | + }, |
| 43 | + statusIcon: { |
| 44 | + marginRight: "10px", |
| 45 | + }, |
22 | 46 | }));
|
23 | 47 |
|
24 | 48 | const LabeledRow = (props: LabeledRowProps): ReactElement => {
|
25 | 49 | const { label, value, showCopyIcon, reserveSpaceForCopyIcon } = props;
|
26 | 50 | const classes = useStyles(props);
|
27 | 51 |
|
28 | 52 | return (
|
29 |
| - <Grid container item justify="space-between" alignItems="center"> |
30 |
| - <Grid item xs={reserveSpaceForCopyIcon ? 3 : 4} className={classes.cell}> |
| 53 | + <Grid container item alignItems="center"> |
| 54 | + <Grid |
| 55 | + item |
| 56 | + xs={reserveSpaceForCopyIcon ? 2 : 3} |
| 57 | + className={`${classes.cell} ${classes.textLabel}`} |
| 58 | + > |
31 | 59 | {label}
|
32 | 60 | </Grid>
|
33 |
| - <Divider orientation="vertical" flexItem /> |
34 |
| - <Grid item xs={reserveSpaceForCopyIcon ? 6 : 7} className={classes.cell}> |
35 |
| - {value} |
| 61 | + |
| 62 | + <Grid |
| 63 | + item |
| 64 | + xs={reserveSpaceForCopyIcon ? 6 : 7} |
| 65 | + className={`${classes.cell} ${classes.textValue}`} |
| 66 | + > |
| 67 | + {props.statusIcon ? ( |
| 68 | + <div className={classes.statusContainer}> |
| 69 | + <img |
| 70 | + src={props.statusIcon} |
| 71 | + className={classes.statusIcon} |
| 72 | + alt="status" |
| 73 | + /> |
| 74 | + {value} |
| 75 | + </div> |
| 76 | + ) : ( |
| 77 | + <div>{value}</div> |
| 78 | + )} |
36 | 79 | </Grid>
|
37 | 80 | {reserveSpaceForCopyIcon && (
|
38 | 81 | <Grid item xs={2} className={classes.cell}>
|
39 | 82 | {showCopyIcon && (
|
40 |
| - <IconButton |
41 |
| - icon={<FileCopyOutlinedIcon fontSize="small" />} |
42 |
| - tooltipTitle="Copy to clipboard" |
43 |
| - onClick={() => copyToClipboard(value)} |
44 |
| - /> |
| 83 | + <div className={classes.copyContainer}> |
| 84 | + <ButtonBase onClick={() => copyToClipboard(value)}> |
| 85 | + <img src={copyIcon} alt="copy" className={classes.copyIcon} /> |
| 86 | + Copy |
| 87 | + </ButtonBase> |
| 88 | + </div> |
45 | 89 | )}
|
46 | 90 | </Grid>
|
47 | 91 | )}
|
|
0 commit comments