diff --git a/.eslintignore b/.eslintignore index 010a45c..a063e81 100644 --- a/.eslintignore +++ b/.eslintignore @@ -11,3 +11,4 @@ Dockerfile *.html *.scss *.png +doc diff --git a/.gitignore b/.gitignore index 6922247..8101f3d 100755 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,8 @@ npm-debug.log verdaccio-*.tgz .DS_Store build/ +doc + ### node_modules package-lock.json diff --git a/src/components/NotFound/NotFound.tsx b/src/components/NotFound/NotFound.tsx index 14ab9c0..2f5d290 100644 --- a/src/components/NotFound/NotFound.tsx +++ b/src/components/NotFound/NotFound.tsx @@ -1,53 +1,47 @@ -import ListItem from '@material-ui/core/ListItem'; +import Box from '@material-ui/core/Box'; import Typography from '@material-ui/core/Typography'; -import withWidth, { isWidthUp, WithWidthProps } from '@material-ui/core/withWidth'; +import styled from 'react-emotion'; import React, { useCallback } from 'react'; -import { RouteComponentProps, withRouter } from 'react-router-dom'; +import { useHistory } from 'react-router-dom'; + +import Button from '../../muiComponents/Button'; +import colors from '../../utils/styles/colors'; +import { spacings } from '../../utils/styles/spacings'; import PackageImg from './img/package.svg'; -import { Card, EmptyPackage, Heading, Inner, List, Wrapper } from './styles'; -export const NOT_FOUND_TEXT = `Sorry, we couldn't find it...`; -export const LABEL_NOT_FOUND = `The page you're looking for doesn't exist.`; -export const LABEL_FOOTER_NOT_FOUND = 'Perhaps these links will help find what you are looking for:'; +export const NOT_FOUND_TEXT = "Sorry, we couldn't find it..."; +export const LABEL_NOT_FOUND = "The page you're looking for doesn't exist."; +export const GO_TO_HOME_PAGE = 'Go to the home page'; -export type NotFoundProps = RouteComponentProps & WithWidthProps; +const EmptyPackage = styled('img')({ + width: '150px', + margin: '0 auto', +}); -const HOME_LABEL = 'Home'; +const StyledHeading = styled(Typography)({ + color: colors.primary, + marginBottom: spacings.sm, +}); -const renderSubTitle = (): JSX.Element => ( - -
{LABEL_NOT_FOUND}
-
{LABEL_FOOTER_NOT_FOUND}
-
-); +const NotFound: React.FC = () => { + const history = useHistory(); -const NotFound: React.FC = ({ history, width }) => { const handleGomHome = useCallback(() => { history.push('/'); }, [history]); - const renderList = (): JSX.Element => ( - - - {HOME_LABEL} - - - ); - - /* eslint-disable @typescript-eslint/no-non-null-assertion */ return ( - - - - - {NOT_FOUND_TEXT} - - {renderSubTitle()} - {renderList()} - - + + + + {NOT_FOUND_TEXT} + + + ); }; -export default withRouter>(withWidth()(NotFound)); +export default NotFound; diff --git a/src/components/NotFound/Notfound.test.tsx b/src/components/NotFound/Notfound.test.tsx index a2b20dd..6207de5 100644 --- a/src/components/NotFound/Notfound.test.tsx +++ b/src/components/NotFound/Notfound.test.tsx @@ -1,18 +1,17 @@ import React from 'react'; import { BrowserRouter as Router } from 'react-router-dom'; -import { shallow } from 'enzyme'; +import { render } from '@testing-library/react'; import NotFound from './NotFound'; -console.error = jest.fn(); - describe(' component', () => { test('should load the component in default state', () => { - const routerWrapper = shallow( + const { container } = render( ); - expect(routerWrapper.find(NotFound)).toMatchSnapshot(); + expect(container.firstChild).toMatchSnapshot(); }); + test.todo('Test Button Click'); }); diff --git a/src/components/NotFound/__snapshots__/Notfound.test.tsx.snap b/src/components/NotFound/__snapshots__/Notfound.test.tsx.snap index 02fe057..8e17e4f 100644 --- a/src/components/NotFound/__snapshots__/Notfound.test.tsx.snap +++ b/src/components/NotFound/__snapshots__/Notfound.test.tsx.snap @@ -1,3 +1,33 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[` component should load the component in default state 1`] = ``; +exports[` component should load the component in default state 1`] = ` +
+ 404 - Page not found +

+ Sorry, we couldn't find it... +

+ +
+`; diff --git a/src/components/NotFound/index.ts b/src/components/NotFound/index.ts index 106131b..cbfef77 100644 --- a/src/components/NotFound/index.ts +++ b/src/components/NotFound/index.ts @@ -1 +1 @@ -export { default } from './NotFound'; +export { default, NOT_FOUND_TEXT } from './NotFound'; diff --git a/src/components/NotFound/styles.ts b/src/components/NotFound/styles.ts deleted file mode 100644 index 3647875..0000000 --- a/src/components/NotFound/styles.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { default as MuiCard } from '@material-ui/core/Card'; -import { default as MuiList } from '@material-ui/core/List'; -import Typography from '@material-ui/core/Typography'; -import styled from 'react-emotion'; - -export const Wrapper = styled('div')({ - display: 'flex', - alignItems: 'center', - flexDirection: 'column', - justifyContent: 'center', - flex: 1, - padding: '16px', -}); - -export const Inner = styled('div')({ - maxWidth: '650px', - display: 'flex', - flexDirection: 'column', -}); - -export const EmptyPackage = styled('img')({ - width: '150px', - margin: '0 auto', -}); - -export const Heading = styled(Typography)({ - '&&': { - color: '#4b5e40', - }, -}); - -export const List = styled(MuiList)({ - '&&': { - padding: 0, - color: '#4b5e40', - }, -}); - -export const Card = styled(MuiCard)({ - marginTop: '24px', -}); diff --git a/src/components/Versions/Versions.test.tsx b/src/components/Versions/Versions.test.tsx index e103eb3..0d15334 100644 --- a/src/components/Versions/Versions.test.tsx +++ b/src/components/Versions/Versions.test.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { mount } from 'enzyme'; -import { MemoryRouter } from 'react-router'; +import { MemoryRouter } from 'react-router-dom'; import { render, cleanup } from '@testing-library/react'; import { DetailContext, DetailContextProps } from '../../pages/Version'; diff --git a/src/utils/styles/spacings.ts b/src/utils/styles/spacings.ts index 7c7c372..7478d92 100644 --- a/src/utils/styles/spacings.ts +++ b/src/utils/styles/spacings.ts @@ -3,4 +3,5 @@ export const spacings = { lg: '30px', + sm: '16px', }; diff --git a/yarn.lock b/yarn.lock index 534e100..7c1bf85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -14023,4 +14023,4 @@ yup@^0.27.0: lodash "^4.17.11" property-expr "^1.5.0" synchronous-promise "^2.0.6" - toposort "^2.0.2" + toposort "^2.0.2" \ No newline at end of file