1
0
Fork 0
mirror of https://github.com/GuerillaStudio/vanillalist.git synced 2024-12-30 11:51:57 +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() { constructor() {
this.plugins = null this.plugins = null
this.container = document.querySelector('[data-search="results"]') this.container = document.querySelector('[data-search="results"]')
this.noresult = document.querySelector('[data-search="noresult"]')
this.form = document.querySelector('[data-search="form"]') this.form = document.querySelector('[data-search="form"]')
this.input = document.querySelector('[data-search="input"]') this.input = document.querySelector('[data-search="input"]')
this.cardGenerator = window.vanillalistCard this.cardGenerator = window.vanillalistCard
@ -41,9 +42,13 @@ class PluginSearch {
} }
generateResults(plugins) { generateResults(plugins) {
this.container.innerHTML = plugins.map(plugin => { if (plugins.length === 0) {
return this.cardGenerator(plugin) this.noresult.classList.remove('hidden')
}).join(''); } else {
this.container.innerHTML = plugins.map(plugin => {
return this.cardGenerator(plugin)
}).join('');
}
} }
updateResults(plugins) { updateResults(plugins) {

View file

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