@@ -32,6 +32,8 @@ export class AppBlog {
3232 @State ( ) searchIsError : boolean = false ;
3333 @State ( ) searchIsLoading : boolean = false ;
3434
35+ @State ( ) displaySearchBar : boolean = false ;
36+
3537 pageSize = 3 ;
3638 indexOfFeaturedPost = - 1 ;
3739 pageOfFeaturedPost = 0 ;
@@ -318,6 +320,14 @@ export class AppBlog {
318320 return pagination ;
319321 }
320322
323+ showSearchbar ( ) {
324+ this . displaySearchBar = true ;
325+ }
326+
327+ hideSearchBar ( ) {
328+ this . displaySearchBar = false ;
329+ }
330+
321331 render ( ) {
322332 const featuredPost = this . renderFeaturedPost ( this . featuredPost , this . featuredIsLoading , this . featuredIsError ) ;
323333 const filters = this . renderFilters ( this . blogFilter , this . searchIsLoading || this . blogIsLoading , this . searchQuery ) ;
@@ -340,24 +350,36 @@ export class AppBlog {
340350 < div id = "blog-filters" class = "blog-filters" >
341351 < div class = "blog-filters-nav" >
342352 < div class = "blog-search-group d-md-none" >
343- < span class = "blog-search-icon fa fa-search" />
353+ < span class = "blog-search-icon-top fa fa-search" />
344354 < input id = "blog-search" type = "search" class = "blog-search-input" placeholder = "Search the blog" onKeyUp = { e => this . handleSearch ( e . target [ 'value' ] ) } />
345355 </ div >
346356
347- < ul class = "blog-filters-list" >
348- { filters }
349- < li class = "blog-filter-item d-none d-lg-block" >
357+ { this . displaySearchBar ? (
358+ < div class = "searchbar-top" >
350359 < div class = "blog-search-group" >
351- < span class = "blog-search-icon fa fa-search" />
352- < input id = "blog-search" type = "search" class = "blog-search-input" placeholder = "Search the blog" onKeyUp = { e => this . handleSearch ( e . target [ 'value' ] ) } />
360+ < span class = "blog-search-icon-top fa fa-search" />
361+ < input id = "blog-search" type = "search" class = "blog-search-input-top " placeholder = "Search the blog" onKeyUp = { e => this . handleSearch ( e . target [ 'value' ] ) } />
353362 </ div >
354- </ li >
355- < li class = "blog-filter-item d-lg-none" >
356- < div class = "blog-search-group" >
357- < span class = "blog-search-icon fa fa-search" />
358- </ div >
359- </ li >
360- </ ul >
363+ < button onClick = { ( ) => this . hideSearchBar ( ) } >
364+ < i class = "far fa-times-circle" />
365+ </ button >
366+ </ div >
367+ ) : (
368+ < ul class = "blog-filters-list" >
369+ { filters }
370+ < li class = "blog-filter-item d-none d-lg-block" >
371+ < div class = "blog-search-group" >
372+ < span class = "blog-search-icon fa fa-search" />
373+ < input id = "blog-search" type = "search" class = "blog-search-input" placeholder = "Search the blog" onKeyUp = { e => this . handleSearch ( e . target [ 'value' ] ) } />
374+ </ div >
375+ </ li >
376+ < li class = "blog-filter-item d-lg-none" onClick = { ( ) => this . showSearchbar ( ) } >
377+ < div class = "blog-search-group" >
378+ < span class = "blog-search-icon fa fa-search" />
379+ </ div >
380+ </ li >
381+ </ ul >
382+ ) }
361383 </ div >
362384 </ div >
363385 < div class = "row posts-row" >
0 commit comments