Skip to content

Commit

Permalink
Merge branch 'canary' into patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
lharries authored Dec 31, 2020
2 parents b95b3bf + 088f374 commit 35f66cc
Show file tree
Hide file tree
Showing 31 changed files with 4,129 additions and 97 deletions.
1 change: 1 addition & 0 deletions docs/api-reference/next/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The following is the definition of the `router` object returned by both [`useRou
- `locale`: `String` - The active locale (if enabled).
- `locales`: `String[]` - All supported locales (if enabled).
- `defaultLocale`: `String` - The current default locale (if enabled).
- `isReady`: `boolean` - Whether the router fields are updated client-side and ready for use. Should only be used inside of `useEffect` methods and not for conditionally rendering on the server.

Additionally, the following methods are also included inside `router`:

Expand Down
35 changes: 35 additions & 0 deletions examples/with-mdbreact/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

/.idea
# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local

# vercel
.vercel
21 changes: 21 additions & 0 deletions examples/with-mdbreact/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# mdbreact Example

This example shows how to use [MDBReact](https://mdbootstrap.com/docs/react) with Next.js.

## Deploy your own

Deploy the example using [Vercel](https://vercel.com):

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/import/git?s=https://github.com/vercel/next.js/tree/canary/examples/with-mdbreact)

## How to use

Execute [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app) with [npm](https://docs.npmjs.com/cli/init) or [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) to bootstrap the example:

```bash
npx create-next-app --example with-mdbreact with-mdbreact-app
# or
yarn create next-app --example with-mdbreact with-mdbreact-app
```

Deploy it to the cloud with [Vercel](https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=readme&utm_campaign=next-example) ([Documentation](https://nextjs.org/docs/deployment)).
16 changes: 16 additions & 0 deletions examples/with-mdbreact/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "with-mdbreact",
"version": "0.1.0",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"mdbreact": "^5.0.0",
"next": "latest",
"react": "17.0.1",
"react-dom": "17.0.1"
},
"license": "MIT"
}
10 changes: 10 additions & 0 deletions examples/with-mdbreact/pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import '@fortawesome/fontawesome-free/css/all.min.css'
import 'bootstrap-css-only/css/bootstrap.min.css'
import 'mdbreact/dist/css/mdb.css'
import '../styles/globals.css'

function MyApp({ Component, pageProps }) {
return <Component {...pageProps} />
}

export default MyApp
118 changes: 118 additions & 0 deletions examples/with-mdbreact/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import Head from 'next/head'
import {
MDBBtn,
MDBCard,
MDBCardBody,
MDBCardText,
MDBCardTitle,
MDBCol,
MDBContainer,
MDBFooter,
MDBRow,
} from 'mdbreact'

export default function Home() {
return (
<>
<Head>
<title>NextJS with Material Design Bootstrap for React</title>
<link rel="icon" href="/favicon.ico" />
</Head>
<MDBContainer className="text-center mt-5">
<h1 className="h1-responsive font-weight-bolder">
Welcome to <a href="https://nextjs.org">Next.js!</a>
</h1>
<p className="mb-3">
Get started by editing <code>pages/index.js</code>
</p>
<MDBRow>
<MDBCol sm="6">
<MDBCard className="my-3">
<MDBCardBody>
<MDBCardTitle tag="h5">Documentation</MDBCardTitle>
<MDBCardText>
Find in-depth information about Next.js features and API.
</MDBCardText>
<MDBBtn
color="primary"
size="sm"
className="text-capitalize"
href="https://nextjs.org/docs"
>
More &rarr;
</MDBBtn>
</MDBCardBody>
</MDBCard>
</MDBCol>
<MDBCol sm="6">
<MDBCard className="my-3">
<MDBCardBody>
<MDBCardTitle tag="h5">Learn</MDBCardTitle>
<MDBCardText>
Learn about Next.js in an interactive course with quizzes!
</MDBCardText>
<MDBBtn
color="primary"
size="sm"
className="text-capitalize"
href="https://nextjs.org/learn"
>
More &rarr;
</MDBBtn>
</MDBCardBody>
</MDBCard>
</MDBCol>
</MDBRow>
<MDBRow>
<MDBCol sm="6">
<MDBCard className="my-3">
<MDBCardBody>
<MDBCardTitle tag="h5">Examples</MDBCardTitle>
<MDBCardText>
Discover and deploy boilerplate example Next.js projects.
</MDBCardText>
<MDBBtn
color="primary"
size="sm"
className="text-capitalize"
href="https://github.com/vercel/next.js/tree/master/examples"
>
More &rarr;
</MDBBtn>
</MDBCardBody>
</MDBCard>
</MDBCol>
<MDBCol sm="6">
<MDBCard className="my-3">
<MDBCardBody>
<MDBCardTitle tag="h5">Deploy</MDBCardTitle>
<MDBCardText>
Instantly deploy your Next.js site to a public URL with
Vercel.
</MDBCardText>
<MDBBtn
color="primary"
size="sm"
className="text-capitalize"
href="https://vercel.com/import?filter=next.js&utm_source=github&utm_medium=example&utm_campaign=next-example"
>
More &rarr;
</MDBBtn>
</MDBCardBody>
</MDBCard>
</MDBCol>
</MDBRow>
<MDBFooter className="text-center mt-4" color="white">
<span className="black-text"> Powered by</span>
<a
href="https://vercel.com?filter=next.js&utm_source=github&utm_medium=example&utm_campaign=next-example"
target="_blank"
rel="noopener noreferrer"
>
<img src="/vercel.svg" alt="Vercel Logo" />
</a>
</MDBFooter>
</MDBContainer>
</>
)
}
Binary file added examples/with-mdbreact/public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions examples/with-mdbreact/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions examples/with-mdbreact/styles/globals.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}

a {
color: inherit;
text-decoration: none;
}

* {
box-sizing: border-box;
}
2 changes: 1 addition & 1 deletion examples/with-mongodb-mongoose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"mongoose": "^5.9.13",
"next": "^9.4.2",
"next": "latest",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"swr": "0.2.2"
Expand Down
4 changes: 2 additions & 2 deletions packages/next/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ declare global {

type RenderRouteInfo = PrivateRouteInfo & {
App: AppComponent
scroll?: boolean
scroll?: { x: number; y: number } | null
}
type RenderErrorProps = Omit<RenderRouteInfo, 'Component' | 'styleSheets'>

Expand Down Expand Up @@ -753,7 +753,7 @@ function doRender(input: RenderRouteInfo): Promise<any> {
}

if (input.scroll) {
window.scrollTo(0, 0)
window.scrollTo(input.scroll.x, input.scroll.y)
}
}

Expand Down
1 change: 1 addition & 0 deletions packages/next/client/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const urlPropertyFields = [
'locale',
'locales',
'defaultLocale',
'isReady',
]
const routerEvents = [
'routeChangeStart',
Expand Down
Loading

0 comments on commit 35f66cc

Please sign in to comment.