mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 22:25:59 -05:00
6c73a1d38a
GitOrigin-RevId: 7cee1e153d5ae3d15250097dc87f430f4e799957
33 lines
820 B
TypeScript
33 lines
820 B
TypeScript
import { useCallback, useRef, useState } from 'react'
|
|
import useCollapsiblePanel from '@/features/ide-react/hooks/use-collapsible-panel'
|
|
import { ImperativePanelHandle } from 'react-resizable-panels'
|
|
|
|
export const useSidebarPane = () => {
|
|
const [isOpen, setIsOpen] = useState(true)
|
|
const [resizing, setResizing] = useState(false)
|
|
const panelRef = useRef<ImperativePanelHandle>(null)
|
|
useCollapsiblePanel(isOpen, panelRef)
|
|
|
|
const togglePane = useCallback(() => {
|
|
setIsOpen(value => !value)
|
|
}, [])
|
|
|
|
const handlePaneExpand = useCallback(() => {
|
|
setIsOpen(true)
|
|
}, [])
|
|
|
|
const handlePaneCollapse = useCallback(() => {
|
|
setIsOpen(false)
|
|
}, [])
|
|
|
|
return {
|
|
isOpen,
|
|
setIsOpen,
|
|
panelRef,
|
|
togglePane,
|
|
handlePaneExpand,
|
|
handlePaneCollapse,
|
|
resizing,
|
|
setResizing,
|
|
}
|
|
}
|