mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-15 14:40:59 -05:00
6c73a1d38a
GitOrigin-RevId: 7cee1e153d5ae3d15250097dc87f430f4e799957
34 lines
930 B
TypeScript
34 lines
930 B
TypeScript
import { useLayoutContext } from '@/shared/context/layout-context'
|
|
import useCollapsiblePanel from '@/features/ide-react/hooks/use-collapsible-panel'
|
|
import { useCallback, useRef, useState } from 'react'
|
|
import { ImperativePanelHandle } from 'react-resizable-panels'
|
|
|
|
export const useChatPane = () => {
|
|
const { chatIsOpen: isOpen, setChatIsOpen: setIsOpen } = useLayoutContext()
|
|
const [resizing, setResizing] = useState(false)
|
|
const panelRef = useRef<ImperativePanelHandle>(null)
|
|
|
|
useCollapsiblePanel(isOpen, panelRef)
|
|
|
|
const togglePane = useCallback(() => {
|
|
setIsOpen(value => !value)
|
|
}, [setIsOpen])
|
|
|
|
const handlePaneExpand = useCallback(() => {
|
|
setIsOpen(true)
|
|
}, [setIsOpen])
|
|
|
|
const handlePaneCollapse = useCallback(() => {
|
|
setIsOpen(false)
|
|
}, [setIsOpen])
|
|
|
|
return {
|
|
isOpen,
|
|
panelRef,
|
|
resizing,
|
|
setResizing,
|
|
togglePane,
|
|
handlePaneExpand,
|
|
handlePaneCollapse,
|
|
}
|
|
}
|