1
0
Fork 1
mirror of https://github.com/SomboChea/ui synced 2024-05-04 02:21:36 +07:00
verdaccio-ui/src/components/Dist/Dist.tsx
Priscila Oliveira 42d3bb8508 feat: login Dialog Component - Replaced class by func. comp + added react-hook-form (#341)
* refactor: convert class to func

* refactor: changed login form logic

* refactor: conver to testing-library tests

* refactor: moved dependency

* refactor: replaced uglifyjs-webpack-plugin by terser-webpack-plugin

* fix: fixed e2e errors

* fix: fixed e2e test

* Delete settings.json

* fix: vscode settings rollback

* refactor: rollback webpack config

* refactor: updated eslint rule

* fix: removed --fix

* refactor: incresed the bundle size
2019-12-06 18:09:01 +01:00

44 lines
1.1 KiB
TypeScript

import React, { FC, useContext } from 'react';
import { DetailContext } from '../../pages/Version';
import fileSizeSI from '../../utils/file-size';
import { formatLicense } from '../../utils/package';
import List from '../../muiComponents/List';
import { StyledText, DistListItem, DistChips } from './styles';
const DistChip: FC<{ name: string }> = ({ name, children }) =>
children ? (
<DistChips
label={
<>
<b>{name}</b>
{': '}
{children}
</>
}
/>
) : null;
const Dist: FC = () => {
const { packageMeta } = useContext(DetailContext);
if (!packageMeta) {
return null;
}
const { dist, license } = packageMeta && packageMeta.latest;
return (
<List subheader={<StyledText variant="subtitle1">{'Latest Distribution'}</StyledText>}>
<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;