-
Notifications
You must be signed in to change notification settings - Fork 30
/
RowHeader.tsx
88 lines (82 loc) · 1.81 KB
/
RowHeader.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import { TableCell, TableRow } from '@material-ui/core';
import { Flex } from '@weaveworks/weave-gitops';
import styled from 'styled-components';
const RowTitle = styled.div`
font-weight: 600;
font-size: ${props => props.theme.fontSizes};
color: ${props => props.theme.colors.neutral30};
`;
const RowBody = styled.div`
font-weight: 400;
font-size: ${props => props.theme.fontSizes};
margin-left: ${props => props.theme.spacing.xs};
color: ${props => props.theme.colors.neutral40};
`;
export interface SectionRowHeader {
children?: any;
rowkey: string;
value?: string | JSX.Element | undefined;
hidden?: boolean;
}
export const RowHeaders = ({ rows }: { rows: Array<SectionRowHeader> }) => {
return (
<>
{rows.map(r => {
return r.hidden === true ? null : (
<RowHeader rowkey={r.rowkey} value={r.value} key={r.rowkey}>
{r.children}
</RowHeader>
);
})}
</>
);
};
export function KeyValueRow({
entryObj,
}: {
entryObj: Array<any>;
}): JSX.Element {
const [key, val] = entryObj;
return (
<TableRow
key={key}
data-testid={key}
style={{
height: '40px',
}}
>
<TableCell
style={{
textTransform: 'capitalize',
width: '30%',
}}
>
{key.replace(/([a-z])([A-Z])/g, '$1 $2')}
</TableCell>
<TableCell
style={{
width: '70%',
}}
>
{val}
</TableCell>
</TableRow>
);
}
function RowHeader({
children,
rowkey,
value,
}: {
children?: any;
rowkey: string;
value: string | JSX.Element | undefined;
}) {
return (
<Flex start gap="8" data-testid={rowkey}>
<RowTitle>{rowkey} :</RowTitle>
<RowBody>{children || value || '--'}</RowBody>
</Flex>
);
}
export default RowHeader;