2024-06-07 20:17:03 +03:00
|
|
|
import { IconLibrary2, IconManuals, IconNewItem2 } from '@/components/Icons';
|
2025-02-19 23:29:45 +03:00
|
|
|
import { useWindowSize } from '@/hooks/useWindowSize';
|
2025-01-14 21:57:32 +03:00
|
|
|
import { useAppLayoutStore } from '@/stores/appLayout';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
|
|
|
|
import { urls } from '../urls';
|
2025-02-12 21:36:03 +03:00
|
|
|
|
2025-02-19 23:29:45 +03:00
|
|
|
import { Logo } from './Logo';
|
|
|
|
|
import { NavigationButton } from './NavigationButton';
|
2025-02-10 01:32:16 +03:00
|
|
|
import { useConceptNavigation } from './NavigationContext';
|
2025-02-19 23:29:45 +03:00
|
|
|
import { ToggleNavigation } from './ToggleNavigation';
|
|
|
|
|
import { UserMenu } from './UserMenu';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
2025-02-10 01:32:16 +03:00
|
|
|
export function Navigation() {
|
2024-06-07 20:17:03 +03:00
|
|
|
const router = useConceptNavigation();
|
2024-12-11 23:37:23 +03:00
|
|
|
const size = useWindowSize();
|
2025-01-14 21:57:32 +03:00
|
|
|
const noNavigationAnimation = useAppLayoutStore(state => state.noNavigationAnimation);
|
2024-06-07 20:17:03 +03:00
|
|
|
|
2025-02-26 16:28:16 +03:00
|
|
|
const navigateHome = (event: React.MouseEvent<Element>) =>
|
|
|
|
|
router.push({ path: urls.home, newTab: event.ctrlKey || event.metaKey });
|
2025-02-22 14:03:13 +03:00
|
|
|
const navigateLibrary = (event: React.MouseEvent<Element>) =>
|
2025-02-26 16:28:16 +03:00
|
|
|
router.push({ path: urls.library, newTab: event.ctrlKey || event.metaKey });
|
|
|
|
|
const navigateHelp = (event: React.MouseEvent<Element>) =>
|
|
|
|
|
router.push({ path: urls.manuals, newTab: event.ctrlKey || event.metaKey });
|
2025-02-22 14:03:13 +03:00
|
|
|
const navigateCreateNew = (event: React.MouseEvent<Element>) =>
|
2025-02-26 16:28:16 +03:00
|
|
|
router.push({ path: urls.create_schema, newTab: event.ctrlKey || event.metaKey });
|
2024-06-07 20:17:03 +03:00
|
|
|
|
|
|
|
|
return (
|
2025-03-10 16:01:40 +03:00
|
|
|
<nav className='z-navigation sticky top-0 left-0 right-0 select-none bg-prim-100'>
|
2024-06-26 19:47:05 +03:00
|
|
|
<ToggleNavigation />
|
2024-12-11 23:37:23 +03:00
|
|
|
<div
|
2025-03-10 16:01:40 +03:00
|
|
|
className='pl-2 pr-6 sm:pr-4 h-12 flex cc-shadow-border'
|
2024-12-11 23:37:23 +03:00
|
|
|
style={{
|
2025-02-22 16:12:29 +03:00
|
|
|
maxHeight: noNavigationAnimation ? '0rem' : '3rem',
|
2024-12-11 23:37:23 +03:00
|
|
|
translate: noNavigationAnimation ? '0 -1.5rem' : '0'
|
|
|
|
|
}}
|
2024-06-07 20:17:03 +03:00
|
|
|
>
|
2025-03-10 16:01:40 +03:00
|
|
|
<div className='flex items-center mr-auto cursor-pointer' onClick={!size.isSmall ? navigateHome : undefined}>
|
2024-06-07 20:17:03 +03:00
|
|
|
<Logo />
|
|
|
|
|
</div>
|
2025-03-07 02:45:37 +03:00
|
|
|
<div className='flex gap-2 items-center'>
|
2024-06-23 14:20:37 +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} />
|
2024-06-07 20:17:03 +03:00
|
|
|
<UserMenu />
|
|
|
|
|
</div>
|
2024-12-11 23:37:23 +03:00
|
|
|
</div>
|
2024-06-07 20:17:03 +03:00
|
|
|
</nav>
|
|
|
|
|
);
|
|
|
|
|
}
|