2019-12-19 03:30:42 +07:00
|
|
|
import React, { useContext } from 'react';
|
|
|
|
import styled from '@emotion/styled';
|
2019-06-20 19:37:28 +07:00
|
|
|
|
2019-12-19 03:30:42 +07:00
|
|
|
import { DetailContext } from '../../pages/Version';
|
|
|
|
import Paper from '../../muiComponents/Paper';
|
2019-12-03 15:44:44 +07:00
|
|
|
import ActionBar from '../ActionBar';
|
2019-12-19 03:30:42 +07:00
|
|
|
import Repository from '../Repository';
|
|
|
|
import Engines from '../Engines';
|
|
|
|
import Dist from '../Dist';
|
|
|
|
import Install from '../Install';
|
2019-06-20 19:37:28 +07:00
|
|
|
import Author from '../Author';
|
2019-12-18 08:57:53 +07:00
|
|
|
import Developers, { DeveloperType } from '../Developers';
|
2019-12-19 03:30:42 +07:00
|
|
|
import { Theme } from '../../design-tokens/theme';
|
2019-06-20 19:37:28 +07:00
|
|
|
|
2019-12-19 03:30:42 +07:00
|
|
|
import DetailSidebarTitle from './DetailSidebarTitle';
|
|
|
|
import DetailSidebarFundButton from './DetailSidebarFundButton';
|
2019-06-20 19:37:28 +07:00
|
|
|
|
2019-12-19 03:30:42 +07:00
|
|
|
const StyledPaper = styled(Paper)<{ theme?: Theme }>(({ theme }) => ({
|
|
|
|
padding: theme.spacing(3, 2),
|
|
|
|
}));
|
2019-09-01 18:09:23 +07:00
|
|
|
|
2019-12-19 03:30:42 +07:00
|
|
|
const DetailSidebar: React.FC = () => {
|
|
|
|
const detailContext = useContext(DetailContext);
|
2019-09-01 18:09:23 +07:00
|
|
|
|
2019-12-19 03:30:42 +07:00
|
|
|
const { packageMeta, packageName, packageVersion } = detailContext;
|
|
|
|
|
|
|
|
if (!packageMeta || !packageName) {
|
|
|
|
return null;
|
|
|
|
}
|
2019-08-25 19:34:27 +07:00
|
|
|
|
|
|
|
return (
|
2019-12-19 03:30:42 +07:00
|
|
|
<StyledPaper className={'sidebar-info'}>
|
|
|
|
<DetailSidebarTitle
|
|
|
|
description={packageMeta.latest?.description}
|
|
|
|
isLatest={typeof packageVersion === 'undefined'}
|
|
|
|
packageName={packageName}
|
|
|
|
version={packageVersion || packageMeta.latest.version}
|
|
|
|
/>
|
|
|
|
<ActionBar />
|
|
|
|
<Install />
|
|
|
|
{packageMeta?.latest?.funding && <DetailSidebarFundButton to={packageMeta.latest.funding.url} />}
|
|
|
|
<Repository />
|
|
|
|
<Engines />
|
|
|
|
<Dist />
|
|
|
|
<Author />
|
|
|
|
<Developers type={DeveloperType.MAINTAINERS} />
|
|
|
|
<Developers type={DeveloperType.CONTRIBUTORS} />
|
|
|
|
</StyledPaper>
|
2019-08-25 19:34:27 +07:00
|
|
|
);
|
|
|
|
};
|
2019-06-20 19:37:28 +07:00
|
|
|
|
|
|
|
export default DetailSidebar;
|