diff --git a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx index f6d9544411d0..1c6193313b75 100644 --- a/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx +++ b/packages/twenty-front/src/modules/object-metadata/components/ObjectMetadataNavItems.tsx @@ -1,5 +1,4 @@ -import React from 'react'; - +import { AnimatePresence, motion } from 'framer-motion'; import { useLocation } from 'react-router-dom'; import { useRecoilValue } from 'recoil'; import { isDefined, useIcons } from 'twenty-ui'; @@ -17,6 +16,20 @@ import { NavigationDrawerSubItem } from '@/ui/navigation/navigation-drawer/compo import { useNavigationSection } from '@/ui/navigation/navigation-drawer/hooks/useNavigationSection'; import { View } from '@/views/types/View'; import { getObjectMetadataItemViews } from '@/views/utils/getObjectMetadataItemViews'; +import { Theme, useTheme } from '@emotion/react'; + +const navItemsAnimationVariants = (theme: Theme) => ({ + hidden: { + height: 0, + opacity: 0, + marginTop: 0, + }, + visible: { + height: 'auto', + opacity: 1, + marginTop: theme.spacing(1), + }, +}); export const ObjectMetadataNavItems = ({ isRemote }: { isRemote: boolean }) => { const currentUser = useRecoilValue(currentUserState); @@ -36,6 +49,8 @@ export const ObjectMetadataNavItems = ({ isRemote }: { isRemote: boolean }) => { const { records: views } = usePrefetchedData(PrefetchKey.AllViews); const loading = useIsPrefetchLoading(); + const theme = useTheme(); + if (loading && isDefined(currentUser)) { return ; } @@ -96,7 +111,7 @@ export const ObjectMetadataNavItems = ({ isRemote }: { isRemote: boolean }) => { objectMetadataViews.length > 1; return ( - +
{ currentPath === `/objects/${objectMetadataItem.namePlural}` } /> - {shouldSubItemsBeDisplayed && - objectMetadataViews - .sort((viewA, viewB) => - viewA.key === 'INDEX' - ? -1 - : viewA.position - viewB.position, - ) - .map((view) => ( - - ))} - + + {shouldSubItemsBeDisplayed && ( + + {objectMetadataViews + .sort((viewA, viewB) => + viewA.key === 'INDEX' + ? -1 + : viewA.position - viewB.position, + ) + .map((view) => ( +
+ +
+ ))} +
+ )} +
+
); })}