2023-12-15 17:34:50 +03:00
|
|
|
import clsx from 'clsx';
|
|
|
|
|
2024-05-02 17:04:18 +03:00
|
|
|
import { IconLibrary2, IconManuals, IconNewItem2 } from '@/components/Icons';
|
2025-02-19 23:30:35 +03:00
|
|
|
import { useWindowSize } from '@/hooks/useWindowSize';
|
2025-01-14 21:58:16 +03:00
|
|
|
import { useAppLayoutStore } from '@/stores/appLayout';
|
2024-12-12 13:19:12 +03:00
|
|
|
import { PARAMETER } from '@/utils/constants';
|
2023-12-13 14:32:57 +03:00
|
|
|
|
2024-04-01 21:45:10 +03:00
|
|
|
import { urls } from '../urls';
|
2025-02-12 21:36:25 +03:00
|
|
|
|
2025-02-19 23:30:35 +03:00
|
|
|
import { Logo } from './Logo';
|
|
|
|
import { NavigationButton } from './NavigationButton';
|
2025-02-10 01:32:55 +03:00
|
|
|
import { useConceptNavigation } from './NavigationContext';
|
2025-02-19 23:30:35 +03:00
|
|
|
import { ToggleNavigation } from './ToggleNavigation';
|
|
|
|
import { UserMenu } from './UserMenu';
|
2023-07-15 17:46:19 +03:00
|
|
|
|
2025-02-10 01:32:55 +03:00
|
|
|
export function Navigation() {
|
2023-12-13 14:32:57 +03:00
|
|
|
const router = useConceptNavigation();
|
2024-12-12 13:19:12 +03:00
|
|
|
const size = useWindowSize();
|
2025-01-14 21:58:16 +03:00
|
|
|
const noNavigationAnimation = useAppLayoutStore(state => state.noNavigationAnimation);
|
2023-07-15 17:46:19 +03:00
|
|
|
|
2025-02-22 14:04:01 +03:00
|
|
|
const navigateHome = (event: React.MouseEvent<Element>) => router.push(urls.home, event.ctrlKey || event.metaKey);
|
|
|
|
const navigateLibrary = (event: React.MouseEvent<Element>) =>
|
|
|
|
router.push(urls.library, event.ctrlKey || event.metaKey);
|
|
|
|
const navigateHelp = (event: React.MouseEvent<Element>) => router.push(urls.manuals, event.ctrlKey || event.metaKey);
|
|
|
|
const navigateCreateNew = (event: React.MouseEvent<Element>) =>
|
|
|
|
router.push(urls.create_schema, event.ctrlKey || event.metaKey);
|
2023-12-28 14:04:44 +03:00
|
|
|
|
2023-07-15 17:46:19 +03:00
|
|
|
return (
|
2024-01-06 03:15:02 +03:00
|
|
|
<nav
|
|
|
|
className={clsx(
|
2025-01-27 15:03:48 +03:00
|
|
|
'z-navigation', //
|
2024-01-06 03:15:02 +03:00
|
|
|
'sticky top-0 left-0 right-0',
|
2025-01-27 15:03:48 +03:00
|
|
|
'select-none',
|
|
|
|
'bg-prim-100'
|
2024-01-06 03:15:02 +03:00
|
|
|
)}
|
|
|
|
>
|
2024-06-26 19:47:31 +03:00
|
|
|
<ToggleNavigation />
|
2024-12-12 13:19:12 +03:00
|
|
|
<div
|
2024-02-17 12:50:25 +03:00
|
|
|
className={clsx(
|
2025-01-27 15:03:48 +03:00
|
|
|
'pl-2 pr-[1.5rem] sm:pr-[0.9rem] h-[3rem]', //
|
2024-05-29 22:40:23 +03:00
|
|
|
'flex',
|
2024-05-22 14:26:17 +03:00
|
|
|
'cc-shadow-border'
|
2024-02-17 12:50:25 +03:00
|
|
|
)}
|
2024-12-12 13:19:12 +03:00
|
|
|
style={{
|
2025-02-22 16:46:42 +03:00
|
|
|
willChange: 'max-height, translate',
|
|
|
|
transitionProperty: 'max-height, translate',
|
2024-12-12 13:19:12 +03:00
|
|
|
transitionDuration: `${PARAMETER.moveDuration}ms`,
|
2025-02-22 16:46:42 +03:00
|
|
|
maxHeight: noNavigationAnimation ? '0rem' : '3rem',
|
2024-12-12 13:19:12 +03:00
|
|
|
translate: noNavigationAnimation ? '0 -1.5rem' : '0'
|
|
|
|
}}
|
2023-12-26 14:23:51 +03:00
|
|
|
>
|
2024-12-12 13:19:12 +03:00
|
|
|
<div
|
|
|
|
tabIndex={-1}
|
|
|
|
className={clsx('flex items-center mr-auto', !size.isSmall && 'cursor-pointer')}
|
|
|
|
onClick={!size.isSmall ? navigateHome : undefined}
|
|
|
|
>
|
2023-12-28 14:04:44 +03:00
|
|
|
<Logo />
|
|
|
|
</div>
|
2024-06-07 23:18:05 +03:00
|
|
|
<div className='flex gap-1 py-[0.3rem]'>
|
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-01-27 15:03:48 +03:00
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
<UserMenu />
|
|
|
|
</div>
|
2024-12-12 13:19:12 +03:00
|
|
|
</div>
|
2023-12-28 14:04:44 +03:00
|
|
|
</nav>
|
|
|
|
);
|
2023-07-15 17:46:19 +03:00
|
|
|
}
|