Skip to content

Commit ed6bca1

Browse files
committed
added docs to website
1 parent d44df7c commit ed6bca1

File tree

16 files changed

+669
-12
lines changed

16 files changed

+669
-12
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"bolt": {
2020
"workspaces": [
2121
"packages/*",
22-
"website"
22+
"website",
23+
"website/loaders/*"
2324
]
2425
},
2526
"preconstruct": {
@@ -87,6 +88,7 @@
8788
"react": "^16.3.1",
8889
"react-addons-test-utils": "^15.6.2",
8990
"react-dom": "^16.3.1",
91+
"style-loader": "^0.23.1",
9092
"webpack": "^4.29.6",
9193
"webpack-cli": "^3.3.0",
9294
"webpack-dev-server": "^3.2.1"

website/.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["@babel/preset-react", "@babel/preset-env"]
2+
"presets": ["@babel/preset-react", "@babel/preset-env"],
3+
"plugins": ["@babel/plugin-proposal-class-properties"]
34
}

website/DOCS

Whitespace-only changes.

website/loaders/docs-loader/index.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const bolt = require('bolt');
2+
const path = require('path');
3+
const fs = require('fs');
4+
const { promisify } = require('util');
5+
6+
const readFile = promisify(fs.readFile);
7+
const fsStat = promisify(fs.stat);
8+
9+
module.exports = async function docsLoader() {
10+
let docs = {};
11+
const ws = await bolt.getWorkspaces();
12+
13+
for (let workspace of ws) {
14+
const readMeExists = fs.existsSync(path.resolve(workspace.dir, 'README.md'));
15+
if (readMeExists) {
16+
docs[workspace.name] = await readFile(path.join(workspace.dir, 'README.md'), 'utf-8');
17+
}
18+
}
19+
20+
return `export default ${JSON.stringify(docs)}`;
21+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"name": "docs-loader",
3+
"version": "0.0.0",
4+
"main": "index.js"
5+
}

website/package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@
22
"name": "website",
33
"version": "0.0.0",
44
"dependencies": {
5+
"bolt": "^0.22.6",
6+
"css-loader": "^2.1.1",
7+
"extract-react-types": "^0.16.0",
8+
"lz-string": "^1.4.4",
9+
"pretty-proptypes": "^0.6.0",
510
"react": "^16.3.1",
6-
"react-dom": "^16.3.1"
11+
"react-codemirror": "^1.0.0",
12+
"react-dom": "^16.3.1",
13+
"react-markdown": "^4.0.6",
14+
"react-router-dom": "^5.0.0"
715
},
816
"devDependencies": {
917
"@babel/core": "^7.4.0",
18+
"@babel/plugin-proposal-class-properties": "^7.4.0",
1019
"@babel/preset-env": "^7.4.2",
1120
"@babel/preset-react": "^7.0.0",
1221
"babel-loader": "^8.0.5",
1322
"html-webpack-plugin": "^3.2.0",
23+
"null-loader": "^0.1.1",
24+
"style-loader": "^0.23.1",
1425
"webpack": "^4.29.6",
1526
"webpack-cli": "^3.3.0",
1627
"webpack-dev-server": "^3.2.1"

website/src/app.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3+
import ReactMarkdown from 'react-markdown';
4+
import { HashRouter as Router, Route, Link } from 'react-router-dom';
35

4-
const App = () => <div>Hello World!</div>;
6+
import docs from '../DOCS';
7+
import Header from './components/Header';
8+
import Home from './pages/home';
9+
import PackageDoc from './pages/PackageDoc';
10+
import Repl from './pages/Repl';
11+
12+
const App = () => (
13+
<Router>
14+
<Header />
15+
<Route path="/" exact component={Home} />
16+
<Route path="/packages" component={PackageDoc} />
17+
<Route path="/repl" component={Repl} />
18+
</Router>
19+
);
20+
21+
/**Sample code to print markdown from html */
22+
/*
23+
{Object.keys(docs).map(doc => (
24+
<ReactMarkdown source={docs[doc]} />
25+
))}
26+
*/
527

628
const root = document.createElement('div');
729
root.id = 'root';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
import { Link } from 'react-router-dom';
3+
import './style.css';
4+
5+
export default () => (
6+
<nav>
7+
<Link to="/">Home</Link>
8+
<Link to="/packages">Packages</Link>
9+
<Link to="/repl">Try it out</Link>
10+
</nav>
11+
);

website/src/components/Header/style.css

Whitespace-only changes.

website/src/pages/App.css

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
.container {
2+
display: flex;
3+
height: calc(100vh - 80px);
4+
}
5+
6+
.container .block {
7+
flex: 0 0 50%;
8+
border: 1px solid #a1a1a1;
9+
}
10+
11+
.container .block.proptypes {
12+
padding: 15px;
13+
box-sizing: border-box;
14+
}
15+
16+
.container .block .ReactCodeMirror {
17+
height: 100%;
18+
}
19+
20+
.side-bar {
21+
background: linear-gradient(270deg, #6738ff, #c3ffbf);
22+
color: #6554c0;
23+
padding: 15px;
24+
display: flex;
25+
align-items: center;
26+
justify-content: space-between;
27+
height: 50px;
28+
}
29+
30+
.side-bar h1 {
31+
display: inline-block;
32+
text-shadow: 7px 6px 20px #6a4fc6;
33+
margin: 5px;
34+
}
35+
36+
.side-bar .header-controls {
37+
color: #c0feba;
38+
}
39+
40+
.side-bar .header-controls select {
41+
margin-left: 10px;
42+
}
43+
44+
.error-container {
45+
position: absolute;
46+
bottom: 0;
47+
background: rgb(255, 0, 0);
48+
width: 100%;
49+
height: 200px;
50+
overflow: scroll;
51+
margin: 0;
52+
}
53+
54+
.CodeMirror {
55+
height: 100%;
56+
}

0 commit comments

Comments
 (0)