Skip to content

Commit 3a21706

Browse files
JennySimenchalin
authored andcommitted
feat: no search entries found page (#5372)
1 parent 30d2376 commit 3a21706

File tree

3 files changed

+20
-6
lines changed

3 files changed

+20
-6
lines changed

assets/icons/search-not-found.png

40.7 KB
Loading

assets/js/registrySearch.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,12 @@ function executeSearch(searchQuery) {
163163
let results = miniSearch.search(searchQuery);
164164
document.getElementById('search-loading').style.display = 'none';
165165

166-
if (results.length > 0) {
167-
populateResults(results);
168-
} else {
169-
document.querySelector('#search-results').innerHTML +=
170-
'<p>No matches found</p>';
171-
}
166+
if (results.length === 0) {
167+
document.getElementById('no-search-result').style.display = 'block';
168+
}
169+
170+
populateResults(results);
171+
172172
}, 0);
173173
};
174174

layouts/shortcodes/ecosystem/registry/search-form.html

+14
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,20 @@
141141
<span class="spinner-border spinner-border-sm" aria-hidden="true"></span>
142142
<span role="status">Loading results…</span>
143143
</div>
144+
145+
<!-- When search hs no result -->
146+
<div style="display: none; padding:20px; text-align: center;" id="no-search-result">
147+
<div style="margin-left: auto; margin-right: auto; width: fit-content;">
148+
{{ with resources.Get "icons/search-not-found.png" }}
149+
<img style="border: none;" src="{{ .RelPermalink }}" width="250" alt="no result found">
150+
{{ end }}
151+
</div>
152+
<p style="color: #4f62ad; font-size: 28px; margin-bottom: 0;">Oops no results found</p>
153+
<p>No results match the filter criteria. Remove filter or clear all filters to show results</p>
154+
<button type="button" class="btn btn-outline-danger"
155+
onclick="document.getElementById('input-s').value = ''; document.getElementById('input-language').value = 'all';document.getElementById('input-component').value = 'all';document.getElementById('searchForm').submit();">Reset filters</button>
156+
</div>
157+
144158
<ul class="list-unstyled" id="search-results"></ul>
145159
<ul class="list-unstyled" id="default-body">
146160
{{ range $key, $value := $registry -}}

0 commit comments

Comments
 (0)