1111{{ partial "overview_block.html" .}}
1212
1313< style >
14-
1514 .search-overlay {
1615 cursor : pointer;
1716 position : fixed;
2726 & .isfocused {
2827 z-index : 12000 ;
2928 }
29+
3030 position : relative;
31+
3132 .search-panel {
3233 display : block;
3334 }
5657 margin-top : 10px ;
5758 margin-bottom : 10px ;
5859 }
60+
5961 .search-result-image {
6062 height : auto;
6163 width : auto;
64+
6265 @media (min-width : 992px ) {
6366 position : absolute;
6467 }
68+
6569 top : 0 ;
6670 left : 0 ;
6771 bottom : 0 ;
7579 margin-top : 40px ;
7680 }
7781
82+ .search-tags-desktop {
83+ @media (max-width : 992px ) {
84+ display : none;
85+ }
86+
87+ @media (min-width : 992px ) {
88+ bottom : 13px ;
89+ }
90+ }
91+
92+ .search-tags-mobile {
93+ @media (min-width : 992px ) {
94+ display : none;
95+ }
96+
97+ @media (max-width : 992px ) {
98+ top : 30px ;
99+ right : 30px ;
100+ }
101+ }
102+
78103 ol .ais-Hits-list {
79104 list-style : none;
80105 }
@@ -121,7 +146,7 @@ <h2 class="pt-5 color-blue">{{i18n "search" }}</h2>
121146 indexName : 'website_pages' ,
122147 searchClient,
123148 future : { preserveSharedStateOnUnmount : true } ,
124- searchFunction : function ( helper ) {
149+ searchFunction : function ( helper ) {
125150 if ( helper . state . query === '' ) {
126151 return ;
127152 }
@@ -163,16 +188,50 @@ <h2 class="pt-5 color-blue">{{i18n "search" }}</h2>
163188 }
164189
165190 const searchInput = $ ( ".ais-SearchBox-input" ) ;
166- if ( ! searchInput . is ( ":focus" ) ) {
191+ if ( ! searchInput . is ( ":focus" ) ) {
167192 container . querySelector ( 'ol' ) . innerHTML = "" ;
168193 return ;
169194 }
170195
171- if ( ! items || ! items . length > 0 ) {
196+ if ( ! items || ! items . length > 0 ) {
172197 container . querySelector ( 'ol' ) . innerHTML = `<p>{{i18n "search-no-results"}}</p>` ;
173198 return ;
174199 }
175-
200+
201+ const tagToHighlightClass = ( tag ) => {
202+ if ( tag === "Kennisplatform"
203+ || tag === "Knowledge platform" ) {
204+ return `highlight-lightblue-sm` ;
205+ }
206+
207+ if ( tag === "Algoprudentie"
208+ || tag === "Algoprudence" ) {
209+ return `highlight-red-sm` ;
210+ }
211+
212+ if ( tag === "Technische tools"
213+ || tag === "Technical tools" ) {
214+ return `highlight-yellow-sm` ;
215+ }
216+
217+ if ( tag === "Events"
218+ || tag === "Evenementen" ) {
219+ return `highlight-lightblue-sm` ;
220+ }
221+
222+ if ( tag === "About"
223+ || tag === "Over ons" ) {
224+ return `highlight-lightblue-sm` ;
225+ }
226+ }
227+
228+ const tagToHtml = ( tag ) => {
229+ if ( ! tag ) {
230+ return '' ;
231+ }
232+ return `<span class="${ tagToHighlightClass ( tag ) } mr-3">${ tag } </span>` ;
233+ } ;
234+
176235 container . querySelector ( 'ol' ) . innerHTML = items
177236 . map (
178237 item => {
@@ -181,15 +240,22 @@ <h2 class="pt-5 color-blue">{{i18n "search" }}</h2>
181240 <a href=${ item . url } class="container">
182241 <div class="row search-result-row">
183242 <div class="col-12 col-lg-2">
243+ <div class="position-absolute search-tags-mobile">
244+ ${ tagToHtml ( item . tag ) }
245+ </div>
184246 <div class="my-3 text-center image-frame">
185247 <img class="image-fluid search-result-image d-inline p-2" src='${ item . image } ' alt='${ item . title } ' />
186248 </div>
187249 </div>
188250 <div class="col-12 col-lg-10">
189251 <h3 class="color-blue search-result-title">${ item . _highlightResult . title . value } </h3>
190252 <p class="color-gray search-result-subtitle">${ item . _highlightResult . subtitle . value } </p>
253+ <div class="position-absolute search-tags-desktop">
254+ ${ tagToHtml ( item . tag ) }
255+ </div>
191256 </div>
192257 </div>
258+
193259 </a>
194260 </li>
195261 ` ;
0 commit comments