forked from verdaccio/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDist.tsx
More file actions
46 lines (38 loc) · 1.23 KB
/
Dist.tsx
File metadata and controls
46 lines (38 loc) · 1.23 KB
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
import React, { FC, useContext } from 'react';
import List from '@material-ui/core/List';
import { DetailContext } from '../../pages/Version';
import { Heading, DistListItem, DistChips } from './styles';
import fileSizeSI from '../../utils/file-size';
import { formatLicense } from '../../utils/package';
const DistChip: FC<{ name: string }> = ({ name, children }) =>
children ? (
<DistChips
// lint rule conflicting with prettier
/* eslint-disable react/jsx-wrap-multilines */
label={
<>
<b>{name}</b>
{': '}
{children}
</>
}
/* eslint-enable */
/>
) : null;
const Dist: FC = () => {
const { packageMeta } = useContext(DetailContext);
if (!packageMeta) {
return null;
}
const { dist, license } = packageMeta && packageMeta.latest;
return (
<List subheader={<Heading variant="subtitle1">{'Latest Distribution'}</Heading>}>
<DistListItem button={true}>
<DistChip name="file count">{dist.fileCount}</DistChip>
<DistChip name="size">{dist.unpackedSize && fileSizeSI(dist.unpackedSize)}</DistChip>
<DistChip name="license">{formatLicense(license)}</DistChip>
</DistListItem>
</List>
);
};
export default Dist;