Fix search behavior
This commit is contained in:
@@ -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>
|
||||
);
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user