@verdaccio/ui-components 3.0.0-next.1 → 3.0.0-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/build/components/ActionBar/ActionBar.js +6 -2
  3. package/build/components/ActionBar/ActionBarAction.js +15 -7
  4. package/build/components/Author/Author.js +15 -7
  5. package/build/components/Author/styles.js +7 -23
  6. package/build/components/CopyClipboard/CopyToClipBoard.js +11 -10
  7. package/build/components/Deprecated/Deprecated.js +11 -19
  8. package/build/components/Engines/Engines.js +7 -7
  9. package/build/components/Install/Install.js +7 -4
  10. package/build/components/Install/InstallListItem.js +25 -37
  11. package/build/components/Package/Package.js +14 -6
  12. package/build/components/RawViewer/RawViewer.js +0 -1
  13. package/build/components/Readme/Readme.js +11 -26
  14. package/build/components/Readme/Readme.js.map +1 -1
  15. package/build/components/Readme/ReadmeDark.js +46 -0
  16. package/build/components/Readme/ReadmeLight.js +46 -0
  17. package/build/components/Readme/github-markdown-dark.css +1015 -0
  18. package/build/components/Readme/github-markdown-light.css +1014 -0
  19. package/build/components/SettingsMenu/SettingsMenu.js +16 -3
  20. package/build/components/SideBarTittle/SideBarTittle.js +5 -4
  21. package/build/components/Versions/HistoryList.js +32 -4
  22. package/build/components/Versions/Versions.js +16 -2
  23. package/build/components/Versions/__partials__/data.json +1 -0
  24. package/build/components/Versions/__partials__/deprecated-versions.json +175 -0
  25. package/build/providers/AppConfigurationProvider/AppConfigurationProvider.js +1 -0
  26. package/build/providers/PersistenceSettingProvider/PersistenceSettingProvider.js +2 -1
  27. package/build/src/__mocks__/react-markdown.d.ts +2 -2
  28. package/build/src/components/Author/styles.d.ts +0 -4
  29. package/build/src/components/CopyClipboard/CopyToClipBoard.d.ts +1 -1
  30. package/build/src/components/Deprecated/Deprecated.d.ts +0 -1
  31. package/build/src/components/Heading/Heading.d.ts +1 -1
  32. package/build/src/components/Icons/DevsIcons/CommonJS.d.ts +2 -2
  33. package/build/src/components/Icons/DevsIcons/ES6Module.d.ts +2 -2
  34. package/build/src/components/Icons/DevsIcons/Git.d.ts +2 -2
  35. package/build/src/components/Icons/DevsIcons/NodeJS.d.ts +2 -2
  36. package/build/src/components/Icons/DevsIcons/TypeScript.d.ts +2 -2
  37. package/build/src/components/Icons/Earth.d.ts +2 -2
  38. package/build/src/components/Icons/FileBinary.d.ts +2 -2
  39. package/build/src/components/Icons/Law.d.ts +2 -2
  40. package/build/src/components/Icons/License.d.ts +2 -2
  41. package/build/src/components/Icons/Managers/Npm.d.ts +2 -2
  42. package/build/src/components/Icons/Managers/Pnpm.d.ts +2 -2
  43. package/build/src/components/Icons/Managers/Yarn.d.ts +2 -2
  44. package/build/src/components/Icons/SvgIcon.d.ts +1 -1
  45. package/build/src/components/Icons/Time.d.ts +2 -2
  46. package/build/src/components/Icons/Version.d.ts +2 -2
  47. package/build/src/components/Install/InstallListItem.d.ts +2 -0
  48. package/build/src/components/Link/Link.d.ts +1 -1
  49. package/build/src/components/LoginDialog/LoginDialog.stories.d.ts +2 -2
  50. package/build/src/components/LoginDialog/LoginDialogForm.d.ts +1 -1
  51. package/build/src/components/LoginDialog/LoginDialogFormError.d.ts +1 -1
  52. package/build/src/components/MenuItem/MenuItem.d.ts +1 -1
  53. package/build/src/components/Readme/Readme.d.ts +0 -1
  54. package/build/src/components/Readme/ReadmeDark.d.ts +5 -0
  55. package/build/src/components/Readme/ReadmeLight.d.ts +5 -0
  56. package/build/src/components/Search/AutoComplete/styles.d.ts +1 -1
  57. package/build/src/components/Search/Search.stories.d.ts +2 -2
  58. package/build/src/components/Search/styles.d.ts +1 -1
  59. package/build/src/components/TextField/TextField.d.ts +1 -1
  60. package/build/src/components/Versions/HistoryList.d.ts +1 -0
  61. package/build/src/sections/Footer/Footer.d.ts +2 -2
  62. package/build/src/sections/Header/LanguageSwitch.d.ts +2 -2
  63. package/build/src/sections/Header/styles.d.ts +1 -1
  64. package/build/src/types/packageMeta.d.ts +1 -0
  65. package/build/src/utils/loadable.d.ts +2 -2
  66. package/build/store/models/download.js +0 -1
  67. package/package.json +13 -11
  68. package/src/components/ActionBar/ActionBar.stories.tsx +1 -1
  69. package/src/components/ActionBar/ActionBar.test.tsx +17 -10
  70. package/src/components/ActionBar/ActionBar.tsx +16 -12
  71. package/src/components/ActionBar/ActionBarAction.tsx +15 -10
  72. package/src/components/Author/Author.tsx +13 -4
  73. package/src/components/Author/styles.ts +0 -6
  74. package/src/components/CopyClipboard/CopyToClipBoard.tsx +4 -3
  75. package/src/components/Deprecated/Deprecated.tsx +6 -19
  76. package/src/components/Engines/Engines.tsx +5 -5
  77. package/src/components/Install/Install.test.tsx +29 -37
  78. package/src/components/Install/Install.tsx +15 -4
  79. package/src/components/Install/InstallListItem.tsx +46 -30
  80. package/src/components/Package/Package.tsx +10 -1
  81. package/src/components/RawViewer/RawViewer.tsx +1 -6
  82. package/src/components/Readme/Readme.tsx +10 -21
  83. package/src/components/Readme/ReadmeDark.tsx +32 -0
  84. package/src/components/Readme/ReadmeLight.tsx +32 -0
  85. package/src/components/Readme/github-markdown-dark.css +1015 -0
  86. package/src/components/Readme/github-markdown-light.css +1014 -0
  87. package/src/components/SettingsMenu/SettingsMenu.tsx +23 -4
  88. package/src/components/SideBarTittle/SideBarTittle.tsx +1 -0
  89. package/src/components/Versions/HistoryList.tsx +29 -1
  90. package/src/components/Versions/Versions.test.tsx +16 -1
  91. package/src/components/Versions/Versions.tsx +17 -1
  92. package/src/components/Versions/__partials__/data.json +1 -0
  93. package/src/components/Versions/__partials__/deprecated-versions.json +175 -0
  94. package/src/providers/AppConfigurationProvider/AppConfigurationProvider.tsx +1 -0
  95. package/src/providers/PersistenceSettingProvider/PersistenceSettingProvider.tsx +2 -0
  96. package/src/store/models/download.ts +0 -1
  97. package/src/types/packageMeta.ts +1 -0
