mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-15 19:04:45 +08:00
feat: add surprise-me
This commit is contained in:
49
frontend/src/components/ui/confetti-button.tsx
Normal file
49
frontend/src/components/ui/confetti-button.tsx
Normal file
@@ -0,0 +1,49 @@
|
||||
"use client";
|
||||
|
||||
import React, { type MouseEventHandler } from "react";
|
||||
import confetti from "canvas-confetti";
|
||||
|
||||
import { Button } from "@/components/ui/button";
|
||||
|
||||
interface ConfettiButtonProps extends React.ComponentProps<typeof Button> {
|
||||
angle?: number;
|
||||
particleCount?: number;
|
||||
startVelocity?: number;
|
||||
spread?: number;
|
||||
onClick?: MouseEventHandler<HTMLButtonElement>;
|
||||
}
|
||||
|
||||
export function ConfettiButton({
|
||||
className,
|
||||
children,
|
||||
angle = 90,
|
||||
particleCount = 75,
|
||||
startVelocity = 35,
|
||||
spread = 70,
|
||||
onClick,
|
||||
...props
|
||||
}: ConfettiButtonProps) {
|
||||
const handleClick: MouseEventHandler<HTMLButtonElement> = (event) => {
|
||||
const target = event.currentTarget;
|
||||
if (target) {
|
||||
const rect = target.getBoundingClientRect();
|
||||
confetti({
|
||||
particleCount,
|
||||
startVelocity,
|
||||
angle,
|
||||
spread,
|
||||
origin: {
|
||||
x: (rect.left + rect.width / 2) / window.innerWidth,
|
||||
y: (rect.top + rect.height / 2) / window.innerHeight,
|
||||
},
|
||||
});
|
||||
}
|
||||
onClick?.(event);
|
||||
};
|
||||
|
||||
return (
|
||||
<Button onClick={handleClick} className={className} {...props}>
|
||||
{children}
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
LightbulbIcon,
|
||||
PaperclipIcon,
|
||||
PlusIcon,
|
||||
SparklesIcon,
|
||||
ZapIcon,
|
||||
} from "lucide-react";
|
||||
import { useSearchParams } from "next/navigation";
|
||||
@@ -30,6 +31,7 @@ import {
|
||||
usePromptInputController,
|
||||
type PromptInputMessage,
|
||||
} from "@/components/ai-elements/prompt-input";
|
||||
import { ConfettiButton } from "@/components/ui/confetti-button";
|
||||
import {
|
||||
DropdownMenuGroup,
|
||||
DropdownMenuLabel,
|
||||
@@ -386,6 +388,14 @@ function SuggestionList() {
|
||||
);
|
||||
return (
|
||||
<Suggestions className="w-fit">
|
||||
<ConfettiButton
|
||||
className="text-muted-foreground cursor-pointer rounded-full px-4 text-xs font-normal"
|
||||
variant="outline"
|
||||
size="sm"
|
||||
onClick={() => handleSuggestionClick("Surprise me")}
|
||||
>
|
||||
<SparklesIcon className="size-4" /> Surprise
|
||||
</ConfettiButton>
|
||||
{t.inputBox.suggestions.map((suggestion) => (
|
||||
<Suggestion
|
||||
key={suggestion.suggestion}
|
||||
|
||||
Reference in New Issue
Block a user