This repository was archived by the owner on Jul 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Create 404 page #7
Open
HigorSegobia
wants to merge
12
commits into
prest:main
Choose a base branch
from
HigorSegobia:page-not-found
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
beec299
Add images of the page
HigorSegobia 026cb83
Create components for error page
HigorSegobia e1b19e8
Create test for the component
HigorSegobia 4146144
Create and implements 404 page
HigorSegobia a1e2eb0
Remove unused lines
HigorSegobia e7e1baf
Change the use of makeStykes to withStyles
HigorSegobia 874416b
Remove return and correct CamelCase
HigorSegobia 02ad352
Create tests for BackgroundParticles component
HigorSegobia 47a140b
Fix for components tests
HigorSegobia 7232d17
Create tests for 404 page
HigorSegobia 132dae2
Refactoring of error page tests
HigorSegobia eced9d7
refactoring page style by removing any
HigorSegobia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| import React from 'react'; | ||
| import Particles, { IParticlesParams } from 'react-particles-js'; | ||
| import { withStyles } from '@material-ui/core/styles'; | ||
|
|
||
| const useStyles = withStyles((theme) => ({ | ||
| root: { | ||
| '& > canvas': { | ||
| background: theme.palette.secondary.main, | ||
| }, | ||
| }, | ||
| })); | ||
|
|
||
| const styles = { | ||
| position: 'absolute', | ||
| top: 0, | ||
| left: 0, | ||
| zIndex: 1, | ||
| }; | ||
|
|
||
| const params: IParticlesParams = { | ||
| particles: { | ||
| number: { | ||
| value: 80, | ||
| density: { | ||
| enable: true, | ||
| value_area: 800, | ||
| }, | ||
| }, | ||
| color: { | ||
| value: '#9580FF', | ||
| }, | ||
| shape: { | ||
| type: 'polygon', | ||
| stroke: { | ||
| width: 0, | ||
| color: '#000000', | ||
| }, | ||
| polygon: { | ||
| nb_sides: 5, | ||
| }, | ||
| image: { | ||
| src: 'img/github.svg', | ||
| width: 100, | ||
| height: 100, | ||
| }, | ||
| }, | ||
| opacity: { | ||
| value: 0.4, | ||
| random: false, | ||
| anim: { | ||
| enable: false, | ||
| speed: 1, | ||
| opacity_min: 0.1, | ||
| sync: false, | ||
| }, | ||
| }, | ||
| size: { | ||
| value: 3, | ||
| random: true, | ||
| anim: { | ||
| enable: false, | ||
| speed: 40, | ||
| size_min: 0.1, | ||
| sync: false, | ||
| }, | ||
| }, | ||
| line_linked: { | ||
| enable: true, | ||
| distance: 150, | ||
| color: '#9580FF', | ||
| opacity: 0.1, | ||
| width: 1, | ||
| }, | ||
| move: { | ||
| enable: true, | ||
| speed: 6, | ||
| direction: 'none', | ||
| random: false, | ||
| straight: false, | ||
| out_mode: 'out', | ||
| bounce: false, | ||
| attract: { | ||
| enable: false, | ||
| rotateX: 600, | ||
| rotateY: 1200, | ||
| }, | ||
| }, | ||
| }, | ||
| }; | ||
|
|
||
| type Props = { classes: Record<string, string> }; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I discover how to fix it and avoid it! import { WithStyles } from '@material-ui/core/styles';
interface Props extends WithStyles<typeof BackgroundParticlesStyles> {
// other props
} |
||
|
|
||
| export const BackgroundParticles = ({ classes }: Props): React.ReactElement => { | ||
| return <Particles style={styles} params={params} className={classes.root} />; | ||
| }; | ||
|
|
||
| export default useStyles(BackgroundParticles); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import React from 'react'; | ||
| import useStyles from './styles'; | ||
|
|
||
| type Props = { | ||
| code: string; | ||
| message: string; | ||
| description: string; | ||
| classes: any; | ||
| }; | ||
|
|
||
| export const PageError = ({ classes, code, message, description }: Props): React.ReactElement => { | ||
| return ( | ||
| <div className={classes.container}> | ||
| <h1 className={classes.h1}> | ||
| {code} <small>{message}</small> | ||
| </h1> | ||
| <h2 className={classes.h2}>{description}</h2> | ||
| <img src="/site/about_img3.png" className={classes.errorImage} /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default useStyles(PageError); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { withStyles } from '@material-ui/core/styles'; | ||
|
|
||
| const useStyles = withStyles((theme) => ({ | ||
| container: { | ||
| height: '100vh', | ||
| justifyContent: 'center', | ||
| alignItems: 'center', | ||
| display: 'flex', | ||
| flexDirection: 'column', | ||
| position: 'relative', | ||
| zIndex: 2, | ||
| }, | ||
| errorImage: { | ||
| maxWidth: '300px', | ||
| }, | ||
| h1: { | ||
| padding: '0', | ||
| margin: '0', | ||
| fontSize: '120px', | ||
| textAlign: 'center', | ||
| fontWeight: 'bold', | ||
| color: theme.palette.primary.main, | ||
| lineHeight: '75px', | ||
| '& > small': { | ||
| textTransform: 'uppercase', | ||
| display: 'block', | ||
| fontSize: '20%', | ||
| }, | ||
| }, | ||
| h2: { | ||
| color: '#FFFFFF', | ||
| fontWeight: 'bold', | ||
| maxWidth: '300px', | ||
| textAlign: 'center', | ||
| margin: '0 0 40px', | ||
| }, | ||
| })); | ||
|
|
||
| export default useStyles; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import React from 'react'; | ||
| import PageError from '~/components/PageError'; | ||
| import BackgroundParticles from '~/components/BackgroundParticles'; | ||
|
|
||
| export const PageNotFound = (): React.ReactElement => ( | ||
| <> | ||
| <PageError | ||
| code="404" | ||
| message="page not found" | ||
| description="We are sorry but the page are looking for does not exist." | ||
| /> | ||
| <BackgroundParticles /> | ||
| </> | ||
| ); | ||
|
|
||
| export default PageNotFound; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import React from 'react'; | ||
| import { shallow } from 'enzyme'; | ||
| import BackgroundParticles from './../../src/components/BackgroundParticles'; | ||
| import Particles from 'react-particles-js'; | ||
|
|
||
| describe('components/BackgroundParticles', () => { | ||
| it('should render component properly', () => { | ||
| const wrap = shallow(<BackgroundParticles />); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You not test it properly! You should chec toContainsElement en see if it calls Particle with correct arguments. |
||
|
|
||
| expect(wrap.find(Particles)).toMatchSnapshot(); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import React from 'react'; | ||
| import { shallow } from 'enzyme'; | ||
| import { PageError } from '../../src/components/PageError'; | ||
|
|
||
| describe('components/PageError', () => { | ||
| it('should render component properly', () => { | ||
| const fakeCode = '404'; | ||
| const fakeDescription = 'bar'; | ||
| const fakeMessage = 'foo'; | ||
| const wrap = shallow( | ||
| <PageError classes={{}} code={fakeCode} message={fakeMessage} description={fakeDescription} />, | ||
| ); | ||
| console.log(wrap.debug()); | ||
| expect(wrap.find('h1')).toHaveText(`${fakeCode} ${fakeMessage}`); | ||
| expect(wrap.find('h2')).toHaveText(fakeDescription); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import React from 'react'; | ||
|
|
||
| import { shallow } from 'enzyme'; | ||
|
|
||
| import PageNotFound from '../../src/pages/404'; | ||
| import PageError from '../../src/components/PageError'; | ||
| import BackgroundParticles from './../../src/components/BackgroundParticles'; | ||
|
|
||
| describe('pages/404', () => { | ||
| it('should render correctly items on 404 page', () => { | ||
| const wrap = shallow(<PageNotFound />); | ||
| expect(wrap).toContainMatchingElement(PageError); | ||
| expect(wrap).toContainMatchingElement(BackgroundParticles); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will need that you change it to: