Skip to content

Commit c12f95a

Browse files
committed
open chat ui on click
1 parent a5f23bd commit c12f95a

File tree

5 files changed

+55
-56
lines changed

5 files changed

+55
-56
lines changed

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/(chainPage)/layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import Link from "next/link";
1919
import { redirect } from "next/navigation";
2020
import { getThirdwebClient } from "../../../../../../@/constants/thirdweb.server";
2121
import { mapV4ChainToV5Chain } from "../../../../../../contexts/map-chains";
22-
import { NebulaFloatingChatButton } from "../../../../../nebula-app/(app)/components/FloatingChat/FloatingChat";
22+
import { NebulaChatButton } from "../../../../../nebula-app/(app)/components/FloatingChat/FloatingChat";
2323
import {
2424
getAuthToken,
2525
getAuthTokenWalletAddress,
@@ -99,7 +99,8 @@ The following is the user's message:
9999

100100
return (
101101
<>
102-
<NebulaFloatingChatButton
102+
<NebulaChatButton
103+
isFloating={true}
103104
pageType="chain"
104105
authToken={authToken ?? undefined}
105106
label="Ask AI about this chain"

apps/dashboard/src/app/(app)/(dashboard)/(chain)/[chain_id]/[contractAddress]/layout.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { localhost } from "thirdweb/chains";
88
import { getContractMetadata } from "thirdweb/extensions/common";
99
import { isAddress, isContractDeployed } from "thirdweb/utils";
1010
import { shortenIfAddress } from "utils/usedapp-external";
11-
import { NebulaFloatingChatButton } from "../../../../../nebula-app/(app)/components/FloatingChat/FloatingChat";
11+
import { NebulaChatButton } from "../../../../../nebula-app/(app)/components/FloatingChat/FloatingChat";
1212
import {
1313
getAuthToken,
1414
getAuthTokenWalletAddress,
@@ -114,7 +114,8 @@ The following is the user's message:`;
114114
teamsAndProjects={teamsAndProjects}
115115
client={client}
116116
>
117-
<NebulaFloatingChatButton
117+
<NebulaChatButton
118+
isFloating={true}
118119
pageType="contract"
119120
authToken={authToken ?? undefined}
120121
label="Ask AI about this contract"

apps/dashboard/src/app/(app)/(dashboard)/support/page.tsx

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Button } from "@/components/ui/button";
22
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
33
import { getThirdwebClient } from "@/constants/thirdweb.server";
4-
import { NebulaIcon } from "app/nebula-app/(app)/icons/NebulaIcon";
54
import { BookOpenIcon, ChevronRightIcon } from "lucide-react";
65
import type { Metadata } from "next";
76
import Image from "next/image";
@@ -11,7 +10,7 @@ import contractsIcon from "../../../../../public/assets/support/contracts.png";
1110
import engineIcon from "../../../../../public/assets/support/engine.png";
1211
import miscIcon from "../../../../../public/assets/support/misc.svg";
1312
import connectIcon from "../../../../../public/assets/support/wallets.png";
14-
import { NebulaFloatingChatButton } from "../../../nebula-app/(app)/components/FloatingChat/FloatingChat";
13+
import { NebulaChatButton } from "../../../nebula-app/(app)/components/FloatingChat/FloatingChat";
1514
import {
1615
getAuthToken,
1716
getAuthTokenWalletAddress,
@@ -159,14 +158,22 @@ export default async function SupportPage() {
159158
</p>
160159
{/* biome-ignore lint/nursery/useSortedClasses: <explanation> */}
161160
<div className="mt-6 w-full flex flex-col items-center gap-3">
162-
<Button
163-
variant="default"
164-
className="gap-2 rounded-full"
165-
size="default"
166-
>
167-
<NebulaIcon className="size-4" />
168-
Ask Nebula AI for support
169-
</Button>
161+
<NebulaChatButton
162+
isFloating={false}
163+
pageType="support"
164+
authToken={authToken ?? undefined}
165+
label="Ask Nebula AI for support"
166+
client={client}
167+
nebulaParams={{
168+
messagePrefix: supportPromptPrefix,
169+
chainIds: [],
170+
wallet: accountAddress ?? undefined,
171+
}}
172+
examplePrompts={examplePrompts.map((prompt) => ({
173+
title: prompt,
174+
message: prompt,
175+
}))}
176+
/>
170177

171178
<Link
172179
href="/support/create-ticket"
@@ -230,22 +237,6 @@ export default async function SupportPage() {
230237
))}
231238
</div>
232239
</section>
233-
234-
<NebulaFloatingChatButton
235-
pageType="support"
236-
authToken={authToken ?? undefined}
237-
label="Ask Nebula AI for support"
238-
client={client}
239-
nebulaParams={{
240-
messagePrefix: supportPromptPrefix,
241-
chainIds: [],
242-
wallet: accountAddress ?? undefined,
243-
}}
244-
examplePrompts={examplePrompts.map((prompt) => ({
245-
title: prompt,
246-
message: prompt,
247-
}))}
248-
/>
249240
</main>
250241
);
251242
}

apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChat.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,22 @@ import type { Meta, StoryObj } from "@storybook/react";
22
import { storybookThirdwebClient } from "stories/utils";
33
import { ThirdwebProvider } from "thirdweb/react";
44
import { examplePrompts } from "../../data/examplePrompts";
5-
import { NebulaFloatingChatButton } from "./FloatingChat";
5+
import { NebulaChatButton } from "./FloatingChat";
66

77
const meta = {
88
title: "Nebula/FloatingChat",
9-
component: NebulaFloatingChatButton,
9+
component: NebulaChatButton,
1010
decorators: [
1111
(Story) => (
1212
<ThirdwebProvider>
1313
<Story />
1414
</ThirdwebProvider>
1515
),
1616
],
17-
} satisfies Meta<typeof NebulaFloatingChatButton>;
17+
} satisfies Meta<typeof NebulaChatButton>;
1818

1919
export default meta;
20-
type Story = StoryObj<typeof NebulaFloatingChatButton>;
20+
type Story = StoryObj<typeof NebulaChatButton>;
2121

2222
export const LoggedIn: Story = {
2323
args: {

apps/dashboard/src/app/nebula-app/(app)/components/FloatingChat/FloatingChat.tsx

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,13 @@ import { NebulaIcon } from "../../icons/NebulaIcon";
2121

2222
const LazyFloatingChatContent = lazy(() => import("./FloatingChatContent"));
2323

24-
export function NebulaFloatingChatButton(props: {
24+
export function NebulaChatButton(props: {
2525
pageType: "chain" | "contract" | "support";
2626
authToken: string | undefined;
2727
examplePrompts: ExamplePrompt[];
2828
label: string;
2929
client: ThirdwebClient;
30+
isFloating: boolean;
3031
nebulaParams:
3132
| {
3233
messagePrefix: string;
@@ -47,25 +48,30 @@ export function NebulaFloatingChatButton(props: {
4748

4849
return (
4950
<>
50-
{!isOpen && (
51-
<div className="fixed right-6 bottom-6 z-50 flex items-center gap-1.5">
52-
<Button
53-
onClick={() => {
54-
setIsOpen(true);
55-
setHasBeenOpened(true);
56-
trackEvent({
57-
category: "floating_nebula",
58-
action: "click",
59-
label: "open",
60-
page: props.pageType,
61-
});
62-
}}
63-
variant="default"
64-
className="gap-2 rounded-full"
65-
>
66-
<NebulaIcon className="size-4" />
67-
{props.label}
68-
</Button>
51+
<div
52+
className={cn(
53+
"flex items-center gap-1.5",
54+
props.isFloating && "fixed right-6 bottom-6 z-50",
55+
)}
56+
>
57+
<Button
58+
onClick={() => {
59+
setIsOpen(true);
60+
setHasBeenOpened(true);
61+
trackEvent({
62+
category: "floating_nebula",
63+
action: "click",
64+
label: "open",
65+
page: props.pageType,
66+
});
67+
}}
68+
variant="default"
69+
className="gap-2 rounded-full"
70+
>
71+
<NebulaIcon className="size-4" />
72+
{props.label}
73+
</Button>
74+
{props.isFloating && (
6975
<Button
7076
variant="outline"
7177
className="size-10 rounded-full bg-card p-0"
@@ -81,8 +87,8 @@ export function NebulaFloatingChatButton(props: {
8187
>
8288
<XIcon className="size-4" />
8389
</Button>
84-
</div>
85-
)}
90+
)}
91+
</div>
8692

8793
<NebulaChatUIContainer
8894
onClose={closeModal}

0 commit comments

Comments
 (0)