File tree Expand file tree Collapse file tree 3 files changed +66
-5
lines changed Expand file tree Collapse file tree 3 files changed +66
-5
lines changed Original file line number Diff line number Diff line change 1
1
# Getting Started
2
2
3
+ Please add pretty-proptypes as dependency to the project,
3
4
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
+ ```
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
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' ;
4
4
import '@atlaskit/css-reset' ;
5
5
6
6
import Header from './components/Header' ;
7
- import Home from './pages/home' ;
7
+ // import Home from './pages/home';
8
8
import PackageDoc from './pages/PackageDoc' ;
9
9
import Repl from './pages/repl' ;
10
10
Original file line number Diff line number Diff line change @@ -11,9 +11,13 @@ const kebabToTitleCase = string =>
11
11
string
12
12
. replace ( / .m d $ / , '' )
13
13
. replace ( / ^ [ 0 - 9 ] * / , '' )
14
- . replace ( / - ( [ a - z ] ) / g, s => ` ${ s [ 1 ] } ` ) ;
14
+ . replace ( / - ( [ a - z ] ) / g, s => ` ${ s [ 1 ] . toUpperCase ( ) } ` ) ;
15
15
16
- const CodeBlock = ( { value } ) => < AkCodeBlock text = { value } /> ;
16
+ const CodeBlock = ( { value } ) => (
17
+ < div style = { { marginTop : '10px' } } >
18
+ < AkCodeBlock text = { value } />
19
+ </ div >
20
+ ) ;
17
21
18
22
export default function PackageDoc ( { location } ) {
19
23
let params = new URLSearchParams ( location . search ) ;
@@ -26,7 +30,15 @@ export default function PackageDoc({ location }) {
26
30
< h2 > Documentation</ h2 >
27
31
< ul >
28
32
{ 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
+ >
30
42
< Link to = { { pathname : '/' , search : `package=${ docTitle } ` } } >
31
43
{ kebabToTitleCase ( docTitle ) }
32
44
</ Link >
You can’t perform that action at this time.
0 commit comments