diff --git a/packages/twenty-front/src/modules/object-record/components/CommandMenuLayout.tsx b/packages/twenty-front/src/modules/object-record/components/CommandMenuLayout.tsx deleted file mode 100644 index 20b6da0518a..00000000000 --- a/packages/twenty-front/src/modules/object-record/components/CommandMenuLayout.tsx +++ /dev/null @@ -1,151 +0,0 @@ -import { CommandMenuRouter } from '@/command-menu/components/CommandMenuRouter'; -import { useCommandMenuHotKeys } from '@/command-menu/hooks/useCommandMenuHotKeys'; -import { isCommandMenuOpenedState } from '@/command-menu/states/isCommandMenuOpenedState'; -import { tableWidthResizeIsActiveState } from '@/object-record/record-table/states/tableWidthResizeIsActivedState'; -import { ModalContainerContext } from '@/ui/layout/modal/contexts/ModalContainerContext'; -import { PageBody } from '@/ui/layout/page/components/PageBody'; -import { useTheme } from '@emotion/react'; -import styled from '@emotion/styled'; -import { motion } from 'framer-motion'; -import { type ReactNode, useCallback, useState } from 'react'; -import { useRecoilValue, useSetRecoilState } from 'recoil'; -import { useIsMobile } from 'twenty-ui/utilities'; - -type CommandMenuPageLayoutProps = { - children: ReactNode; - isSidePanelOpen?: boolean; -}; - -const DEFAULT_SIDE_PANEL_WIDTH = 400; - -const StyledLayout = styled.div` - display: flex; - flex: 1; - min-height: 0; - padding-bottom: ${({ theme }) => theme.spacing(3)}; - padding-right: ${({ theme }) => theme.spacing(3)}; -`; - -const StyledPageBody = styled(PageBody)` - flex: 1; - min-width: 0; - padding-bottom: 0; - padding-right: 0; -`; - -const StyledSidePanelWrapper = styled(motion.div)` - flex-shrink: 0; - min-width: 0; - overflow: hidden; -`; - -const StyledSidePanel = styled(motion.aside)` - background: ${({ theme }) => theme.background.primary}; - border: 1px solid ${({ theme }) => theme.border.color.medium}; - border-radius: ${({ theme }) => theme.border.radius.md}; - display: flex; - flex-direction: column; - height: 100%; - overflow: hidden; - position: relative; - width: ${DEFAULT_SIDE_PANEL_WIDTH}px; - box-sizing: border-box; -`; - -const StyledModalContainer = styled.div` - height: 100%; - left: 0; - pointer-events: none; - position: absolute; - top: 0; - width: 100%; - z-index: 1; -`; - -export const CommandMenuPageLayout = ({ - children, - isSidePanelOpen, -}: CommandMenuPageLayoutProps) => { - const theme = useTheme(); - const isMobile = useIsMobile(); - const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState); - const [modalContainer, setModalContainer] = useState( - null, - ); - - const setTableWidthResizeIsActive = useSetRecoilState( - tableWidthResizeIsActiveState, - ); - - const resolvedIsSidePanelOpen = - isSidePanelOpen ?? isCommandMenuOpened ?? false; - - const [shouldRenderContent, setShouldRenderContent] = useState( - resolvedIsSidePanelOpen, - ); - - const shouldShowContent = resolvedIsSidePanelOpen || shouldRenderContent; - - const handleAnimationComplete = () => { - if (!resolvedIsSidePanelOpen) { - setShouldRenderContent(false); - } - - setTableWidthResizeIsActive(true); - }; - - const handleAnimationStart = () => { - if (resolvedIsSidePanelOpen && !shouldRenderContent) { - setShouldRenderContent(true); - } - - setTableWidthResizeIsActive(false); - }; - - const handleModalContainerRef = useCallback( - (element: HTMLDivElement | null) => { - setModalContainer(element); - }, - [], - ); - - useCommandMenuHotKeys(); - - if (isMobile) { - return <>{children}; - } - - return ( - - {children} - - - - - - {shouldShowContent && } - - - - - ); -}; diff --git a/packages/twenty-front/src/modules/object-record/components/CommandMenuPageLayout.tsx b/packages/twenty-front/src/modules/object-record/components/CommandMenuPageLayout.tsx index 2467681c462..b8daa7c6727 100644 --- a/packages/twenty-front/src/modules/object-record/components/CommandMenuPageLayout.tsx +++ b/packages/twenty-front/src/modules/object-record/components/CommandMenuPageLayout.tsx @@ -135,9 +135,6 @@ export const CommandMenuPageLayout = ({ >