@@ -186,8 +186,12 @@ class CssSnippetStoreModal extends Modal {
186
186
187
187
contentEl . createEl ( 'h1' , { text : 'CSS Snippet Store' } ) ;
188
188
189
+ // Wrapper for search + status message
190
+ const topContainer = contentEl . createDiv ( ) ;
191
+ topContainer . style . marginBottom = '1rem' ;
192
+
189
193
// Search bar
190
- const searchInput = contentEl . createEl ( 'input' , {
194
+ const searchInput = topContainer . createEl ( 'input' , {
191
195
type : 'text' ,
192
196
placeholder : 'Search snippets...' ,
193
197
} ) ;
@@ -196,11 +200,20 @@ class CssSnippetStoreModal extends Modal {
196
200
searchInput . style . width = '100%' ;
197
201
searchInput . style . padding = '0.5rem' ;
198
202
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
+
199
210
const grid = contentEl . createEl ( 'div' , { cls : 'community-items-container' } ) ;
200
211
201
212
// Render Function
202
213
const renderSnippets = ( filter : string = "" ) => {
203
214
grid . empty ( ) ;
215
+ messageEl . empty ( ) ;
216
+
204
217
const lowerFilter = filter . toLowerCase ( ) ;
205
218
206
219
const filteredSnippets = this . snippets . filter ( snippet =>
@@ -211,17 +224,11 @@ class CssSnippetStoreModal extends Modal {
211
224
) ;
212
225
213
226
if ( filteredSnippets . length === 0 ) {
214
- const noResultsMessage = grid . createEl ( 'div' , {
215
- text : this . snippets . length === 0
227
+ messageEl . setText (
228
+ this . snippets . length === 0
216
229
? "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
+ ) ;
225
232
return ;
226
233
}
227
234
@@ -274,7 +281,6 @@ class CssSnippetStoreModal extends Modal {
274
281
} ) ;
275
282
} ;
276
283
277
-
278
284
// Initial rendering
279
285
renderSnippets ( ) ;
280
286
0 commit comments