2016-09-21 22:40:25 +02:00
|
|
|
import './index.html';
|
2016-09-22 02:18:54 +02:00
|
|
|
import './sass/main.scss';
|
2016-09-21 22:40:25 +02:00
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
|
|
|
|
2016-09-22 02:18:54 +02:00
|
|
|
import {Header} from './components/Header';
|
2016-09-21 22:40:25 +02:00
|
|
|
import {NewWordForm} from './components/NewWordForm';
|
2016-09-22 16:25:49 +02:00
|
|
|
import {Button} from './components/Button';
|
2016-09-22 02:18:54 +02:00
|
|
|
import {Dictionary} from './components/Dictionary';
|
2016-09-21 22:40:25 +02:00
|
|
|
|
|
|
|
class Lexiconga extends React.Component {
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
2016-09-22 02:18:54 +02:00
|
|
|
|
|
|
|
this.state = {
|
|
|
|
scroll: {
|
|
|
|
x: 0,
|
|
|
|
y: 0
|
2016-09-22 15:42:07 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
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
|
2016-09-22 02:18:54 +02:00
|
|
|
}
|
2016-09-22 15:42:07 +02:00
|
|
|
};
|
2016-09-22 02:18:54 +02:00
|
|
|
|
2016-09-22 15:42:07 +02:00
|
|
|
this.defaultDictionaryJSON = JSON.stringify(this.state.dictionaryDetails); //Saves a stringifyed default dictionary.
|
2016-09-22 02:18:54 +02:00
|
|
|
this.previousDictionary = {};
|
|
|
|
|
|
|
|
// this.addTestWord();
|
2016-09-21 22:40:25 +02:00
|
|
|
}
|
|
|
|
|
2016-09-22 16:25:49 +02:00
|
|
|
changeDictionaryName() {
|
|
|
|
// To change elements within the dictionary object, you can set it to
|
|
|
|
// a variable, manipulate the variable, then use setState() to set
|
|
|
|
// the object equal to the changed variable.
|
|
|
|
let updateDictionary = this.state.currentDictionary;
|
|
|
|
updateDictionary.name = 'something else'
|
|
|
|
this.setState({
|
|
|
|
currentDictionary: updateDictionary
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2016-09-21 22:40:25 +02:00
|
|
|
render() {
|
|
|
|
return (
|
2016-09-22 02:18:54 +02:00
|
|
|
<div>
|
|
|
|
<Header />
|
2016-09-22 15:42:07 +02:00
|
|
|
<NewWordForm reference={this.state.currentDictionary} />
|
2016-09-22 16:25:49 +02:00
|
|
|
<Button
|
|
|
|
action={() => this.changeDictionaryName()}
|
|
|
|
label='change name' />
|
2016-09-22 15:42:07 +02:00
|
|
|
<Dictionary reference={this.state.currentDictionary} />
|
2016-09-22 02:18:54 +02:00
|
|
|
</div>
|
2016-09-21 22:40:25 +02:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<Lexiconga />, document.getElementById('site'));
|