Skip to content

Commit d5d81a8

Browse files
committed
Updated styles for SearchDialog.
1 parent 897fd85 commit d5d81a8

File tree

5 files changed

+45
-36
lines changed

5 files changed

+45
-36
lines changed

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/docs/components/Dialog/Dialog.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
const classes = $derived(
5757
{
5858
drawer: `${commonClasses} top-0 left-0 right-0 bottom-0 h-screen w-fit max-w-[500px]`,
59-
modal: `${commonClasses} top-4 md:top-[15%] left-1/2 -translate-x-1/2 w-[calc(100%-2rem)] max-w-[500px] rounded-md bg-surface-700`,
59+
modal: `${commonClasses} top-4 md:top-[15%] left-1/2 -translate-x-1/2 w-[calc(100%-2rem)] max-w-[500px] rounded-md bg-surface-700 max-h-[75vh] max-w-[800px] overflow-auto`,
6060
}[type],
6161
);
6262

src/docs/components/PageHeader/SearchDialog.svelte renamed to src/docs/components/Dialog/SearchDialog.svelte

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script lang="ts">
2-
import Dialog from '../Dialog/Dialog.svelte';
2+
import Dialog from './Dialog.svelte';
33
import SearchIcon from 'lucide-svelte/icons/search';
4+
import LoaderIcon from 'lucide-svelte/icons/loader';
45
import { page } from '$app/stores';
56
67
let open = $state(false);
@@ -13,7 +14,7 @@
1314
1415
// FIXME: https://github.com/sveltejs/eslint-plugin-svelte/issues/652
1516
// eslint-disable-next-line svelte/valid-compile
16-
const result = await $page.data.pagefind.search(query);
17+
const result = await $page.data.pagefind.debouncedSearch(query, {}, 250);
1718
1819
if (result === null) {
1920
return [];
@@ -56,30 +57,38 @@
5657
/>
5758
<SearchIcon class="absolute left-4 top-1/2 -translate-y-1/2" />
5859
</div>
59-
<div class="p-4 flex flex-col gap-1 max-h-[600px] overflow-auto min-h-[100px]" tabindex="-1">
60-
{#await searchPromise then results}
61-
{#if results.length > 0}
62-
<p class="text-lg text-center">
63-
Found {results.length}
64-
{results.length === 1 ? 'result' : 'results'} for "{query}":
60+
<div class="flex flex-col gap-1 p-4" tabindex="-1">
61+
{#if query === ''}
62+
<p class="text-lg text-center py-16">What can we help you find?</p>
63+
{:else}
64+
{#await searchPromise}
65+
<p class="text-lg text-center py-16">
66+
<LoaderIcon class="inline animate-spin" size={16} />
6567
</p>
66-
<nav>
67-
<ul class="flex flex-col gap-4">
68-
{#each results as result}
69-
<li>
70-
<a href={result.url.replace('.html', '')} class="text-xl font-semibold"
71-
>{result.meta.title}</a
72-
>
73-
<!-- eslint-disable-next-line svelte/no-at-html-tags-->
74-
<p class="text-sm line-clamp-2">{@html result.excerpt}</p>
75-
</li>
76-
{/each}
77-
</ul>
78-
</nav>
79-
{:else if query !== ''}
80-
<p class="text-lg text-center">No results found for "{query}"</p>
81-
{/if}
82-
{/await}
68+
{:then results}
69+
{#if results.length > 0}
70+
<nav>
71+
<ul class="space-y-4">
72+
{#each results as result}
73+
<li>
74+
<a
75+
href={result.url.replace('.html', '')}
76+
class="block text-xl font-semibold hover:bg-surface-500 focus:bg-surface-500 transition p-1 rounded-md"
77+
>
78+
{result.meta.title}
79+
80+
<!-- eslint-disable-next-line svelte/no-at-html-tags-->
81+
<p class="text-sm line-clamp-2">{@html result.excerpt}</p>
82+
</a>
83+
</li>
84+
{/each}
85+
</ul>
86+
</nav>
87+
{:else if query !== ''}
88+
<p class="text-lg text-center py-16">No results found for "{query}"</p>
89+
{/if}
90+
{/await}
91+
{/if}
8392
</div>
8493
</div>
8594
</Dialog>

src/docs/components/PageHeader/PageHeader.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
// Icons
55
import IconMenu from 'lucide-svelte/icons/menu';
6-
import SearchDialog from './SearchDialog.svelte';
6+
import SearchDialog from '../Dialog/SearchDialog.svelte';
77
import { getDrawer } from '$docs/stores.svelte.js';
88
99
const drawer = getDrawer();

vite.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import pagefind from 'vite-plugin-pagefind';
55

66
export default defineConfig({
77
plugins: [sveltekit(), svelteTesting(), pagefind()],
8-
experimental: {
9-
// Remove when https://github.com/sveltejs/vite-plugin-svelte/issues/909 is fixed
10-
hmrPartialAccept: false,
11-
},
8+
// experimental: {
9+
// // Remove when https://github.com/sveltejs/vite-plugin-svelte/issues/909 is fixed
10+
// hmrPartialAccept: false,
11+
// },
1212
test: {
1313
include: ['./src/lib/**/*.{test,test.svelte}.{js,ts}'],
1414
setupFiles: ['./src/vitest.setup.ts'],

0 commit comments

Comments
 (0)