From 7efddf2edbdb09921f628abfc7eaed537beef6a3 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 29 Sep 2016 20:26:16 -0600 Subject: [PATCH] Got Dictionary Info (description and details) displaying correctly! Going with a tabbed display this time. :) --- src/components/Dictionary.jsx | 43 +++++------- src/components/InfoDisplay.jsx | 117 +++++++++++++++++++++++++++++++++ src/index.jsx | 14 ++-- src/sass/_lexiconga.scss | 21 ++++-- src/sass/_styles.scss | 19 ++++-- src/sass/_variables.scss | 2 + 6 files changed, 176 insertions(+), 40 deletions(-) create mode 100644 src/components/InfoDisplay.jsx diff --git a/src/components/Dictionary.jsx b/src/components/Dictionary.jsx index ce841b4..0408465 100644 --- a/src/components/Dictionary.jsx +++ b/src/components/Dictionary.jsx @@ -9,37 +9,28 @@ export class Dictionary extends React.Component { } showWords() { - let words = this.props.words.map((word) => { - return this.props.updateWord(wordId, wordObject)} />; - }); + if (this.props.words.length > 0) { + let words = this.props.words.map((word) => { + return this.props.updateWord(wordId, wordObject)} />; + }); - return
{words}
; + return
{words}
; + } else { + return

No words yet!

; + } } render() { return ( -
-

- {this.props.details.name} -

- -

- {this.props.details.createdBy} -

-
- Dictionary is complete: {this.props.settings.isComplete.toString()} -
- -
- {this.showWords()} -
+
+ {this.showWords()}
); } diff --git a/src/components/InfoDisplay.jsx b/src/components/InfoDisplay.jsx new file mode 100644 index 0000000..8f3ea87 --- /dev/null +++ b/src/components/InfoDisplay.jsx @@ -0,0 +1,117 @@ +import React from 'react'; +import marked from 'marked'; + +import {WordForm} from './WordForm'; +import {Button} from './Button'; + +const saveIcon = 💾; +const editIcon = 🖉; + +export class InfoDisplay extends React.Component { + constructor(props) { + super(props); + + this.state = { + isDisplayed: props.startDisplayed || false, + tabDisplay: 0 + }; + } + + showTabbedInterface() { + if (this.state.isDisplayed) { + return ( +
+ +
+ ); + } + } + + toggleDisplay() { + this.setState({ + isDisplayed: !this.state.isDisplayed + }); + } + + displaySelectedTab() { + switch(this.state.tabDisplay) { + case 1: { + return ( +
+ {this.showDetails()} +
+ ); + break; + } + default: { + return ( +
+ {this.showDescription()} +
+ ); + break; + } + } + } + + showDescription() { + return ( +
+ ); + } + + showDetails() { + return ( +
+ +

+ Created By {this.props.details.createdBy} +

+ +
+ {this.props.numberOfWords} Total Word{(this.props.numberOfWords !== 1) ? 's' : ''} +
+ +
+ {(!this.props.isComplete) ? 'Note: This dictionary is not yet complete and is likely to change.' : ''} +
+ +
+ ); + } + + changeTab(tabNumber) { + this.setState({ + tabDisplay: tabNumber + }); + } + + render() { + return ( +
+
+ ); + } +} + +InfoDisplay.defaultProps = { + isEditing: false +} \ No newline at end of file diff --git a/src/index.jsx b/src/index.jsx index d4bf6e1..6464927 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -8,6 +8,7 @@ import {Header} from './components/Header'; import {Footer} from './components/Footer'; import {WordForm} from './components/WordForm'; import {Button} from './components/Button'; +import {InfoDisplay} from './components/InfoDisplay'; import {EditDictionaryForm} from './components/EditDictionaryForm'; import {Dictionary} from './components/Dictionary'; @@ -229,10 +230,6 @@ class Lexiconga extends React.Component {
-
- Dictionary is complete: {this.state.settings.isComplete.toString()} -
-