ChatControls.svelte 1.58 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
2
3
4
5
6
7
8
<script lang="ts">
	import { slide } from 'svelte/transition';
	import Modal from '../common/Modal.svelte';
	import Controls from './Controls/Controls.svelte';
	import { onMount } from 'svelte';

	export let show = false;

Timothy J. Baek's avatar
Timothy J. Baek committed
9
10
	export let models = [];

11
	export let chatId = null;
Timothy J. Baek's avatar
Timothy J. Baek committed
12

Timothy J. Baek's avatar
Timothy J. Baek committed
13
14
	export let chatFiles = [];
	export let valves = {};
15
	export let params = {};
Timothy J. Baek's avatar
Timothy J. Baek committed
16

17
	let largeScreen = false;
Timothy J. Baek's avatar
Timothy J. Baek committed
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
	onMount(() => {
		// listen to resize 1024px
		const mediaQuery = window.matchMedia('(min-width: 1024px)');

		const handleMediaQuery = (e) => {
			if (e.matches) {
				largeScreen = true;
			} else {
				largeScreen = false;
			}
		};

		mediaQuery.addEventListener('change', handleMediaQuery);

		handleMediaQuery(mediaQuery);

		return () => {
			mediaQuery.removeEventListener('change', handleMediaQuery);
		};
	});
</script>

{#if largeScreen}
Timothy J. Baek's avatar
Timothy J. Baek committed
41
42
43
44
	{#if show}
		<div class=" absolute bottom-0 right-0 z-20 h-full pointer-events-none">
			<div class="pr-4 pt-14 pb-8 w-[24rem] h-full" in:slide={{ duration: 200, axis: 'x' }}>
				<div
Timothy J. Baek's avatar
Timothy J. Baek committed
45
					class="w-full h-full px-5 py-4 bg-white dark:shadow-lg dark:bg-gray-850 border border-gray-50 dark:border-gray-800 rounded-xl z-50 pointer-events-auto overflow-y-auto scrollbar-hidden"
Timothy J. Baek's avatar
Timothy J. Baek committed
46
47
48
49
50
				>
					<Controls
						on:close={() => {
							show = false;
						}}
Timothy J. Baek's avatar
Timothy J. Baek committed
51
						{models}
Timothy J. Baek's avatar
Timothy J. Baek committed
52
						bind:chatFiles
Timothy J. Baek's avatar
Timothy J. Baek committed
53
						bind:valves
54
						bind:params
Timothy J. Baek's avatar
Timothy J. Baek committed
55
56
					/>
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
57
58
			</div>
		</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
59
	{/if}
Timothy J. Baek's avatar
Timothy J. Baek committed
60
61
{:else}
	<Modal bind:show>
62
		<div class="  px-6 py-4 h-full">
Timothy J. Baek's avatar
Timothy J. Baek committed
63
64
65
66
			<Controls
				on:close={() => {
					show = false;
				}}
Timothy J. Baek's avatar
Timothy J. Baek committed
67
				{models}
Timothy J. Baek's avatar
Timothy J. Baek committed
68
				bind:chatFiles
Timothy J. Baek's avatar
Timothy J. Baek committed
69
				bind:valves
70
				bind:params
Timothy J. Baek's avatar
Timothy J. Baek committed
71
72
73
74
			/>
		</div>
	</Modal>
{/if}