1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-08-26 09:44:32 +02:00

Use Preact, rather than React (#91)

* moving to Preact to shave off 100+kb

* preact'ed
This commit is contained in:
Mike Kamermans
2017-04-02 14:32:06 -07:00
committed by GitHub
parent bcc465d26b
commit 25a18d8891
18 changed files with 122 additions and 251 deletions

View File

@@ -1,36 +1,27 @@
var React = require('react');
var ReactRouter = require('react-router');
var Link = ReactRouter.Link;
var sections = require("./sections");
var sectionPages = Object.keys(sections);
var SectionHeader = require("./SectionHeader.jsx");
var Navigation = React.createClass({
generateNavItem: function(name, entry) {
var Type = sections[name];
var title = Type.getDefaultProps().title;
var title = Type.defaultProps.title;
var locale = SectionHeader.locale;
if (typeof window !== "undefined" && window.location.toString().indexOf(locale) === -1) {
locale = '';
}
var fragmentid = `${locale ? './' + locale + '/': '.'}#${name}`;
var link = <a href={fragmentid}>{ title }</a>;
if (this.props.fullNav) {
link = <Link to={name}>{title}</Link>;
}
var last = sectionPages.length - 1;
if (entry===last) entry = null;
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 }>
<navigation>
<ul className="navigation">
{ sectionPages.map(this.generateNavItem) }
</ul>