proper open/close modal
Browse files
src/lib/components/InferencePlayground/InferencePlayground.svelte
CHANGED
@@ -40,6 +40,7 @@
|
|
40 |
let hfToken: string | null = import.meta.env.VITE_HF_TOKEN;
|
41 |
let viewCode = false;
|
42 |
let showTokenModal = false;
|
|
|
43 |
let loading = false;
|
44 |
let tokens = 0;
|
45 |
let latency = 0;
|
@@ -218,6 +219,14 @@
|
|
218 |
/>
|
219 |
{/if}
|
220 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
221 |
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
222 |
<div
|
223 |
class="w-dvh grid divide-gray-200 overflow-hidden bg-gray-100/50 max-md:divide-y md:h-dvh dark:[color-scheme:dark]
|
@@ -395,5 +404,3 @@
|
|
395 |
</div>
|
396 |
{/if}
|
397 |
</div>
|
398 |
-
|
399 |
-
<ModelPickerModal {models} on:modelSelected={(e) => changeModel(e.detail)} />
|
|
|
40 |
let hfToken: string | null = import.meta.env.VITE_HF_TOKEN;
|
41 |
let viewCode = false;
|
42 |
let showTokenModal = false;
|
43 |
+
let showModelPickerModal = true;
|
44 |
let loading = false;
|
45 |
let tokens = 0;
|
46 |
let latency = 0;
|
|
|
219 |
/>
|
220 |
{/if}
|
221 |
|
222 |
+
{#if showModelPickerModal}
|
223 |
+
<ModelPickerModal
|
224 |
+
{models}
|
225 |
+
on:modelSelected={(e) => changeModel(e.detail)}
|
226 |
+
on:close={(e) => (showModelPickerModal = false)}
|
227 |
+
/>
|
228 |
+
{/if}
|
229 |
+
|
230 |
<!-- svelte-ignore a11y-no-static-element-interactions -->
|
231 |
<div
|
232 |
class="w-dvh grid divide-gray-200 overflow-hidden bg-gray-100/50 max-md:divide-y md:h-dvh dark:[color-scheme:dark]
|
|
|
404 |
</div>
|
405 |
{/if}
|
406 |
</div>
|
|
|
|
src/lib/components/InferencePlayground/InferencePlaygroundModelPickerModal.svelte
CHANGED
@@ -4,10 +4,35 @@
|
|
4 |
|
5 |
export let models: ModelEntryWithTokenizer[];
|
6 |
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
</script>
|
9 |
|
10 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
11 |
<div class="flex w-full max-w-[600px] items-start justify-center p-10">
|
12 |
<div
|
13 |
class="flex h-full w-full flex-col overflow-hidden rounded-lg border bg-white text-gray-900 shadow-md"
|
|
|
4 |
|
5 |
export let models: ModelEntryWithTokenizer[];
|
6 |
|
7 |
+
let backdropEl: HTMLDivElement;
|
8 |
+
|
9 |
+
const dispatch = createEventDispatcher<{ modelSelected: string; close: void }>();
|
10 |
+
|
11 |
+
function handleKeydown(event: KeyboardEvent) {
|
12 |
+
// close on ESC
|
13 |
+
if (event.key === 'Escape') {
|
14 |
+
event.preventDefault();
|
15 |
+
dispatch('close');
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
function handleBackdropClick(event: MouseEvent) {
|
20 |
+
if (window?.getSelection()?.toString()) {
|
21 |
+
return;
|
22 |
+
}
|
23 |
+
if (event.target === backdropEl) {
|
24 |
+
dispatch('close');
|
25 |
+
}
|
26 |
+
}
|
27 |
</script>
|
28 |
|
29 |
+
<svelte:window on:keydown={handleKeydown} />
|
30 |
+
|
31 |
+
<div
|
32 |
+
class="fixed inset-0 z-10 flex h-screen items-start justify-center bg-black/85 pt-32"
|
33 |
+
bind:this={backdropEl}
|
34 |
+
on:click|stopPropagation={handleBackdropClick}
|
35 |
+
>
|
36 |
<div class="flex w-full max-w-[600px] items-start justify-center p-10">
|
37 |
<div
|
38 |
class="flex h-full w-full flex-col overflow-hidden rounded-lg border bg-white text-gray-900 shadow-md"
|