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): JSX.Element => { return (
{description}
{version ? {`${isLatest ? 'Latest v' : 'v'}${version}`} : null}
); }; const renderCopyCLI = (): JSX.Element => ; const renderMaintainers = (): JSX.Element => ; const renderContributors = (): JSX.Element => ; const renderRepository = (): JSX.Element => ; const renderAuthor = (): JSX.Element => ; const renderEngine = (): JSX.Element => ; const renderDist = (): JSX.Element => ; const renderActionBar = (): JSX.Element => ; const renderTitle = (packageName, packageVersion, packageMeta): JSX.Element => { 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 = (): JSX.Element => { const { packageName, packageMeta, packageVersion } = React.useContext(DetailContext); return renderSideBar(packageName, packageVersion, packageMeta); }; export default DetailSidebar;