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

62 lines
2.3 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
import { motion } from 'framer-motion';
2024-05-02 17:04:18 +03:00
import { IconLibrary2, IconManuals, IconNewItem2 } from '@/components/Icons';
import { CProps } from '@/components/props';
import { useConceptOptions } from '@/context/ConceptOptionsContext';
2023-12-26 14:23:51 +03:00
import { useConceptNavigation } from '@/context/NavigationContext';
import { animateNavigation } from '@/styling/animations';
import { urls } from '../urls';
import Logo from './Logo';
2023-07-15 17:46:19 +03:00
import NavigationButton from './NavigationButton';
import ToggleNavigation from './ToggleNavigation';
2023-07-15 17:46:19 +03:00
import UserMenu from './UserMenu';
2023-12-28 14:04:44 +03:00
function Navigation() {
const router = useConceptNavigation();
2024-04-01 19:07:20 +03:00
const { noNavigationAnimation } = useConceptOptions();
2023-07-15 17:46:19 +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);
2023-12-28 14:04:44 +03:00
2023-07-15 17:46:19 +03:00
return (
<nav
className={clsx(
'z-navigation', // prettier: split lines
'sticky top-0 left-0 right-0',
2024-05-22 14:26:17 +03:00
'w-full',
'clr-app',
'select-none'
)}
>
<ToggleNavigation />
2023-12-28 14:04:44 +03:00
<motion.div
2024-02-17 12:50:25 +03:00
className={clsx(
2024-05-22 14:26:17 +03:00
'pl-2 pr-[0.9rem] h-[3rem] w-full', // prettier: split lines
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
)}
2023-12-28 14:04:44 +03:00
initial={false}
animate={!noNavigationAnimation ? 'open' : 'closed'}
variants={animateNavigation}
2023-12-26 14:23:51 +03:00
>
2024-05-29 22:40:23 +03:00
<div tabIndex={-1} className='flex items-center mr-auto cursor-pointer' onClick={navigateHome}>
2023-12-28 14:04:44 +03:00
<Logo />
</div>
<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} />
2023-12-28 14:04:44 +03:00
<UserMenu />
</div>
</motion.div>
</nav>
);
2023-07-15 17:46:19 +03:00
}
2023-12-28 14:04:44 +03:00
export default Navigation;