mirror of
https://github.com/overleaf/overleaf.git
synced 2025-01-07 11:10:40 +00:00
8c91a2e4cf
GitOrigin-RevId: b4185a192b393e339aee8bc27e615d61d66a8b34
34 lines
982 B
TypeScript
34 lines
982 B
TypeScript
import { useLayoutContext } from '@/shared/context/layout-context'
|
|
import useFixedSizeColumn from '@/features/ide-react/hooks/use-fixed-size-column'
|
|
import useCollapsiblePanel from '@/features/ide-react/hooks/use-collapsible-panel'
|
|
import { useCallback, useState } from 'react'
|
|
|
|
export const useChatPane = () => {
|
|
const { chatIsOpen: isOpen, setChatIsOpen: setIsOpen } = useLayoutContext()
|
|
const [resizing, setResizing] = useState(false)
|
|
const { fixedPanelRef, handleLayout } = useFixedSizeColumn(isOpen)
|
|
useCollapsiblePanel(isOpen, fixedPanelRef)
|
|
|
|
const togglePane = useCallback(() => {
|
|
setIsOpen(value => !value)
|
|
}, [setIsOpen])
|
|
|
|
const handlePaneExpand = useCallback(() => {
|
|
setIsOpen(true)
|
|
}, [setIsOpen])
|
|
|
|
const handlePaneCollapse = useCallback(() => {
|
|
setIsOpen(false)
|
|
}, [setIsOpen])
|
|
|
|
return {
|
|
isOpen,
|
|
fixedPanelRef,
|
|
handleLayout,
|
|
resizing,
|
|
setResizing,
|
|
togglePane,
|
|
handlePaneExpand,
|
|
handlePaneCollapse,
|
|
}
|
|
}
|