import React, { useContext, useEffect, useState } from 'react' import { Toolbar } from './Toolbar' import { Note } from './Note' import { Button, Slide, VStack, Flex, Heading, Box, IconButton } from '@chakra-ui/react' import { Scrollbars } from 'react-custom-scrollbars-2' import { ChevronLeftIcon, ChevronRightIcon, HamburgerIcon } from '@chakra-ui/icons' import { BiFile } from 'react-icons/bi' import { GraphData, NodeObject, LinkObject } from 'force-graph' import { OrgRoamNode } from '../../api' import { ThemeContext } from '../../util/themecontext' import { LinksByNodeId, NodeByCite, NodeById } from '../../pages/index' export interface SidebarProps { isOpen: boolean onClose: any onOpen: any nodeById: NodeById previewNode: NodeObject setPreviewNode: any linksByNodeId: LinksByNodeId nodeByCite: NodeByCite setSidebarHighlightedNode: any } const Sidebar = (props: SidebarProps) => { const { isOpen, onOpen, onClose, previewNode, setPreviewNode, nodeById, linksByNodeId, nodeByCite, setSidebarHighlightedNode, } = props const { highlightColor } = useContext(ThemeContext) const [previewRoamNode, setPreviewRoamNode] = useState() useEffect(() => { if (!previewNode?.id) { onClose() return } onOpen() setPreviewRoamNode(previewNode as OrgRoamNode) }, [previewNode?.id]) const [justification, setJustification] = useState(1) const justificationList = ['justify', 'start', 'end', 'center'] const [font, setFont] = useState('sans serif') const [indent, setIndent] = useState(0) //maybe want to close it when clicking outside, but not sure //const outsideClickRef = useRef(); return ( {previewRoamNode?.title} } aria-label="Close file-viewer" variant="link" onClick={onClose} /> ( )} > ) } export default Sidebar