From 3b85747d3f962e1832f9727447f31b9fbe3e646e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?= <71827178+bosiraphael@users.noreply.github.com> Date: Wed, 15 Apr 2026 17:53:26 +0200 Subject: [PATCH] Go back to the original command K button (#19727) ## Before https://github.com/user-attachments/assets/868e5293-8843-44c8-8011-b7130e97fa95 ## After https://github.com/user-attachments/assets/89cf46cc-1fb1-4e78-bfef-53e1d04e8ebf --- .../components/SidePanelToggleButton.tsx | 168 ++++++++++++++--- .../PageHeaderToggleSidePanelButton.tsx | 178 ------------------ 2 files changed, 140 insertions(+), 206 deletions(-) delete mode 100644 packages/twenty-front/src/modules/ui/layout/page-header/components/PageHeaderToggleSidePanelButton.tsx diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelToggleButton.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelToggleButton.tsx index cecb8bc450..d8832e56f6 100644 --- a/packages/twenty-front/src/modules/side-panel/components/SidePanelToggleButton.tsx +++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelToggleButton.tsx @@ -1,53 +1,165 @@ +import { SIDE_PANEL_TOP_BAR_HEIGHT_MOBILE } from '@/side-panel/constants/SidePanelTopBarHeightMobile'; import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu'; import { isSidePanelOpenedState } from '@/side-panel/states/isSidePanelOpenedState'; +import { isLayoutCustomizationModeEnabledState } from '@/layout-customization/states/isLayoutCustomizationModeEnabledState'; +import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices'; import { PAGE_HEADER_SIDE_PANEL_BUTTON_CLICK_OUTSIDE_ID } from '@/ui/layout/page-header/constants/PageHeaderSidePanelButtonClickOutsideId'; import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue'; import { styled } from '@linaria/react'; import { t } from '@lingui/core/macro'; -import { - AppTooltip, - IconLayoutSidebarRightExpand, - IconX, - TooltipDelay, - TooltipPosition, -} from 'twenty-ui/display'; +import { motion } from 'framer-motion'; +import { useContext } from 'react'; +import { AppTooltip, TooltipDelay, TooltipPosition } from 'twenty-ui/display'; import { AnimatedButton } from 'twenty-ui/input'; -import { themeCssVariables } from 'twenty-ui/theme-constants'; -import { AnimatedIconCrossfade, useIsMobile } from 'twenty-ui/utilities'; +import { getOsControlSymbol, useIsMobile } from 'twenty-ui/utilities'; +import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants'; + +const StyledButtonWrapper = styled.div<{ alignToTop: boolean }>` + align-items: ${({ alignToTop }) => (alignToTop ? 'center' : 'initial')}; + display: ${({ alignToTop }) => (alignToTop ? 'flex' : 'block')}; + height: ${({ alignToTop }) => + alignToTop ? `${SIDE_PANEL_TOP_BAR_HEIGHT_MOBILE}px` : 'auto'}; + position: ${({ alignToTop }) => (alignToTop ? 'fixed' : 'static')}; + right: ${({ alignToTop }) => + alignToTop ? themeCssVariables.spacing[3] : 'auto'}; + top: ${({ alignToTop }) => (alignToTop ? '0' : 'auto')}; + z-index: ${RootStackingContextZIndices.SidePanelButton}; +`; const StyledTooltipWrapper = styled.div` font-size: ${themeCssVariables.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 = ({ + isSidePanelOpened, +}: { + isSidePanelOpened: boolean; +}) => { + const { theme } = useContext(ThemeContext); + + return ( + + + + + {Object.values(xPaths).map((path, index) => ( + + ))} + + + + + + ); +}; + export const SidePanelToggleButton = () => { const { toggleSidePanelMenu } = useSidePanelMenu(); const isSidePanelOpened = useAtomStateValue(isSidePanelOpenedState); + const isLayoutCustomizationModeEnabled = useAtomStateValue( + isLayoutCustomizationModeEnabledState, + ); const isMobile = useIsMobile(); + const alignWithSidePanelTopBar = + isMobile && isLayoutCustomizationModeEnabled && isSidePanelOpened; + const ariaLabel = isSidePanelOpened ? t`Close side panel` : t`Open side panel`; + const { theme } = useContext(ThemeContext); return ( -
- - } - dataClickOutsideId={PAGE_HEADER_SIDE_PANEL_BUTTON_CLICK_OUTSIDE_ID} - dataTestId="page-header-side-panel-button" - size={isMobile ? 'medium' : 'small'} - variant="secondary" - accent="default" - title={isSidePanelOpened ? t`Close` : t`More`} - ariaLabel={ariaLabel} - onClick={toggleSidePanelMenu} - /> + +
+ } + dataClickOutsideId={PAGE_HEADER_SIDE_PANEL_BUTTON_CLICK_OUTSIDE_ID} + dataTestId="page-header-side-panel-button" + size={isMobile ? 'medium' : 'small'} + variant="secondary" + accent="default" + hotkeys={[getOsControlSymbol(), 'K']} + ariaLabel={ariaLabel} + onClick={toggleSidePanelMenu} + animate={{ + rotate: isSidePanelOpened ? 90 : 0, + }} + transition={{ + duration: theme.animation.duration.normal, + ease: 'easeInOut', + }} + /> +
+ { noArrow /> -
+ ); }; diff --git a/packages/twenty-front/src/modules/ui/layout/page-header/components/PageHeaderToggleSidePanelButton.tsx b/packages/twenty-front/src/modules/ui/layout/page-header/components/PageHeaderToggleSidePanelButton.tsx deleted file mode 100644 index dc6da71d91..0000000000 --- a/packages/twenty-front/src/modules/ui/layout/page-header/components/PageHeaderToggleSidePanelButton.tsx +++ /dev/null @@ -1,178 +0,0 @@ -import { SIDE_PANEL_TOP_BAR_HEIGHT_MOBILE } from '@/side-panel/constants/SidePanelTopBarHeightMobile'; -import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu'; -import { isSidePanelOpenedState } from '@/side-panel/states/isSidePanelOpenedState'; -import { isLayoutCustomizationModeEnabledState } from '@/layout-customization/states/isLayoutCustomizationModeEnabledState'; -import { RootStackingContextZIndices } from '@/ui/layout/constants/RootStackingContextZIndices'; -import { PAGE_HEADER_SIDE_PANEL_BUTTON_CLICK_OUTSIDE_ID } from '@/ui/layout/page-header/constants/PageHeaderSidePanelButtonClickOutsideId'; -import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue'; -import { styled } from '@linaria/react'; -import { t } from '@lingui/core/macro'; -import { motion } from 'framer-motion'; -import { useContext } from 'react'; -import { AppTooltip, TooltipDelay, TooltipPosition } from 'twenty-ui/display'; -import { AnimatedButton } from 'twenty-ui/input'; -import { getOsControlSymbol, useIsMobile } from 'twenty-ui/utilities'; -import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants'; -const StyledButtonWrapper = styled.div<{ alignToTop: boolean }>` - align-items: ${({ alignToTop }) => (alignToTop ? 'center' : 'initial')}; - display: ${({ alignToTop }) => (alignToTop ? 'flex' : 'block')}; - height: ${({ alignToTop }) => - alignToTop ? `${SIDE_PANEL_TOP_BAR_HEIGHT_MOBILE}px` : 'auto'}; - position: ${({ alignToTop }) => (alignToTop ? 'fixed' : 'static')}; - right: ${({ alignToTop }) => - alignToTop ? themeCssVariables.spacing[3] : 'auto'}; - top: ${({ alignToTop }) => (alignToTop ? '0' : 'auto')}; - z-index: ${RootStackingContextZIndices.SidePanelButton}; -`; - -const StyledTooltipWrapper = styled.div` - font-size: ${themeCssVariables.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 = ({ - isSidePanelOpened, -}: { - isSidePanelOpened: boolean; -}) => { - const { theme } = useContext(ThemeContext); - - return ( - - - {/* Center dot */} - - - {/* X lines expanding from center */} - {Object.values(xPaths).map((path, index) => ( - - ))} - - {/* Top dot */} - - - {/* Bottom dot */} - - - ); -}; - -export const PageHeaderToggleSidePanelButton = () => { - const { toggleSidePanelMenu } = useSidePanelMenu(); - const isSidePanelOpened = useAtomStateValue(isSidePanelOpenedState); - const isLayoutCustomizationModeEnabled = useAtomStateValue( - isLayoutCustomizationModeEnabledState, - ); - - const isMobile = useIsMobile(); - - const alignWithSidePanelTopBar = - isMobile && isLayoutCustomizationModeEnabled && isSidePanelOpened; - - const ariaLabel = isSidePanelOpened - ? t`Close side panel` - : t`Open side panel`; - - const { theme } = useContext(ThemeContext); - return ( - -
- } - dataClickOutsideId={PAGE_HEADER_SIDE_PANEL_BUTTON_CLICK_OUTSIDE_ID} - dataTestId="page-header-side-panel-button" - size={isMobile ? 'medium' : 'small'} - variant="secondary" - accent="default" - hotkeys={[getOsControlSymbol(), 'K']} - ariaLabel={ariaLabel} - onClick={toggleSidePanelMenu} - animate={{ - rotate: isSidePanelOpened ? 90 : 0, - }} - transition={{ - duration: theme.animation.duration.normal, - ease: 'easeInOut', - }} - /> -
- - - - -
- ); -};