From 1e2758f3d3c62532f2441f8c11d691c9d9618c59 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Thu, 22 Sep 2016 07:42:07 -0600 Subject: [PATCH] Got dictionary and words displaying by reference. Need to decide where the dictionary will be stored so all components needed to reference it will be able to. --- src/components/Dictionary.jsx | 41 +++++++++++++++++++---------------- src/components/Word.jsx | 33 ++++++++++++++-------------- src/index.jsx | 27 ++++++++++++++++++----- 3 files changed, 61 insertions(+), 40 deletions(-) diff --git a/src/components/Dictionary.jsx b/src/components/Dictionary.jsx index d38dfe0..a3b8215 100644 --- a/src/components/Dictionary.jsx +++ b/src/components/Dictionary.jsx @@ -8,18 +8,18 @@ export class Dictionary extends React.Component { super(props); this.state = { - name: "New", - description: "A new dictionary.", - createdBy: 'Someone', - words: [], - nextWordId: 1, - externalID: 0, - allowDuplicates: false, - caseSensitive: false, - partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction", - sortByEquivalent: false, - isComplete: false, - isPublic: false + name: this.props.reference.name, + description: this.props.reference.description, + createdBy: this.props.reference.createdBy, + words: this.props.reference.words, + nextWordId: this.props.reference.nextWordId, + externalID: this.props.reference.externalID, + allowDuplicates: this.props.reference.settings.allowDuplicates, + caseSensitive: this.props.reference.settings.caseSensitive, + partsOfSpeech: this.props.reference.settings.partOfSpeech, + sortByEquivalent: this.props.reference.settings.sortByEquivalent, + isComplete: this.props.reference.settings.isComplete, + isPublic: this.props.reference.settings.isPublic } // this.addTestWord(); @@ -28,13 +28,16 @@ export class Dictionary extends React.Component { showWords() { let words = this.state.words.map((word, index) => { return + reference={word} + initialPosition={index} />; + // return ; }); return
{words}
; diff --git a/src/components/Word.jsx b/src/components/Word.jsx index 2d2bc23..9ab46e6 100644 --- a/src/components/Word.jsx +++ b/src/components/Word.jsx @@ -5,12 +5,13 @@ export class Word extends React.Component { super(props); this.state = { - name: this.props.name, - wordId: this.props.wordId, - pronunciation: this.props.pronunciation || '', - partOfSpeech: this.props.partOfSpeech || '', - simpleDefinition: this.props.simpleDefinition || '', - longDefinition: this.props.longDefinition || '', + word: this.props.reference, + // name: this.props.name, + // wordId: this.props.wordId, + // pronunciation: this.props.pronunciation || '', + // partOfSpeech: this.props.partOfSpeech || '', + // simpleDefinition: this.props.simpleDefinition || '', + // longDefinition: this.props.longDefinition || '', sortPosition: this.props.initialPosition } } @@ -27,35 +28,35 @@ export class Word extends React.Component { */ showPronunciation() { - if (this.state.pronunciation !== '') { - return
{this.state.pronunciation}
; + if (this.state.word.pronunciation !== '') { + return
{this.state.word.pronunciation}
; } } showPartOfSpeech() { - if (this.state.partOfSpeech !== '') { - return
{this.state.partOfSpeech}
; + if (this.state.word.partOfSpeech !== '') { + return
{this.state.word.partOfSpeech}
; } } showSimpleDefinition() { - if (this.state.simpleDefinition !== '') { - return
{this.state.simpleDefinition}
; + if (this.state.word.simpleDefinition !== '') { + return
{this.state.word.simpleDefinition}
; } } showLongDefinition() { - if (this.state.longDefinition !== '') { - return
{this.state.longDefinition}
; + if (this.state.word.longDefinition !== '') { + return
{this.state.word.longDefinition}
; } } render() { return (
- +
- {this.state.name} + {this.state.word.name}
{this.showPronunciation()} diff --git a/src/index.jsx b/src/index.jsx index 7be6df2..70dc000 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -16,10 +16,27 @@ class Lexiconga extends React.Component { scroll: { x: 0, y: 0 - } - } + }, - // this.defaultDictionaryJSON = JSON.stringify(this.state.dictionaryDetails); //Saves a stringifyed default dictionary. + currentDictionary: { + name: "New", + description: "A new dictionary.", + createdBy: 'Someone', + words: [], + settings: { + allowDuplicates: false, + caseSensitive: false, + partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction", + sortByEquivalent: false, + isComplete: false, + isPublic: false + }, + nextWordId: 1, + externalID: 0 + } + }; + + this.defaultDictionaryJSON = JSON.stringify(this.state.dictionaryDetails); //Saves a stringifyed default dictionary. this.previousDictionary = {}; // this.addTestWord(); @@ -29,8 +46,8 @@ class Lexiconga extends React.Component { return (
- - + +
); }