Skip to content

Commit c9273bf

Browse files
committed
fix(design): improvements from feedbacks
- No results - Select Icon - Start screen message
1 parent 3513478 commit c9273bf

4 files changed

Lines changed: 71 additions & 39 deletions

File tree

src/NoResultsScreen.tsx

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { NoResultsIcon } from './icons';
1010

1111
interface NoResultsScreenProps
1212
extends AutocompleteApi<
13-
InternalDocSearchHit,
14-
React.FormEvent,
15-
React.MouseEvent,
16-
React.KeyboardEvent
13+
InternalDocSearchHit,
14+
React.FormEvent,
15+
React.MouseEvent,
16+
React.KeyboardEvent
1717
> {
1818
state: AutocompleteState<InternalDocSearchHit>;
1919
inputRef: React.MutableRefObject<null | HTMLInputElement>;
@@ -26,43 +26,45 @@ export function NoResultsScreen(props: NoResultsScreenProps) {
2626
return (
2727
<div className="DocSearch-NoResults">
2828
<div className="DocSearch-Screen-Icon">
29-
<NoResultsIcon/>
29+
<NoResultsIcon />
3030
</div>
3131
<p className="DocSearch-Title">
3232
No results for "<strong>{props.state.query}</strong>".
3333
</p>
3434

3535
{searchSuggestions && searchSuggestions.length > 0 && (
36-
<p>
37-
Try searching for{' '}
38-
{searchSuggestions.slice(0, 3).reduce<React.ReactNode[]>(
39-
(acc, search) => [
40-
...acc,
41-
<button
42-
className="DocSearch-Prefill"
43-
key={search}
44-
onClick={() => {
45-
props.setQuery(search.toLowerCase() + ' ');
46-
props.refresh();
47-
props.inputRef.current!.focus();
48-
}}
49-
>
50-
{search}
51-
</button>,
52-
],
53-
[]
54-
)}
55-
</p>
36+
<div className="DocSearch-NoResults-Prefill-List">
37+
<p className="DocSearch-Help">Try searching for:</p>
38+
<ul>
39+
{searchSuggestions.slice(0, 3).reduce<React.ReactNode[]>(
40+
(acc, search) => [
41+
...acc,
42+
<li><button
43+
className="DocSearch-Prefill"
44+
key={search}
45+
onClick={() => {
46+
props.setQuery(search.toLowerCase() + ' ');
47+
props.refresh();
48+
props.inputRef.current!.focus();
49+
}}
50+
>
51+
{search}
52+
</button></li>,
53+
],
54+
[]
55+
)}
56+
</ul>
57+
</div>
5658
)}
5759

5860
<p className="DocSearch-Help">
59-
If you believe this query should return results, please{' '}
61+
You believe this query should return results?{' '}
6062
<a
6163
href="https://github.com/algolia/docsearch-configs/issues/new?template=Missing_results.md"
6264
target="_blank"
6365
rel="noopener noreferrer"
6466
>
65-
let us know on GitHub
67+
Let us know
6668
</a>
6769
.
6870
</p>

src/StartScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function StartScreen(props: StartScreenProps) {
2727
if (props.state.status === 'idle' && props.hasSuggestions === false) {
2828
return (
2929
<div className="DocSearch-StartScreen">
30-
<p className="DocSearch-Help">Your search history will appear here.</p>
30+
<p className="DocSearch-Help">No recent searches</p>
3131
</div>
3232
);
3333
}

src/icons/SelectIcon.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22

33
export function SelectIcon() {
44
return (
5-
<svg width="20" height="20" viewBox="0 0 20 20">
5+
<svg className="DocSearch-Hit-Select-Icon" width="20" height="20" viewBox="0 0 20 20">
66
<g
77
stroke="currentColor"
88
fill="none"

src/style.css

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -538,15 +538,19 @@ html[data-theme='dark'] {
538538
border-radius: 50%;
539539
}
540540

541+
svg.DocSearch-Hit-Select-Icon {
542+
display: none;
543+
}
544+
.DocSearch-Hit[aria-selected='true'] svg.DocSearch-Hit-Select-Icon {
545+
display: block;
546+
}
547+
548+
541549
.DocSearch-Hit-action-button:hover {
542550
transition: background-color .1s ease-in;
543551
background: rgba(0,0,0,0.2);
544552
}
545553

546-
.DocSearch-Hit-action-button:active {
547-
transform: scale(1.2);
548-
}
549-
550554
.DocSearch-Hit-action-button:hover path{
551555
fill: white;
552556
}
@@ -557,7 +561,7 @@ html[data-theme='dark'] {
557561
width: 80%;
558562
margin: 0 8px;
559563
line-height: 1.1em;
560-
flex: 2 1 auto;
564+
flex: 1 1 auto;
561565
font-weight: 500;
562566
overflow-x: hidden;
563567
white-space: nowrap;
@@ -592,21 +596,47 @@ html[data-theme='dark'] {
592596
padding-bottom: 12px;
593597
}
594598

599+
.DocSearch-NoResults-Prefill-List {
600+
text-align: left;
601+
display: flex;
602+
padding-bottom: 24px;
603+
align-items: flex-start;
604+
flex-wrap: nowrap;
605+
}
606+
607+
.DocSearch-NoResults-Prefill-List p{
608+
width: 50%;
609+
text-align: right;
610+
}
611+
612+
.DocSearch-NoResults-Prefill-List ul{
613+
padding: 0 12px;
614+
flex-grow: 1;
615+
width: 50%;
616+
}
617+
618+
.DocSearch-NoResults-Prefill-List li{
619+
list-style-type: '- ';
620+
list-style-position: inside;
621+
padding: 0;
622+
margin:0;
623+
}
624+
595625
.DocSearch-Prefill {
596626
appearance: none;
597627
cursor: pointer;
598628
border: none;
599629
display: inline-block;
600630
border-radius: 1em;
601-
font-size: 0.8em;
602-
background-color: var(--docsearch-muted-color);
603-
margin: 0 4px;
604-
padding: 4px 12px;
631+
font-size: 1em;
632+
background: none;
633+
/* background-color: var(--docsearch-muted-color); */
634+
padding: 0;
605635
}
606636

607637
.DocSearch-Prefill:hover {
608638
outline: none;
609-
background-color: var(--docsearch-primary-color);
639+
color: var(--docsearch-primary-color);
610640
}
611641

612642
/* Responsive */

0 commit comments

Comments
 (0)