Skip to content

Commit eeb6d60

Browse files
authored
Merge pull request #305 from NGO-Algorithm-Audit/feature/search-improvements
Feature/search improvements
2 parents a589c27 + 7afe074 commit eeb6d60

File tree

5 files changed

+49
-21
lines changed

5 files changed

+49
-21
lines changed

i18n/en.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,11 @@ other = "Medium risk"
9191
[score-card--low-risk]
9292
other = "Low risk"
9393

94+
[search]
95+
other = "Search"
96+
9497
[search-type-to-start]
95-
other = "Type to start searching"
98+
other = "Type to start searching"
99+
100+
[search-no-results]
101+
other = "No results found"

i18n/nl.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,11 @@ other = "Medium risico"
9191
[score-card--low-risk]
9292
other = "Laag risico"
9393

94+
[search]
95+
other = "Zoeken"
96+
9497
[search-type-to-start]
95-
other = "Typ om te beginnen met zoeken"
98+
other = "Typ om te beginnen met zoeken"
99+
100+
[search-no-results]
101+
other = "Geen resultaten gevonden"

layouts/index.html

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
width: 100%;
2121
height: 200vh;
2222
background-color: rgba(0, 0, 0, 0.35);
23-
z-index: 1000;
23+
z-index: 11000;
2424
}
2525

2626
.algolia-search {
27-
z-index: 5000;
27+
&.isfocused {
28+
z-index: 12000;
29+
}
2830
position: relative;
2931
.search-panel {
3032
display: block;
@@ -34,11 +36,6 @@
3436
flex: 3;
3537
}
3638

37-
.ais-Highlight-highlighted {
38-
color: inherit;
39-
font-size: inherit;
40-
}
41-
4239
#searchbox {
4340
margin-bottom: 2rem;
4441
}
@@ -59,9 +56,16 @@
5956
margin-top: 10px;
6057
margin-bottom: 10px;
6158
}
62-
6359
.search-result-image {
6460
height: auto;
61+
width: auto;
62+
@media (min-width: 992px) {
63+
position: absolute;
64+
}
65+
top: 0;
66+
left: 0;
67+
bottom: 0;
68+
right: 0;
6569
max-height: 175px;
6670
max-width: 100%;
6771
margin: auto;
@@ -75,19 +79,18 @@
7579
list-style: none;
7680
}
7781

78-
.ais-Highlight-highlighted,
79-
.ais-Snippet-highlighted {
82+
mark {
8083
background-color: #FFFF92;
8184
}
8285
}
8386
</style>
8487
<!-- Search -->
8588
<div class="search-overlay d-none"></div>
86-
<section class="section color-blue">
89+
<section class="section color-blue" id="search">
8790
<div class="container algolia-search rounded-lg">
8891
<div class="row">
8992
<div class="col">
90-
<h2 class="pt-5 color-blue">Search</h2>
93+
<h2 class="pt-5 color-blue">{{i18n "search" }}</h2>
9194
</div>
9295
</div>
9396
<div class="row">
@@ -165,6 +168,11 @@ <h2 class="pt-5 color-blue">Search</h2>
165168
return;
166169
}
167170

171+
if(!items || !items.length > 0) {
172+
container.querySelector('ol').innerHTML = `<p>{{i18n "search-no-results"}}</p>`;
173+
return;
174+
}
175+
168176
container.querySelector('ol').innerHTML = items
169177
.map(
170178
item => {
@@ -173,13 +181,13 @@ <h2 class="pt-5 color-blue">Search</h2>
173181
<a href=${item.url} class="container">
174182
<div class="row search-result-row">
175183
<div class="col-12 col-lg-2">
176-
<div class="my-3">
177-
<img class="image-fluid search-result-image d-flex" src=${item.image} alt=${item.title} />
184+
<div class="my-3 text-center image-frame">
185+
<img class="image-fluid search-result-image d-inline p-2" src=${item.image} alt=${item.title} />
178186
</div>
179187
</div>
180188
<div class="col-12 col-lg-10">
181-
<h3 class="color-blue search-result-title">${item.title}</h3>
182-
<p class="color-gray search-result-subtitle">${item.subtitle}</p>
189+
<h3 class="color-blue search-result-title">${item._highlightResult.title.value}</h3>
190+
<p class="color-gray search-result-subtitle">${item._highlightResult.subtitle.value}</p>
183191
</div>
184192
</div>
185193
</a>
@@ -195,7 +203,7 @@ <h3 class="color-blue search-result-title">${item.title}</h3>
195203
placeholder: '{{ i18n "search-type-to-start" }}',
196204
}),
197205
instantsearch.widgets.configure({
198-
hitsPerPage: 3,
206+
hitsPerPage: 8,
199207
filters: "language:{{$.Site.Language.Lang}}"
200208
}),
201209
infiniteHits({
@@ -211,6 +219,7 @@ <h3 class="color-blue search-result-title">${item.title}</h3>
211219
docReady(function () {
212220
$("input.ais-SearchBox-input").on("focus", function () {
213221
$(".algolia-search").addClass("bg-lightblue");
222+
$(".algolia-search").addClass("isfocused");
214223
$("#hits").addClass("d-block");
215224
$("#hits").removeClass("d-none");
216225
$(".search-overlay").removeClass("d-none");
@@ -219,6 +228,7 @@ <h3 class="color-blue search-result-title">${item.title}</h3>
219228

220229
$(".search-overlay").on("click", function () {
221230
$(".algolia-search").removeClass("bg-lightblue");
231+
$(".algolia-search").removeClass("isfocused");
222232
$("#hits").removeClass("d-block");
223233
$("#hits").addClass("d-none");
224234
$(".search-overlay").addClass("d-none");

layouts/partials/head.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
<meta name="search_title" content="{{if .Params.search.title}}{{.Params.search.title}}{{else}}{{.Params.title}}{{end}}">
2121
<meta name="search_subtitle" content="{{if .Params.search.title}}{{.Params.search.subtitle}}{{else}}{{.Params.subtitle}}{{end}}">
22-
<meta name="search_image" content="{{if .Params.search.image}}{{.Params.search.image}}{{else}}{{.Params.image}}{{end}}">
22+
<meta name="search_image" content="{{if .Params.search.image}}{{.Params.search.image | relURL}}{{else}}{{.Params.image | relURL}}{{end}}">
2323

2424
<!--Favicon-->
2525
<link rel="shortcut icon" href="{{ site.Params.favicon | absURL }}" type="image/x-icon">

layouts/partials/header.html

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,14 @@
5959
{{ end }}
6060
{{ end }}
6161

62+
<!-- Search -->
63+
<li class="nav-item">
64+
<a class="nav-link" href='{{ if eq .Site.Language.Lang "en" }}{{else}}/nl{{end}}/#search' title="Search">{{i18n "search" }} <i class="fas fa-search"></i></a>
65+
</li>
66+
<!-- /Search -->
67+
68+
6269
<!-- Language toggle -->
63-
6470
{{ if .IsTranslated }}
6571
{{ range .Translations }}
6672
<li class="nav-item d-inline-block" style="min-width: 137px;">

0 commit comments

Comments
 (0)