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 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+ ```
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import ReactDOM from 'react-dom' ;
3- import { BrowserRouter as Router , Route } from 'react-router-dom' ;
3+ import { HashRouter as Router , Route } from 'react-router-dom' ;
44import '@atlaskit/css-reset' ;
55
66import Header from './components/Header' ;
7- import Home from './pages/home' ;
7+ // import Home from './pages/home';
88import PackageDoc from './pages/PackageDoc' ;
99import Repl from './pages/repl' ;
1010
Original file line number Diff line number Diff line change @@ -11,9 +11,13 @@ const kebabToTitleCase = string =>
1111 string
1212 . replace ( / .m d $ / , '' )
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
1822export 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 >
You can’t perform that action at this time.
0 commit comments