Lexiconga/src/index.jsx

85 lines
1.9 KiB
React
Raw Normal View History

// import './assets/fonts/fonts.scss';
import './sass/main.scss';
import Inferno from 'inferno';
import Component from 'inferno-component';
import dictionary from './managers/DictionaryData';
if (process.env.NODE_ENV !== 'production') {
require('inferno-devtools');
}
import {Header} from './components/structure/Header';
import {MainDisplay} from './components/MainDisplay';
import {Footer} from './components/structure/Footer';
class App extends Component {
constructor (props) {
super(props);
this.state = {
2017-06-25 23:49:23 +02:00
name: dictionary.name,
specification: dictionary.specification,
description: dictionary.description,
partsOfSpeech: dictionary.partsOfSpeech,
displayedWords: [],
searchConfig: null,
}
}
get dictionaryInfo () {
const {name, specification, description, partsOfSpeech} = this.state;
const info = {
2017-06-25 23:49:23 +02:00
name,
specification,
description,
partsOfSpeech,
};
return info;
}
2017-06-25 23:49:23 +02:00
updatePartsOfSpeech () {
this.setState({
partsOfSpeech: dictionary.partsOfSpeech,
});
}
2017-06-25 22:23:42 +02:00
updateDisplayedWords () {
// const {searchIn, searchTerm, filteredPartsOfSpeech} = this.state.searchConfig;
// TODO: Sort out searching to remove this temporary solution.
2017-06-25 22:23:42 +02:00
dictionary.wordsPromise.then(words => {
this.setState({
2017-06-25 23:49:23 +02:00
displayedWords: words,
2017-06-25 22:23:42 +02:00
})
});
}
search (searchConfig) {
this.setState({
2017-06-25 23:49:23 +02:00
searchConfig: searchConfig,
});
}
render () {
return (
<div>
<Header
2017-06-25 23:49:23 +02:00
partsOfSpeech={ this.state.partsOfSpeech }
search={ searchConfig => this.search(searchConfig) } />
<MainDisplay
2017-06-25 23:49:23 +02:00
dictionaryInfo={ this.dictionaryInfo }
wordsToDisplay={ this.state.displayedWords }
updateDisplay={ this.updateDisplayedWords.bind(this) } />
<Footer />
</div>
);
}
}
Inferno.render(<App />, document.getElementById('site'));