1
0
Fork 0
mirror of https://github.com/GuerillaStudio/vanillalist.git synced 2024-12-21 08:31:55 +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,10 +42,14 @@ class PluginSearch {
} }
generateResults(plugins) { generateResults(plugins) {
if (plugins.length === 0) {
this.noresult.classList.remove('hidden')
} else {
this.container.innerHTML = plugins.map(plugin => { this.container.innerHTML = plugins.map(plugin => {
return this.cardGenerator(plugin) return this.cardGenerator(plugin)
}).join(''); }).join('');
} }
}
updateResults(plugins) { updateResults(plugins) {
const queryParams = new URLSearchParams(window.location.search); const queryParams = new URLSearchParams(window.location.search);

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>