import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu'; import { isCommandMenuOpenedState } from '@/command-menu/states/isCommandMenuOpenedState'; import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices'; import { useTheme } from '@emotion/react'; import styled from '@emotion/styled'; import { i18n } from '@lingui/core'; import { t } from '@lingui/core/macro'; import { motion } from 'framer-motion'; import { useRecoilValue } from 'recoil'; import { AppTooltip, TooltipDelay, TooltipPosition } from 'twenty-ui/display'; import { AnimatedButton } from 'twenty-ui/input'; import { getOsControlSymbol, useIsMobile } from 'twenty-ui/utilities'; const StyledButtonWrapper = styled.div` z-index: ${RootStackingContextZIndices.CommandMenuButton}; `; const StyledTooltipWrapper = styled.div` font-size: ${({ theme }) => theme.font.size.md}; `; 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 PageHeaderToggleCommandMenuButton = () => { const { toggleCommandMenu } = useCommandMenu(); const isCommandMenuOpened = useRecoilValue(isCommandMenuOpenedState); const isMobile = useIsMobile(); const ariaLabel = isCommandMenuOpened ? t`Close command menu` : t`Open command menu`; const theme = useTheme(); return (
} 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', }} />
); };