2023-11-01 19:29:50 -07:00
|
|
|
<script lang="ts">
|
2024-05-01 22:55:42 -07:00
|
|
|
import Bolt from '$lib/components/icons/Bolt.svelte';
|
2024-10-05 03:07:56 -07:00
|
|
|
import { onMount, getContext, createEventDispatcher } from 'svelte';
|
2024-05-07 08:43:25 +02:00
|
|
|
|
|
|
|
|
const i18n = getContext('i18n');
|
2024-10-05 03:07:56 -07:00
|
|
|
const dispatch = createEventDispatcher();
|
2024-05-01 22:55:42 -07:00
|
|
|
|
2023-12-03 11:54:11 -08:00
|
|
|
export let suggestionPrompts = [];
|
2024-02-07 18:51:45 -08:00
|
|
|
|
|
|
|
|
let prompts = [];
|
|
|
|
|
|
2024-09-12 10:56:16 -04:00
|
|
|
$: prompts = (suggestionPrompts ?? [])
|
2024-04-30 17:07:03 -07:00
|
|
|
.reduce((acc, current) => [...acc, ...[current]], [])
|
|
|
|
|
.sort(() => Math.random() - 0.5);
|
2023-11-01 19:29:50 -07:00
|
|
|
</script>
|
|
|
|
|
|
2024-05-01 22:55:42 -07:00
|
|
|
{#if prompts.length > 0}
|
2024-10-05 13:26:52 -07:00
|
|
|
<div class="mb-1 flex gap-1 text-sm font-medium items-center text-gray-400 dark:text-gray-600">
|
2024-05-01 22:55:42 -07:00
|
|
|
<Bolt />
|
2024-05-07 08:43:25 +02:00
|
|
|
{$i18n.t('Suggested')}
|
2024-05-01 22:55:42 -07:00
|
|
|
</div>
|
|
|
|
|
{/if}
|
|
|
|
|
|
2024-10-05 13:25:30 -07:00
|
|
|
<div class=" h-40 max-h-full overflow-auto scrollbar-none">
|
2024-10-05 03:07:56 -07:00
|
|
|
{#each prompts as prompt, promptIdx}
|
|
|
|
|
<button
|
|
|
|
|
class="flex flex-col flex-1 shrink-0 w-full justify-between px-3 py-2 rounded-xl bg-transparent hover:bg-black/5 dark:hover:bg-white/5 transition group"
|
|
|
|
|
on:click={() => {
|
|
|
|
|
dispatch('select', prompt.content);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<div class="flex flex-col text-left">
|
|
|
|
|
{#if prompt.title && prompt.title[0] !== ''}
|
|
|
|
|
<div
|
|
|
|
|
class=" font-medium dark:text-gray-300 dark:group-hover:text-gray-200 transition line-clamp-1"
|
|
|
|
|
>
|
|
|
|
|
{prompt.title[0]}
|
2024-02-25 12:31:31 -08:00
|
|
|
</div>
|
2024-10-05 03:07:56 -07:00
|
|
|
<div class="text-xs text-gray-500 font-normal line-clamp-1">{prompt.title[1]}</div>
|
|
|
|
|
{:else}
|
|
|
|
|
<div
|
|
|
|
|
class=" font-medium dark:text-gray-300 dark:group-hover:text-gray-200 transition line-clamp-1"
|
|
|
|
|
>
|
|
|
|
|
{prompt.content}
|
2024-02-25 12:31:31 -08:00
|
|
|
</div>
|
2024-05-01 23:01:00 -07:00
|
|
|
|
2024-10-05 03:07:56 -07:00
|
|
|
<div class="text-xs text-gray-500 font-normal line-clamp-1">Prompt</div>
|
|
|
|
|
{/if}
|
|
|
|
|
</div>
|
|
|
|
|
</button>
|
|
|
|
|
{/each}
|
2023-11-01 19:29:50 -07:00
|
|
|
</div>
|