This repository has been archived by the owner on Oct 20, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(router): use reach router and remove prop-types warnings in …
…site console (#26) * refactor(router): use new react router and upgrade react in site * fix(Notfound): back issue in notfound page
- Loading branch information
Showing
17 changed files
with
5,741 additions
and
5,528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
import React from 'react' | ||
import Center from 'widgets/Center' | ||
import Markdown from 'widgets/Markdown' | ||
import Header from 'widgets/Header' | ||
import Footer from 'widgets/Footer' | ||
import BackToTop from 'earth-ui/lib/BackToTop' | ||
import ScrollUp from 'widgets/ScrollUp' | ||
import html from '../../../CHANGELOG.md' | ||
import config from '../config' | ||
import './index.less' | ||
|
||
export default () => { | ||
return ( | ||
<div className="changelog"> | ||
<Header /> | ||
<Center> | ||
<Markdown html={html} /> | ||
</Center> | ||
<Footer /> | ||
<BackToTop {...config.backToTop} /> | ||
</div> | ||
<ScrollUp> | ||
<div className="changelog"> | ||
<Center> | ||
<Markdown html={html} /> | ||
</Center> | ||
<Footer /> | ||
<BackToTop {...config.backToTop} /> | ||
</div> | ||
</ScrollUp> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
import React from 'react' | ||
import Center from 'widgets/Center' | ||
import Markdown from 'widgets/Markdown' | ||
import Header from 'widgets/Header' | ||
import Footer from 'widgets/Footer' | ||
import ScrollUp from 'widgets/ScrollUp' | ||
import BackToTop from 'earth-ui/lib/BackToTop' | ||
import html from '../../../README.zh-CN.md' | ||
import config from '../config' | ||
import './index.less' | ||
|
||
export default () => { | ||
return ( | ||
<div className="guide"> | ||
<Header /> | ||
<Center> | ||
<Markdown html={html} /> | ||
</Center> | ||
<Footer /> | ||
<BackToTop {...config.backToTop} /> | ||
</div> | ||
<ScrollUp> | ||
<div className="guide"> | ||
<Center> | ||
<Markdown html={html} /> | ||
</Center> | ||
<Footer /> | ||
<BackToTop {...config.backToTop} /> | ||
</div> | ||
</ScrollUp> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
import React from 'react' | ||
import PropType from 'prop-types' | ||
import Button from 'earth-ui/lib/Button' | ||
import ScrollUp from 'widgets/ScrollUp' | ||
import './index.less' | ||
|
||
const NotFound = (props) => { | ||
return ( | ||
<div className="not-found"> | ||
<h1>404</h1> | ||
<p>您访问的页面不存在,也可能被移除了</p> | ||
<Button onClick={() => props.history.goBack()}>返回</Button> | ||
</div> | ||
<ScrollUp> | ||
<div className="not-found"> | ||
<h1>404</h1> | ||
<p>您访问的页面不存在,也可能被移除了</p> | ||
<Button onClick={() => window.history.back()}>返回</Button> | ||
</div> | ||
</ScrollUp> | ||
) | ||
} | ||
|
||
NotFound.propTypes = { | ||
history: PropType.object | ||
} | ||
|
||
export default NotFound |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
.not-found { | ||
padding-top: 150px; | ||
text-align: center; | ||
h1 { | ||
margin: 0; | ||
padding-top: 90px; | ||
font-size: 100px; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,34 @@ | ||
import React from 'react' | ||
import { render } from 'react-dom' | ||
import { Router, browserHistory, Route, IndexRoute, IndexRedirect } from 'react-router' | ||
// import { BrowserRouter as Router, Route, Redirect, Switch } from 'react-router-dom' | ||
import process from 'nprogress' | ||
import ReactDOM from 'react-dom' | ||
import { Router, Redirect } from '@reach/router' | ||
import Imported, { whenComponentsReady } from 'react-imported-component' | ||
import NProgress from 'nprogress' | ||
import App from './pages/index' | ||
|
||
render(( | ||
<Router onUpdate={() => { | ||
process.done() | ||
window.scrollTo(0, 0) | ||
}} history={browserHistory}> | ||
<Route | ||
path="/" | ||
onEnter={() => process.start()} | ||
onChange={() => process.start()} | ||
component={App} | ||
> | ||
<IndexRoute getComponent={(nextState, cb) => { | ||
require.ensure([], require => { | ||
cb(null, require('./pages/Home').default) | ||
}) | ||
}} /> | ||
<Route path="guide" getComponent={(nextState, cb) => { | ||
require.ensure([], require => { | ||
cb(null, require('./pages/Guide').default) | ||
}) | ||
}} /> | ||
<Route path="Design" getComponent={(nextState, cb) => { | ||
require.ensure([], require => { | ||
cb(null, require('./pages/Design').default) | ||
}) | ||
}} > | ||
<IndexRedirect to="/design/layout" /> | ||
<Route path=":designElement" getComponent={(nextState, cb) => { | ||
const designElement = nextState.location.pathname.split('/').pop() | ||
require.ensure([], require => { | ||
cb(null, require(`./pages/Design/docs/${designElement}.md`)) | ||
}) | ||
}} /> | ||
</Route> | ||
<Route path="components" getComponent={(nextState, cb) => { | ||
require.ensure([], require => { | ||
cb(null, require('./pages/Components').default) | ||
}) | ||
}}> | ||
<IndexRedirect to="/components/Layout" /> | ||
<Route path=":component" getComponent={(nextState, cb) => { | ||
const component = nextState.location.pathname.split('/').pop() | ||
require.ensure([], require => { | ||
cb(null, require(`./pages/Components/docs/${component}.doc`).default) | ||
}) | ||
}} /> | ||
</Route> | ||
<Route path="Changelog" getComponent={(nextState, cb) => { | ||
require.ensure([], require => { | ||
cb(null, require('./pages/Changelog').default) | ||
}) | ||
}} /> | ||
<Route path="*" getComponent={(nextState, cb) => { | ||
require.ensure([], require => { | ||
cb(null, require('./pages/NotFound').default) | ||
}) | ||
}} /> | ||
</Route> | ||
const asyncComponent = path => Imported(() => { | ||
NProgress.start() | ||
whenComponentsReady().then(() => NProgress.done()) | ||
return import(`./pages/${path}` /* webpackChunkName: 'chunk-[request][index]' */) | ||
}) | ||
|
||
const Home = asyncComponent('Home') | ||
const Guide = asyncComponent('Guide') | ||
const Changelog = asyncComponent('Changelog') | ||
const NotFound = asyncComponent('NotFound') | ||
const Components = asyncComponent('Components') | ||
const Doc = routeProps => React.createElement(asyncComponent(`Components/docs/${routeProps.component}.doc`)) | ||
|
||
ReactDOM.render(( | ||
<Router> | ||
<App path="/"> | ||
<Home path="/" /> | ||
<Guide path="/guide" /> | ||
<Redirect noThrow from="/components" to="/components/Layout" /> | ||
<Components path="/components"> | ||
<Doc path=":component" /> | ||
</Components> | ||
<Changelog path="/changelog" /> | ||
<NotFound default /> | ||
</App> | ||
</Router> | ||
), document.getElementById('app')) |
Oops, something went wrong.