File size: 2,156 Bytes
bc27e65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<script lang="ts">

	import CodeExecutionModal from './CodeExecutionModal.svelte';

	import Spinner from '$lib/components/common/Spinner.svelte';

	import Check from '$lib/components/icons/Check.svelte';

	import XMark from '$lib/components/icons/XMark.svelte';

	import EllipsisHorizontal from '$lib/components/icons/EllipsisHorizontal.svelte';



	export let codeExecutions = [];



	let selectedCodeExecution = null;

	let showCodeExecutionModal = false;



	$: if (codeExecutions) {

		updateSelectedCodeExecution();

	}



	const updateSelectedCodeExecution = () => {

		if (selectedCodeExecution) {

			selectedCodeExecution = codeExecutions.find(

				(execution) => execution.id === selectedCodeExecution.id

			);

		}

	};

</script>

<CodeExecutionModal bind:show={showCodeExecutionModal} codeExecution={selectedCodeExecution} />

{#if codeExecutions.length > 0}
	<div class="mt-1 mb-2 w-full flex gap-1 items-center flex-wrap">
		{#each codeExecutions as execution (execution.id)}
			<div class="flex gap-1 text-xs font-semibold">
				<button

					class="flex dark:text-gray-300 py-1 px-1 bg-gray-50 hover:bg-gray-100 dark:bg-gray-850 dark:hover:bg-gray-800 transition rounded-xl max-w-96"

					on:click={() => {
						selectedCodeExecution = execution;
						showCodeExecutionModal = true;
					}}
				>
					<div

						class="bg-white dark:bg-gray-700 rounded-full size-4 flex items-center justify-center"

					>
						{#if execution?.result}
							{#if execution.result?.error}
								<XMark />
							{:else if execution.result?.output}
								<Check strokeWidth="3" className="size-3" />
							{:else}
								<EllipsisHorizontal />
							{/if}
						{:else}
							<Spinner className="size-4" />
						{/if}
					</div>
					<div

						class="flex-1 mx-2 line-clamp-1 code-execution-name {execution?.result ? '' : 'pulse'}"

					>
						{execution.name}
					</div>
				</button>
			</div>
		{/each}
	</div>
{/if}

<style>

	@keyframes pulse {

		0%,

		100% {

			opacity: 1;

		}

		50% {

			opacity: 0.6;

		}

	}



	.pulse {

		opacity: 1;

		animation: pulse 1.5s ease;

	}

</style>