-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(router): setup doc site router
- Loading branch information
1 parent
af5066c
commit adf20e3
Showing
10 changed files
with
140 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<!-- Hack to redirect SPA routes back to the index.html --> | ||
<meta http-equiv="refresh" content="0;URL='http://technologyadvice.github.io/stardust'" /> | ||
<script> | ||
sessionStorage.ghPagesRedirect = location.href | ||
</script> | ||
</head> | ||
<body></body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React, { Component } from 'react' | ||
import { Router, browserHistory } from 'react-router' | ||
|
||
import routes from './routes' | ||
|
||
export default class App extends Component { | ||
render() { | ||
return ( | ||
<Router history={browserHistory} routes={routes} /> | ||
) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'semantic-ui-css/semantic.js' | ||
import 'semantic-ui-css/semantic.css' | ||
import 'highlight.js/styles/github.css' | ||
import _ from 'lodash' | ||
import React, { Component, PropTypes } from 'react' | ||
import { routerShape } from 'react-router' | ||
|
||
import * as stardust from 'stardust' | ||
|
||
import ComponentDoc from '../Components/ComponentDoc/ComponentDoc' | ||
import DocsMenu from '../Components/Sidebar/Sidebar' | ||
import style from '../Style' | ||
|
||
const { Grid, Segment } = stardust | ||
|
||
export default class Root extends Component { | ||
static contextTypes = { | ||
router: routerShape, | ||
} | ||
static propTypes = { | ||
children: PropTypes.node, | ||
location: PropTypes.object, | ||
params: PropTypes.object, | ||
route: PropTypes.object, | ||
routeParams: PropTypes.object, | ||
} | ||
|
||
state = { menuSearch: '' } | ||
|
||
render() { | ||
const { children, location, params, route, routeParams, } = this.props | ||
const components = _.map(stardust, '_meta') | ||
.sort(({ name }) => name) | ||
.map(_meta => ( | ||
<Grid.Row key={_meta.name} id={_meta.name}> | ||
<Grid.Column> | ||
<Segment className='basic'> | ||
<ComponentDoc _meta={_meta} /> | ||
</Segment> | ||
</Grid.Column> | ||
</Grid.Row> | ||
)) | ||
|
||
return ( | ||
<div style={style.container}> | ||
<div style={style.menu}> | ||
<DocsMenu /> | ||
</div> | ||
<div style={style.main}> | ||
{location.pathname !== '' ? ( | ||
<div> | ||
{/* TODO will cleanup, debug to prove router works */} | ||
<h1>router:</h1> | ||
<pre>{JSON.stringify(this.context.router, null, 2)}</pre> | ||
<h1>location:</h1> | ||
<pre>{JSON.stringify(location, null, 2)}</pre> | ||
<h1>params:</h1> | ||
<pre>{JSON.stringify(params, null, 2)}</pre> | ||
<h1>route:</h1> | ||
<pre>{JSON.stringify(route, null, 2)}</pre> | ||
<h1>routeParams:</h1> | ||
<pre>{JSON.stringify(routeParams, null, 2)}</pre> | ||
<h1>children:</h1> | ||
{children} | ||
</div> | ||
) : ( | ||
<Grid className='vertically divided padded'> | ||
{components} | ||
</Grid> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Stardust</title> | ||
<script> | ||
// Apply gh-pages SPA redirect that was applied in 404.html | ||
(function() { | ||
var ghPagesRedirect = sessionStorage.ghPagesRedirect | ||
delete sessionStorage.ghPagesRedirect | ||
if (ghPagesRedirect && ghPagesRedirect !== location.href) { | ||
history.replaceState(null, null, ghPagesRedirect) | ||
} | ||
})() | ||
</script> | ||
</head> | ||
<body> | ||
<div id="root"></div> | ||
|
||
</body> | ||
</html> |
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react' | ||
import { render } from 'react-dom' | ||
import App from './App' | ||
|
||
const mountNode = document.createElement('div') | ||
document.body.appendChild(mountNode) | ||
|
||
render(<App />, mountNode) |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react' | ||
import { Route } from 'react-router' | ||
|
||
import Root from './Components/Root' | ||
import ButtonExamples from './Examples/elements/Button/ButtonExamples' | ||
|
||
const redirect = to => (nextState, replace) => replace(to) | ||
|
||
const routes = ( | ||
<Route path='/' component={Root}> | ||
<Route path='elements'> | ||
<Route path='button' component={ButtonExamples} /> | ||
</Route> | ||
<Route path='*' onEnter={redirect('/')} /> | ||
</Route> | ||
) | ||
|
||
export default routes |
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