mirror of
https://github.com/SomboChea/ui
synced 2024-09-29 21:07:47 +07:00
42d3bb8508
* 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
44 lines
1.1 KiB
TypeScript
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;
|