From 814775977bdf5493cc8b921b090d23bbf3ef0863 Mon Sep 17 00:00:00 2001 From: Berkeley Martinez Date: Thu, 19 Mar 2015 00:04:49 -0700 Subject: [PATCH] Hide bonfire moreInfo button when no descrition is avaiable closes #233 --- common/components/bonfires/Bonfires.jsx | 2 +- common/components/bonfires/SidePanel.jsx | 61 +++++++++++++++--------- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/common/components/bonfires/Bonfires.jsx b/common/components/bonfires/Bonfires.jsx index 5b872dcc8aa3eb..6b63eee41891e8 100644 --- a/common/components/bonfires/Bonfires.jsx +++ b/common/components/bonfires/Bonfires.jsx @@ -32,7 +32,7 @@ var Bonfire = React.createClass({ // create proper URI from react-router var path = this.context.makePath('bonfires', { bonfireName: bonfireName }); - // is html5 push state exists, update URI + // if html5 push state exists, update URI // else we are using hash location and should just cause a re render if (his) { his.replaceState({ path: path }, '', path); diff --git a/common/components/bonfires/SidePanel.jsx b/common/components/bonfires/SidePanel.jsx index 07f0690b8f6d04..7b3176420075d6 100644 --- a/common/components/bonfires/SidePanel.jsx +++ b/common/components/bonfires/SidePanel.jsx @@ -17,12 +17,9 @@ var SidePanel = React.createClass({ getDefaultProps: function() { return { - difficulty: 2, - brief: 'This is a brief description', - description: [ - 'a sentence', - 'another' - ] + name: 'Welcome to Bonfires!', + difficulty: 5, + brief: 'This is a brief description' }; }, @@ -54,22 +51,43 @@ var SidePanel = React.createClass({ }); }, - _renderMoreInfo: function() { + _renderMoreInfo: function(isDescription) { var description = this.props.description.map((sentance, index) => { return

{ sentance }

; }); - return ( - - - { description } - - - ); + if (isDescription) { + return ( + + + { description } + + + ); + } + return null; + }, + + _renderMoreInfoButton: function(isDescription) { + if (isDescription) { + return ( + + ); + } + return null; }, render: function() { var isMoreInfoOpen = this.state.isMoreInfoOpen; + var isDescription = this.props.description && + this.props.description.length > 1; return (

{ this.props.brief }

- { isMoreInfoOpen ? this._renderMoreInfo() : null } - + { + isMoreInfoOpen ? + this._renderMoreInfo(isDescription) : + null + } + { this._renderMoreInfoButton(isDescription) }