Tools.svelte 1.52 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
2
3
4
5
6
7
8
9
<script>
	import { getContext } from 'svelte';

	const i18n = getContext('i18n');

	import CodeEditor from './Tools/CodeEditor.svelte';

	let loading = false;

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
10
11
	let name = '';

Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
12
13
	let codeEditor;

Timothy J. Baek's avatar
Timothy J. Baek committed
14
15
16
	const submitHandler = async () => {
		loading = true;
		// Call the API to submit the code
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
17
18
19
20

		if (codeEditor) {
			codeEditor.submitHandler();
		}
Timothy J. Baek's avatar
Timothy J. Baek committed
21
22
23
24
25
26
	};
</script>

<div class=" flex flex-col justify-between w-full overflow-y-auto h-full">
	<div class="mx-auto w-full md:px-0 h-full">
		<div class=" flex flex-col max-h-[100dvh] h-full">
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
27
28
29
30
			<div class="">
				<div class="flex justify-between items-center">
					<div class=" text-lg font-semibold self-center">{$i18n.t('Tools')}</div>
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
31
			</div>
Timothy J. Baek's avatar
refac  
Timothy J. Baek committed
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

			<hr class="  dark:border-gray-850 my-2" />

			<div class="flex flex-col flex-1 overflow-auto h-0 rounded-lg">
				<div class="w-full mb-2">
					<!-- Toolkit Name Input -->
					<input
						class="w-full px-3 py-2 text-sm font-medium bg-gray-100 dark:bg-gray-850 dark:text-gray-200 rounded-lg outline-none"
						type="text"
						placeholder="Toolkit Name (e.g. my_toolkit)"
						bind:value={name}
					/>
				</div>

				<div class="mb-2 flex-1 overflow-auto h-0 rounded-lg">
					<CodeEditor bind:this={codeEditor} />
				</div>

				<div class="pb-3 flex justify-end">
					<button
						class="px-3 py-1.5 text-sm font-medium bg-emerald-600 hover:bg-emerald-700 text-gray-50 transition rounded-lg"
						on:click={() => {
							submitHandler();
						}}
					>
						{$i18n.t('Save')}
					</button>
				</div>
Timothy J. Baek's avatar
Timothy J. Baek committed
60
61
62
63
			</div>
		</div>
	</div>
</div>