import React, { ReactElement } from 'react'; import Card from '@material-ui/core/Card'; import CardContent from '@material-ui/core/CardContent'; import List from '@material-ui/core/List'; import { ActionBar } from '../ActionBar/ActionBar'; 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'; import { DetailContext } from '../../pages/Version'; import { TitleListItem, TitleListItemText } from './styles'; const renderLatestDescription = (description, version, isLatest: boolean = true) => { return (
{description}
{version ? {`${isLatest ? 'Latest v' : 'v'}${version}`} : null}
); }; const renderCopyCLI = () => ; const renderMaintainers = () => ; const renderContributors = () => ; const renderRepository = () => ; const renderAuthor = () => ; const renderEngine = () => ; const renderDist = () => ; const renderActionBar = () => ; const renderTitle = (packageName, packageVersion, packageMeta) => { const version = packageVersion ? packageVersion : packageMeta.latest.version; const isLatest = typeof packageVersion === 'undefined'; return ( {packageName}} secondary={renderLatestDescription(packageMeta.latest.description, version, isLatest)} /> ); }; function renderSideBar(packageName, packageVersion, packageMeta): ReactElement { return (
{renderTitle(packageName, packageVersion, packageMeta)} {renderActionBar()} {renderCopyCLI()} {renderRepository()} {renderEngine()} {renderDist()} {renderAuthor()} {renderMaintainers()} {renderContributors()}
); } const DetailSidebar = () => { const { packageName, packageMeta, packageVersion } = React.useContext(DetailContext); return renderSideBar(packageName, packageVersion, packageMeta); }; export default DetailSidebar;