From a7068d640a1b6e8997b6c7d43d731f2113a116a0 Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Wed, 21 Sep 2016 18:18:54 -0600 Subject: [PATCH] Having trouble getting the Dictionary component to render its list of words at all, let alone re-render when it's updated. Added working header and button components, made sass imports work by putting _ before the .scss files to import. --- src/components/Button.jsx | 32 +++++ src/components/Dictionary.jsx | 107 ++++++++++++++ src/components/Header.jsx | 89 ++++++++++++ src/components/Input.jsx | 2 + src/components/TextArea.jsx | 6 +- src/components/Word.jsx | 71 ++++++++++ src/index.jsx | 22 ++- src/sass/{lexiconga.scss => _lexiconga.scss} | 4 +- src/sass/{mobile.scss => _mobile.scss} | 0 src/sass/{styles.scss => _styles.scss} | 142 ++++++++++--------- src/sass/main.scss | 4 +- 11 files changed, 406 insertions(+), 73 deletions(-) create mode 100644 src/components/Button.jsx create mode 100644 src/components/Dictionary.jsx create mode 100644 src/components/Header.jsx create mode 100644 src/components/Word.jsx rename src/sass/{lexiconga.scss => _lexiconga.scss} (96%) rename src/sass/{mobile.scss => _mobile.scss} (100%) rename src/sass/{styles.scss => _styles.scss} (83%) diff --git a/src/components/Button.jsx b/src/components/Button.jsx new file mode 100644 index 0000000..76077a0 --- /dev/null +++ b/src/components/Button.jsx @@ -0,0 +1,32 @@ +import React from 'react'; + +export class Button extends React.Component { + constructor(props) { + super(props); + } + + processClasses() { + var classes = 'clickable'; + + if (this.props.classes) { + classes += ' ' + this.props.classes; + } + + return classes; + } + + render() { + return ( + + {this.props.label} + + ); + } +} + +Button.defaultProps = { + action: () => console.log('no action bound to button') +} \ No newline at end of file diff --git a/src/components/Dictionary.jsx b/src/components/Dictionary.jsx new file mode 100644 index 0000000..afcde81 --- /dev/null +++ b/src/components/Dictionary.jsx @@ -0,0 +1,107 @@ +import React from 'react'; + +import {Word} from './Word'; +import {Button} from './Button'; + +export class Dictionary extends React.Component { + constructor(props) { + super(props); + + this.state = { + name: "New", + description: "A new dictionary.", + createdBy: 'Someone', + words: [{ + name: 'word', + pronunciation: 'pronunciation', + partOfSpeech: 'partOfSpeech', + simpleDefinition: 'simpleDefinition', + longDefinition: 'longDefinition', + wordId: 'wordId' + }], + nextWordId: 1, + externalID: 0, + allowDuplicates: false, + caseSensitive: false, + partsOfSpeech: "Noun,Adjective,Verb,Adverb,Preposition,Pronoun,Conjunction", + sortByEquivalent: false, + isComplete: false, + isPublic: false + } + + // this.addTestWord(); + } + + showWords() { + let words = this.state.words.map((word, index) => { + + }); + + return
{words}
; + } + + addTestWord() { + this.setState({ + words: this.state.words.concat([{ + name: 'word', + pronunciation: 'pronunciation', + partOfSpeech: 'partOfSpeech', + simpleDefinition: 'simpleDefinition', + longDefinition: 'longDefinition', + wordId: 'wordId' + }]) + }, () => console.log(this.state.words)); + } + + changeTestWord() { + this.setState( + words[0].name: 'cool' + ); + } + + render() { + return ( +
+

+ {this.state.name} +

+ +

+ {this.state.createdBy} +

+
+ Dictionary is complete: {this.state.isComplete.toString()} +
+ +
+ + {this.showWords()} +
+ +
+ ); + } +} \ No newline at end of file diff --git a/src/components/Header.jsx b/src/components/Header.jsx new file mode 100644 index 0000000..0a14656 --- /dev/null +++ b/src/components/Header.jsx @@ -0,0 +1,89 @@ +import React from 'react'; + +import {Button} from './Button'; + +export class Header extends React.Component { + constructor(props) { + super(props); + + this.state = { + loggedIn: false, + lockedOut: false + } + } + + logUserIn() { + this.setState({ + loggedIn: true + }); + } + + logUserOut() { + this.setState({ + loggedIn: false + }); + } + + lockUserOut() { + this.setState({ + loggedIn: false, + lockedOut: true + }); + } + + unlockUser() { + this.setState({ + lockedOut: false + }); + } + + showAccountButtons() { + var buttons; + + if (this.state.loggedIn) { + buttons = [ +