This repository has been archived by the owner on Feb 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- navigate between examples with react-router (each example has got a slug) - extract ExampleViewer into a separate component, determine its size using react-sizeme - make ExampleBrowser component functional (i.e. pure)
- Loading branch information
Showing
5 changed files
with
77 additions
and
82 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ | |
|
||
#panel #content .link { | ||
color: #2194CE; | ||
display: block; | ||
text-decoration: none; | ||
cursor: pointer; | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import sizeMe from 'react-sizeme'; | ||
|
||
const ExampleViewer = ({ example, size }) => { | ||
let sourceButton = null; | ||
let exampleContent = null; | ||
|
||
if (example) { | ||
const { | ||
component: ExampleComponent, | ||
url, | ||
} = example; | ||
exampleContent = (<ExampleComponent width={size.width} height={size.height} />); | ||
sourceButton = (<div key="src" id="button"> | ||
<a | ||
href={`https://github.com/toxicFork/react-three-renderer-example/blob/master/src/examples/${url}.js`} | ||
target="_blank" | ||
> | ||
View source | ||
</a> | ||
</div>); | ||
} | ||
|
||
return ( | ||
<div id="viewer"> | ||
{exampleContent} | ||
{sourceButton} | ||
</div> | ||
); | ||
}; | ||
|
||
ExampleViewer.propTypes = { | ||
example: React.PropTypes.object, | ||
size: React.PropTypes.object, | ||
}; | ||
|
||
export default sizeMe({ monitorHeight: true, refreshRate: 200 })(ExampleViewer); |
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,14 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Router, Route, hashHistory } from 'react-router'; | ||
import ExampleBrowser from './examples/ExampleBrowser'; | ||
import Perf from 'react-addons-perf'; | ||
|
||
window.Perf = Perf; | ||
|
||
ReactDOM.render(<ExampleBrowser/>, document.getElementById('content')); | ||
ReactDOM.render( | ||
<Router history={hashHistory}> | ||
<Route path="/(:slug)" component={ExampleBrowser} /> | ||
</Router>, | ||
document.getElementById('content') | ||
); |