Fix search behavior

This commit is contained in:
Georgi Gardev
2023-11-19 13:41:33 +02:00
parent 07d48ad09f
commit ed8ff6c921
3 changed files with 9 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
import { Accessor, For } from 'solid-js';
import { Accessor, For, Show } from 'solid-js';
import { AppDefinition } from '~/types';
import { App } from './App';
@@ -7,18 +7,20 @@ import style from './AppList.module.css';
export function AppList(props: {
category: Accessor<string>;
apps: Accessor<AppDefinition[]>;
resetCategory?(): void;
onReset?(): void;
}) {
return (
<div class={style.AppListWrap}>
<h2 class={style.Header}>
{props.category()}
<span class={style.Close} onClick={props.resetCategory}>
<span class={style.Close} onClick={props.onReset}>
×
</span>
</h2>
<div class={style.AppList}>
<For each={props.apps()}>{(app) => <App {...app} />}</For>
<Show when={props.apps().length !== 0} fallback="No apps found">
<For each={props.apps()}>{(app) => <App {...app} />}</For>
</Show>
</div>
</div>
);

View File

@@ -61,7 +61,7 @@ export function Search(props: SearchProps) {
/>
<div class={style.Provider}>{activeProvider()?.name}</div>
</div>
<Show when={props.canOpenApp}>
<Show when={props.canOpenApp()}>
<span class={style.Hint}>Press Shift+Enter to open first result</span>
</Show>
</div>

View File

@@ -88,7 +88,7 @@ export default function Home() {
<AppList
category={() => 'search results'}
apps={searchResults}
resetCategory={() => setSearchTerm('')}
onReset={() => setSearchTerm('')}
/>
</Show>
</>
@@ -97,7 +97,7 @@ export default function Home() {
<AppList
category={() => activeCategoryDef()?.name ?? ''}
apps={() => activeCategoryDef()?.apps ?? []}
resetCategory={resetCategory}
onReset={resetCategory}
/>
</Show>
</div>