An AI-powered search engine with a generative UI
TypeScript generative-aigenerative-uinextjsollamareactsearxngshadcn-uitailwindcsstavilytypescriptupstashvercel-ai-sdk
fix: Improve panel animations - smooth slide-in, instant close
Yoshiki Miura33691878ce2f
diff --git a/components/artifact/artifact-panel.tsx b/components/artifact/artifact-panel.tsxindex 2148bdac..b8d496fc 100644--- a/components/artifact/artifact-panel.tsx+++ b/components/artifact/artifact-panel.tsx@@ -12,8 +12,8 @@ export function ArtifactPanel() {if (!artifact) return nullreturn (- <div className="h-full flex flex-col overflow-hidden bg-muted md:px-4 md:py-4 md:pb-4 md:pt-14">- <div className="flex flex-col h-full bg-background rounded-xl">+ <div className="h-full flex flex-col overflow-hidden bg-muted md:px-4 md:py-14">+ <div className="flex flex-col h-full bg-background rounded-xl md:border"><div className="flex items-center justify-between px-4 py-2"><h3 className="flex items-center gap-2"><div className="bg-muted p-2 rounded-md flex items-center gap-2">diff --git a/components/artifact/chat-artifact-container.tsx b/components/artifact/chat-artifact-container.tsxindex 2d363cfc..19fa025a 100644--- a/components/artifact/chat-artifact-container.tsx+++ b/components/artifact/chat-artifact-container.tsx@@ -20,26 +20,14 @@ export function ChatArtifactContainer({const { state } = useArtifact()const isMobile = useMediaQuery('(max-width: 767px)') // Below md breakpointconst [renderPanel, setRenderPanel] = useState(state.isOpen)- const [isClosing, setIsClosing] = useState(false)useEffect(() => {- let timer: NodeJS.Timeoutif (state.isOpen) {setRenderPanel(true)- setIsClosing(false)} else {- if (renderPanel) {- setIsClosing(true)- timer = setTimeout(() => {- setRenderPanel(false)- setIsClosing(false)- }, 200)- }+ setRenderPanel(false)}- return () => {- clearTimeout(timer)- }- }, [state.isOpen, renderPanel])+ }, [state.isOpen])return (<div className="flex-1 min-h-0 h-screen flex">@@ -49,17 +37,25 @@ export function ChatArtifactContainer({direction="horizontal"className="flex flex-1 min-w-0 h-full" // Responsive classes removed>- <ResizablePanel className="min-w-0">{children}</ResizablePanel>+ <ResizablePanel+ className={cn(+ 'min-w-0',+ state.isOpen && 'transition-[flex-basis] duration-200 ease-out'+ )}+ >+ {children}+ </ResizablePanel>{renderPanel && (<><ResizableHandle /><ResizablePanel- className={cn('min-w-96 w-96 overflow-hidden', {- 'animate-slide-in-right': state.isOpen && !isClosing,- 'animate-slide-out-right': isClosing+ className={cn('overflow-hidden', {+ 'animate-slide-in-right': state.isOpen})}maxSize={50}+ minSize={30}+ defaultSize={40}><ArtifactPanel /></ResizablePanel>