mirror of
https://github.com/lingble/twenty.git
synced 2025-10-30 04:12:28 +00:00
ISSUE Closes https://github.com/twentyhq/twenty/issues/7085 DEMO https://github.com/user-attachments/assets/39692906-c02e-4e4c-9205-82447fa142df --------- Co-authored-by: Lucas Bordeau <bordeau.lucas@gmail.com>
75 lines
2.2 KiB
TypeScript
75 lines
2.2 KiB
TypeScript
import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
|
|
import { isCommandMenuOpenedState } from '@/command-menu/states/isCommandMenuOpenedState';
|
|
import { useOpenSettingsMenu } from '@/navigation/hooks/useOpenSettings';
|
|
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
|
|
import { useRecoilState } from 'recoil';
|
|
import {
|
|
IconComponent,
|
|
IconList,
|
|
IconSearch,
|
|
IconSettings,
|
|
NavigationBar,
|
|
} from 'twenty-ui';
|
|
import { useIsSettingsPage } from '../hooks/useIsSettingsPage';
|
|
import { currentMobileNavigationDrawerState } from '../states/currentMobileNavigationDrawerState';
|
|
|
|
type NavigationBarItemName = 'main' | 'search' | 'tasks' | 'settings';
|
|
|
|
export const MobileNavigationBar = () => {
|
|
const [isCommandMenuOpened] = useRecoilState(isCommandMenuOpenedState);
|
|
const { closeCommandMenu, openCommandMenu } = useCommandMenu();
|
|
const isSettingsPage = useIsSettingsPage();
|
|
const [isNavigationDrawerExpanded, setIsNavigationDrawerExpanded] =
|
|
useRecoilState(isNavigationDrawerExpandedState);
|
|
const [currentMobileNavigationDrawer, setCurrentMobileNavigationDrawer] =
|
|
useRecoilState(currentMobileNavigationDrawerState);
|
|
|
|
const { openSettingsMenu } = useOpenSettingsMenu();
|
|
|
|
const activeItemName = isNavigationDrawerExpanded
|
|
? currentMobileNavigationDrawer
|
|
: isCommandMenuOpened
|
|
? 'search'
|
|
: isSettingsPage
|
|
? 'settings'
|
|
: 'main';
|
|
|
|
const items: {
|
|
name: NavigationBarItemName;
|
|
Icon: IconComponent;
|
|
onClick: () => void;
|
|
}[] = [
|
|
{
|
|
name: 'main',
|
|
Icon: IconList,
|
|
onClick: () => {
|
|
closeCommandMenu();
|
|
setIsNavigationDrawerExpanded(
|
|
(previousIsOpen) => activeItemName !== 'main' || !previousIsOpen,
|
|
);
|
|
setCurrentMobileNavigationDrawer('main');
|
|
},
|
|
},
|
|
{
|
|
name: 'search',
|
|
Icon: IconSearch,
|
|
onClick: () => {
|
|
if (!isCommandMenuOpened) {
|
|
openCommandMenu();
|
|
}
|
|
setIsNavigationDrawerExpanded(false);
|
|
},
|
|
},
|
|
{
|
|
name: 'settings',
|
|
Icon: IconSettings,
|
|
onClick: () => {
|
|
closeCommandMenu();
|
|
openSettingsMenu();
|
|
},
|
|
},
|
|
];
|
|
|
|
return <NavigationBar activeItemName={activeItemName} items={items} />;
|
|
};
|