mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-06-30 12:54:16 +02:00
Improve loader for word list
This commit is contained in:
parent
fba6063f55
commit
09946e1504
4 changed files with 16 additions and 1 deletions
|
@ -16,6 +16,7 @@ export class MainDisplay extends Component {
|
||||||
|
|
||||||
PropTypes.checkPropTypes({
|
PropTypes.checkPropTypes({
|
||||||
dictionaryInfo: PropTypes.object.isRequired,
|
dictionaryInfo: PropTypes.object.isRequired,
|
||||||
|
isLoadingWords: PropTypes.bool,
|
||||||
wordsToDisplay: PropTypes.array.isRequired,
|
wordsToDisplay: PropTypes.array.isRequired,
|
||||||
wordsAreFiltered: PropTypes.bool,
|
wordsAreFiltered: PropTypes.bool,
|
||||||
wordsInCurrentList: PropTypes.number,
|
wordsInCurrentList: PropTypes.number,
|
||||||
|
@ -56,6 +57,7 @@ export class MainDisplay extends Component {
|
||||||
render () {
|
render () {
|
||||||
const {
|
const {
|
||||||
dictionaryInfo,
|
dictionaryInfo,
|
||||||
|
isLoadingWords,
|
||||||
wordsToDisplay,
|
wordsToDisplay,
|
||||||
wordsAreFiltered,
|
wordsAreFiltered,
|
||||||
wordsInCurrentList,
|
wordsInCurrentList,
|
||||||
|
@ -116,6 +118,7 @@ export class MainDisplay extends Component {
|
||||||
isTop />
|
isTop />
|
||||||
|
|
||||||
<WordsList
|
<WordsList
|
||||||
|
isLoadingWords={ isLoadingWords }
|
||||||
words={ wordsToDisplay }
|
words={ wordsToDisplay }
|
||||||
adsEveryXWords={ 10 }
|
adsEveryXWords={ 10 }
|
||||||
updateDisplay={ updateDisplay } />
|
updateDisplay={ updateDisplay } />
|
||||||
|
|
|
@ -13,6 +13,7 @@ export class WordsList extends Component {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
PropTypes.checkPropTypes({
|
PropTypes.checkPropTypes({
|
||||||
|
isLoadingWords: PropTypes.bool,
|
||||||
adsEveryXWords: PropTypes.number,
|
adsEveryXWords: PropTypes.number,
|
||||||
words: PropTypes.array,
|
words: PropTypes.array,
|
||||||
updateDisplay: PropTypes.func.isRequired,
|
updateDisplay: PropTypes.func.isRequired,
|
||||||
|
@ -22,6 +23,12 @@ export class WordsList extends Component {
|
||||||
render () {
|
render () {
|
||||||
const adsEveryXWords = this.props.adsEveryXWords || 10;
|
const adsEveryXWords = this.props.adsEveryXWords || 10;
|
||||||
|
|
||||||
|
if (this.props.isLoadingWords) {
|
||||||
|
return <div className="content has-text-centered">
|
||||||
|
<div className="loader" style="display: inline-block; width: 60px; height: 60px;" />
|
||||||
|
</div>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='box'>
|
<div className='box'>
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ export const Pagination = (props) => {
|
||||||
const { currentPage, itemsPerPage, stats, setPage, wordsInCurrentList, isTop } = props;
|
const { currentPage, itemsPerPage, stats, setPage, wordsInCurrentList, isTop } = props;
|
||||||
|
|
||||||
if (wordsInCurrentList === null) {
|
if (wordsInCurrentList === null) {
|
||||||
return <div className="loader"></div>;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastPage = Math.floor(wordsInCurrentList / itemsPerPage);
|
const lastPage = Math.floor(wordsInCurrentList / itemsPerPage);
|
||||||
|
|
|
@ -46,6 +46,7 @@ class App extends Component {
|
||||||
ignoreDiacritics: false,
|
ignoreDiacritics: false,
|
||||||
filteredPartsOfSpeech: [...dictionary.partsOfSpeech, 'Uncategorized'],
|
filteredPartsOfSpeech: [...dictionary.partsOfSpeech, 'Uncategorized'],
|
||||||
},
|
},
|
||||||
|
isLoadingWords: true,
|
||||||
wordsInCurrentList: null,
|
wordsInCurrentList: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,18 +182,21 @@ class App extends Component {
|
||||||
displayedWords,
|
displayedWords,
|
||||||
stats: getWordsStats(words, partsOfSpeech, this.state.settings.caseSensitive),
|
stats: getWordsStats(words, partsOfSpeech, this.state.settings.caseSensitive),
|
||||||
wordsInCurrentList,
|
wordsInCurrentList,
|
||||||
|
isLoadingWords: false,
|
||||||
}, () => callback());
|
}, () => callback());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
search (searchConfig) {
|
search (searchConfig) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
isLoadingWords: true,
|
||||||
searchConfig: searchConfig,
|
searchConfig: searchConfig,
|
||||||
}, () => this.updateDisplayedWords());
|
}, () => this.updateDisplayedWords());
|
||||||
}
|
}
|
||||||
|
|
||||||
setPage (newPage) {
|
setPage (newPage) {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
isLoadingWords: true,
|
||||||
currentPage: newPage,
|
currentPage: newPage,
|
||||||
}, () => this.updateDisplayedWords());
|
}, () => this.updateDisplayedWords());
|
||||||
}
|
}
|
||||||
|
@ -208,6 +212,7 @@ class App extends Component {
|
||||||
|
|
||||||
<MainDisplay
|
<MainDisplay
|
||||||
dictionaryInfo={ this.dictionaryInfo }
|
dictionaryInfo={ this.dictionaryInfo }
|
||||||
|
isLoadingWords={ this.state.isLoadingWords }
|
||||||
wordsToDisplay={ this.state.displayedWords }
|
wordsToDisplay={ this.state.displayedWords }
|
||||||
wordsAreFiltered={ this.isUsingFilter }
|
wordsAreFiltered={ this.isUsingFilter }
|
||||||
wordsInCurrentList={ this.state.wordsInCurrentList }
|
wordsInCurrentList={ this.state.wordsInCurrentList }
|
||||||
|
|
Loading…
Add table
Reference in a new issue