|
1 | 1 | import 'babel-core/polyfill';
|
| 2 | + |
2 | 3 | import React from 'react';
|
3 | 4 | import ReactDOM from 'react-dom';
|
4 |
| -import Header from './components/Header.js'; |
5 |
| -import Footer from './components/Footer.js'; |
6 |
| -import ProgressBar from 'react-progress-bar-plus'; |
| 5 | +import {createHistory, useBasename} from 'history'; |
| 6 | +import Router from 'react-router'; |
| 7 | +import App from 'components/App.js'; |
| 8 | +import {name} from '../../package.json'; |
7 | 9 |
|
8 |
| -import './bower_components/bootstrap-customize/css/bootstrap.css'; |
| 10 | +import 'assets/bower_components/bootstrap-customize/css/bootstrap.css'; |
9 | 11 | import 'react-progress-bar-plus/src/progress-bar.scss';
|
10 |
| -import './assets/styles/app.scss'; |
11 |
| - |
12 |
| -class App extends React.Component { |
13 |
| - state = { |
14 |
| - percent: -1, |
15 |
| - autoIncrement: false, |
16 |
| - intervalTime: 200 |
17 |
| - }; |
18 |
| - |
19 |
| - setPercent = (percent) => { |
20 |
| - return () => { |
21 |
| - this.setState({ |
22 |
| - percent: percent |
23 |
| - }); |
24 |
| - }; |
25 |
| - }; |
26 |
| - |
27 |
| - startWithAutoIncrement = () => { |
28 |
| - this.setState({ |
29 |
| - percent: 0, |
30 |
| - autoIncrement: true, |
31 |
| - intervalTime: (Math.random() * 1000) |
32 |
| - }); |
33 |
| - }; |
34 |
| - |
35 |
| - render() { |
36 |
| - return ( |
37 |
| - <div className='layout-page'> |
38 |
| - <Header/> |
39 |
| - <main className='layout-main'> |
40 |
| - <div className='container'> |
41 |
| - <ProgressBar percent={this.state.percent} |
42 |
| - autoIncrement={this.state.autoIncrement} |
43 |
| - intervalTime={this.state.intervalTime}/> |
44 |
| - |
45 |
| - <div className='text-center'> |
46 |
| - <div className='btn-group'> |
47 |
| - <button className='btn btn-default' |
48 |
| - onClick={this.setPercent(0)}> |
49 |
| - Start |
50 |
| - </button> |
51 |
| - <button className='btn btn-default' |
52 |
| - onClick={this.setPercent(25)}> |
53 |
| - Set 25 |
54 |
| - </button> |
55 |
| - <button className='btn btn-default' |
56 |
| - onClick={this.setPercent(50)}> |
57 |
| - Set 50 |
58 |
| - </button> |
59 |
| - <button className='btn btn-default' |
60 |
| - onClick={this.setPercent(75)}> |
61 |
| - Set 75 |
62 |
| - </button> |
63 |
| - <button className='btn btn-default' |
64 |
| - onClick={this.setPercent(100)}>Finish |
65 |
| - </button> |
66 |
| - </div> |
67 |
| - </div> |
68 |
| - <hr/> |
69 |
| - <div className='text-center'> |
70 |
| - <h4> |
71 |
| - Current intervalTime: <code>{this.state.intervalTime}</code> |
72 |
| - </h4> |
73 |
| - |
74 |
| - <div className='btn-group'> |
75 |
| - <button className='btn btn-default' |
76 |
| - onClick={this.startWithAutoIncrement}> |
77 |
| - Start with auto increment |
78 |
| - </button> |
79 |
| - <button className='btn btn-default' |
80 |
| - onClick={this.setPercent(100)}> |
81 |
| - Finish |
82 |
| - </button> |
83 |
| - </div> |
84 |
| - </div> |
85 |
| - </div> |
86 |
| - </main> |
87 |
| - <Footer/> |
88 |
| - </div> |
89 |
| - ); |
90 |
| - } |
91 |
| -} |
92 |
| - |
93 |
| -function run() { |
94 |
| - ReactDOM.render(<App />, document.getElementById('app')); |
95 |
| -} |
| 12 | +import 'assets/styles/app.scss'; |
| 13 | + |
| 14 | +const routes = { |
| 15 | + path: '/', |
| 16 | + component: App, |
| 17 | + indexRoute: { |
| 18 | + component: require('./components/pages/Home') |
| 19 | + }, |
| 20 | + childRoutes: [ |
| 21 | + require('./routes/Example1Route') |
| 22 | + ] |
| 23 | +}; |
| 24 | + |
| 25 | +const DEV = process && process.env && process.env.NODE_ENV === 'development'; |
| 26 | +const history = useBasename(createHistory)({ |
| 27 | + basename: '/' + (DEV ? '' : name) |
| 28 | +}); |
| 29 | + |
| 30 | +const run = () => { |
| 31 | + ReactDOM.render( |
| 32 | + <Router routes={routes} history={history}/>, |
| 33 | + document.getElementById('app') |
| 34 | + ); |
| 35 | +}; |
96 | 36 |
|
97 | 37 | if (window.addEventListener) {
|
98 | 38 | window.addEventListener('DOMContentLoaded', run);
|
|
0 commit comments