2023-12-20 06:48:24 -05:00
|
|
|
import { useCallback, useRef, useState } from 'react'
|
2023-12-05 05:19:00 -05:00
|
|
|
import useCollapsiblePanel from '@/features/ide-react/hooks/use-collapsible-panel'
|
2023-12-20 06:48:24 -05:00
|
|
|
import { ImperativePanelHandle } from 'react-resizable-panels'
|
2023-12-05 05:19:00 -05:00
|
|
|
|
|
|
|
export const useSidebarPane = () => {
|
|
|
|
const [isOpen, setIsOpen] = useState(true)
|
|
|
|
const [resizing, setResizing] = useState(false)
|
2023-12-20 06:48:24 -05:00
|
|
|
const panelRef = useRef<ImperativePanelHandle>(null)
|
|
|
|
useCollapsiblePanel(isOpen, panelRef)
|
2023-12-05 05:19:00 -05:00
|
|
|
|
|
|
|
const togglePane = useCallback(() => {
|
|
|
|
setIsOpen(value => !value)
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
const handlePaneExpand = useCallback(() => {
|
|
|
|
setIsOpen(true)
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
const handlePaneCollapse = useCallback(() => {
|
|
|
|
setIsOpen(false)
|
|
|
|
}, [])
|
|
|
|
|
|
|
|
return {
|
|
|
|
isOpen,
|
|
|
|
setIsOpen,
|
2023-12-20 06:48:24 -05:00
|
|
|
panelRef,
|
2023-12-05 05:19:00 -05:00
|
|
|
togglePane,
|
|
|
|
handlePaneExpand,
|
|
|
|
handlePaneCollapse,
|
|
|
|
resizing,
|
|
|
|
setResizing,
|
|
|
|
}
|
|
|
|
}
|