Skip to content

Commit b58c84e

Browse files
committed
feat(demo): initial router setup
1 parent 3d4a607 commit b58c84e

File tree

4 files changed

+53
-2
lines changed

4 files changed

+53
-2
lines changed

src/components/index.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,7 @@ const Components = () => {
9393
);
9494
};
9595

96+
Components.path = `/components`;
97+
Components.title = `Components`;
98+
9699
export default Components;

src/demo-home/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react';
2+
3+
const DemoHome = () =>
4+
<div>
5+
<h2>{`Welcome to the Spark React Components Example Page`}</h2>
6+
</div>;
7+
8+
DemoHome.title = `Home`;
9+
DemoHome.path = `/`;
10+
11+
export default DemoHome;

src/demo-wrapper/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import {IndexLink, Link} from 'react-router';
3+
import DemoHome from '../demo-home';
4+
import Components from '../components';
5+
6+
const DemoWrapper = (props) => {
7+
const title = `Spark React Components`;
8+
return (
9+
<div>
10+
<h1>{title}</h1>
11+
<ul>
12+
<li><IndexLink to={DemoHome.path}>{DemoHome.title}</IndexLink></li>
13+
<li><Link to={Components.path}>{Components.title}</Link></li>
14+
</ul>
15+
{props.children}
16+
</div>
17+
);
18+
};
19+
20+
DemoWrapper.propTypes = {
21+
children: React.PropTypes.node
22+
};
23+
24+
export default DemoWrapper;

src/demo.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom';
3+
import {Router, Route, IndexRoute, hashHistory} from 'react-router';
34

45
import {IntlProvider} from 'react-intl';
56
import messages from './locales/en';
67

8+
import DemoWrapper from './demo-wrapper';
9+
import DemoHome from './demo-home';
710
import Components from './components';
811

9-
1012
ReactDOM.render(
1113
<IntlProvider locale={`en`} messages={messages}>
12-
<Components />
14+
<Router history={hashHistory}>
15+
<Route
16+
component={DemoWrapper}
17+
path="/"
18+
>
19+
<IndexRoute component={DemoHome} />
20+
<Route
21+
component={Components}
22+
path={Components.path}
23+
/>
24+
</Route>
25+
</Router>
1326
</IntlProvider>,
1427
document.getElementById(`main`)
1528
);

0 commit comments

Comments
 (0)