mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-03 14:22:13 +08:00
feat: add flip display effect
This commit is contained in:
29
frontend/src/components/workspace/flip-display.tsx
Normal file
29
frontend/src/components/workspace/flip-display.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { AnimatePresence, motion } from "motion/react";
|
||||
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
export function FlipDisplay({
|
||||
uniqueKey,
|
||||
children,
|
||||
className,
|
||||
}: {
|
||||
uniqueKey: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<div className={cn("relative h-6 overflow-hidden", className)}>
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.div
|
||||
key={uniqueKey}
|
||||
initial={{ y: 8, opacity: 0 }}
|
||||
animate={{ y: 2, opacity: 1 }}
|
||||
exit={{ y: -8, opacity: 0 }}
|
||||
transition={{ duration: 0.25, ease: [0.4, 0, 0.2, 1] }}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
</AnimatePresence>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -29,6 +29,8 @@ import { useRehypeSplitWordsIntoSpans } from "@/core/rehype";
|
||||
import { extractTitleFromMarkdown } from "@/core/utils/markdown";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
import { FlipDisplay } from "../flip-display";
|
||||
|
||||
export function MessageGroup({
|
||||
className,
|
||||
messages,
|
||||
@@ -62,17 +64,20 @@ export function MessageGroup({
|
||||
{open && steps.length > 1 ? (
|
||||
<div>{steps.length} steps</div>
|
||||
) : (
|
||||
<MessageResponse rehypePlugins={rehypePlugins}>
|
||||
{label}
|
||||
</MessageResponse>
|
||||
<FlipDisplay uniqueKey={`step-${steps.length}`}>
|
||||
<MessageResponse rehypePlugins={rehypePlugins}>
|
||||
{label}
|
||||
</MessageResponse>
|
||||
</FlipDisplay>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{!open && steps.length > 1 && (
|
||||
<div className="tet-xs opacity-60">
|
||||
{steps.length - 1} more step
|
||||
{steps.length - 1 > 1 ? "s" : ""}
|
||||
<div>
|
||||
{steps.length - 1 > 1
|
||||
? `${steps.length - 1} more steps`
|
||||
: `${steps.length - 1} more step`}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -28,7 +28,7 @@ export function MessageList({
|
||||
<Conversation
|
||||
className={cn("flex size-full flex-col justify-center pt-2", className)}
|
||||
>
|
||||
<ConversationContent className="mx-auto w-full max-w-(--container-width-md) gap-12">
|
||||
<ConversationContent className="mx-auto w-full max-w-(--container-width-md) gap-10">
|
||||
{groupMessages(
|
||||
thread.messages,
|
||||
(groupedMessages) => {
|
||||
|
||||
Reference in New Issue
Block a user