import { ComponentView } from '@/components/ComponentView'; import { PanelResizer } from '@/components/PanelResizer'; import { SmartTagsSection } from '@/components/Tags/SmartTagsSection'; import { TagsSection } from '@/components/Tags/TagsSection'; import { toDirective } from '@/components/utils'; import { PanelSide, ResizeFinishCallback, } from '@/directives/views/panelResizer'; import { WebApplication } from '@/ui_models/application'; import { PANEL_NAME_NAVIGATION } from '@/views/constants'; import { PrefKey } from '@standardnotes/snjs'; import { observer } from 'mobx-react-lite'; import { FunctionComponent } from 'preact'; import { useCallback, useEffect, useMemo, useState } from 'preact/hooks'; import { PremiumModalProvider } from './Premium'; type Props = { application: WebApplication; }; export const Navigation: FunctionComponent = observer( ({ application }) => { const appState = useMemo(() => application.getAppState(), [application]); const componentViewer = appState.foldersComponentViewer; const enableNativeSmartTagsFeature = appState.features.enableNativeSmartTagsFeature; const [panelRef, setPanelRef] = useState(null); useEffect(() => { const elem = document.querySelector( 'navigation' ) as HTMLDivElement | null; setPanelRef(elem); }, [setPanelRef]); const onCreateNewTag = useCallback(() => { appState.tags.createNewTemplate(); }, [appState]); const panelResizeFinishCallback: ResizeFinishCallback = useCallback( (_lastWidth, _lastLeft, _isMaxWidth, isCollapsed) => { appState.noteTags.reloadTagsContainerMaxWidth(); appState.panelDidResize(PANEL_NAME_NAVIGATION, isCollapsed); }, [appState] ); const panelWidthEventCallback = useCallback(() => { appState.noteTags.reloadTagsContainerMaxWidth(); }, [appState]); return (
{componentViewer ? (
) : (
Views
{!enableNativeSmartTagsFeature && (
)}
)} {panelRef && ( )}
); } ); export const NavigationDirective = toDirective(Navigation);