Skip to content

Commit

Permalink
8976 modify mobile page header (#9020)
Browse files Browse the repository at this point in the history
Closes #8976
  • Loading branch information
bosiraphael authored Dec 11, 2024
1 parent 6067852 commit ad04040
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ActionMenuContext } from '@/action-menu/contexts/ActionMenuContext';
import { contextStoreCurrentObjectMetadataIdComponentState } from '@/context-store/states/contextStoreCurrentObjectMetadataIdComponentState';
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { useIsMobile } from 'twenty-ui';

export const RecordIndexActionMenu = () => {
const contextStoreCurrentObjectMetadataId = useRecoilComponentValueV2(
Expand All @@ -22,6 +23,8 @@ export const RecordIndexActionMenu = () => {
'IS_PAGE_HEADER_V2_ENABLED',
);

const isMobile = useIsMobile();

return (
<>
{contextStoreCurrentObjectMetadataId && (
Expand All @@ -32,7 +35,7 @@ export const RecordIndexActionMenu = () => {
}}
>
{isPageHeaderV2Enabled ? (
<RecordIndexActionMenuButtons />
<>{!isMobile && <RecordIndexActionMenuButtons />}</>
) : (
<RecordIndexActionMenuBar />
)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, IconButton, IconDotsVertical } from 'twenty-ui';
import { Button, IconButton, IconDotsVertical, useIsMobile } from 'twenty-ui';

import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
Expand All @@ -10,16 +10,18 @@ export const PageHeaderOpenCommandMenuButton = () => {
'IS_PAGE_HEADER_V2_ENABLED',
);

const isMobile = useIsMobile();

return (
<>
{isPageHeaderV2Enabled ? (
<Button
Icon={IconDotsVertical}
dataTestId="page-header-open-command-menu-button"
size="small"
size={isMobile ? 'medium' : 'small'}
variant="secondary"
accent="default"
shortcut="⌘K"
shortcut={isMobile ? '' : '⌘K'}
ariaLabel="Open command menu"
onClick={openCommandMenu}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { Button, IconButton, IconPlus } from 'twenty-ui';
import { Button, IconButton, IconPlus, useIsMobile } from 'twenty-ui';

type PageAddButtonProps = {
onClick?: () => void;
Expand All @@ -9,16 +9,18 @@ export const PageAddButton = ({ onClick }: PageAddButtonProps) => {
const isPageHeaderV2Enabled = useIsFeatureEnabled(
'IS_PAGE_HEADER_V2_ENABLED',
);
const isMobile = useIsMobile();

return (
<>
{isPageHeaderV2Enabled ? (
<Button
Icon={IconPlus}
dataTestId="add-button"
size="small"
size={isMobile ? 'medium' : 'small'}
variant="secondary"
accent="default"
title="New record"
title={isMobile ? '' : 'New record'}
onClick={onClick}
ariaLabel="New record"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,14 @@ export const PageHeader = ({
<>
<IconButton
Icon={IconChevronUp}
size="small"
size={isMobile ? 'medium' : 'small'}
variant="secondary"
disabled={!hasPreviousRecord}
onClick={() => navigateToPreviousRecord?.()}
/>
<IconButton
Icon={IconChevronDown}
size="small"
size={isMobile ? 'medium' : 'small'}
variant="secondary"
disabled={!hasNextRecord}
onClick={() => navigateToNextRecord?.()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { PageHeaderOpenCommandMenuButton } from '@/ui/layout/page-header/components/PageHeaderOpenCommandMenuButton';
import { ShowPageAddButton } from '@/ui/layout/show-page/components/ShowPageAddButton';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { useIsMobile } from 'twenty-ui';

type RecordShowPageBaseHeaderProps = {
isFavorite: boolean;
Expand All @@ -26,29 +27,35 @@ export const RecordShowPageBaseHeader = ({
'IS_FAVORITE_FOLDER_ENABLED',
);

const isMobile = useIsMobile();

return (
<>
{isFavoriteFolderEnabled ? (
<PageFavoriteFoldersDropdown
key={FAVORITE_FOLDER_PICKER_DROPDOWN_ID}
dropdownId={FAVORITE_FOLDER_PICKER_DROPDOWN_ID}
isFavorite={isFavorite}
record={record}
objectNameSingular={objectNameSingular}
/>
) : (
<PageFavoriteButton
isFavorite={isFavorite}
onClick={handleFavoriteButtonClick}
/>
{!isMobile && (
<>
{isFavoriteFolderEnabled ? (
<PageFavoriteFoldersDropdown
key={FAVORITE_FOLDER_PICKER_DROPDOWN_ID}
dropdownId={FAVORITE_FOLDER_PICKER_DROPDOWN_ID}
isFavorite={isFavorite}
record={record}
objectNameSingular={objectNameSingular}
/>
) : (
<PageFavoriteButton
isFavorite={isFavorite}
onClick={handleFavoriteButtonClick}
/>
)}
<ShowPageAddButton
key="add"
activityTargetObject={{
id: record?.id ?? '0',
targetObjectNameSingular: objectMetadataItem.nameSingular,
}}
/>
</>
)}
<ShowPageAddButton
key="add"
activityTargetObject={{
id: record?.id ?? '0',
targetObjectNameSingular: objectMetadataItem.nameSingular,
}}
/>
<PageHeaderOpenCommandMenuButton key="more" />
</>
);
Expand Down

0 comments on commit ad04040

Please sign in to comment.