const React = require('react'); const createClass = require('create-react-class'); const Moment = require('moment'); const Nav = require('naturalcrit/nav/nav.jsx'); const MetadataNav = createClass({ displayName : 'MetadataNav', getDefaultProps : function() { return { }; }, getInitialState : function() { return { showMetaWindow : false }; }, componentDidMount : function() { }, toggleMetaWindow : function(){ this.setState((prevProps)=>({ showMetaWindow : !prevProps.showMetaWindow })); }, getAuthors : function(){ if(!this.props.brew.authors || this.props.brew.authors.length == 0) return 'No authors'; return <> {this.props.brew.authors.map((author, idx, arr)=>{ const spacer = arr.length - 1 == idx ? <> : , ; return {author}{spacer}; })} ; }, getTags : function(){ if(!this.props.brew.tags || this.props.brew.tags.length == 0) return 'No tags'; return <> {this.props.brew.tags.map((tag, idx)=>{ return {tag}; })} ; }, getSystems : function(){ if(!this.props.brew.systems || this.props.brew.systems.length == 0) return 'No systems'; return this.props.brew.systems.join(', '); }, renderMetaWindow : function(){ return

Description

{this.props.brew.description || 'No description.'}

Authors

{this.getAuthors()}

Tags

{this.getTags()}

Systems

{this.getSystems()}

Updated

{Moment(this.props.brew.updatedAt).fromNow()}

; }, render : function(){ return this.toggleMetaWindow()}> {this.props.children} {this.renderMetaWindow()} ; } }); module.exports = MetadataNav;