2019-10-06 21:55:49 +07:00
|
|
|
import React, { useContext } from 'react';
|
2019-11-23 19:41:14 +07:00
|
|
|
import styled from '@emotion/styled';
|
2019-03-28 05:39:06 +07:00
|
|
|
|
2019-10-06 21:55:49 +07:00
|
|
|
import { DetailContext } from '../../pages/Version';
|
2019-10-13 02:41:42 +07:00
|
|
|
import Text from '../../muiComponents/Text';
|
2019-10-13 03:26:56 +07:00
|
|
|
import List from '../../muiComponents/List';
|
2019-12-12 22:10:27 +07:00
|
|
|
import { Theme } from '../../design-tokens/theme';
|
2019-08-25 19:34:27 +07:00
|
|
|
|
2019-10-06 21:55:49 +07:00
|
|
|
import InstallListItem, { DependencyManager } from './InstallListItem';
|
2019-02-03 17:23:33 +07:00
|
|
|
|
2019-12-12 22:10:27 +07:00
|
|
|
const StyledText = styled(Text)<{ theme?: Theme }>(props => ({
|
|
|
|
fontWeight: props.theme && props.theme.fontWeight.bold,
|
2019-10-06 21:55:49 +07:00
|
|
|
textTransform: 'capitalize',
|
2019-12-12 22:10:27 +07:00
|
|
|
}));
|
2019-03-28 05:39:06 +07:00
|
|
|
|
2019-10-06 21:55:49 +07:00
|
|
|
const Install: React.FC = () => {
|
|
|
|
const detailContext = useContext(DetailContext);
|
2019-06-20 19:37:28 +07:00
|
|
|
|
2019-10-06 21:55:49 +07:00
|
|
|
const { packageMeta, packageName } = detailContext;
|
|
|
|
|
|
|
|
if (!packageMeta || !packageName) {
|
|
|
|
return null;
|
2019-03-28 05:39:06 +07:00
|
|
|
}
|
2019-02-03 17:23:33 +07:00
|
|
|
|
2019-10-06 21:55:49 +07:00
|
|
|
return (
|
2019-10-13 02:41:42 +07:00
|
|
|
<List data-testid={'installList'} subheader={<StyledText variant={'subtitle1'}>{'Installation'}</StyledText>}>
|
2019-10-06 21:55:49 +07:00
|
|
|
<InstallListItem dependencyManager={DependencyManager.NPM} packageName={packageName} />
|
|
|
|
<InstallListItem dependencyManager={DependencyManager.YARN} packageName={packageName} />
|
|
|
|
<InstallListItem dependencyManager={DependencyManager.PNPM} packageName={packageName} />
|
|
|
|
</List>
|
|
|
|
);
|
|
|
|
};
|
2019-02-03 17:23:33 +07:00
|
|
|
|
|
|
|
export default Install;
|