Skip to content

Commit 16e555c

Browse files
committed
added the getting started docs
1 parent afa6d9a commit 16e555c

File tree

3 files changed

+66
-5
lines changed

3 files changed

+66
-5
lines changed

docs/01-getting-started.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,52 @@
11
# Getting Started
22

3+
Please add pretty-proptypes as dependency to the project,
34

5+
```sh
6+
yarn add pretty-proptypes
7+
```
8+
9+
## Using webpack loader
10+
11+
Add the extract-react-types-loader as dev dependency,
12+
13+
```bash
14+
yarn add extract-react-types-loader --dev
15+
```
16+
17+
We can use webpack's inline loader feature to create documentation,
18+
19+
```jsx
20+
import Props from 'pretty-proptypes';
21+
22+
// render the props documentation on the page
23+
<Props
24+
heading="My Cool Component"
25+
props={require('!!extract-react-types-loader!../MyCoolComponent')}
26+
/>
27+
```
28+
29+
## Using Babel plugin
30+
31+
Add the babel-plugin-extract-react-types as dev dependency,
32+
33+
```bash
34+
yarn add babel-plugin-extract-react-types --dev
35+
```
36+
37+
Update the babel config to use this plugin,
38+
39+
```js
40+
{
41+
"plugins": ["babel-plugin-extract-react-types"]
42+
}
43+
```
44+
45+
```js
46+
import MyCoolComponent from 'MyCoolComponent';
47+
import Props from 'pretty-proptypes';
48+
49+
<Props
50+
heading="My Cool Component"
51+
props={MyCoolComponent)}
52+
```

website/src/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3-
import { BrowserRouter as Router, Route } from 'react-router-dom';
3+
import { HashRouter as Router, Route } from 'react-router-dom';
44
import '@atlaskit/css-reset';
55

66
import Header from './components/Header';
7-
import Home from './pages/home';
7+
// import Home from './pages/home';
88
import PackageDoc from './pages/PackageDoc';
99
import Repl from './pages/repl';
1010

website/src/pages/PackageDoc/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@ const kebabToTitleCase = string =>
1111
string
1212
.replace(/.md$/, '')
1313
.replace(/^[0-9]*/, '')
14-
.replace(/-([a-z])/g, s => ` ${s[1]}`);
14+
.replace(/-([a-z])/g, s => ` ${s[1].toUpperCase()}`);
1515

16-
const CodeBlock = ({ value }) => <AkCodeBlock text={value} />;
16+
const CodeBlock = ({ value }) => (
17+
<div style={{ marginTop: '10px' }}>
18+
<AkCodeBlock text={value} />
19+
</div>
20+
);
1721

1822
export default function PackageDoc({ location }) {
1923
let params = new URLSearchParams(location.search);
@@ -26,7 +30,15 @@ export default function PackageDoc({ location }) {
2630
<h2>Documentation</h2>
2731
<ul>
2832
{Object.keys(staticDocs).map(docTitle => (
29-
<li key={docTitle} className={docName && docName === docTitle ? 'active' : ''}>
33+
<li
34+
key={docTitle}
35+
className={
36+
(docName && docName === docTitle) ||
37+
(docName == null && docTitle === '01-getting-started.md')
38+
? 'active'
39+
: ''
40+
}
41+
>
3042
<Link to={{ pathname: '/', search: `package=${docTitle}` }}>
3143
{kebabToTitleCase(docTitle)}
3244
</Link>

0 commit comments

Comments
 (0)