2023-11-02 02:29:50 +00:00
|
|
|
<script lang="ts">
|
2024-05-02 05:55:42 +00:00
|
|
|
import Bolt from '$lib/components/icons/Bolt.svelte';
|
2024-10-05 10:07:56 +00:00
|
|
|
import { onMount, getContext, createEventDispatcher } from 'svelte';
|
2024-05-07 06:43:25 +00:00
|
|
|
|
|
|
|
const i18n = getContext('i18n');
|
2024-10-05 10:07:56 +00:00
|
|
|
const dispatch = createEventDispatcher();
|
2024-05-02 05:55:42 +00:00
|
|
|
|
2023-12-03 19:54:11 +00:00
|
|
|
export let suggestionPrompts = [];
|
2024-02-08 02:51:45 +00:00
|
|
|
|
|
|
|
let prompts = [];
|
|
|
|
|
2024-09-12 14:56:16 +00:00
|
|
|
$: prompts = (suggestionPrompts ?? [])
|
2024-05-01 00:07:03 +00:00
|
|
|
.reduce((acc, current) => [...acc, ...[current]], [])
|
|
|
|
.sort(() => Math.random() - 0.5);
|
2023-11-02 02:29:50 +00:00
|
|
|
</script>
|
|
|
|
|
2024-05-02 05:55:42 +00:00
|
|
|
{#if prompts.length > 0}
|
2024-10-05 20:26:52 +00:00
|
|
|
<div class="mb-1 flex gap-1 text-sm font-medium items-center text-gray-400 dark:text-gray-600">
|
2024-05-02 05:55:42 +00:00
|
|
|
<Bolt />
|
2024-05-07 06:43:25 +00:00
|
|
|
{$i18n.t('Suggested')}
|
2024-05-02 05:55:42 +00:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
2024-10-05 20:25:30 +00:00
|
|
|
<div class=" h-40 max-h-full overflow-auto scrollbar-none">
|
2024-10-05 10:07:56 +00: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 20:31:31 +00:00
|
|
|
</div>
|
2024-10-05 10:07:56 +00: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 20:31:31 +00:00
|
|
|
</div>
|
2024-05-02 06:01:00 +00:00
|
|
|
|
2024-10-05 10:07:56 +00:00
|
|
|
<div class="text-xs text-gray-500 font-normal line-clamp-1">Prompt</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</button>
|
|
|
|
{/each}
|
2023-11-02 02:29:50 +00:00
|
|
|
</div>
|