0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-12-22 04:18:21 -05:00

feat: add images, error_box & new message when no results are provided (#185)

This commit is contained in:
neon_arch 2023-08-10 04:32:47 +03:00
parent 9fd8275b17
commit c4935f202a
8 changed files with 67 additions and 4 deletions

1
public/images/info.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#000000" data-darkreader-inline-color="" style="--darkreader-inline-color: #e8e6e3;"><path d="M12 11.5v5M12 7.51l.01-.011M12 22c5.523 0 10-4.477 10-10S17.523 2 12 2 2 6.477 2 12s4.477 10 10 10z" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #000000;"></path></svg>

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg width="24px" height="24px" stroke-width="1.5" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" color="#000000" data-darkreader-inline-color="" style="--darkreader-inline-color: #e8e6e3;"><path d="M20.043 21H3.957c-1.538 0-2.5-1.664-1.734-2.997l8.043-13.988c.77-1.337 2.699-1.337 3.468 0l8.043 13.988C22.543 19.336 21.58 21 20.043 21zM12 9v4" stroke="#000000" stroke-width="1.5" stroke-linecap="round" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #000000;"></path><path d="M12 17.01l.01-.011" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" data-darkreader-inline-stroke="" style="--darkreader-inline-stroke: #000000;"></path></svg>

After

Width:  |  Height:  |  Size: 750 B

View File

@ -0,0 +1,3 @@
function toggleErrorBox() {
}

View File

@ -70,6 +70,27 @@ body {
filter: brightness(1.2);
}
.result_not_found {
display: flex;
flex-direction: column;
font-size: 1.5rem;
color: var(--foreground-color);
}
.result_not_found p {
margin: 1rem 0;
}
.result_not_found ul {
margin: 1rem 0;
}
.result_not_found img {
width: 40rem;
}
/* styles for the footer and header */
header {

View File

@ -1,8 +1,8 @@
{{>header this.style}}
<main class="results">
{{>search_bar}}
{{>search_bar this}}
<div class="results_aggregated">
{{#each results}}
{{#if results}} {{#each results}}
<div class="result">
<h1><a href="{{{this.visitingUrl}}}">{{{this.title}}}</a></h1>
<small>{{{this.url}}}</small>
@ -13,13 +13,27 @@
{{/each}}
</div>
</div>
{{/each}}
{{/each}} {{else}}
<div class="result_not_found">
<p>Your search - {{{this.pageQuery}}} - did not match any documents.</p>
<p class="suggestions">Suggestions:</p>
<ul>
<li>Make sure that all words are spelled correctly.</li>
<li>Try different keywords.</li>
<li>Try more general keywords.</li>
</ul>
<img src="./images/no_results.gif" alt="Man fishing gif" />
</div>
{{/if}}
</div>
<div class="page_navigation">
<button type="button" onclick="navigate_backward()">&#8592; previous</button>
<button type="button" onclick="navigate_backward()">
&#8592; previous
</button>
<button type="button" onclick="navigate_forward()">next &#8594;</button>
</div>
</main>
<script src="static/index.js"></script>
<script src="static/pagination.js"></script>
<script src="static/error_box.js"></script>
{{>footer}}

View File

@ -6,4 +6,20 @@
placeholder="Type to search"
/>
<button type="submit" onclick="searchWeb()">search</button>
<div class="error_box">
<button onclick="toggleErrorBox()" class="error_box_dropdown">
<img src="./images/info.svg" alt="Info icon for error box" />
</button>
{{#each engineErrorsInfo}}
<div class="error_item">
<span class="engine_name">{{{this.engine}}}</span>
<span class="engine_name">{{{this.error}}}</span>
<span
class="severity_color"
style="background: {{{this.severity_color}}}; width: 400px; height: 400px"
>lsl</span
>
</div>
{{/each}}
</div>
</div>

View File

@ -116,10 +116,12 @@ impl RawSearchResult {
}
}
///
#[derive(Serialize, Deserialize)]
pub struct EngineErrorInfo {
pub error: String,
pub engine: String,
pub severity_color: String,
}
impl EngineErrorInfo {
@ -131,6 +133,11 @@ impl EngineErrorInfo {
EngineError::UnexpectedError => String::from("UnexpectedError"),
},
engine,
severity_color: match error {
EngineError::RequestError => String::from("green"),
EngineError::EmptyResultSet => String::from("blue"),
EngineError::UnexpectedError => String::from("red"),
},
}
}
}