import { AnimatedButton, IconButton, IconDotsVertical, getOsControlSymbol, useIsMobile, } from 'twenty-ui'; import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu'; import { isCommandMenuOpenedState } from '@/command-menu/states/isCommandMenuOpenedState'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { t } from '@lingui/core/macro'; import { motion } from 'framer-motion'; import { useRecoilValue } from 'recoil'; import { FeatureFlagKey } from '~/generated/graphql'; const StyledButtonWrapper = styled.div` z-index: 30; `; const xPaths = { topLeft: `M12 12 L6 6`, topRight: `M12 12 L18 6`, bottomLeft: `M12 12 L6 18`, bottomRight: `M12 12 L18 18`, }; const AnimatedIcon = ({ isCommandMenuOpened, }: { isCommandMenuOpened: boolean; }) => { const theme = useTheme(); return ( {/* Center dot */} {/* X lines expanding from center */} {Object.values(xPaths).map((path, index) => ( ))} {/* Top dot */} {/* Bottom dot */} ); }; export const PageHeaderOpenCommandMenuButton = () => { const { toggleCommandMenu } = useCommandMenu(); const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState); const isCommandMenuV2Enabled = useIsFeatureEnabled( FeatureFlagKey.IsCommandMenuV2Enabled, ); const isMobile = useIsMobile(); const ariaLabel = isCommandMenuOpened ? t`Close command menu` : t`Open command menu`; const theme = useTheme(); return ( {isCommandMenuV2Enabled ? ( } className="page-header-command-menu-button" dataTestId="page-header-command-menu-button" size={isMobile ? 'medium' : 'small'} variant="secondary" accent="default" hotkeys={[getOsControlSymbol(), 'K']} ariaLabel={ariaLabel} onClick={toggleCommandMenu} animate={{ rotate: isCommandMenuOpened ? 90 : 0, }} transition={{ duration: theme.animation.duration.normal, ease: 'easeInOut', }} /> ) : ( )} ); };