-
Notifications
You must be signed in to change notification settings - Fork 535
[Dashboard] siwa chat widget #7128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1e918d0
siwa chat widget
Yash094 4994fbe
lint
Yash094 c8843ae
replace api url
Yash094 dca105c
fixes
joaquim-verges ae19f80
more fixes
joaquim-verges 3a50e8c
update prompts
joaquim-verges b32f10b
lint
joaquim-verges File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
apps/dashboard/src/app/nebula-app/(app)/components/CustomChat/CustomChatButton.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
"use client"; | ||
|
||
import { Button } from "@/components/ui/button"; | ||
import { cn } from "@/lib/utils"; | ||
import { MessageCircleIcon, XIcon } from "lucide-react"; | ||
import { useCallback, useRef, useState } from "react"; | ||
import type { ThirdwebClient } from "thirdweb"; | ||
import type { ExamplePrompt } from "../../data/examplePrompts"; | ||
import CustomChatContent from "./CustomChatContent"; | ||
|
||
export function CustomChatButton(props: { | ||
isLoggedIn: boolean; | ||
networks: "mainnet" | "testnet" | "all" | null; | ||
isFloating: boolean; | ||
pageType: "chain" | "contract" | "support"; | ||
label: string; | ||
client: ThirdwebClient; | ||
customApiParams: any; | ||
examplePrompts: ExamplePrompt[]; | ||
authToken: string | undefined; | ||
requireLogin?: boolean; | ||
}) { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const [hasBeenOpened, setHasBeenOpened] = useState(false); | ||
const [isDismissed, setIsDismissed] = useState(false); | ||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
|
||
const closeModal = useCallback(() => setIsOpen(false), []); | ||
const ref = useRef<HTMLDivElement>(null); | ||
|
||
// Close on outside click | ||
// (optional: can add if you want exact Nebula behavior) | ||
// useEffect(() => { ... }, [onOutsideClick]); | ||
|
||
if (isDismissed) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
{/* Inline Button (not floating) */} | ||
<Button | ||
onClick={() => { | ||
setIsOpen(true); | ||
setHasBeenOpened(true); | ||
}} | ||
variant="default" | ||
className="gap-2 rounded-full shadow-lg" | ||
> | ||
<MessageCircleIcon className="size-4" /> | ||
{props.label} | ||
</Button> | ||
|
||
{/* Popup/Modal */} | ||
<div | ||
className={cn( | ||
"slide-in-from-bottom-20 zoom-in-95 fade-in-0 fixed bottom-0 left-0 z-50 flex h-[80vh] w-[100vw] animate-in flex-col overflow-hidden rounded-t-2xl border bg-background shadow-2xl duration-200 lg:right-6 lg:bottom-6 lg:left-auto lg:h-[80vh] lg:max-w-xl lg:rounded-xl", | ||
!isOpen && "hidden", | ||
)} | ||
ref={ref} | ||
> | ||
{/* Header with close button */} | ||
<div className="flex items-center justify-between border-b px-4 py-2"> | ||
<div className="font-semibold text-lg flex items-center gap-2"> | ||
<MessageCircleIcon className="size-5 text-muted-foreground" /> | ||
{props.label} | ||
</div> | ||
<Button | ||
variant="ghost" | ||
size="icon" | ||
onClick={closeModal} | ||
className="h-auto w-auto p-1 text-muted-foreground" | ||
aria-label="Close chat" | ||
> | ||
<XIcon className="size-5" /> | ||
</Button> | ||
</div> | ||
{/* Chat Content */} | ||
<div className="relative flex grow flex-col overflow-hidden"> | ||
{hasBeenOpened && isOpen && ( | ||
<CustomChatContent | ||
authToken={props.authToken} | ||
client={props.client} | ||
examplePrompts={props.examplePrompts} | ||
pageType={props.pageType} | ||
customApiParams={props.customApiParams} | ||
networks={props.networks} | ||
requireLogin={props.requireLogin} | ||
/> | ||
)} | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.