Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit 13c6f2d

Browse files
committed
feat: add search status message for no results and internet connection
1 parent 128fb4d commit 13c6f2d

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

main.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,12 @@ class CssSnippetStoreModal extends Modal {
186186

187187
contentEl.createEl('h1', { text: 'CSS Snippet Store' });
188188

189+
// Wrapper for search + status message
190+
const topContainer = contentEl.createDiv();
191+
topContainer.style.marginBottom = '1rem';
192+
189193
// Search bar
190-
const searchInput = contentEl.createEl('input', {
194+
const searchInput = topContainer.createEl('input', {
191195
type: 'text',
192196
placeholder: 'Search snippets...',
193197
});
@@ -196,11 +200,20 @@ class CssSnippetStoreModal extends Modal {
196200
searchInput.style.width = '100%';
197201
searchInput.style.padding = '0.5rem';
198202

203+
// Message container
204+
const messageEl = topContainer.createEl('div');
205+
messageEl.style.marginTop = '0.5rem';
206+
messageEl.style.textAlign = 'center';
207+
messageEl.style.color = 'var(--text-muted)';
208+
messageEl.style.fontStyle = 'italic';
209+
199210
const grid = contentEl.createEl('div', { cls: 'community-items-container' });
200211

201212
// Render Function
202213
const renderSnippets = (filter: string = "") => {
203214
grid.empty();
215+
messageEl.empty();
216+
204217
const lowerFilter = filter.toLowerCase();
205218

206219
const filteredSnippets = this.snippets.filter(snippet =>
@@ -211,17 +224,11 @@ class CssSnippetStoreModal extends Modal {
211224
);
212225

213226
if (filteredSnippets.length === 0) {
214-
const noResultsMessage = grid.createEl('div', {
215-
text: this.snippets.length === 0
227+
messageEl.setText(
228+
this.snippets.length === 0
216229
? "No Internet connection"
217-
: "No snippets match your search.",
218-
cls: 'no-snippets-message'
219-
});
220-
noResultsMessage.style.marginTop = '1rem';
221-
noResultsMessage.style.textAlign = 'center';
222-
noResultsMessage.style.color = 'var(--text-muted)';
223-
noResultsMessage.style.fontStyle = 'italic';
224-
noResultsMessage.style.width = '100%';
230+
: "No snippets match your search."
231+
);
225232
return;
226233
}
227234

@@ -274,7 +281,6 @@ class CssSnippetStoreModal extends Modal {
274281
});
275282
};
276283

277-
278284
// Initial rendering
279285
renderSnippets();
280286

0 commit comments

Comments
 (0)