Files
twenty/packages/twenty-front/src/modules/command-menu/components/CommandMenuButton.tsx
Félix Malfait bfefcd3755 feat(twenty-front): generalize the page primary/secondary bars (flat redesign) (#21308)
Replaces #21279 and #21282 with one clean PR from `main`.

Generalizes the settings primary-bar / secondary-bar card chrome to the
record index, record show and standalone pages via a shared
`PageCardLayout` + `PageCardHeader` (the side panel sits as a sibling of
the content card), and applies the new flat design direction: square
corners on the card, side panel and loading skeletons.

Iterating toward the new design (Figma node 102282-221623); the
confirmed direction and the explicit "remove rounded corners" change are
in, remaining designer specifics to follow.
2026-06-08 22:47:05 +02:00

90 lines
2.6 KiB
TypeScript

import { getCommandMenuItemLabel } from '@/command-menu-item/utils/getCommandMenuItemLabel';
import { styled } from '@linaria/react';
import { type MessageDescriptor } from '@lingui/core';
import { type MouseEvent } from 'react';
import { type Nullable } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
import {
AppTooltip,
type IconComponent,
TooltipDelay,
TooltipPosition,
} from 'twenty-ui-deprecated/display';
import { Button, IconButton } from 'twenty-ui-deprecated/input';
import { themeCssVariables } from 'twenty-ui-deprecated/theme-constants';
const StyledWrapper = styled.div`
font-size: ${themeCssVariables.font.size.md};
`;
export type CommandMenuButtonProps = {
command: {
key: string;
label: Nullable<string | MessageDescriptor>;
shortLabel?: Nullable<string | MessageDescriptor>;
Icon: IconComponent;
isPrimaryCTA?: boolean;
};
onClick?: (event?: MouseEvent<HTMLElement>) => void;
to?: string;
disabled?: boolean;
isPrimaryAction?: boolean;
};
export const CommandMenuButton = ({
command,
onClick,
to,
disabled = false,
isPrimaryAction = false,
}: CommandMenuButtonProps) => {
const resolvedLabel = getCommandMenuItemLabel(command.label);
const resolvedShortLabel = isDefined(command.shortLabel)
? getCommandMenuItemLabel(command.shortLabel)
: undefined;
const buttonAccent = command.isPrimaryCTA ? 'blue' : 'default';
return (
<>
{resolvedShortLabel !== undefined ? (
<Button
Icon={command.Icon}
size="small"
variant={isPrimaryAction ? 'primary' : 'secondary'}
accent={isPrimaryAction ? 'blue' : buttonAccent}
to={to}
onClick={onClick}
disabled={disabled}
title={resolvedShortLabel}
ariaLabel={resolvedLabel}
/>
) : (
<div id={`command-menu-item-entry-${command.key}`} key={command.key}>
<IconButton
Icon={command.Icon}
size="small"
variant={isPrimaryAction ? 'primary' : 'secondary'}
accent={isPrimaryAction ? 'blue' : buttonAccent}
to={to}
onClick={onClick}
disabled={disabled}
ariaLabel={resolvedLabel}
/>
<StyledWrapper>
<AppTooltip
anchorSelect={`#command-menu-item-entry-${command.key}`}
content={resolvedLabel}
delay={TooltipDelay.longDelay}
place={TooltipPosition.Bottom}
offset={5}
noArrow
/>
</StyledWrapper>
</div>
)}
</>
);
};