Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added example with flow #814

Merged
merged 2 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/with-flow/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": [
"next/babel"
],
"plugins": [
"transform-flow-strip-types"
]
}
7 changes: 7 additions & 0 deletions examples/with-flow/.flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ignore]

[include]

[libs]

[options]
29 changes: 29 additions & 0 deletions examples/with-flow/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Example app with [Flow](https://flowtype.org/)

## How to use

Download the example [or clone the repo](https://github.com/zeit/next.js):

```bash
curl https://codeload.github.com/zeit/next.js/tar.gz/master | tar -xz --strip=2 next.js-master/examples/with-styled-components
cd with-flow
```

Install it and run:

```bash
npm install
npm run dev
```

Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))

```bash
now
```

## The idea behind the example

This example shows how you can use Flow, with the transform-flow-strip-types babel plugin stripping flow type annotations from your output code.

![with-flow](with-flow.gif)
31 changes: 31 additions & 0 deletions examples/with-flow/components/layout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// @flow

import type {Element} from 'React'
import Link from 'next/link'
import Head from 'next/head'

type Props = {
children?: Element<any>,
title?: string
}

export default ({children, title = 'This is the default title'}: Props) => (
<div>
<Head>
<title>{title}</title>
<meta charSet='utf-8' />
<meta name='viewport' content='initial-scale=1.0, width=device-width' />
</Head>
<header>
<nav>
<Link href='/'><a>Home</a></Link>|
<Link href='/about'><a>About</a></Link>|
<Link href='/contact'><a>Contact</a></Link>
</nav>
</header>
{children}
<footer>
I`m here to stay
</footer>
</div>
)
20 changes: 20 additions & 0 deletions examples/with-flow/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "with-flow",
"version": "1.0.0",
"license": "MIT",
"author": "Jag Reehal",
"scripts": {
"dev": "next",
"build": "next build",
"flow": "flow; test $? -eq 0 -o $? -eq 2",
"start": "next start"
},
"dependencies": {
"next": "^2.0.0-beta"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"babel-plugin-transform-flow-strip-types": "^6.21.0",
"flow-bin": "^0.37.4"
}
}
9 changes: 9 additions & 0 deletions examples/with-flow/pages/about.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @flow

import Layout from '../components/layout'

export default () => (
<Layout title='About us'>
<div>About us</div>
</Layout>
)
9 changes: 9 additions & 0 deletions examples/with-flow/pages/contact.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @flow

import Layout from '../components/layout'

export default () => (
<Layout title='Contact us'>
<div>Contact</div>
</Layout>
)
9 changes: 9 additions & 0 deletions examples/with-flow/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// @flow

import Layout from '../components/layout'

export default () => (
<Layout>
<div>Hello World.</div>
</Layout>
)
Binary file added examples/with-flow/with-flow.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.