var Preact = require('preact'), h = require('preact').h, createClass = require('preact-compat').createClass, Plugin = require('./plugin.jsx'); var InitialPageLength = 10; var PageExtensionLength = 20; /* States site loaded */ var PluginList = createClass({ getInitialState: function() { return { bootstrapped: false } }, componentWillReceiveProps: function() { // Recieving a set of plugins this.setState({ bootstrapped: true, searchPage: 0 }); }, increaseSearchResults: function() { this.setState({ searchPage: this.state.searchPage + 1 }); }, render: function() { if (!this.state.bootstrapped) { var emptyPluginList = []; for (var i = 0; i < InitialPageLength; i++) { emptyPluginList.push() }; return (
{emptyPluginList}
) } else { var plugins = this.props.plugins; var showMore = null, visiblePlugins = []; if (plugins.length - this.state.searchPage * PageExtensionLength > InitialPageLength) { showMore =
Show More
; } if (plugins.length === 0) { return (
No plugins found. Learn how to create one
); } else { for (var i = 0; i < InitialPageLength + this.state.searchPage * PageExtensionLength; i++) { if (plugins[i]) { visiblePlugins.push(); } else { break; } }; return (
{visiblePlugins} {showMore}
); } } } }); module.exports = PluginList;