Skip to content

Commit 3b0ae7a

Browse files
committed
section open
1 parent 0e81a42 commit 3b0ae7a

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

components/Sidebar/Section.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Box, Flex, IconButton } from '@chakra-ui/react'
2-
import React, { FC, PropsWithChildren, ReactChild, useContext, useEffect, useState } from 'react'
2+
import React, { FC, PropsWithChildren, useContext, useEffect, useState } from 'react'
33
import { VscCircleFilled, VscCircleOutline } from 'react-icons/vsc'
44
import { ChevronDownIcon, ChevronUpIcon } from '@chakra-ui/icons'
55
import { NoteContext } from '../../util/NoteContext'
6+
import { DEFAULT_SECTION_OPEN } from '../../constants/action'
67

78
export interface SectionProps {
89
className: string
@@ -13,7 +14,7 @@ export const Section: FC<PropsWithChildren<SectionProps>> = (props) => {
1314
children,
1415
className, // outline
1516
} = props
16-
const [open, setOpen] = useState(true)
17+
const [open, setOpen] = useState(DEFAULT_SECTION_OPEN)
1718
const { collapse } = useContext(NoteContext)
1819
useEffect(() => {
1920
setOpen(!collapse)

components/Sidebar/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { LinksByNodeId, NodeByCite, NodeById, Scope } from '../../pages/index'
2525
import { Resizable } from 're-resizable'
2626
import { usePersistantState } from '../../util/persistant-state'
2727
import { initialFilter, TagColors } from '../config'
28+
import { DEFAULT_SECTION_OPEN } from '../constants/action'
2829

2930
export interface SidebarProps {
3031
isOpen: boolean
@@ -101,7 +102,7 @@ const Sidebar = (props: SidebarProps) => {
101102
const justificationList = ['justify', 'start', 'end', 'center']
102103
const [font, setFont] = useState('sans serif')
103104
const [indent, setIndent] = useState(0)
104-
const [collapse, setCollapse] = useState(false)
105+
const [collapse, setCollapse] = useState(!DEFAULT_SECTION_OPEN)
105106
//maybe want to close it when clicking outside, but not sure
106107
//const outsideClickRef = useRef();
107108
return (

constants/action.ts

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const TITLE_NAME = process.env.NEXT_PUBLIC_TITLE ?? 'ORUI'
2+
const DEFAULT_SECTION_OPEN = process.env.NEXT_PUBLIC_DEFAULT_SECTION_OPEN === 'true'
3+
export { TITLE_NAME, DEFAULT_SECTION_OPEN }

pages/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ import { getLinkColor } from '../util/getLinkColor'
6666
import { Search } from '../components/Search'
6767
import { useRouter } from "next/router";
6868
import { usePathname, useSearchParams } from 'next/navigation'
69+
import { TITLE_NAME } from '../constants/action'
6970

7071
const d3promise = import('d3-force-3d')
7172

@@ -110,7 +111,7 @@ export default function Home() {
110111
return (
111112
<>
112113
<Head>
113-
<title>{process.env.NEXT_PUBLIC_TITLE ?? "ORUI"}</title>
114+
<title>{TITLE_NAME}</title>
114115
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/9000.0.1/themes/prism-tomorrow.min.css" />
115116
</Head>
116117
<GraphPage />

0 commit comments

Comments
 (0)