Add share button for assistant intro page (#960) (#965)
Browse files* Add share button for assistant intro page
* Fix padding on share assistant
* gap
---------
Co-authored-by: Victor Mustar <victor.mustar@gmail.com>
src/lib/components/chat/AssistantIntroduction.svelte
CHANGED
@@ -4,6 +4,12 @@
|
|
4 |
import { base } from "$app/paths";
|
5 |
import type { Assistant } from "$lib/types/Assistant";
|
6 |
import IconInternet from "../icons/IconInternet.svelte";
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
export let assistant: Pick<
|
9 |
Assistant,
|
@@ -25,6 +31,12 @@
|
|
25 |
(assistant?.rag?.allowedDomains?.length ?? 0) > 0 ||
|
26 |
(assistant?.rag?.allowedLinks?.length ?? 0) > 0 ||
|
27 |
assistant?.dynamicPrompt;
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
</script>
|
29 |
|
30 |
<div class="flex h-full w-full flex-col content-center items-center justify-center pb-52">
|
@@ -84,11 +96,33 @@
|
|
84 |
</div>
|
85 |
|
86 |
<div class="absolute right-3 top-3 md:right-4 md:top-4">
|
87 |
-
<
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
</div>
|
93 |
</div>
|
94 |
{#if assistant.exampleInputs}
|
|
|
4 |
import { base } from "$app/paths";
|
5 |
import type { Assistant } from "$lib/types/Assistant";
|
6 |
import IconInternet from "../icons/IconInternet.svelte";
|
7 |
+
import CarbonExport from "~icons/carbon/export";
|
8 |
+
import CarbonCheckmark from "~icons/carbon/checkmark";
|
9 |
+
|
10 |
+
import { share } from "$lib/utils/share";
|
11 |
+
import { PUBLIC_ORIGIN, PUBLIC_SHARE_PREFIX } from "$env/static/public";
|
12 |
+
import { page } from "$app/stores";
|
13 |
|
14 |
export let assistant: Pick<
|
15 |
Assistant,
|
|
|
31 |
(assistant?.rag?.allowedDomains?.length ?? 0) > 0 ||
|
32 |
(assistant?.rag?.allowedLinks?.length ?? 0) > 0 ||
|
33 |
assistant?.dynamicPrompt;
|
34 |
+
|
35 |
+
const prefix = PUBLIC_SHARE_PREFIX || `${PUBLIC_ORIGIN || $page.url.origin}${base}`;
|
36 |
+
|
37 |
+
$: shareUrl = `${prefix}/assistant/${assistant?._id}`;
|
38 |
+
|
39 |
+
let isCopied = false;
|
40 |
</script>
|
41 |
|
42 |
<div class="flex h-full w-full flex-col content-center items-center justify-center pb-52">
|
|
|
96 |
</div>
|
97 |
|
98 |
<div class="absolute right-3 top-3 md:right-4 md:top-4">
|
99 |
+
<div class="flex flex-row items-center gap-1">
|
100 |
+
<button
|
101 |
+
class="flex h-7 items-center gap-1.5 rounded-full border bg-white px-2.5 py-1 text-gray-800 shadow-sm hover:shadow-inner max-sm:px-1.5 md:text-sm dark:border-gray-700 dark:bg-gray-700 dark:text-gray-300/90 dark:hover:bg-gray-800"
|
102 |
+
on:click={() => {
|
103 |
+
if (!isCopied) {
|
104 |
+
share(shareUrl, assistant.name);
|
105 |
+
isCopied = true;
|
106 |
+
setTimeout(() => {
|
107 |
+
isCopied = false;
|
108 |
+
}, 2000);
|
109 |
+
}
|
110 |
+
}}
|
111 |
+
>
|
112 |
+
{#if isCopied}
|
113 |
+
<CarbonCheckmark class="text-xxs text-green-600 max-sm:text-xs" />
|
114 |
+
<span class="text-green-600 max-sm:hidden"> Copied </span>
|
115 |
+
{:else}
|
116 |
+
<CarbonExport class="text-xxs max-sm:text-xs" />
|
117 |
+
<span class="max-sm:hidden"> Share </span>
|
118 |
+
{/if}
|
119 |
+
</button>
|
120 |
+
<a
|
121 |
+
href="{base}/settings/assistants/{assistant._id.toString()}"
|
122 |
+
class="flex h-7 items-center gap-1.5 rounded-full border bg-white px-2.5 py-1 text-gray-800 shadow-sm hover:shadow-inner md:text-sm dark:border-gray-700 dark:bg-gray-700 dark:text-gray-300/90 dark:hover:bg-gray-800"
|
123 |
+
><IconGear class="text-xxs" />Settings</a
|
124 |
+
>
|
125 |
+
</div>
|
126 |
</div>
|
127 |
</div>
|
128 |
{#if assistant.exampleInputs}
|