2017-06-25 16:23:03 -06:00
|
|
|
// import 'font-awesome/scss/font-awesome.scss';
|
2016-09-21 18:18:54 -06:00
|
|
|
import './sass/main.scss';
|
2016-09-21 14:40:25 -06:00
|
|
|
|
2017-01-14 12:55:42 -07:00
|
|
|
import Inferno from 'inferno';
|
|
|
|
import Component from 'inferno-component';
|
2016-09-21 14:40:25 -06:00
|
|
|
|
2017-08-20 23:53:59 -06:00
|
|
|
import { addHelpfulPrototypes } from './Helpers';
|
|
|
|
addHelpfulPrototypes();
|
|
|
|
|
2017-04-19 15:11:37 -06:00
|
|
|
import dictionary from './managers/DictionaryData';
|
2017-08-20 11:57:17 -06:00
|
|
|
import { Updater } from './managers/Updater';
|
2017-08-16 16:53:55 -06:00
|
|
|
|
2017-04-04 14:39:35 -06:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
require('inferno-devtools');
|
|
|
|
}
|
|
|
|
|
2017-07-25 22:11:33 -06:00
|
|
|
import { Header } from './components/structure/Header';
|
|
|
|
import { MainDisplay } from './components/MainDisplay';
|
|
|
|
import { Footer } from './components/structure/Footer';
|
2017-04-04 14:39:35 -06:00
|
|
|
|
2017-04-03 22:24:14 -06:00
|
|
|
class App extends Component {
|
|
|
|
constructor (props) {
|
2016-09-21 14:40:25 -06:00
|
|
|
super(props);
|
2017-04-19 15:11:37 -06:00
|
|
|
|
|
|
|
this.state = {
|
2017-06-25 15:49:23 -06:00
|
|
|
name: dictionary.name,
|
|
|
|
specification: dictionary.specification,
|
|
|
|
description: dictionary.description,
|
|
|
|
partsOfSpeech: dictionary.partsOfSpeech,
|
2017-08-20 14:41:08 -06:00
|
|
|
details: dictionary.details,
|
|
|
|
alphabeticalOrder: dictionary.alphabeticalOrder,
|
|
|
|
|
2017-06-25 15:49:23 -06:00
|
|
|
displayedWords: [],
|
|
|
|
searchConfig: null,
|
2017-04-19 15:11:37 -06:00
|
|
|
}
|
2017-08-16 16:53:55 -06:00
|
|
|
|
|
|
|
this.updater = new Updater(this, dictionary);
|
2017-04-19 15:11:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
get dictionaryInfo () {
|
2017-08-20 14:41:08 -06:00
|
|
|
const {
|
2017-06-25 15:49:23 -06:00
|
|
|
name,
|
|
|
|
specification,
|
|
|
|
description,
|
|
|
|
partsOfSpeech,
|
2017-08-20 14:41:08 -06:00
|
|
|
details,
|
|
|
|
alphabeticalOrder,
|
|
|
|
} = this.state;
|
2017-04-19 15:11:37 -06:00
|
|
|
|
2017-08-20 14:41:08 -06:00
|
|
|
return {
|
|
|
|
name,
|
|
|
|
specification,
|
|
|
|
description,
|
|
|
|
partsOfSpeech,
|
|
|
|
details,
|
|
|
|
alphabeticalOrder,
|
|
|
|
};
|
2017-04-19 15:11:37 -06:00
|
|
|
}
|
|
|
|
|
2017-06-25 15:49:23 -06:00
|
|
|
updatePartsOfSpeech () {
|
|
|
|
this.setState({
|
|
|
|
partsOfSpeech: dictionary.partsOfSpeech,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-06-25 14:23:42 -06:00
|
|
|
updateDisplayedWords () {
|
2017-04-19 15:11:37 -06:00
|
|
|
// const {searchIn, searchTerm, filteredPartsOfSpeech} = this.state.searchConfig;
|
|
|
|
|
|
|
|
// TODO: Sort out searching to remove this temporary solution.
|
2017-07-25 22:11:33 -06:00
|
|
|
dictionary.wordsPromise.then((words) => {
|
2017-06-25 14:23:42 -06:00
|
|
|
this.setState({
|
2017-06-25 15:49:23 -06:00
|
|
|
displayedWords: words,
|
2017-06-25 14:23:42 -06:00
|
|
|
})
|
|
|
|
});
|
2017-04-19 15:11:37 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
search (searchConfig) {
|
|
|
|
this.setState({
|
2017-06-25 15:49:23 -06:00
|
|
|
searchConfig: searchConfig,
|
2017-04-19 15:11:37 -06:00
|
|
|
});
|
2016-09-22 14:05:49 -06:00
|
|
|
}
|
|
|
|
|
2017-04-03 22:24:14 -06:00
|
|
|
render () {
|
2016-09-21 14:40:25 -06:00
|
|
|
return (
|
2016-09-21 18:18:54 -06:00
|
|
|
<div>
|
2017-04-19 15:11:37 -06:00
|
|
|
<Header
|
2017-06-25 15:49:23 -06:00
|
|
|
partsOfSpeech={ this.state.partsOfSpeech }
|
2017-08-16 16:53:55 -06:00
|
|
|
search={ (searchConfig) => this.search(searchConfig) }
|
|
|
|
/>
|
2017-01-14 12:55:42 -07:00
|
|
|
|
2017-04-19 15:11:37 -06:00
|
|
|
<MainDisplay
|
2017-06-25 15:49:23 -06:00
|
|
|
dictionaryInfo={ this.dictionaryInfo }
|
|
|
|
wordsToDisplay={ this.state.displayedWords }
|
2017-08-16 16:53:55 -06:00
|
|
|
updateDisplay={ this.updateDisplayedWords.bind(this) }
|
|
|
|
updater={ this.updater }
|
|
|
|
/>
|
2016-09-27 15:12:48 -06:00
|
|
|
|
2017-04-04 14:39:35 -06:00
|
|
|
<Footer />
|
2016-09-21 18:18:54 -06:00
|
|
|
</div>
|
2016-09-21 14:40:25 -06:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-04-03 22:24:14 -06:00
|
|
|
Inferno.render(<App />, document.getElementById('site'));
|