From 42b3091d7a40095dc47d41a8584c025ff7917851 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Sat, 24 Sep 2016 08:58:09 -0600 Subject: [PATCH] You can now add a word while editing a word, allowing the edit word form to stay open and reorganize! Cool stuff! Also fixed a small styling thing. --- src/components/Dictionary.jsx | 17 ++------- src/components/Input.jsx | 9 ++++- src/components/TextArea.jsx | 2 +- src/components/Word.jsx | 10 ++--- src/components/WordForm.jsx | 2 +- src/index.jsx | 70 +++++++++++++++++------------------ src/sass/_lexiconga.scss | 14 +++---- src/sass/_styles.scss | 2 +- 8 files changed, 61 insertions(+), 65 deletions(-) diff --git a/src/components/Dictionary.jsx b/src/components/Dictionary.jsx index 5764e9b..3b888dc 100644 --- a/src/components/Dictionary.jsx +++ b/src/components/Dictionary.jsx @@ -9,31 +9,20 @@ export class Dictionary extends React.Component { } showWords() { - let words = this.props.words.map((word, index) => { - return { + return this.passWordAndUpdate(index, wordObject)} />; + updateWord={(wordId, wordObject) => this.props.updateWord(wordId, wordObject)} />; }); - if (this.showConsoleMessages) { - console.log('Showing these words:'); - console.log(words); - } - return
{words}
; } - passWordAndUpdate(index, wordObject) { - console.log('Passing edited up: ' + wordObject.name); - this.props.updateWord(index, wordObject); - } - render() { return (
diff --git a/src/components/Input.jsx b/src/components/Input.jsx index 77bd84d..0e925b2 100644 --- a/src/components/Input.jsx +++ b/src/components/Input.jsx @@ -18,6 +18,7 @@ export class Input extends React.Component { // Bind listeners this.handleOnChange = this.handleOnChange.bind(this); + this.handleOnKeyDown = this.handleOnKeyDown.bind(this); } // Whenever the input changes we update the value state of this component @@ -28,6 +29,12 @@ export class Input extends React.Component { }); } + handleOnKeyDown(event) { + if (this.props.onKeyDown) { + this.props.onKeyDown(event); + } + } + showHelperLink() { if (this.props.helperLink) { return ( @@ -49,7 +56,7 @@ export class Input extends React.Component { {this.props.name} {this.showHelperLink()} - this.props.onKeyDown(event)} value={this.state.value} /> + ); } diff --git a/src/components/TextArea.jsx b/src/components/TextArea.jsx index 3c564e5..cca7295 100644 --- a/src/components/TextArea.jsx +++ b/src/components/TextArea.jsx @@ -36,7 +36,7 @@ export class TextArea extends Input { action={() => this.handleMaximizeClick()} label='Maximize' /> -