@@ -133,12 +133,7 @@ function initializeMeilisearchIntegration() {
133133 if ( ! isFlexContainer ) {
134134 // Create a wrapper to center the search bar
135135 const flexWrapper = document . createElement ( 'div' ) ;
136- flexWrapper . style . cssText = `
137- display: flex;
138- justify-content: center;
139- align-items: center;
140- width: 100%;
141- ` ;
136+ flexWrapper . className = 'meilisearch-flexwrapper' ;
142137 flexWrapper . appendChild ( searchBarContainer ) ;
143138 headerContainer . appendChild ( flexWrapper ) ;
144139 } else {
@@ -352,7 +347,10 @@ function initializeMeilisearchIntegration() {
352347
353348 debounceTimer = setTimeout ( ( ) => {
354349 // Show loading indicator
355- resultsContainer . innerHTML = '<div style="padding: 20px; text-align: center; color: rgba(255, 255, 255, 0.7);">Searching...</div>' ;
350+ const indicatorEl = document . createElement ( 'div' ) ;
351+ indicatorEl . className = 'meilisearch-modal__indicator' ;
352+ indicatorEl . innerHTML = 'Searching…' ;
353+ resultsContainer . appendChild ( indicatorEl ) ;
356354
357355 // Perform search
358356 index . search ( query , {
@@ -369,7 +367,11 @@ function initializeMeilisearchIntegration() {
369367 resultsContainer . innerHTML = '' ;
370368
371369 if ( response . hits . length === 0 ) {
372- resultsContainer . innerHTML = '<div style="padding: 20px; text-align: center; color: rgba(255, 255, 255, 0.5);">No results found</div>' ;
370+ const noResultsEl = document . createElement ( 'div' ) ;
371+ noResultsEl . className = 'meilisearch-modal__indicator' ;
372+ noResultsEl . innerHTML = 'No results found' ;
373+ resultsContainer . appendChild ( noResultsEl ) ;
374+
373375 return ;
374376 }
375377
@@ -398,27 +400,27 @@ function initializeMeilisearchIntegration() {
398400 results . forEach ( hit => {
399401 const resultItem = document . createElement ( 'a' ) ;
400402 resultItem . href = hit . url || `/${ hit . path } ` ;
401- resultItem . className = 'meilisearch-modal__category-link ' ;
403+ resultItem . className = 'meilisearch-modal__result ' ;
402404
403405 // Format content nicely
404406 // Build title from hierarchy levels
405407 const hierarchy_lvl1 = hit . _formatted ?. hierarchy_lvl1
406- ? hit . _formatted . hierarchy_lvl1 . replace ( / < e m > / g, '<em style="font-style: normal; color: #f472b6; font-weight: bold; ">' )
408+ ? hit . _formatted . hierarchy_lvl1 . replace ( / < e m > / g, '<em class="meilisearch-modal__category-em ">' )
407409 : '' ;
408410 const hierarchy_lvl2 = hit . _formatted ?. hierarchy_lvl2
409- ? hit . _formatted . hierarchy_lvl2 . replace ( / < e m > / g, '<em style="font-style: normal; color: #f472b6; font-weight: bold; ">' )
411+ ? hit . _formatted . hierarchy_lvl2 . replace ( / < e m > / g, '<em class="meilisearch-modal__category-em ">' )
410412 : '' ;
411413 const hierarchy_lvl3 = hit . _formatted ?. hierarchy_lvl3
412- ? hit . _formatted . hierarchy_lvl3 . replace ( / < e m > / g, '<em style="font-style: normal; color: #f472b6; font-weight: bold; ">' )
414+ ? hit . _formatted . hierarchy_lvl3 . replace ( / < e m > / g, '<em class="meilisearch-modal__category-em ">' )
413415 : '' ;
414416 const hierarchy_lvl4 = hit . _formatted ?. hierarchy_lvl4
415- ? hit . _formatted . hierarchy_lvl4 . replace ( / < e m > / g, '<em style="font-style: normal; color: #f472b6; font-weight: bold; ">' )
417+ ? hit . _formatted . hierarchy_lvl4 . replace ( / < e m > / g, '<em class="meilisearch-modal__category-em ">' )
416418 : '' ;
417419 const hierarchy_lvl5 = hit . _formatted ?. hierarchy_lvl5
418- ? hit . _formatted . hierarchy_lvl5 . replace ( / < e m > / g, '<em style="font-style: normal; color: #f472b6; font-weight: bold; ">' )
420+ ? hit . _formatted . hierarchy_lvl5 . replace ( / < e m > / g, '<em class="meilisearch-modal__category-em ">' )
419421 : '' ;
420422 const content = hit . _formatted ?. content
421- ? hit . _formatted . content . replace ( / < e m > / g, '<em style="font-style: normal; color: #f472b6; font-weight: bold; ">' )
423+ ? hit . _formatted . content . replace ( / < e m > / g, '<em class="meilisearch-modal__category-em ">' )
422424 : '' ;
423425
424426 let title = '' ;
@@ -439,20 +441,10 @@ function initializeMeilisearchIntegration() {
439441 }
440442
441443 resultItem . innerHTML = `
442- <div style="font-weight: 500; margin-bottom: 4px; ">${ title } </div>
443- ${ content ? `<div style="font-size: 13px; color: rgba(255, 255, 255, 0.6); ">${ content } </div>` : '' }
444+ <div class="meilisearch-modal__result-heading ">${ title } </div>
445+ ${ content ? `<div class="meilisearch-modal__result-content ">${ content } </div>` : '' }
444446 ` ;
445447
446- resultItem . addEventListener ( 'mouseover' , ( ) => {
447- resultItem . style . backgroundColor = 'rgba(255, 255, 255, 0.05)' ;
448- resultItem . style . borderLeftColor = '#f472b6' ;
449- } ) ;
450-
451- resultItem . addEventListener ( 'mouseout' , ( ) => {
452- resultItem . style . backgroundColor = 'transparent' ;
453- resultItem . style . borderLeftColor = 'transparent' ;
454- } ) ;
455-
456448 // Make clicking the result close the modal
457449 resultItem . addEventListener ( 'click' , ( ) => {
458450 document . getElementById ( 'meilisearch-modal-overlay' ) . style . display = 'none' ;
@@ -465,7 +457,11 @@ function initializeMeilisearchIntegration() {
465457 } )
466458 . catch ( error => {
467459 console . error ( 'Meilisearch error:' , error ) ;
468- resultsContainer . innerHTML = '<div style="padding: 20px; text-align: center; color: #f87171;">Search error. Please try again.</div>' ;
460+ const errorEl = document . createElement ( 'div' ) ;
461+ errorEl . className = 'meilisearch-modal__error' ;
462+ errorEl . innerHTML = 'Search error. Please try again.' ;
463+
464+ resultsContainer . appendChild ( errorEl ) ;
469465 } ) ;
470466 } , 300 ) ;
471467 } ) ;
0 commit comments