@@ -5,6 +5,7 @@ import { PackageManagers } from '@verdaccio/types';
5
5
  import { useConfig } from '../../providers';
6
6
  import { render, screen } from '../../test/test-react-testing-library';
7
7
  import Install from './Install';
8
+ import { getGlobalInstall } from './InstallListItem';
8
9
  import data from './__partials__/data.json';
9
10
 
10
11
  const ComponentToBeRendered: React.FC<{ pkgManagers?: PackageManagers[] }> = () => {
@@ -16,12 +17,9 @@ const ComponentToBeRendered: React.FC<{ pkgManagers?: PackageManagers[] }> = ()
16
17
  describe('<Install />', () => {
17
18
  test('renders correctly', () => {
18
19
  render(<ComponentToBeRendered />);
19
- expect(screen.getByText('sidebar.installation.install-using-pnpm')).toBeInTheDocument();
20
- expect(screen.getByText('sidebar.installation.install-using-yarn')).toBeInTheDocument();
21
- expect(screen.getByText('sidebar.installation.install-using-npm')).toBeInTheDocument();
22
- expect(screen.getByText('sidebar.installation.install-using-npm-command')).toBeInTheDocument();
23
- expect(screen.getByText('sidebar.installation.install-using-yarn-command')).toBeInTheDocument();
24
- expect(screen.getByText('sidebar.installation.install-using-pnpm-command')).toBeInTheDocument();
20
+ expect(screen.getByText('yarn add foo@8.0.0')).toBeInTheDocument();
21
+ expect(screen.getByText('pnpm install foo@8.0.0')).toBeInTheDocument();
22
+ expect(screen.getByText('npm install foo@8.0.0')).toBeInTheDocument();
25
23
  });
26
24
 
27
25
  test('should have 3 children', () => {
@@ -38,47 +36,41 @@ describe('<Install />', () => {
38
36
  render(<ComponentToBeRendered />);
39
37
 
40
38
  expect(screen.getByText('sidebar.installation.title')).toBeTruthy();
41
- expect(screen.queryByText('sidebar.installation.install-using-pnpm')).not.toBeInTheDocument();
42
- expect(screen.queryByText('sidebar.installation.install-using-yarn')).not.toBeInTheDocument();
43
- expect(screen.getByText('sidebar.installation.install-using-npm')).toBeInTheDocument();
44
- expect(screen.getByText('sidebar.installation.install-using-npm-command')).toBeInTheDocument();
45
- expect(
46
- screen.queryByText('sidebar.installation.install-using-yarn-command')
47
- ).not.toBeInTheDocument();
48
- expect(
49
- screen.queryByText('sidebar.installation.install-using-pnpm-command')
50
- ).not.toBeInTheDocument();
39
+ expect(screen.queryByText('pnpm')).not.toBeInTheDocument();
40
+ expect(screen.queryByText('yarn')).not.toBeInTheDocument();
41
+ expect(screen.getByText('npm install foo@8.0.0')).toBeInTheDocument();
51
42
  });
52
43
 
53
44
  test('should have the element YARN', () => {
54
45
  window.__VERDACCIO_BASENAME_UI_OPTIONS.pkgManagers = ['yarn'];
55
46
  render(<ComponentToBeRendered />);
56
47
  expect(screen.getByText('sidebar.installation.title')).toBeTruthy();
57
- expect(screen.queryByText('sidebar.installation.install-using-pnpm')).not.toBeInTheDocument();
58
- expect(screen.getByText('sidebar.installation.install-using-yarn')).toBeInTheDocument();
59
- expect(screen.queryByText('sidebar.installation.install-using-npm')).not.toBeInTheDocument();
60
- expect(
61
- screen.queryByText('sidebar.installation.install-using-npm-command')
62
- ).not.toBeInTheDocument();
63
- expect(screen.getByText('sidebar.installation.install-using-yarn-command')).toBeInTheDocument();
64
- expect(
65
- screen.queryByText('sidebar.installation.install-using-pnpm-command')
66
- ).not.toBeInTheDocument();
48
+ expect(screen.queryByText('pnpm')).not.toBeInTheDocument();
49
+ expect(screen.queryByText('npm')).not.toBeInTheDocument();
50
+ expect(screen.getByText('yarn add foo@8.0.0')).toBeInTheDocument();
67
51
  });
68
52
 
69
53
  test('should have the element PNPM', () => {
70
54
  window.__VERDACCIO_BASENAME_UI_OPTIONS.pkgManagers = ['pnpm'];
71
55
  render(<ComponentToBeRendered />);
72
- expect(screen.getByText('sidebar.installation.title')).toBeTruthy();
73
- expect(screen.getByText('sidebar.installation.install-using-pnpm')).toBeInTheDocument();
74
- expect(screen.queryByText('sidebar.installation.install-using-yarn')).not.toBeInTheDocument();
75
- expect(screen.queryByText('sidebar.installation.install-using-npm')).not.toBeInTheDocument();
76
- expect(
77
- screen.queryByText('sidebar.installation.install-using-npm-command')
78
- ).not.toBeInTheDocument();
79
- expect(
80
- screen.queryByText('sidebar.installation.install-using-yarn-command')
81
- ).not.toBeInTheDocument();
82
- expect(screen.getByText('sidebar.installation.install-using-pnpm-command')).toBeInTheDocument();
56
+ expect(screen.queryByText('pnpm')).not.toBeInTheDocument();
57
+ expect(screen.queryByText('yarn')).not.toBeInTheDocument();
58
+ expect(screen.getByText('pnpm install foo@8.0.0')).toBeInTheDocument();
59
+ });
60
+ });
61
+
62
+ describe('getGlobalInstall', () => {
63
+ test('no global', () => {
64
+ expect(getGlobalInstall(false, 'foo', '1.0.0')).toEqual('1.0.0@foo');
65
+ });
66
+ test('global', () => {
67
+ expect(getGlobalInstall(true, 'foo', '1.0.0')).toEqual('-g 1.0.0@foo');
68
+ });
69
+
70
+ test('yarn no global', () => {
71
+ expect(getGlobalInstall(false, 'foo', '1.0.0', true)).toEqual('1.0.0@foo');
72
+ });
73
+ test('yarn global', () => {
74
+ expect(getGlobalInstall(true, 'foo', '1.0.0', true)).toEqual('1.0.0@foo');
83
75
  });
84
76
  });
@@ -27,7 +27,6 @@ export type Props = {
27
27
  const Install: React.FC<Props> = ({ packageMeta, packageName, configOptions }) => {
28
28
  const { t } = useTranslation();
29
29
  const theme = useTheme();
30
-
31
30
  if (!packageMeta || !packageName) {
32
31
  return null;
33
32
  }
@@ -51,13 +50,25 @@ const Install: React.FC<Props> = ({ packageMeta, packageName, configOptions }) =
51
50
  subheader={<StyledText variant={'subtitle1'}>{t('sidebar.installation.title')}</StyledText>}
52
51
  >
53
52
  {hasNpm && (
54
- <InstallListItem dependencyManager={DependencyManager.NPM} packageName={packageName} />
53
+ <InstallListItem
54
+ dependencyManager={DependencyManager.NPM}
55
+ packageName={packageName}
56
+ packageVersion={packageMeta.latest.version}
57
+ />
55
58
  )}
56
59
  {hasYarn && (
57
- <InstallListItem dependencyManager={DependencyManager.YARN} packageName={packageName} />
60
+ <InstallListItem
61
+ dependencyManager={DependencyManager.YARN}
62
+ packageName={packageName}
63
+ packageVersion={packageMeta.latest.version}
64
+ />
58
65
  )}
59
66
  {hasPnpm && (
60
- <InstallListItem dependencyManager={DependencyManager.PNPM} packageName={packageName} />
67
+ <InstallListItem
68
+ dependencyManager={DependencyManager.PNPM}
69
+ packageName={packageName}
70
+ packageVersion={packageMeta.latest.version}
71
+ />
61
72
  )}
62
73
  </List>
63
74
  </>
@@ -2,8 +2,8 @@ import styled from '@emotion/styled';
2
2
  import Avatar from '@mui/material/Avatar';
3
3
  import ListItem from '@mui/material/ListItem';
4
4
  import ListItemText from '@mui/material/ListItemText';
5
+ import { useTheme } from '@mui/styles';
5
6
  import React from 'react';
6
- import { useTranslation } from 'react-i18next';
7
7
 
8
8
  import { useSettings } from '../../providers/PersistenceSettingProvider';
9
9
  import CopyToClipBoard from '../CopyClipboard';
@@ -35,78 +35,94 @@ export enum DependencyManager {
35
35
  interface Interface {
36
36
  packageName: string;
37
37
  dependencyManager: DependencyManager;
38
+ packageVersion?: string;
38
39
  }
39
40
 
40
- const InstallListItem: React.FC<Interface> = ({ packageName, dependencyManager }) => {
41
- const { t } = useTranslation();
41
+ export function getGlobalInstall(isGlobal, packageVersion, packageName, isYarn = false) {
42
+ const name = isGlobal
43
+ ? `${isYarn ? '' : '-g'} ${packageVersion ? `${packageName}@${packageVersion}` : packageName}`
44
+ : packageVersion
45
+ ? `${packageName}@${packageVersion}`
46
+ : packageName;
47
+
48
+ return name.trim();
49
+ }
50
+
51
+ const InstallListItem: React.FC<Interface> = ({
52
+ packageName,
53
+ dependencyManager,
54
+ packageVersion,
55
+ }) => {
42
56
  const { localSettings } = useSettings();
57
+ const theme = useTheme();
43
58
  const isGlobal = localSettings[packageName]?.global ?? false;
44
- const pkgName = isGlobal ? `-g ${packageName}` : packageName;
45
-
46
59
  switch (dependencyManager) {
47
60
  case DependencyManager.NPM:
48
61
  return (
49
62
  <InstallItem data-testid={'installListItem-npm'}>
50
- <PackageMangerAvatar alt="npm" sx={{ bgcolor: '#FFF' }}>
63
+ <PackageMangerAvatar alt="npm" sx={{ bgcolor: theme.palette.white }}>
51
64
  <Npm />
52
65
  </PackageMangerAvatar>
53
66
  <InstallListItemText
54
67
  primary={
55
68
  <CopyToClipBoard
56
- dataTestId="installYarn"
57
- text={t('sidebar.installation.install-using-npm-command', {
58
- packageName: pkgName,
59
- })}
60
- title={t('sidebar.installation.install-using-npm-command', {
61
- packageName: pkgName,
62
- })}
69
+ dataTestId="instalNpm"
70
+ text={`npm install ${getGlobalInstall(isGlobal, packageVersion, packageName)}`}
71
+ title={`npm install ${getGlobalInstall(isGlobal, packageVersion, packageName)}`}
63
72
  />
64
73
  }
65
- secondary={t('sidebar.installation.install-using-npm')}
66
74
  />
67
75
  </InstallItem>
68
76
  );
69
77
  case DependencyManager.YARN:
70
78
  return (
71
79
  <InstallItem data-testid={'installListItem-yarn'}>
72
- <PackageMangerAvatar alt="yarn" sx={{ bgcolor: '#FFF' }}>
80
+ <PackageMangerAvatar alt="yarn" sx={{ bgcolor: theme.palette.white }}>
73
81
  <Yarn />
74
82
  </PackageMangerAvatar>
75
83
  <InstallListItemText
76
84
  primary={
77
85
  <CopyToClipBoard
78
86
  dataTestId="installYarn"
79
- text={t('sidebar.installation.install-using-yarn-command', {
80
- packageName: pkgName,
81
- })}
82
- title={t('sidebar.installation.install-using-yarn-command', {
83
- packageName: pkgName,
84
- })}
87
+ text={
88
+ isGlobal
89
+ ? `yarn ${localSettings.yarnModern ? '' : 'global'} add ${getGlobalInstall(
90
+ isGlobal,
91
+ packageVersion,
92
+ packageName,
93
+ true
94
+ )}`
95
+ : `yarn add ${getGlobalInstall(isGlobal, packageVersion, packageName, true)}`
96
+ }
97
+ title={
98
+ isGlobal
99
+ ? `yarn global add ${getGlobalInstall(
100
+ isGlobal,
101
+ packageVersion,
102
+ packageName,
103
+ true
104
+ )}`
105
+ : `yarn add ${getGlobalInstall(isGlobal, packageVersion, packageName, true)}`
106
+ }
85
107
  />
86
108
  }
87
- secondary={t('sidebar.installation.install-using-yarn')}
88
109
  />
89
110
  </InstallItem>
90
111
  );
91
112
  case DependencyManager.PNPM:
92
113
  return (
93
114
  <InstallItem data-testid={'installListItem-pnpm'}>
94
- <PackageMangerAvatar alt={'pnpm'} sx={{ bgcolor: '#FFF' }}>
115
+ <PackageMangerAvatar alt={'pnpm'} sx={{ bgcolor: theme.palette.white }}>
95
116
  <Pnpm />
96
117
  </PackageMangerAvatar>
97
118
  <InstallListItemText
98
119
  primary={
99
120
  <CopyToClipBoard
100
121
  dataTestId="installPnpm"
101
- text={t('sidebar.installation.install-using-pnpm-command', {
102
- packageName: pkgName,
103
- })}
104
- title={t('sidebar.installation.install-using-pnpm-command', {
105
- packageName: pkgName,
106
- })}
122
+ text={`pnpm install ${getGlobalInstall(isGlobal, packageVersion, packageName)}`}
123
+ title={`pnpm install ${getGlobalInstall(isGlobal, packageVersion, packageName)}`}
107
124
  />
108
125
  }
109
- secondary={t('sidebar.installation.install-using-pnpm')}
110
126
  />
111
127
  </InstallItem>
112
128
  );
@@ -4,6 +4,7 @@ import BugReport from '@mui/icons-material/BugReport';
4
4
  import DownloadIcon from '@mui/icons-material/CloudDownload';
5
5
  import HomeIcon from '@mui/icons-material/Home';
6
6
  import { useTheme } from '@mui/material';
7
+ import CircularProgress from '@mui/material/CircularProgress';
7
8
  import Grid from '@mui/material/Grid';
8
9
  import ListItem from '@mui/material/ListItem';
9
10
  import Tooltip from '@mui/material/Tooltip';
@@ -71,6 +72,7 @@ const Package: React.FC<PackageInterface> = ({
71
72
  const dispatch = useDispatch<Dispatch>();
72
73
  const { t } = useTranslation();
73
74
  const theme = useTheme();
75
+ const isLoading = useSelector((state: RootState) => state?.loading?.models.download);
74
76
 
75
77
  const handleDownload = useCallback(
76
78
  async (tarballDist: string) => {
@@ -173,7 +175,13 @@ const Package: React.FC<PackageInterface> = ({
173
175
  title={t('package.tarball')}
174
176
  >
175
177
  <IconButton aria-label={t('package.download')} size="large">
176
- <DownloadIcon />
178
+ {isLoading ? (
179
+ <CircularProgress size={13}>
180
+ <DownloadIcon />
181
+ </CircularProgress>
182
+ ) : (
183
+ <DownloadIcon />
184
+ )}
177
185
  </IconButton>
178
186
  </Tooltip>
179
187
  </Link>
@@ -194,6 +202,7 @@ const Package: React.FC<PackageInterface> = ({
194
202
  container={true}
195
203
  item={true}
196
204
  justify="flex-end"
205
+ spacing={3}
197
206
  xs={true}
198
207
  >
199
208
  {renderHomePageLink()}
@@ -47,12 +47,7 @@ type Props = {
47
47
  const RawViewer: React.FC<Props> = ({ isOpen = false, onClose, packageMeta }) => {
48
48
  const { t } = useTranslation();
49
49
  return (
50
- <Dialog
51
- data-testid={'rawViewer--dialog'}
52
- fullScreen={true}
53
- id="raw-viewer--dialog-container"
54
- open={isOpen}
55
- >
50
+ <Dialog data-testid={'rawViewer--dialog'} fullScreen={true} open={isOpen}>
56
51
  <ViewerTitle id="viewer-title" onClose={onClose}>
57
52
  {t('action-bar-action.raw')}
58
53
  </ViewerTitle>
@@ -1,30 +1,19 @@
1
- import styled from '@emotion/styled';
2
- import 'github-markdown-css';
3
1
  import 'highlight.js/styles/default.css';
4
2
  import React from 'react';
5
3
 
6
- import { Theme } from '../../Theme';
4
+ import { useCustomTheme } from '../../';
5
+ import ReadmeDark from './ReadmeDark';
6
+ import ReadmeLight from './ReadmeLight';
7
7
  import { Props } from './types';
8
- import { parseReadme } from './utils';
9
8
 
10
9
  const Readme: React.FC<Props> = ({ description }) => {
11
- return (
12
- <Wrapper
13
- className="markdown-body"
14
- dangerouslySetInnerHTML={{ __html: parseReadme(description) as string }}
15
- />
10
+ // @ts-ignore
11
+ const { isDarkMode } = useCustomTheme();
12
+
13
+ return isDarkMode ? (
14
+ <ReadmeDark description={description} />
15
+ ) : (
16
+ <ReadmeLight description={description} />
16
17
  );
17
18
  };
18
19
  export default Readme;
19
-
20
- const Wrapper = styled('div')<{ theme?: Theme }>(({ theme }) => ({
21
- background: theme?.palette.white,
22
- color: theme?.palette.black,
23
- padding: theme?.spacing(2, 3),
24
- ul: {
25
- listStyle: 'disc',
26
- },
27
- img: {
28
- maxWidth: '100%',
29
- },
30
- }));
@@ -0,0 +1,32 @@
1
+ import styled from '@emotion/styled';
2
+ import cx from 'classnames';
3
+ import 'highlight.js/styles/default.css';
4
+ import React from 'react';
5
+
6
+ import { Theme } from '../../Theme';
7
+ // @ts-ignore
8
+ import styles from './github-markdown-dark.css';
9
+ import { Props } from './types';
10
+ import { parseReadme } from './utils';
11
+
12
+ const Readme: React.FC<Props> = ({ description }) => {
13
+ return (
14
+ <Wrapper
15
+ className={cx('markdown-body', styles['markdown-body'])}
16
+ dangerouslySetInnerHTML={{ __html: parseReadme(description) as string }}
17
+ />
18
+ );
19
+ };
20
+ export default Readme;
21
+
22
+ const Wrapper = styled('div')<{ theme?: Theme }>(({ theme }) => ({
23
+ background: theme?.palette.white,
24
+ color: theme?.palette.black,
25
+ padding: theme?.spacing(2, 3),
26
+ ul: {
27
+ listStyle: 'disc',
28
+ },
29
+ img: {
30
+ maxWidth: '100%',
31
+ },
32
+ }));
@@ -0,0 +1,32 @@
1
+ import styled from '@emotion/styled';
2
+ import cx from 'classnames';
3
+ import 'highlight.js/styles/default.css';
4
+ import React from 'react';
5
+
6
+ import { Theme } from '../../Theme';
7
+ // @ts-ignore
8
+ import styles from './github-markdown-light.css';
9
+ import { Props } from './types';
10
+ import { parseReadme } from './utils';
11
+
12
+ const Readme: React.FC<Props> = ({ description }) => {
13
+ return (
14
+ <Wrapper
15
+ className={cx('markdown-body', styles['markdown-body'])}
16
+ dangerouslySetInnerHTML={{ __html: parseReadme(description) as string }}
17
+ />
18
+ );
19
+ };
20
+ export default Readme;
21
+
22
+ const Wrapper = styled('div')<{ theme?: Theme }>(({ theme }) => ({
23
+ background: theme?.palette.white,
24
+ color: theme?.palette.black,
25
+ padding: theme?.spacing(2, 3),
26
+ ul: {
27
+ listStyle: 'disc',
28
+ },
29
+ img: {
30
+ maxWidth: '100%',
31
+ },
32
+ }));