ConceptPortal-public/rsconcept/frontend/src/app/navigation/navigation.tsx

57 lines
2.4 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
2025-03-12 12:04:50 +03:00
import { IconLibrary2, IconManuals, IconNewItem2 } from '@/components/icons';
2025-03-12 11:55:43 +03:00
import { useWindowSize } from '@/hooks/use-window-size';
import { useAppLayoutStore } from '@/stores/app-layout';
2025-04-10 11:07:26 +03:00
import { useDialogsStore } from '@/stores/dialogs';
import { urls } from '../urls';
2025-02-12 21:36:25 +03:00
2025-03-12 12:04:50 +03:00
import { Logo } from './logo';
2025-07-11 13:34:00 +03:00
import { MenuAI } from './menu-ai';
import { MenuUser } from './menu-user';
2025-03-12 11:55:43 +03:00
import { NavigationButton } from './navigation-button';
import { useConceptNavigation } from './navigation-context';
import { ToggleNavigation } from './toggle-navigation';
2023-07-15 17:46:19 +03:00
export function Navigation() {
const { push } = useConceptNavigation();
const size = useWindowSize();
const noNavigationAnimation = useAppLayoutStore(state => state.noNavigationAnimation);
2025-04-10 11:07:26 +03:00
const activeDialog = useDialogsStore(state => state.active);
2023-07-15 17:46:19 +03:00
const navigateHome = (event: React.MouseEvent<Element>) =>
push({ path: urls.home, newTab: event.ctrlKey || event.metaKey });
2025-02-22 14:04:01 +03:00
const navigateLibrary = (event: React.MouseEvent<Element>) =>
push({ path: urls.library, newTab: event.ctrlKey || event.metaKey });
const navigateHelp = (event: React.MouseEvent<Element>) =>
push({ path: urls.manuals, newTab: event.ctrlKey || event.metaKey });
2025-02-22 14:04:01 +03:00
const navigateCreateNew = (event: React.MouseEvent<Element>) =>
push({ path: urls.create_schema, newTab: event.ctrlKey || event.metaKey });
2023-12-28 14:04:44 +03:00
2023-07-15 17:46:19 +03:00
return (
<nav className='z-navigation sticky top-0 left-0 right-0 select-none bg-background' inert={activeDialog !== null}>
<ToggleNavigation />
<div
className={clsx(
2025-03-14 21:06:55 +03:00
'pl-2 sm:pr-4 h-12 flex cc-shadow-border',
2025-04-16 15:22:31 +03:00
'transition-[max-height,translate] ease-bezier duration-move',
noNavigationAnimation ? '-translate-y-6 max-h-0' : 'max-h-12'
)}
2023-12-26 14:23:51 +03:00
>
2025-03-10 16:02:53 +03:00
<div className='flex items-center mr-auto cursor-pointer' onClick={!size.isSmall ? navigateHome : undefined}>
2023-12-28 14:04:44 +03:00
<Logo />
</div>
2025-07-11 13:34:00 +03:00
<div className='flex gap-2 items-center pr-2'>
2024-06-23 14:20:52 +03:00
<NavigationButton text='Новая схема' icon={<IconNewItem2 size='1.5rem' />} onClick={navigateCreateNew} />
<NavigationButton text='Библиотека' icon={<IconLibrary2 size='1.5rem' />} onClick={navigateLibrary} />
<NavigationButton text='Справка' icon={<IconManuals size='1.5rem' />} onClick={navigateHelp} />
2025-07-11 13:34:00 +03:00
<MenuAI />
<MenuUser />
2023-12-28 14:04:44 +03:00
</div>
</div>
2023-12-28 14:04:44 +03:00
</nav>
);
2023-07-15 17:46:19 +03:00
}