1
0
Fork 0
mirror of https://github.com/GuerillaStudio/vanillalist.git synced 2024-10-22 09:27:30 +00:00

Display message when no search result

This commit is contained in:
Tixie 2022-01-03 13:48:57 +01:00
parent e722ef899c
commit a70690880b
2 changed files with 9 additions and 3 deletions

View file

@ -2,6 +2,7 @@ class PluginSearch {
constructor() {
this.plugins = null
this.container = document.querySelector('[data-search="results"]')
this.noresult = document.querySelector('[data-search="noresult"]')
this.form = document.querySelector('[data-search="form"]')
this.input = document.querySelector('[data-search="input"]')
this.cardGenerator = window.vanillalistCard
@ -41,9 +42,13 @@ class PluginSearch {
}
generateResults(plugins) {
this.container.innerHTML = plugins.map(plugin => {
return this.cardGenerator(plugin)
}).join('');
if (plugins.length === 0) {
this.noresult.classList.remove('hidden')
} else {
this.container.innerHTML = plugins.map(plugin => {
return this.cardGenerator(plugin)
}).join('');
}
}
updateResults(plugins) {

View file

@ -18,6 +18,7 @@ class Main {
`;
return `
<div class="txtcenter hidden" data-search="noresult">No plugin found with those keywords :(</div>
<div class="pluginList" data-search="results">
</div>