Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lesnitsky committed Dec 7, 2018
0 parents commit 52b1cd4
Show file tree
Hide file tree
Showing 10 changed files with 5,072 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
sandbox
node_modules
.DS_Store
.next
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "es5",
"printWidth": 120,
"tabWidth": 4,
"singleQuote": true
}
Empty file added README.md
Empty file.
19 changes: 19 additions & 0 deletions components/Example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default ({ children, reactnative, flutter }) => (
<div className="example-container">
{reactnative ? <h2>React Native</h2> : null}
{flutter ? <h2>Flutter</h2> : null}

{children}
<style jsx>{`
.example-container {
flex-basis: 50%;
box-sizing: border-box;
padding: 10px;
}
h2 {
color: #6196cc;
}
`}</style>
</div>
);
10 changes: 10 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const rehypePrism = require('@mapbox/rehype-prism');
const withMDX = require('@zeit/next-mdx')({
options: {
hastPlugins: [rehypePrism],
},
extension: /\.(md|mdx)$/,
});
const withCSS = require('@zeit/next-css');

module.exports = withCSS(withMDX());
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "howtodothisinflutter",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"author": "",
"license": "ISC",
"devDependencies": {
"next": "^7.0.2",
"react": "^16.6.3",
"react-dom": "^16.6.3"
},
"dependencies": {
"@mapbox/rehype-prism": "^0.3.0",
"@mdx-js/mdx": "^0.16.5",
"@zeit/next-css": "^1.0.1",
"@zeit/next-mdx": "^1.2.0",
"prismjs": "^1.15.0"
}
}
19 changes: 19 additions & 0 deletions pages/_document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Document, { Head, Main, NextScript } from 'next/document';

export default class MyDocument extends Document {
render() {
return (
<html>
<Head>
<title>How to do this in Flutter</title>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<style>{`body { margin: 0; background: #212121; color: white; font-family: sans-serif; }`}</style>
</Head>
<body>
<Main />
<NextScript />
</body>
</html>
);
}
}
29 changes: 29 additions & 0 deletions pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import 'prismjs/themes/prism-tomorrow.css';

import Fetch from '../recipes/fetch.md';

export default () => (
<div className="app">
<Fetch />

<style jsx global>{`
h1 {
width: 100%;
}
.app {
width: 70%;
margin: 0 auto;
}
.app > div {
display: flex;
flex-wrap: wrap;
}
h1 {
color: #cc99cd;
}
`}</style>
</div>
);
32 changes: 32 additions & 0 deletions recipes/fetch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Example from '../components/Example';

# Fetching data

<Example reactnative>

```js
fetch('https://somedomain.com/api')
.then(res => res.json())
.then(console.log);
```

</Example>

<Example flutter>

```yaml
dependencies:
http: ^0.12.0
```
```dart
import 'dart:convert'; // json
import 'package:http/http.dart' as http;

http.get('someurl').then((http.Response res) {
final data = json.decode(res.body);
});

```

</Example>
Loading

0 comments on commit 52b1cd4

Please sign in to comment.