1
0
Fork 0
mirror of https://github.com/Alamantus/Lexiconga.git synced 2025-07-03 22:24:16 +02:00
Lexiconga/src/index.jsx

105 lines
2.3 KiB
React
Raw Normal View History

2017-06-25 16:23:03 -06:00
// import 'font-awesome/scss/font-awesome.scss';
import './sass/main.scss';
import Inferno from 'inferno';
import Component from 'inferno-component';
import { addHelpfulPrototypes } from './Helpers';
addHelpfulPrototypes();
import dictionary from './managers/DictionaryData';
2017-08-20 11:57:17 -06:00
import { Updater } from './managers/Updater';
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 15:49:23 -06:00
name: dictionary.name,
specification: dictionary.specification,
description: dictionary.description,
partsOfSpeech: dictionary.partsOfSpeech,
details: dictionary.details,
alphabeticalOrder: dictionary.alphabeticalOrder,
2017-06-25 15:49:23 -06:00
displayedWords: [],
searchConfig: null,
}
this.updater = new Updater(this, dictionary);
}
get dictionaryInfo () {
const {
2017-06-25 15:49:23 -06:00
name,
specification,
description,
partsOfSpeech,
details,
alphabeticalOrder,
} = this.state;
return {
name,
specification,
description,
partsOfSpeech,
details,
alphabeticalOrder,
};
}
2017-06-25 15:49:23 -06:00
updatePartsOfSpeech () {
this.setState({
partsOfSpeech: dictionary.partsOfSpeech,
});
}
2017-06-25 14:23:42 -06:00
updateDisplayedWords () {
// const {searchIn, searchTerm, filteredPartsOfSpeech} = this.state.searchConfig;
// TODO: Sort out searching to remove this temporary solution.
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
})
});
}
search (searchConfig) {
this.setState({
2017-06-25 15:49:23 -06:00
searchConfig: searchConfig,
});
}
render () {
return (
<div>
<Header
2017-06-25 15:49:23 -06:00
partsOfSpeech={ this.state.partsOfSpeech }
search={ (searchConfig) => this.search(searchConfig) }
/>
<MainDisplay
2017-06-25 15:49:23 -06:00
dictionaryInfo={ this.dictionaryInfo }
wordsToDisplay={ this.state.displayedWords }
updateDisplay={ this.updateDisplayedWords.bind(this) }
updater={ this.updater }
/>
<Footer />
</div>
);
}
}
Inferno.render(<App />, document.getElementById('site'));