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 = [ +