Portal/rsconcept/frontend/src/app/Navigation/Navigation.tsx

69 lines
2.5 KiB
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
import clsx from 'clsx';
import { IconLibrary2, IconManuals, IconNewItem2 } from '@/components/Icons';
import { CProps } from '@/components/props';
2024-12-11 23:37:23 +03:00
import useWindowSize from '@/hooks/useWindowSize';
import { useAppLayoutStore } from '@/stores/appLayout';
2024-12-11 23:37:23 +03:00
import { PARAMETER } from '@/utils/constants';
2024-06-07 20:17:03 +03:00
import { urls } from '../urls';
2025-02-12 21:36:03 +03:00
2024-06-07 20:17:03 +03:00
import Logo from './Logo';
import NavigationButton from './NavigationButton';
import { useConceptNavigation } from './NavigationContext';
import ToggleNavigation from './ToggleNavigation';
2024-06-07 20:17:03 +03:00
import UserMenu from './UserMenu';
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();
const noNavigationAnimation = useAppLayoutStore(state => state.noNavigationAnimation);
2024-06-07 20:17:03 +03:00
const navigateHome = (event: CProps.EventMouse) => router.push(urls.home, event.ctrlKey || event.metaKey);
const navigateLibrary = (event: CProps.EventMouse) => router.push(urls.library, event.ctrlKey || event.metaKey);
const navigateHelp = (event: CProps.EventMouse) => router.push(urls.manuals, event.ctrlKey || event.metaKey);
const navigateCreateNew = (event: CProps.EventMouse) =>
router.push(urls.create_schema, event.ctrlKey || event.metaKey);
return (
<nav
className={clsx(
2025-01-23 19:41:31 +03:00
'z-navigation', //
2024-06-07 20:17:03 +03:00
'sticky top-0 left-0 right-0',
2025-01-21 20:33:05 +03:00
'select-none',
'bg-prim-100'
2024-06-07 20:17:03 +03:00
)}
>
<ToggleNavigation />
2024-12-11 23:37:23 +03:00
<div
2024-06-07 20:17:03 +03:00
className={clsx(
2025-01-23 19:41:31 +03:00
'pl-2 pr-[1.5rem] sm:pr-[0.9rem] h-[3rem]', //
2024-06-07 20:17:03 +03:00
'flex',
'cc-shadow-border'
)}
2024-12-11 23:37:23 +03:00
style={{
transitionProperty: 'height, translate',
transitionDuration: `${PARAMETER.moveDuration}ms`,
height: noNavigationAnimation ? '0rem' : '3rem',
translate: noNavigationAnimation ? '0 -1.5rem' : '0'
}}
2024-06-07 20:17:03 +03:00
>
2024-12-11 23:37:23 +03:00
<div
tabIndex={-1}
className={clsx('flex items-center mr-auto', !size.isSmall && 'cursor-pointer')}
onClick={!size.isSmall ? navigateHome : undefined}
>
2024-06-07 20:17:03 +03:00
<Logo />
</div>
<div className='flex gap-1 py-[0.3rem]'>
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} />
2025-01-21 20:33:05 +03:00
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>
);
}