import React, { useState, useEffect } from 'react' import PropTypes from 'prop-types' import { OverlayTrigger, Tooltip } from 'react-bootstrap' import classNames from 'classnames' import OutlineRoot from './OutlineRoot' import localStorage from '../../../modules/localStorage' function OutlinePane({ isTexFile, outline, projectId, jumpToLine, onToggle, eventTracking, highlightedLine }) { const storageKey = `file_outline.expanded.${projectId}` const [expanded, setExpanded] = useState(() => { const storedExpandedState = localStorage(storageKey) !== false return storedExpandedState }) const isOpen = isTexFile && expanded useEffect( () => { onToggle(isOpen) }, [isOpen] ) const expandCollapseIconClasses = classNames('fa', 'outline-caret-icon', { 'fa-angle-down': isOpen, 'fa-angle-right': !isOpen }) const headerClasses = classNames('outline-pane', { 'outline-pane-disabled': !isTexFile }) function handleExpandCollapseClick() { if (isTexFile) { localStorage(storageKey, !expanded) eventTracking.sendMB(expanded ? 'outline-collapse' : 'outline-expand') setExpanded(!expanded) } } return (