This repository has been archived by the owner on Apr 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add skipInitialTransition prop (#29)
* Added skipInitialTransition prop * Updated README.md to contain info about skipInitialTransition prop * Added example called skip-initial-transition
- Loading branch information
1 parent
8c353e7
commit 72f761f
Showing
8 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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,3 @@ | ||
{ | ||
"presets": ["next/babel"] | ||
} |
This file contains 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,11 @@ | ||
{ | ||
"scripts": { | ||
"dev": "next dev" | ||
}, | ||
"dependencies": { | ||
"next": "^8.0.3", | ||
"next-page-transitions": "*", | ||
"react": "^16.8.4", | ||
"react-dom": "^16.8.4" | ||
} | ||
} |
This file contains 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,45 @@ | ||
import App, { Container } from 'next/app' | ||
import React from 'react' | ||
|
||
import { PageTransition } from 'next-page-transitions' | ||
|
||
export default class MyApp extends App { | ||
static async getInitialProps({ Component, ctx }) { | ||
let pageProps = {} | ||
|
||
if (Component.getInitialProps) { | ||
pageProps = await Component.getInitialProps(ctx) | ||
} | ||
|
||
return { pageProps } | ||
} | ||
|
||
render() { | ||
const { Component, pageProps } = this.props | ||
return ( | ||
<Container> | ||
<PageTransition skipInitialTransition={true} timeout={300} classNames="page-transition"> | ||
<Component {...pageProps} /> | ||
</PageTransition> | ||
<style jsx global>{` | ||
.page-transition-enter { | ||
opacity: 0; | ||
transform: translate3d(0, 20px, 0); | ||
} | ||
.page-transition-enter-active { | ||
opacity: 1; | ||
transform: translate3d(0, 0, 0); | ||
transition: opacity 300ms, transform 300ms; | ||
} | ||
.page-transition-exit { | ||
opacity: 1; | ||
} | ||
.page-transition-exit-active { | ||
opacity: 0; | ||
transition: opacity 300ms; | ||
} | ||
`}</style> | ||
</Container> | ||
) | ||
} | ||
} |
This file contains 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,32 @@ | ||
import React from 'react' | ||
import Document, { Head, Main, NextScript } from 'next/document' | ||
|
||
export default class MyDocument extends Document { | ||
static async getInitialProps(ctx) { | ||
const initialProps = await Document.getInitialProps(ctx) | ||
return { ...initialProps } | ||
} | ||
|
||
render() { | ||
return ( | ||
<html lang="en"> | ||
<Head> | ||
<meta | ||
name="viewport" | ||
content="initial-scale=1.0, width=device-width" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" | ||
integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" | ||
crossOrigin="anonymous" | ||
/> | ||
</Head> | ||
<body> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</html> | ||
) | ||
} | ||
} |
This file contains 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,20 @@ | ||
import React, { Fragment } from 'react' | ||
import Link from 'next/link' | ||
|
||
const About = () => ( | ||
<Fragment> | ||
<div className="container-fluid bg-success page"> | ||
<h1>About us</h1> | ||
<Link href="/"> | ||
<a className="btn btn-light">Go back home</a> | ||
</Link> | ||
<style jsx>{` | ||
.page { | ||
height: 100vh; | ||
} | ||
`}</style> | ||
</div> | ||
</Fragment> | ||
) | ||
|
||
export default About |
This file contains 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,18 @@ | ||
import React from 'react' | ||
import Link from 'next/link' | ||
|
||
const Index = () => ( | ||
<div className="container bg-primary page"> | ||
<h1>Hello, world!</h1> | ||
<Link href="/about"> | ||
<a className="btn btn-light">About us</a> | ||
</Link> | ||
<style jsx>{` | ||
.page { | ||
height: 100vh; | ||
} | ||
`}</style> | ||
</div> | ||
) | ||
|
||
export default Index |
This file contains 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