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

55 lines
1.9 KiB
TypeScript
Raw Normal View History

2024-06-07 20:17:03 +03:00
import clsx from 'clsx';
2024-12-19 18:48:43 +03:00
import { IconDarkTheme, IconLightTheme, IconPin, IconUnpin } from '@/components/Icons';
import { useConceptOptions } from '@/context/ConceptOptionsContext';
2024-12-11 23:37:23 +03:00
import { globals, PARAMETER } from '@/utils/constants';
2024-06-07 20:17:03 +03:00
function ToggleNavigation() {
2024-12-19 18:48:43 +03:00
const { noNavigationAnimation, noNavigation, toggleNoNavigation, toggleDarkMode, darkMode } = useConceptOptions();
const iconSize = !noNavigationAnimation ? '0.75rem' : '1rem';
2024-06-07 20:17:03 +03:00
return (
2024-12-19 18:48:43 +03:00
<div
2024-06-07 20:17:03 +03:00
className={clsx(
2024-08-24 19:40:54 +03:00
'absolute top-0 right-0 z-navigation',
2024-12-19 18:48:43 +03:00
'min-h-[2rem] min-w-[2rem]',
'flex items-center justify-center gap-1',
'select-none',
!noNavigation && 'flex-col-reverse'
2024-06-07 20:17:03 +03:00
)}
2024-12-11 23:37:23 +03:00
style={{
2024-12-17 11:37:42 +03:00
transitionProperty: 'height, width, background-color',
2024-12-11 23:37:23 +03:00
transitionDuration: `${PARAMETER.moveDuration}ms`,
2024-12-19 18:48:43 +03:00
height: noNavigationAnimation ? '2rem' : '3rem',
width: noNavigationAnimation ? '3rem' : '2rem'
2024-12-11 23:37:23 +03:00
}}
2024-06-07 20:17:03 +03:00
>
2024-12-19 18:48:43 +03:00
{!noNavigationAnimation ? (
<button
tabIndex={-1}
type='button'
className='p-1 rounded-full'
onClick={toggleDarkMode}
data-tooltip-id={globals.tooltip}
data-tooltip-content={darkMode ? 'Тема: Темная' : 'Тема: Светлая'}
>
{darkMode ? <IconDarkTheme size='0.75rem' /> : null}
{!darkMode ? <IconLightTheme size='0.75rem' /> : null}
</button>
) : null}
<button
tabIndex={-1}
type='button'
className='p-1 rounded-full'
onClick={toggleNoNavigation}
data-tooltip-id={globals.tooltip}
data-tooltip-content={noNavigationAnimation ? 'Показать навигацию' : 'Скрыть навигацию'}
>
{!noNavigationAnimation ? <IconPin size={iconSize} /> : null}
{noNavigationAnimation ? <IconUnpin size={iconSize} /> : null}
</button>
</div>
2024-06-07 20:17:03 +03:00
);
}
export default ToggleNavigation;