2019-08-25 19:34:27 +07:00
|
|
|
import React, { ReactElement } from 'react';
|
2019-06-20 19:37:28 +07:00
|
|
|
|
|
|
|
import Card from '@material-ui/core/Card';
|
|
|
|
import CardContent from '@material-ui/core/CardContent';
|
|
|
|
import List from '@material-ui/core/List';
|
|
|
|
|
2019-08-31 16:02:46 +07:00
|
|
|
import { ActionBar } from '../ActionBar/ActionBar';
|
2019-06-20 19:37:28 +07:00
|
|
|
import Author from '../Author';
|
|
|
|
import Developers from '../Developers';
|
|
|
|
import Dist from '../Dist/Dist';
|
|
|
|
import Engine from '../Engines/Engines';
|
|
|
|
import Install from '../Install';
|
|
|
|
import Repository from '../Repository/Repository';
|
|
|
|
|
2019-08-25 19:34:27 +07:00
|
|
|
import { DetailContext } from '../../pages/Version';
|
2019-06-20 19:37:28 +07:00
|
|
|
|
|
|
|
import { TitleListItem, TitleListItemText } from './styles';
|
|
|
|
|
2019-08-25 19:34:27 +07:00
|
|
|
const renderCopyCLI = () => <Install />;
|
|
|
|
const renderMaintainers = () => <Developers type="maintainers" />;
|
|
|
|
const renderContributors = () => <Developers type="contributors" />;
|
|
|
|
const renderRepository = () => <Repository />;
|
|
|
|
const renderAuthor = () => <Author />;
|
|
|
|
const renderEngine = () => <Engine />;
|
|
|
|
const renderDist = () => <Dist />;
|
|
|
|
const renderActionBar = () => <ActionBar />;
|
|
|
|
const renderTitle = (packageName, packageMeta) => {
|
|
|
|
return (
|
|
|
|
<List className="detail-info">
|
2019-08-31 16:02:46 +07:00
|
|
|
<TitleListItem alignItems="flex-start" button={true}>
|
2019-08-25 19:34:27 +07:00
|
|
|
<TitleListItemText primary={<b>{packageName}</b>} secondary={packageMeta.latest.description} />
|
|
|
|
</TitleListItem>
|
|
|
|
</List>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
function renderSideBar(packageName, packageMeta): ReactElement<HTMLElement> {
|
|
|
|
return (
|
|
|
|
<div className={'sidebar-info'}>
|
|
|
|
<Card>
|
|
|
|
<CardContent>
|
|
|
|
{renderTitle(packageName, packageMeta)}
|
|
|
|
{renderActionBar()}
|
|
|
|
{renderCopyCLI()}
|
|
|
|
{renderRepository()}
|
|
|
|
{renderEngine()}
|
|
|
|
{renderDist()}
|
|
|
|
{renderAuthor()}
|
|
|
|
{renderMaintainers()}
|
|
|
|
{renderContributors()}
|
|
|
|
</CardContent>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2019-06-20 19:37:28 +07:00
|
|
|
|
2019-08-25 19:34:27 +07:00
|
|
|
const DetailSidebar = () => {
|
|
|
|
const { packageName, packageMeta } = React.useContext(DetailContext);
|
2019-06-20 19:37:28 +07:00
|
|
|
|
2019-08-25 19:34:27 +07:00
|
|
|
return renderSideBar(packageName, packageMeta);
|
|
|
|
};
|
2019-06-20 19:37:28 +07:00
|
|
|
|
|
|
|
export default DetailSidebar;
|