mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-30 03:30:34 +02:00
dual rendering possible using --singles
This commit is contained in:
38
components/Navigation.jsx
Normal file
38
components/Navigation.jsx
Normal file
@@ -0,0 +1,38 @@
|
||||
var React = require('react');
|
||||
var ReactRouter = require('react-router');
|
||||
var Link = ReactRouter.Link;
|
||||
|
||||
var sections = require("./sections");
|
||||
var sectionPages = Object.keys(sections);
|
||||
|
||||
// LESS is automatically turned into CSS and bundled in:
|
||||
require("../stylesheets/style.less");
|
||||
|
||||
var Navigation = React.createClass({
|
||||
generateNavItem: function(name, entry) {
|
||||
var Type = sections[name];
|
||||
var title = Type.getDefaultProps().title;
|
||||
var link = <a href={'#' + name}>{ title }</a>;
|
||||
if (this.props.fullNav) { link = <Link to={(name!=="preface") ? name : "/"}>{title}</Link>; }
|
||||
return <li key={name} data-number={entry}>{link}</li>;
|
||||
},
|
||||
|
||||
generateNav: function() {
|
||||
if (this.props.compact) return null;
|
||||
return (
|
||||
<div ref="navigation">
|
||||
<navigation className={ this.props.compact ? "compact" : null }>
|
||||
<ul className="navigation">
|
||||
{ sectionPages.map(this.generateNavItem) }
|
||||
</ul>
|
||||
</navigation>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
return this.generateNav();
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Navigation;
|
Reference in New Issue
Block a user