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

71 lines
2.2 KiB
TypeScript
Raw Normal View History

import clsx from 'clsx';
import { motion } from 'framer-motion';
2023-12-17 20:19:28 +03:00
import { FaSquarePlus } from 'react-icons/fa6';
import { IoLibrary } from 'react-icons/io5';
2023-12-17 20:19:28 +03:00
import { EducationIcon } from '@/components/Icons';
2023-12-26 14:23:51 +03:00
import { useConceptNavigation } from '@/context/NavigationContext';
import { useConceptTheme } from '@/context/ThemeContext';
import { animateNavigation } from '@/styling/animations';
import Logo from './Logo';
2023-07-15 17:46:19 +03:00
import NavigationButton from './NavigationButton';
import ToggleNavigationButton from './ToggleNavigationButton';
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();
const { noNavigationAnimation } = useConceptTheme();
2023-07-15 17:46:19 +03:00
const navigateHome = () => router.push('/');
const navigateLibrary = () => router.push('/library');
const navigateHelp = () => router.push('/manuals');
const navigateCreateNew = () => router.push('/library/create');
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',
'clr-app',
'select-none'
)}
>
2023-12-28 14:04:44 +03:00
<ToggleNavigationButton />
<motion.div
className={clsx('pl-2 pr-[0.9rem] h-[3rem]', 'flex justify-between', 'shadow-border')}
initial={false}
animate={!noNavigationAnimation ? 'open' : 'closed'}
variants={animateNavigation}
2023-12-26 14:23:51 +03:00
>
2023-12-28 14:04:44 +03:00
<div tabIndex={-1} className='flex items-center mr-2 cursor-pointer' onClick={navigateHome}>
<Logo />
</div>
<div className='flex'>
<NavigationButton
text='Новая схема'
title='Создать новую схему'
icon={<FaSquarePlus size='1.5rem' />}
onClick={navigateCreateNew}
/>
<NavigationButton
text='Библиотека'
title='Список схем'
icon={<IoLibrary size='1.5rem' />}
onClick={navigateLibrary}
/>
<NavigationButton
text='Справка'
title='Справочные материалы'
icon={<EducationIcon />}
onClick={navigateHelp}
/>
<UserMenu />
</div>
</motion.div>
</nav>
);
2023-07-15 17:46:19 +03:00
}
2023-12-28 14:04:44 +03:00
export default Navigation;