From 1b488b87fef21c1f430db4131e3ceb82f25612cf Mon Sep 17 00:00:00 2001 From: "Thomas F. K. Jorna" Date: Fri, 1 Oct 2021 20:41:17 +0200 Subject: chore: build and clean --- components/Sidebar/index.tsx | 484 +++++++++++++++++++++---------------------- components/preview.tsx | 20 -- 2 files changed, 237 insertions(+), 267 deletions(-) delete mode 100644 components/preview.tsx (limited to 'components') diff --git a/components/Sidebar/index.tsx b/components/Sidebar/index.tsx index 64436f2..3332d39 100644 --- a/components/Sidebar/index.tsx +++ b/components/Sidebar/index.tsx @@ -1,273 +1,263 @@ import React, { useContext, useEffect, useState } from 'react' -import { UniOrg } from "../../util/uniorg" -import { getOrgText } from "../../util/webSocketFunctions" +import { UniOrg } from '../../util/uniorg' +import { getOrgText } from '../../util/webSocketFunctions' import { - Button, - Slide, - VStack, - Flex, - Heading, - Box, - CloseButton, - Text, - Drawer, - DrawerOverlay, - DrawerHeader, - DrawerBody, - DrawerCloseButton, - DrawerContent, - DrawerFooter, - IconButton, + Button, + Slide, + VStack, + Flex, + Heading, + Box, + CloseButton, + Text, + Drawer, + DrawerOverlay, + DrawerHeader, + DrawerBody, + DrawerCloseButton, + DrawerContent, + DrawerFooter, + IconButton, } from '@chakra-ui/react' import { Scrollbars } from 'react-custom-scrollbars-2' import { ChevronLeftIcon, ChevronRightIcon } from '@chakra-ui/icons' import { GraphData, NodeObject, LinkObject } from 'force-graph' import { OrgRoamNode } from '../../api' -import {ThemeContext} from '../../util/themecontext' +import { ThemeContext } from '../../util/themecontext' export interface SidebarProps { - isOpen: boolean - onClose: any - openNode: string - nodeById: any - previewNode: NodeObject, - orgText: string + isOpen: boolean + onClose: any + //nodeById: any + previewNode: NodeObject + orgText: string } const Sidebar = (props: SidebarProps) => { + const { isOpen, onClose, previewNode, orgText } = props - const { isOpen, onClose, openNode, nodeById, previewNode, orgText } = props + const { highlightColor } = useContext(ThemeContext) + const [previewRoamNode, setPreviewRoamNode] = useState() - const {highlightColor}= useContext(ThemeContext) + useEffect(() => { + if (!previewNode) { + return + } - useEffect(() => { - (async () => { - if (!openNode) { - return - } - if (openNode === 'nil') { - return - } - })() + setPreviewRoamNode(previewNode as OrgRoamNode) + }, [previewNode]) - const previewRoamNode = previewNode as OrgRoamNode - }, [previewNode]) - - //maybe want to close it when clicking outside, but not sure - //const outsideClickRef = useRef(); - return ( - - - } - colorScheme="white" - aria-label="Close file-viewer" - height={100} - variant="ghost" - marginRight={-2} - bg="alt.100" - onClick={onClose} - marginTop={20} - /> - - - {previewNode.title} - - ( - - )} - > - - - - - - - - - - ) + //maybe want to close it when clicking outside, but not sure + //const outsideClickRef = useRef(); + return ( + + + } + colorScheme="white" + aria-label="Close file-viewer" + height={100} + variant="ghost" + marginRight={-2} + bg="alt.100" + onClick={onClose} + marginTop={20} + /> + + + {previewRoamNode} + + ( + + )} + > + + + + + + + + + + ) } export default Sidebar - - - /* {previewNode.title} */ diff --git a/components/preview.tsx b/components/preview.tsx deleted file mode 100644 index 8d3a1ca..0000000 --- a/components/preview.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import { Box, Heading } from '@chakra-ui/react' -import React from 'react' -import UniOrg from '../util/uniorg' -import getOrgText from '../util/getOrgText' - -export interface PreviewProps { - id: string - title: string -} -export const Preview = (props: PreviewProps) => { - const { id, title } = props - const text = getOrgText(id) - - return ( - - {title} - - - ) -} -- cgit v1.2.3