Skip to content

The open alternative to Salesforce, designed for AI.

Migrate Chip to the new twenty-ui API (#25788)

Raphaël Bosibbe547da4b1d
diff --git a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
index 2948c1b7430..1bb4e9d02e7 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -17,6 +17,7 @@ import {
statusControlsTest,
tagControlsTest,
avatarControlsTest,
+ chipControlsTest,
} from '@/__stories__/twenty-ui-gallery/utils/displayControlTests';
import { createGalleryStory } from '@/__stories__/twenty-ui-gallery/utils/createGalleryStory';
import {
@@ -395,3 +396,15 @@ export const AvatarControlsPreact: Story = createGalleryStory({
runtime: 'preact',
play: avatarControlsTest,
});
+
+export const ChipControlsReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-chip-controls',
+ runtime: 'react',
+ play: chipControlsTest,
+});
+
+export const ChipControlsPreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-chip-controls',
+ runtime: 'preact',
+ play: chipControlsTest,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/showcase/twenty-ui-example.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/showcase/twenty-ui-example.front-component.tsx
index dd96b4870ff..a4c23ca7741 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/showcase/twenty-ui-example.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/showcase/twenty-ui-example.front-component.tsx
@@ -1,6 +1,6 @@
import { defineFrontComponent } from 'twenty-sdk/define';
import { useState } from 'react';
-import { Chip, ChipVariant, Status, Tag } from 'twenty-ui/data-display';
+import { Chip, Status, Tag } from 'twenty-ui/data-display';
import { Button } from 'twenty-ui/input';
import { ThemeProvider } from 'twenty-ui/theme-constants';
import { H2Title } from 'twenty-ui/typography';
@@ -51,8 +51,10 @@ const TwentyUiComponent = () => {
<Status color="orange">Away</Status>
</div>
<div style={ROW_STYLE}>
- <Chip label="Highlighted" variant={ChipVariant.Highlighted} />
- <Chip label="Rounded" variant={ChipVariant.Rounded} />
+ <Chip variant="soft">Highlighted</Chip>
+ <Chip variant="ghost" shape="round">
+ Rounded
+ </Chip>
</div>
<p
data-testid="twenty-ui-count"
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-chip-controls.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-chip-controls.front-component.tsx
new file mode 100644
index 00000000000..856ec94e17a
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-chip-controls.front-component.tsx
@@ -0,0 +1,48 @@
+import { useState } from 'react';
+import { defineFrontComponent } from 'twenty-sdk/define';
+import { Chip } from 'twenty-ui/data-display';
+import { IconStar } from 'twenty-ui/icon';
+import { ThemeProvider } from 'twenty-ui/theme-constants';
+import 'twenty-ui/style.css';
+
+import { ComponentGallery } from '../shared/front-components/component-gallery';
+
+const ChipControls = () => {
+ const [activations, setActivations] = useState(0);
+ const handleClick = () => setActivations((count) => count + 1);
+ return (
+ <ThemeProvider colorScheme="light">
+ <ComponentGallery
+ title="Chip controls"
+ entries={[
+ {
+ name: 'Chip',
+ node: (
+ <>
+ <Chip
+ onClick={handleClick}
+ variant="soft"
+ startElement={<IconStar />}
+ >
+ Open chip
+ </Chip>
+ <Chip onClick={handleClick} disabled>
+ Disabled chip
+ </Chip>
+ <Chip shape="round">Static chip</Chip>
+ </>
+ ),
+ },
+ ]}
+ />
+ <output aria-label="Activations">{activations}</output>
+ </ThemeProvider>
+ );
+};
+
+export default defineFrontComponent({
+ universalIdentifier: '38a631c4-a79b-4033-bf58-5c61d057d42b',
+ name: 'twenty-ui-chip-controls',
+ description: 'Chip APIs and interactions in the sandbox',
+ component: ChipControls,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-data-display-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-data-display-gallery.front-component.tsx
index 804988568a8..a7381a3ad44 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-data-display-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-data-display-gallery.front-component.tsx
@@ -54,7 +54,7 @@ const DATA_DISPLAY_ENTRIES: GalleryEntry[] = [
},
{
name: 'Chip',
- node: <Chip label="Chip label" />,
+ node: <Chip>Chip label</Chip>,
},
{
name: 'ColorSample',
@@ -69,7 +69,7 @@ const DATA_DISPLAY_ENTRIES: GalleryEntry[] = [
// Router whose navigator bridges to the host navigate API.
{
name: 'LinkChip',
- node: <LinkChip to="/example" label="Link chip" />,
+ node: <LinkChip to="/example">Link chip</LinkChip>,
},
{
name: 'NotificationCounter',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/displayControlTests.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/displayControlTests.ts
index 9829cfb461b..d6a6f49652d 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/displayControlTests.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/displayControlTests.ts
@@ -75,3 +75,9 @@ export const avatarControlsTest = createDisplayControlTest({
staticContent: 'A',
checkGallery: avatarGalleryTest,
});
+
+export const chipControlsTest = createDisplayControlTest({
+ buttonName: 'Open chip',
+ disabledButtonName: 'Disabled chip',
+ staticContent: 'Static chip',
+});
diff --git a/packages/twenty-front/src/modules/ai/components/ChatReferenceChip.tsx b/packages/twenty-front/src/modules/ai/components/ChatReferenceChip.tsx
index 2927bb1e96c..0b7369e1c94 100644
--- a/packages/twenty-front/src/modules/ai/components/ChatReferenceChip.tsx
+++ b/packages/twenty-front/src/modules/ai/components/ChatReferenceChip.tsx
@@ -1,7 +1,7 @@
import { t } from '@lingui/core/macro';
import { useContext } from 'react';
import { isDefined } from 'twenty-shared/utils';
-import { Chip, ChipVariant, LinkChip } from 'twenty-ui/data-display';
+import { Chip, LinkChip } from 'twenty-ui/data-display';
import { ChatReferenceNavigationEnabledContext } from '@/ai/contexts/ChatReferenceNavigationEnabledContext';
import { useChatReferenceTarget } from '@/ai/hooks/useChatReferenceTarget';
@@ -22,23 +22,24 @@ export const ChatReferenceChip = ({ reference }: ChatReferenceChipProps) => {
if (!isDefined(target.to) || !isNavigationEnabled) {
return (
<Chip
- label={reference.displayName}
emptyLabel={t`Untitled`}
- variant={ChipVariant.Static}
- leftComponent={target.leftComponent}
- clickable={false}
- />
+ variant="soft"
+ startElement={target.leftComponent}
+ >
+ {reference.displayName}
+ </Chip>
);
}
return (
<LinkChip
- label={reference.displayName}
emptyLabel={t`Untitled`}
to={target.to}
onClick={target.onClick}
- variant={ChipVariant.Highlighted}
- leftComponent={target.leftComponent}
- />
+ variant="soft"
+ startElement={target.leftComponent}
+ >
+ {reference.displayName}
+ </LinkChip>
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/__tests__/ChatReferenceChip.test.tsx b/packages/twenty-front/src/modules/ai/components/__tests__/ChatReferenceChip.test.tsx
index f4c08e27060..1a959ea2feb 100644
--- a/packages/twenty-front/src/modules/ai/components/__tests__/ChatReferenceChip.test.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__tests__/ChatReferenceChip.test.tsx
@@ -1,4 +1,5 @@
import { fireEvent, render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
import { type ReactNode } from 'react';
import { MemoryRouter, useLocation } from 'react-router-dom';
import { isDefined } from 'twenty-shared/utils';
@@ -250,7 +251,7 @@ describe('ChatReferenceChip', () => {
});
expect(screen.getByText(reference.displayName).closest('a')).toBeNull();
- expect(screen.getByTestId('chip')).toBeInTheDocument();
+ expect(screen.getByText(reference.displayName)).toBeVisible();
},
);
@@ -364,7 +365,7 @@ describe('ChatReferenceChip', () => {
});
expect(screen.getByText(reference.displayName)).toBeInTheDocument();
- expect(screen.queryByTestId('chip')).not.toBeInTheDocument();
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
});
it.each([
@@ -389,21 +390,29 @@ describe('ChatReferenceChip', () => {
renderWithReferences(<ChatReferenceChip reference={reference} />);
expect(screen.getByText(reference.displayName).closest('a')).toBeNull();
- expect(screen.getByTestId('chip')).toBeInTheDocument();
+ expect(screen.getByText(reference.displayName)).toBeVisible();
});
- it('should render a static chip when navigation is disabled', () => {
- renderWithReferences(
- <ChatReferenceChip reference={findCase('role').reference} />,
- { isNavigationEnabled: false },
- );
+ it('should render a static chip when navigation is disabled', async () => {
+ const reference = findCase('role').reference;
+
+ renderWithReferences(<ChatReferenceChip reference={reference} />, {
+ isNavigationEnabled: false,
+ });
+ const label = screen.getByText(reference.displayName);
+
+ expect(label).toBeVisible();
expect(screen.queryByRole('link')).not.toBeInTheDocument();
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
- const chipClassName = screen.getByTestId('chip').className;
+ await userEvent.click(label);
- expect(chipClassName).not.toMatch(/cursorPointer/);
- expect(chipClassName).toMatch(/backgroundStatic/);
+ expect(openRoutedPageInSidePanelMock).not.toHaveBeenCalled();
+ expect(openRecordInSidePanelMock).not.toHaveBeenCalled();
+ expect(screen.getByTestId('location-probe')).toHaveTextContent(
+ '/objects/companies',
+ );
});
});
@@ -431,7 +440,7 @@ describe('TextWithChatReferences', () => {
/>,
);
- expect(screen.queryByTestId('chip')).not.toBeInTheDocument();
+ expect(screen.queryByRole('link')).not.toBeInTheDocument();
expect(screen.getByText(/Sort by/)).toHaveTextContent(
'Sort by Stage first',
);
diff --git a/packages/twenty-front/src/modules/ai/components/internal/AgentChatFilePreview.tsx b/packages/twenty-front/src/modules/ai/components/internal/AgentChatFilePreview.tsx
index 3787184f53d..6467b44f161 100644
--- a/packages/twenty-front/src/modules/ai/components/internal/AgentChatFilePreview.tsx
+++ b/packages/twenty-front/src/modules/ai/components/internal/AgentChatFilePreview.tsx
@@ -10,7 +10,7 @@ import { t } from '@lingui/core/macro';
import { useCallback, useContext } from 'react';
import { type ExtendedFileUIPart } from 'twenty-shared/ai';
import { isDefined } from 'twenty-shared/utils';
-import { AvatarOrIcon, Chip, ChipVariant } from 'twenty-ui/data-display';
+import { AvatarOrIcon, Chip } from 'twenty-ui/data-display';
import { type IconComponent, IconX } from 'twenty-ui/icon';
import { Loader } from 'twenty-ui/feedback';
import { ThemeContext } from 'twenty-ui/theme-constants';
@@ -90,14 +90,14 @@ export const AgentChatFilePreview = ({
onClick={isClickable ? handleClick : undefined}
>
<Chip
- label={fileName}
emptyLabel={t`Untitled`}
- variant={ChipVariant.Static}
- clickable={isClickable}
- leftComponent={leftComponent}
- rightComponent={rightComponent}
- rightComponentDivider={hasRightDivider}
- />
+ variant="soft"
+ startElement={leftComponent}
+ endElement={rightComponent}
+ endElementDivider={hasRightDivider}
+ >
+ {fileName}
+ </Chip>
</StyledClickableContainer>
);
};
diff --git a/packages/twenty-front/src/modules/blocknote-editor/blocks/MentionInlineContent.tsx b/packages/twenty-front/src/modules/blocknote-editor/blocks/MentionInlineContent.tsx
index fd8f5245f9b..a2b3ad55524 100644
--- a/packages/twenty-front/src/modules/blocknote-editor/blocks/MentionInlineContent.tsx
+++ b/packages/twenty-front/src/modules/blocknote-editor/blocks/MentionInlineContent.tsx
@@ -7,7 +7,7 @@ import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
import { isDefined } from 'twenty-shared/utils';
-import { Chip, ChipVariant } from 'twenty-ui/data-display';
+import { Chip } from 'twenty-ui/data-display';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
@@ -53,20 +53,20 @@ const LegacyMentionRenderer = ({
if (!isDefined(objectMetadataItem)) {
return (
<Chip
- label={t`Unknown object`}
- variant={ChipVariant.Transparent}
+ variant="ghost"
disabled
- />
+ style={{ paddingInlineStart: 0 }}
+ >{t`Unknown object`}</Chip>
);
}
if (!isDefined(record)) {
return (
<Chip
- label={t`Deleted record`}
- variant={ChipVariant.Transparent}
+ variant="ghost"
disabled
- />
+ style={{ paddingInlineStart: 0 }}
+ >{t`Deleted record`}</Chip>
);
}
diff --git a/packages/twenty-front/src/modules/mention/components/MentionRecordChip.tsx b/packages/twenty-front/src/modules/mention/components/MentionRecordChip.tsx
index 8a4440f6632..1856297f380 100644
--- a/packages/twenty-front/src/modules/mention/components/MentionRecordChip.tsx
+++ b/packages/twenty-front/src/modules/mention/components/MentionRecordChip.tsx
@@ -2,12 +2,7 @@ import { getLinkToShowPage } from '@/object-metadata/utils/getLinkToShowPage';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
import { t } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
-import {
- AvatarOrIcon,
- Chip,
- ChipVariant,
- LinkChip,
-} from 'twenty-ui/data-display';
+import { AvatarOrIcon, Chip, LinkChip } from 'twenty-ui/data-display';
type MentionRecordChipProps = {
recordId: string;
@@ -27,20 +22,20 @@ export const MentionRecordChip = ({
if (!isNonEmptyString(objectNameSingular)) {
return (
<Chip
- label={t`Unknown object`}
- variant={ChipVariant.Transparent}
+ variant="ghost"
disabled
- />
+ style={{ paddingInlineStart: 0 }}
+ >{t`Unknown object`}</Chip>
);
}
if (!isNonEmptyString(recordId)) {
return (
<Chip
- label={t`Deleted record`}
- variant={ChipVariant.Transparent}
+ variant="ghost"
disabled
- />
+ style={{ paddingInlineStart: 0 }}
+ >{t`Deleted record`}</Chip>
);
}
@@ -50,12 +45,11 @@ export const MentionRecordChip = ({
return (
<LinkChip
- label={label}
emptyLabel={t`Untitled`}
to={linkToShowPage}
- variant={ChipVariant.Highlighted}
+ variant="soft"
className={className}
- leftComponent={
+ startElement={
<AvatarOrIcon
name={label}
colorSeed={recordId}
@@ -63,6 +57,8 @@ export const MentionRecordChip = ({
src={getAbsoluteImageUrl(imageUrl)}
/>
}
- />
+ >
+ {label}
+ </LinkChip>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx b/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx
index 80203e4bdd9..7d6575b443b 100644
--- a/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx
+++ b/packages/twenty-front/src/modules/object-record/components/RecordChip.tsx
@@ -12,7 +12,6 @@ import {
AvatarOrIcon,
Chip,
type ChipSize,
- ChipVariant,
LinkChip,
} from 'twenty-ui/data-display';
import { type TriggerEventType } from 'twenty-ui/utilities';
@@ -21,7 +20,7 @@ export type RecordChipProps = {
objectNameSingular: string;
record: ObjectRecord;
className?: string;
- variant?: ChipVariant.Highlighted | ChipVariant.Transparent;
+ variant?: 'soft' | 'ghost';
forceDisableClick?: boolean;
isBold?: boolean;
maxWidth?: number;
@@ -76,14 +75,13 @@ export const RecordChip = ({
) {
return (
<Chip
- label={recordChipData.name}
emptyLabel={t`Untitled`}
- isBold={isBold}
+ weight={isBold ? 'medium' : 'regular'}
size={size}
maxWidth={maxWidth}
className={className}
- variant={ChipVariant.Transparent}
- leftComponent={
+ variant="ghost"
+ startElement={
isIconHidden ? null : (
<AvatarOrIcon
name={recordChipData.name}
@@ -93,7 +91,10 @@ export const RecordChip = ({
/>
)
}
- />
+ style={{ paddingInlineStart: 0 }}
+ >
+ {recordChipData.name}
+ </Chip>
);
}
@@ -101,11 +102,10 @@ export const RecordChip = ({
<LinkChip
size={size}
maxWidth={maxWidth}
- label={recordChipData.name}
emptyLabel={t`Untitled`}
- isBold={isBold}
+ weight={isBold ? 'medium' : 'regular'}
isLabelHidden={isLabelHidden}
- leftComponent={
+ startElement={
isIconHidden ? null : (
<AvatarOrIcon
name={recordChipData.name}
@@ -116,13 +116,14 @@ export const RecordChip = ({
)
}
className={className}
- variant={
- variant ??
- (!forceDisableClick ? ChipVariant.Highlighted : ChipVariant.Transparent)
- }
+ variant={variant ?? 'soft'}
+ clickable={variant !== 'ghost'}
+ style={variant === 'ghost' ? { paddingInlineStart: 0 } : undefined}
to={to ?? getLinkToShowPage(objectNameSingular, record)}
onClick={handleCustomClick}
triggerEvent={triggerEvent}
- />
+ >
+ {recordChipData.name}
+ </LinkChip>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCardHeader.tsx b/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCardHeader.tsx
index d0f3e181e18..d763d4d996f 100644
--- a/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCardHeader.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-board/record-board-card/components/RecordBoardCardHeader.tsx
@@ -21,7 +21,6 @@ import { styled } from '@linaria/react';
import { useContext } from 'react';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { isDefined } from 'twenty-shared/utils';
-import { ChipVariant } from 'twenty-ui/data-display';
import { IconEye, IconEyeOff } from 'twenty-ui/icon';
import { Checkbox, LightIconButton } from 'twenty-ui/input';
import { useIsMobile, useIsTouchDevice } from 'twenty-ui/utilities';
@@ -89,7 +88,7 @@ export const RecordBoardCardHeader = () => {
<RecordChip
objectNameSingular={objectMetadataItem.nameSingular}
record={recordStore}
- variant={ChipVariant.Transparent}
+ variant="ghost"
onClick={() => {
activateBoardCard({ rowIndex, columnIndex });
unfocusBoardCard();
@@ -124,7 +123,7 @@ export const RecordBoardCardHeader = () => {
setIsRecordBoardCardSelected(isChecked);
checkIfLastUnselectAndCloseDropdown();
}}
- variant={'outline'}
+ variant="outline"
/>
</StopPropagationContainer>
</StyledCheckboxContainer>
diff --git a/packages/twenty-front/src/modules/object-record/record-calendar/record-calendar-card/components/RecordCalendarCardHeader.tsx b/packages/twenty-front/src/modules/object-record/record-calendar/record-calendar-card/components/RecordCalendarCardHeader.tsx
index a8788e46adc..36772acfd98 100644
--- a/packages/twenty-front/src/modules/object-record/record-calendar/record-calendar-card/components/RecordCalendarCardHeader.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-calendar/record-calendar-card/components/RecordCalendarCardHeader.tsx
@@ -11,7 +11,6 @@ import { useGetCurrentViewOnly } from '@/views/hooks/useGetCurrentViewOnly';
import { styled } from '@linaria/react';
import { useAtomFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomFamilyStateValue';
import { isDefined } from 'twenty-shared/utils';
-import { ChipVariant } from 'twenty-ui/data-display';
import { Checkbox } from 'twenty-ui/input';
import { isRecordCalendarCardSelectedComponentFamilyState } from '@/object-record/record-calendar/record-calendar-card/states/isRecordCalendarCardSelectedComponentFamilyState';
import { themeCssVariables } from 'twenty-ui/theme-constants';
@@ -73,7 +72,7 @@ export const RecordCalendarCardHeader = ({
<RecordChip
objectNameSingular={objectMetadataItem.nameSingular}
record={recordStore}
- variant={ChipVariant.Transparent}
+ variant="ghost"
isIconHidden={true}
forceDisableClick
triggerEvent={'CLICK'}
@@ -83,7 +82,7 @@ export const RecordCalendarCardHeader = ({
<RecordChip
objectNameSingular={objectMetadataItem.nameSingular}
record={recordStore}
- variant={ChipVariant.Transparent}
+ variant="ghost"
isIconHidden={true}
onClick={handleChipClick}
triggerEvent={'CLICK'}
@@ -99,7 +98,7 @@ export const RecordCalendarCardHeader = ({
onCheckedChange={(isChecked) => {
setIsRecordCalendarCardSelected(isChecked);
}}
- variant={'outline'}
+ variant="outline"
/>
</StopPropagationContainer>
</StyledCheckboxContainer>
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/ChipFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/ChipFieldDisplay.tsx
index 8c0ffc089bc..2d4d831ddad 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/ChipFieldDisplay.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/ChipFieldDisplay.tsx
@@ -1,7 +1,6 @@
import { RecordChip } from '@/object-record/components/RecordChip';
import { useChipFieldDisplay } from '@/object-record/record-field/ui/meta-types/hooks/useChipFieldDisplay';
import { isDefined } from 'twenty-shared/utils';
-import { ChipSize } from 'twenty-ui/data-display';
export const ChipFieldDisplay = () => {
const {
@@ -23,7 +22,7 @@ export const ChipFieldDisplay = () => {
maxWidth={maxWidth}
objectNameSingular={objectNameSingular}
record={recordValue}
- size={ChipSize.Small}
+ size="sm"
to={labelIdentifierLink}
forceDisableClick={disableChipClick}
triggerEvent={triggerEvent}
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/FilesFieldMenuItem.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/FilesFieldMenuItem.tsx
index 8e460437b0c..26681975c3b 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/FilesFieldMenuItem.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/input/components/FilesFieldMenuItem.tsx
@@ -1,7 +1,7 @@
import { FileIcon } from '@/file/components/FileIcon';
import { type FieldFilesValue } from '@/object-record/record-field/ui/types/FieldMetadata';
import { getFileCategoryFromExtension } from '@/object-record/record-field/ui/utils/getFileCategoryFromExtension';
-import { Chip, ChipVariant } from 'twenty-ui/data-display';
+import { Chip } from 'twenty-ui/data-display';
import { MultiItemFieldMenuItem } from './MultiItemFieldMenuItem';
type FilesFieldMenuItemProps = {
@@ -28,8 +28,7 @@ export const FilesFieldMenuItem = ({
onClick={onClick}
DisplayComponent={({ value }: { value: string }) => (
<Chip
- label={value}
- leftComponent={
+ startElement={
<FileIcon
fileCategory={
file.fileCategory ??
@@ -39,8 +38,10 @@ export const FilesFieldMenuItem = ({
thumbnailUrl={file.url}
/>
}
- variant={ChipVariant.Rounded}
- />
+ variant="ghost"
+ >
+ {value}
+ </Chip>
)}
showPrimaryIcon={false}
showSetAsPrimaryButton={false}
diff --git a/packages/twenty-front/src/modules/object-record/record-list/components/RecordListRow.tsx b/packages/twenty-front/src/modules/object-record/record-list/components/RecordListRow.tsx
index 40c472b22a9..552a321f45c 100644
--- a/packages/twenty-front/src/modules/object-record/record-list/components/RecordListRow.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-list/components/RecordListRow.tsx
@@ -19,7 +19,7 @@ import { styled } from '@linaria/react';
import { plural, t } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
import { isDefined } from 'twenty-shared/utils';
-import { Chip, ChipVariant, LinkChip } from 'twenty-ui/data-display';
+import { Chip, LinkChip } from 'twenty-ui/data-display';
import { TooltipPosition } from 'twenty-ui/surfaces';
import { themeCssVariables } from 'twenty-ui/theme-constants';
@@ -167,7 +167,7 @@ export const RecordListRow = ({ recordId }: RecordListRowProps) => {
objectNameSingular={objectNameSingular}
record={recordStore}
to={linkToRecord}
- variant={ChipVariant.Transparent}
+ variant="ghost"
isBold
onClick={openRecord}
triggerEvent={'CLICK'}
@@ -188,23 +188,25 @@ export const RecordListRow = ({ recordId }: RecordListRowProps) => {
<StyledOverflowChipContainer>
{isNonEmptyString(linkToRecord) ? (
<LinkChip
- label={overflowChipLabel}
to={linkToRecord}
onClick={openRecord}
triggerEvent="CLICK"
tooltipLabel={overflowChipTooltipLabel}
tooltipPlace={TooltipPosition.Top}
alwaysShowTooltip
- variant={ChipVariant.Highlighted}
- />
+ variant="soft"
+ >
+ {overflowChipLabel}
+ </LinkChip>
) : (
<Chip
- label={overflowChipLabel}
tooltipLabel={overflowChipTooltipLabel}
tooltipPlace={TooltipPosition.Top}
alwaysShowTooltip
- variant={ChipVariant.Highlighted}
- />
+ variant="soft"
+ >
+ {overflowChipLabel}
+ </Chip>
)}
</StyledOverflowChipContainer>
)}
diff --git a/packages/twenty-front/src/modules/object-record/record-list/components/__stories__/RecordListRow.stories.tsx b/packages/twenty-front/src/modules/object-record/record-list/components/__stories__/RecordListRow.stories.tsx
index 010bcf9cc26..d6cda62892b 100644
--- a/packages/twenty-front/src/modules/object-record/record-list/components/__stories__/RecordListRow.stories.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-list/components/__stories__/RecordListRow.stories.tsx
@@ -69,11 +69,7 @@ export const ResponsiveFields: Story = {
{},
{ timeout: 3000 },
);
- const recordIdentifierChip = recordIdentifier.closest(
- '[data-testid="chip"]',
- );
-
- await expect(recordIdentifierChip).toHaveClass(/fontMedium/);
+ await expect(getComputedStyle(recordIdentifier).fontWeight).toBe('500');
const overflowChips = await canvas.findAllByRole('link', {
name: /^\+\d+$/,
diff --git a/packages/twenty-front/src/modules/onboarding/components/import-contacts/OnboardingImportPreviewCompanies.tsx b/packages/twenty-front/src/modules/onboarding/components/import-contacts/OnboardingImportPreviewCompanies.tsx
index 389472668d2..8ed9d860dd8 100644
--- a/packages/twenty-front/src/modules/onboarding/components/import-contacts/OnboardingImportPreviewCompanies.tsx
+++ b/packages/twenty-front/src/modules/onboarding/components/import-contacts/OnboardingImportPreviewCompanies.tsx
@@ -3,13 +3,7 @@ import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { getLogoUrlFromDomainName } from 'twenty-shared/utils';
-import {
- Avatar,
- Chip,
- ChipAccent,
- ChipSize,
- ChipVariant,
-} from 'twenty-ui/data-display';
+import { Avatar, Chip } from 'twenty-ui/data-display';
import { IconBuildingSkyscraper, IconPlus } from 'twenty-ui/icon';
import { Checkbox } from 'twenty-ui/input';
import { themeCssVariables, useTheme } from 'twenty-ui/theme-constants';
@@ -74,12 +68,10 @@ export const OnboardingImportPreviewCompanies = () => {
<StyledRow key={company.id}>
<Checkbox checked={false} hoverable />
<Chip
- label={company.name}
- size={ChipSize.Small}
- variant={ChipVariant.Transparent}
- accent={ChipAccent.TextPrimary}
- clickable={false}
- leftComponent={
+ size="sm"
+ variant="ghost"
+ color="primary"
+ startElement={
<Avatar
shape="square"
size="md"
@@ -90,7 +82,10 @@ export const OnboardingImportPreviewCompanies = () => {
)}
/>
}
- />
+ style={{ paddingInlineStart: 0 }}
+ >
+ {company.name}
+ </Chip>
</StyledRow>
))}
</StyledColumn>
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem.tsx b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem.tsx
index 5b94c371aa1..dbc1a9acbbf 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/call-recording-transcript/components/CallRecordingTranscriptEntryListItem.tsx
@@ -6,7 +6,7 @@ import { t } from '@lingui/core/macro';
import { type Ref } from 'react';
import { type CallRecordingParsedTranscriptEntry } from 'twenty-shared/types';
import { isDefined, isNonEmptyArray } from 'twenty-shared/utils';
-import { Avatar, Chip, ChipVariant } from 'twenty-ui/data-display';
+import { Avatar, Chip } from 'twenty-ui/data-display';
import { themeCssVariables } from 'twenty-ui/theme-constants';
const StyledEntry = styled.li<{
@@ -125,10 +125,8 @@ export const CallRecordingTranscriptEntryListItem = ({
>
<StyledEntryHeader>
<Chip
- clickable={false}
- label={speakerName}
- variant={ChipVariant.Transparent}
- leftComponent={
+ variant="ghost"
+ startElement={
<Avatar
name={speakerName}
colorSeed={speakerName}
@@ -136,7 +134,10 @@ export const CallRecordingTranscriptEntryListItem = ({
shape="circle"
/>
}
- />
+ style={{ paddingInlineStart: 0 }}
+ >
+ {speakerName}
+ </Chip>
{isDefined(formattedStartTimestamp) && (
<StyledTimestamp
as={isSelectable ? 'button' : undefined}
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceContent.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceContent.tsx
index cd063665ceb..d836334ab5c 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceContent.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceContent.tsx
@@ -77,12 +77,11 @@ export const SettingsAdminWorkspaceContent = ({
label: t`Name`,
value: activeWorkspace?.id ? (
<LinkChip
- label={activeWorkspace?.name ?? ''}
emptyLabel={t`Untitled`}
to={getSettingsPath(SettingsPath.AdminPanelWorkspaceDetail, {
workspaceId: activeWorkspace.id,
})}
- leftComponent={
+ startElement={
<AvatarOrIcon
src={getAbsoluteImageUrl(
isNonEmptyString(activeWorkspace?.logo)
@@ -91,7 +90,9 @@ export const SettingsAdminWorkspaceContent = ({
)}
/>
}
- />
+ >
+ {activeWorkspace?.name ?? ''}
+ </LinkChip>
) : (
(activeWorkspace?.name ?? '')
),
diff --git a/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelHoverCard.tsx b/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelHoverCard.tsx
index e9b14442c3e..3a94b8274f6 100644
--- a/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelHoverCard.tsx
+++ b/packages/twenty-front/src/modules/settings/ai/components/SettingsAiModelHoverCard.tsx
@@ -1,12 +1,7 @@
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
import { useContext } from 'react';
-import {
- Chip,
- ChipAccent,
- ChipSize,
- ChipVariant,
-} from 'twenty-ui/data-display';
+import { Chip } from 'twenty-ui/data-display';
import {
IconBolt,
IconBuildingSkyscraper,
@@ -90,19 +85,19 @@ export const SettingsAiModelHoverCard = ({
value: (
<StyledChipContainer>
<Chip
- size={ChipSize.Small}
- accent={ChipAccent.TextPrimary}
- variant={ChipVariant.Static}
- clickable={false}
- label={model.label}
- leftComponent={
+ size="sm"
+ color="primary"
+ variant="soft"
+ startElement={
<ModelIcon
size={theme.icon.size.sm}
stroke={theme.icon.stroke.sm}
/>
}
- rightComponent={null}
- />
+ endElement={null}
+ >
+ {model.label}
+ </Chip>
</StyledChipContainer>
),
},
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsItemTypeTag.tsx b/packages/twenty-front/src/modules/settings/components/SettingsItemTypeTag.tsx
index cc612af5785..3b3e49db4af 100644
--- a/packages/twenty-front/src/modules/settings/components/SettingsItemTypeTag.tsx
+++ b/packages/twenty-front/src/modules/settings/components/SettingsItemTypeTag.tsx
@@ -1,7 +1,7 @@
import { t } from '@lingui/core/macro';
import { AppChip } from '@/applications/components/AppChip';
-import { Avatar, Chip, ChipAccent, ChipVariant } from 'twenty-ui/data-display';
+import { Avatar, Chip } from 'twenty-ui/data-display';
import { isDefined } from 'twenty-shared/utils';
type SettingsItemTypeTagProps = {
@@ -22,10 +22,9 @@ export const SettingsItemTypeTag = ({
return (
<Chip
className={className}
- label={t`Remote`}
- variant={ChipVariant.Transparent}
- accent={ChipAccent.TextPrimary}
- leftComponent={
+ variant="ghost"
+ color="primary"
+ startElement={
<Avatar
shape="square"
variant="outline"
@@ -34,7 +33,8 @@ export const SettingsItemTypeTag = ({
colorSeed="Remote"
/>
}
- />
+ style={{ paddingInlineStart: 0 }}
+ >{t`Remote`}</Chip>
);
} else {
return null;
diff --git a/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockTableRow.tsx b/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockTableRow.tsx
index 48cf0209fab..6439cc2984f 100644
--- a/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockTableRow.tsx
+++ b/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockTableRow.tsx
@@ -5,13 +5,7 @@ import { type BackgroundMockCompany } from '@/sign-in-background-mock/constants/
import { BACKGROUND_MOCK_COLUMN_WIDTHS } from '@/sign-in-background-mock/constants/BackgroundMockColumnWidths';
import { BACKGROUND_MOCK_TABLE_DIMENSIONS } from '@/sign-in-background-mock/constants/BackgroundMockTableDimensions';
import { getAbsoluteImageUrl } from '~/utils/image/getAbsoluteImageUrl';
-import {
- Avatar,
- Chip,
- ChipAccent,
- ChipSize,
- ChipVariant,
-} from 'twenty-ui/data-display';
+import { Avatar, Chip } from 'twenty-ui/data-display';
import { IconLink } from 'twenty-ui/icon';
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
import { Checkbox } from 'twenty-ui/input';
@@ -86,15 +80,16 @@ const PersonChip = ({ fullName }: { fullName: string | null }) => {
return (
<Chip
- label={fullName}
- size={ChipSize.Small}
- variant={ChipVariant.Transparent}
- accent={ChipAccent.TextPrimary}
- clickable={false}
- leftComponent={
+ size="sm"
+ variant="ghost"
+ color="primary"
+ startElement={
<Avatar shape="circle" name={fullName} colorSeed={fullName} size="md" />
}
- />
+ style={{ paddingInlineStart: 0 }}
+ >
+ {fullName}
+ </Chip>
);
};
@@ -113,12 +108,10 @@ export const BackgroundMockTableRow = ({
</StyledCheckboxColumn>
<StyledCell width={BACKGROUND_MOCK_COLUMN_WIDTHS.Name}>
<Chip
- label={company.name}
- size={ChipSize.Small}
- variant={ChipVariant.Transparent}
- accent={ChipAccent.TextPrimary}
- clickable={false}
- leftComponent={
+ size="sm"
+ variant="ghost"
+ color="primary"
+ startElement={
<Avatar
shape="square"
src={getAbsoluteImageUrl(logoUrl)}
@@ -127,23 +120,28 @@ export const BackgroundMockTableRow = ({
size="md"
/>
}
- />
+ style={{ paddingInlineStart: 0 }}
+ >
+ {company.name}
+ </Chip>
</StyledCell>
<StyledCell width={BACKGROUND_MOCK_COLUMN_WIDTHS.Domain}>
<Chip
- label={company.domainName}
- size={ChipSize.Small}
- variant={ChipVariant.Transparent}
- accent={ChipAccent.TextSecondary}
- clickable={false}
- leftComponent={
+ size="sm"
+ variant="ghost"
+ color="secondary"
+ weight="medium"
+ startElement={
<IconLink
size={theme.icon.size.sm}
stroke={theme.icon.stroke.sm}
color={theme.font.color.tertiary}
/>
}
- />
+ style={{ paddingInlineStart: 0 }}
+ >
+ {company.domainName}
+ </Chip>
</StyledCell>
<StyledCell width={BACKGROUND_MOCK_COLUMN_WIDTHS['Created by']}>
<PersonChip fullName={company.createdBy} />
diff --git a/packages/twenty-front/src/modules/skill-suggestion/components/SkillReferenceChip.tsx b/packages/twenty-front/src/modules/skill-suggestion/components/SkillReferenceChip.tsx
index 1c48414aa5a..c5bd79437ae 100644
--- a/packages/twenty-front/src/modules/skill-suggestion/components/SkillReferenceChip.tsx
+++ b/packages/twenty-front/src/modules/skill-suggestion/components/SkillReferenceChip.tsx
@@ -1,6 +1,6 @@
import { SettingsPath } from 'twenty-shared/types';
import { getSettingsPath } from 'twenty-shared/utils';
-import { ChipVariant, LinkChip } from 'twenty-ui/data-display';
+import { LinkChip } from 'twenty-ui/data-display';
import { useIcons } from 'twenty-ui/icon';
import { useTheme } from 'twenty-ui/theme-constants';
@@ -23,12 +23,13 @@ export const SkillReferenceChip = ({
return (
<LinkChip
- label={label}
to={getSettingsPath(SettingsPath.AiSkillDetail, { skillId })}
- variant={ChipVariant.Highlighted}
- leftComponent={
+ variant="soft"
+ startElement={
<Icon size={theme.icon.size.sm} stroke={theme.icon.stroke.sm} />
}
- />
+ >
+ {label}
+ </LinkChip>
);
};
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/ActorDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/ActorDisplay.tsx
index 8b4c1f4d760..543db59223a 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/ActorDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/ActorDisplay.tsx
@@ -2,7 +2,7 @@ import { type FieldActorValue } from '@/object-record/record-field/ui/types/Fiel
import { t } from '@lingui/core/macro';
import { ConnectedAccountProvider } from 'twenty-shared/types';
-import { AvatarOrIcon, Chip, ChipVariant } from 'twenty-ui/data-display';
+import { AvatarOrIcon, Chip } from 'twenty-ui/data-display';
import {
IconApi,
IconCalendar,
@@ -87,11 +87,9 @@ export const ActorDisplay = ({
return (
<Chip
- label={name ?? ''}
- clickable={false}
emptyLabel={t`Untitled`}
- variant={ChipVariant.Transparent}
- leftComponent={
+ variant="ghost"
+ startElement={
<AvatarOrIcon
colorSeed={workspaceMemberId ?? undefined}
shape={workspaceMemberId ? 'circle' : 'square'}
@@ -100,6 +98,9 @@ export const ActorDisplay = ({
src={getAbsoluteImageUrl(avatarUrl ?? undefined)}
/>
}
- />
+ style={{ paddingInlineStart: 0 }}
+ >
+ {name ?? ''}
+ </Chip>
);
};
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/ArrayDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/ArrayDisplay.tsx
index faa6cac280f..7d159ceb6ab 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/ArrayDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/ArrayDisplay.tsx
@@ -1,7 +1,7 @@
import { type FieldArrayValue } from '@/object-record/record-field/ui/types/FieldMetadata';
import { ExpandableList } from '@/ui/layout/expandable-list/components/ExpandableList';
import { t } from '@lingui/core/macro';
-import { Chip, ChipVariant } from 'twenty-ui/data-display';
+import { Chip } from 'twenty-ui/data-display';
type ArrayDisplayProps = {
value: FieldArrayValue;
@@ -11,12 +11,9 @@ export const ArrayDisplay = ({ value }: ArrayDisplayProps) => {
return (
<ExpandableList>
{value?.map((item, index) => (
- <Chip
- key={`${item}-${index}`}
- variant={ChipVariant.Highlighted}
- label={item}
- emptyLabel={t`Untitled`}
- />
+ <Chip key={`${item}-${index}`} variant="soft" emptyLabel={t`Untitled`}>
+ {item}
+ </Chip>
))}
</ExpandableList>
);
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/FileChip.tsx b/packages/twenty-front/src/modules/ui/field/display/components/FileChip.tsx
index 1a10d82f1da..6089e6d6be8 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/FileChip.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/FileChip.tsx
@@ -5,7 +5,7 @@ import { isNonEmptyString } from '@sniptt/guards';
import { FileIcon } from '@/file/components/FileIcon';
import { type FieldFilesValue } from '@/object-record/record-field/ui/types/FieldMetadata';
import { getFileCategoryFromExtension } from '@/object-record/record-field/ui/utils/getFileCategoryFromExtension';
-import { Chip, ChipVariant } from 'twenty-ui/data-display';
+import { Chip } from 'twenty-ui/data-display';
const MAX_WIDTH = 120;
@@ -49,23 +49,24 @@ export const FileChip = ({
onMouseDown={handleMouseDown}
>
<Chip
- label={label}
alwaysShowTooltip={isDeleted}
tooltipLabel={
isDeleted ? t`File no longer exists - ${label}` : undefined
}
disabled={isDeleted}
maxWidth={MAX_WIDTH}
- leftComponent={
+ startElement={
<FileIcon
fileCategory={fileCategory}
size="small"
thumbnailUrl={isDeleted ? undefined : file.url}
/>
}
- variant={isDeleted ? ChipVariant.Static : ChipVariant.Highlighted}
+ variant="soft"
clickable={isClickable}
- />
+ >
+ {label}
+ </Chip>
</StyledClickableContainer>
);
};
diff --git a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableList.tsx b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableList.tsx
index 1a00601795f..aabd7449c2c 100644
--- a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableList.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/ExpandableList.tsx
@@ -11,7 +11,6 @@ import { ExpandableListResizeEffect } from '@/ui/layout/expandable-list/componen
import { ExpandedListDropdown } from '@/ui/layout/expandable-list/components/ExpandedListDropdown';
import { isFirstOverflowingChildElement } from '@/ui/layout/expandable-list/utils/isFirstOverflowingChildElement';
import { isDefined } from 'twenty-shared/utils';
-import { ChipSize } from 'twenty-ui/data-display';
import { AnimatedContainer } from 'twenty-ui/layout';
import { OverflowingTextWithTooltip } from 'twenty-ui/surfaces';
import { themeCssVariables } from 'twenty-ui/theme-constants';
@@ -180,7 +179,7 @@ export const ExpandableList = ({
<StyledUnShrinkableContainer onClick={handleChipCountClick}>
<OverflowingTextWithTooltip
text={`+${hiddenChildrenCount}`}
- size={ChipSize.Small}
+ size="small"
/>
</StyledUnShrinkableContainer>
</AnimatedContainer>
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationGeneralInfo.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationGeneralInfo.tsx
index c0629a2c751..efdffa76de3 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationGeneralInfo.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationGeneralInfo.tsx
@@ -23,13 +23,7 @@ import { isNonEmptyString } from '@sniptt/guards';
import { styled } from '@linaria/react';
import { themeCssVariables } from 'twenty-ui/theme-constants';
import { useQuery } from '@apollo/client/react';
-import {
- AvatarOrIcon,
- Chip,
- ChipSize,
- ChipVariant,
- Tag,
-} from 'twenty-ui/data-display';
+import { AvatarOrIcon, Chip, Tag } from 'twenty-ui/data-display';
import { getSettingsPath, isDefined } from 'twenty-shared/utils';
import { Section } from 'twenty-ui/layout';
import { SettingsPath } from 'twenty-shared/types';
@@ -114,17 +108,17 @@ export const SettingsApplicationRegistrationGeneralInfo = ({
label: t`Owner`,
value: isDefined(ownerWorkspace?.displayName) ? (
<Chip
- size={ChipSize.Large}
- variant={ChipVariant.Highlighted}
- clickable={false}
- leftComponent={
+ size="md"
+ variant="soft"
+ startElement={
<AvatarOrIcon
shape="circle"
src={getAbsoluteImageUrl(ownerWorkspace?.logo ?? undefined)}
/>
}
- label={ownerWorkspace.displayName}
- />
+ >
+ {ownerWorkspace.displayName}
+ </Chip>
) : (
<Tag color="orange">{t`Unclaimed`}</Tag>
),
diff --git a/packages/twenty-ui/src/data-display/Chip/Chip.module.scss b/packages/twenty-ui/src/data-display/Chip/Chip.module.scss
index b8f5e31529b..2ac6653ab7e 100644
--- a/packages/twenty-ui/src/data-display/Chip/Chip.module.scss
+++ b/packages/twenty-ui/src/data-display/Chip/Chip.module.scss
@@ -1,115 +1,83 @@
.chip {
- --chip-horizontal-padding: var(--t-spacing-1);
- --chip-vertical-padding: var(--t-spacing-1);
+ @include focus-ring;
- // Height and max-width are sized against the content box.
+ --tw-chip-padding: var(--t-spacing-1);
box-sizing: content-box;
- text-decoration: none;
align-items: center;
- cursor: inherit;
display: inline-flex;
- justify-content: flex-start;
gap: var(--t-spacing-1);
- max-width: 100%;
+ block-size: var(--t-spacing-3);
+ max-inline-size: var(--tw-chip-max-width, 100%);
overflow: hidden;
- padding: var(--chip-vertical-padding) var(--chip-horizontal-padding);
+ padding: var(--t-spacing-1) var(--tw-chip-padding);
user-select: none;
- font-weight: inherit;
- background-color: inherit;
+ font: inherit;
+ color: var(--t-font-color-primary);
+ background: inherit;
border: none;
border-radius: var(--t-border-radius-sm-round);
corner-shape: round;
+ text-decoration: none;
& > svg {
flex-shrink: 0;
}
-}
-
-.sizeLarge {
- height: var(--t-spacing-4);
-}
-
-.sizeSmall {
- height: var(--t-spacing-3);
-}
-
-.accentTextPrimary {
- color: var(--t-font-color-primary);
-}
-
-.accentTextSecondary {
- color: var(--t-font-color-secondary);
-}
-
-// Disabled color wins over accent colors, matching the Linaria ternary order.
-.disabled {
- color: var(--t-font-color-light);
-}
-
-.fontMedium {
- font-weight: var(--t-font-weight-medium);
-}
-
-.cursorPointer {
- cursor: pointer;
-}
-
-.cursorNotAllowed {
- cursor: not-allowed;
-}
-
-.backgroundHighlighted {
- background-color: var(--t-background-transparent-light);
-
- @include hover-capable {
- &:hover {
- background-color: var(--t-background-transparent-medium);
- }
+ &[data-size='md'] {
+ block-size: var(--t-spacing-4);
}
-
- &:active {
- background-color: var(--t-background-transparent-strong);
+ &[data-shape='round'] {
+ border-radius: var(--t-border-radius-pill);
}
-}
-
-.backgroundStatic {
- background-color: var(--t-background-transparent-light);
-
- &:hover {
- background-color: var(--t-background-transparent-light);
+ &[data-color='secondary'] {
+ color: var(--t-font-color-secondary);
}
-
- &:active {
- background-color: var(--t-background-transparent-light);
+ &[data-weight='medium'] {
+ font-weight: var(--t-font-weight-medium);
}
-}
-
-// Applied only when variant is regular, clickable and not disabled.
-.interactiveRegular {
- @include hover-capable {
- &:hover {
- background-color: var(--t-background-transparent-light);
- }
+ &[data-variant='soft'] {
+ background: var(--t-background-transparent-light);
}
-
- &:active {
- background-color: var(--t-background-transparent-medium);
+ &[data-variant='solid'] {
+ background: var(--t-background-transparent-medium);
+ }
+ &[data-disabled] {
+ color: var(--t-font-color-light);
+ cursor: not-allowed;
+ }
+ &[data-clickable]:not([data-disabled]) {
+ cursor: pointer;
+ @include hover-capable {
+ &:hover {
+ background: var(--t-background-transparent-light);
+ }
+ &[data-variant='soft']:hover {
+ background: var(--t-background-transparent-medium);
+ }
+ &[data-variant='solid']:hover {
+ background: var(--t-background-transparent-strong);
+ }
+ }
+ &:active {
+ background: var(--t-background-transparent-medium);
+ }
+ &[data-variant='soft']:active {
+ background: var(--t-background-transparent-strong);
+ }
+ &[data-variant='solid']:active {
+ background: var(--t-color-transparent-gray8);
+ }
}
}
-.hasMaxWidth {
- max-width: calc(var(--chip-max-width) - 2 * var(--chip-horizontal-padding));
-}
-
-.paddingLeftNone {
- padding-left: var(--t-spacing-0);
+.content {
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
}
-
.emptyLabel {
color: var(--t-font-color-tertiary);
}
-
-.rightComponentDivider {
+.endElementDivider {
align-self: stretch;
- border-left: 1px solid var(--t-border-color-light);
+ border-inline-start: 1px solid var(--t-border-color-light);
}
diff --git a/packages/twenty-ui/src/data-display/Chip/Chip.module.scss.d.ts b/packages/twenty-ui/src/data-display/Chip/Chip.module.scss.d.ts
index eb38f2abac1..de9148e2417 100644
--- a/packages/twenty-ui/src/data-display/Chip/Chip.module.scss.d.ts
+++ b/packages/twenty-ui/src/data-display/Chip/Chip.module.scss.d.ts
@@ -1,19 +1,7 @@
declare const classNames: {
readonly chip: 'chip';
- readonly sizeLarge: 'sizeLarge';
- readonly sizeSmall: 'sizeSmall';
- readonly accentTextPrimary: 'accentTextPrimary';
- readonly accentTextSecondary: 'accentTextSecondary';
- readonly disabled: 'disabled';
- readonly fontMedium: 'fontMedium';
- readonly cursorPointer: 'cursorPointer';
- readonly cursorNotAllowed: 'cursorNotAllowed';
- readonly backgroundHighlighted: 'backgroundHighlighted';
- readonly backgroundStatic: 'backgroundStatic';
- readonly interactiveRegular: 'interactiveRegular';
- readonly hasMaxWidth: 'hasMaxWidth';
- readonly paddingLeftNone: 'paddingLeftNone';
+ readonly content: 'content';
readonly emptyLabel: 'emptyLabel';
- readonly rightComponentDivider: 'rightComponentDivider';
+ readonly endElementDivider: 'endElementDivider';
};
export default classNames;
diff --git a/packages/twenty-ui/src/data-display/Chip/Chip.tsx b/packages/twenty-ui/src/data-display/Chip/Chip.tsx
index bd57beb3407..45a70265272 100644
--- a/packages/twenty-ui/src/data-display/Chip/Chip.tsx
+++ b/packages/twenty-ui/src/data-display/Chip/Chip.tsx
@@ -1,153 +1,99 @@
-import { type ReactNode } from 'react';
+import { Button as ButtonPrimitive } from '@base-ui/react/button';
+import { useRender } from '@base-ui/react/use-render';
+import { clsx } from 'clsx';
+import { type CSSProperties } from 'react';
-import { isNonEmptyString } from '@sniptt/guards';
-import { type TooltipPosition } from '@ui/surfaces/AppTooltip/AppTooltip';
import { OverflowingTextWithTooltip } from '@ui/surfaces/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
-import { clsx } from 'clsx';
import { isDefined } from '@ui/utilities/utils/isDefined';
import styles from './Chip.module.scss';
-
-export enum ChipSize {
- Large = 'large',
- Small = 'small',
-}
-
-export enum ChipAccent {
- TextPrimary = 'text-primary',
- TextSecondary = 'text-secondary',
-}
-
-export enum ChipVariant {
- Highlighted = 'highlighted',
- Regular = 'regular',
- Transparent = 'transparent',
- Rounded = 'rounded',
- Static = 'static',
-}
-
-export type ChipProps = {
- size?: ChipSize;
- disabled?: boolean;
- clickable?: boolean;
- label: string;
- tooltipLabel?: string;
- tooltipPlace?: TooltipPosition;
- alwaysShowTooltip?: boolean;
- isLabelHidden?: boolean;
- isBold?: boolean;
- maxWidth?: number;
- variant?: ChipVariant;
- accent?: ChipAccent;
- leftComponent?: ReactNode | null;
- rightComponent?: (() => ReactNode) | ReactNode | null;
- rightComponentDivider?: boolean;
- className?: string;
- forceEmptyText?: boolean;
- emptyLabel?: string;
-};
-
-const renderRightComponent = (
- rightComponent: (() => ReactNode) | ReactNode | null,
- rightComponentDivider?: boolean,
-) => {
- if (!rightComponent) {
- return null;
- }
-
- const rendered =
- typeof rightComponent === 'function' ? rightComponent() : rightComponent;
-
- if (rightComponentDivider === true) {
- return (
- <>
- <div className={styles.rightComponentDivider} />
- {rendered}
- </>
- );
- }
-
- return rendered;
-};
+import { type ChipProps } from './types/ChipProps';
export const Chip = ({
- size = ChipSize.Small,
- label,
+ children,
+ size = 'sm',
+ variant = 'ghost',
+ color = 'primary',
+ shape = 'square',
+ weight = 'regular',
+ disabled = false,
+ onClick,
+ clickable = isDefined(onClick),
+ nativeButton = true,
+ startElement,
+ endElement,
+ endElementDivider = false,
+ maxWidth,
tooltipLabel,
tooltipPlace,
alwaysShowTooltip = false,
isLabelHidden = false,
- isBold = false,
- disabled = false,
- clickable = true,
- variant = ChipVariant.Regular,
- leftComponent = null,
- rightComponent = null,
- rightComponentDivider = false,
- accent = ChipAccent.TextPrimary,
- className,
- maxWidth,
forceEmptyText = false,
emptyLabel = 'Untitled',
+ className,
+ style,
+ render,
+ ref,
+ ...props
}: ChipProps) => {
- // Cursor precedence mirrors the Linaria ternary:
- // transparent > clickable > disabled > inherit.
- const cursorClass =
- variant === ChipVariant.Transparent
- ? undefined
- : clickable
- ? styles.cursorPointer
- : disabled
- ? styles.cursorNotAllowed
- : undefined;
-
- const backgroundClass =
- variant === ChipVariant.Highlighted
- ? styles.backgroundHighlighted
- : variant === ChipVariant.Static
- ? styles.backgroundStatic
- : variant === ChipVariant.Regular && !disabled && clickable
- ? styles.interactiveRegular
- : undefined;
+ const hasContent =
+ isDefined(children) && children !== '' && children !== false;
- return (
- <div
- data-testid="chip"
- className={clsx(
- styles.chip,
- size === ChipSize.Large ? styles.sizeLarge : styles.sizeSmall,
- accent === ChipAccent.TextPrimary
- ? styles.accentTextPrimary
- : styles.accentTextSecondary,
- disabled && styles.disabled,
- (isBold || accent === ChipAccent.TextSecondary) && styles.fontMedium,
- cursorClass,
- backgroundClass,
- maxWidth ? styles.hasMaxWidth : undefined,
- variant === ChipVariant.Transparent && styles.paddingLeftNone,
- className,
- )}
- style={
- maxWidth
- ? ({ '--chip-max-width': `${maxWidth}px` } as React.CSSProperties)
- : undefined
- }
- >
- {leftComponent}
- {!isLabelHidden && isDefined(label) && isNonEmptyString(label) ? (
- <OverflowingTextWithTooltip
- size={size}
- text={label}
- tooltipContent={tooltipLabel}
- tooltipPlace={tooltipPlace}
- alwaysShowTooltip={alwaysShowTooltip}
- />
- ) : !forceEmptyText && !isLabelHidden ? (
- <div className={styles.emptyLabel}>{emptyLabel}</div>
- ) : (
- ''
- )}
- {renderRightComponent(rightComponent, rightComponentDivider)}
- </div>
- );
+ return useRender({
+ render: isDefined(onClick) ? (
+ <ButtonPrimitive
+ render={render}
+ disabled={disabled}
+ nativeButton={nativeButton}
+ />
+ ) : (
+ render
+ ),
+ ref,
+ state: { size, variant, color, shape, weight, disabled, clickable },
+ props: {
+ ...props,
+ onClick,
+ className: clsx(styles.chip, className),
+ style: {
+ ...(isDefined(maxWidth)
+ ? {
+ '--tw-chip-max-width': `calc(${maxWidth}px - 2 * var(--tw-chip-padding))`,
+ }
+ : {}),
+ ...style,
+ } as CSSProperties,
+ children: (
+ <>
+ {startElement}
+ {!isLabelHidden &&
+ (hasContent ? (
+ typeof children === 'string' ? (
+ <OverflowingTextWithTooltip
+ size={size === 'md' ? 'large' : 'small'}
+ text={children}
+ tooltipContent={tooltipLabel}
+ tooltipPlace={tooltipPlace}
+ alwaysShowTooltip={alwaysShowTooltip}
+ />
+ ) : (
+ <span className={styles.content}>{children}</span>
+ )
+ ) : (
+ !forceEmptyText && (
+ <span className={styles.emptyLabel}>{emptyLabel}</span>
+ )
+ ))}
+ {isDefined(endElement) && endElement !== false && (
+ <>
+ {endElementDivider && (
+ <span className={styles.endElementDivider} />
+ )}
+ {endElement}
+ </>
+ )}
+ </>
+ ),
+ },
+ });
};
diff --git a/packages/twenty-ui/src/data-display/Chip/__stories__/Chip.stories.tsx b/packages/twenty-ui/src/data-display/Chip/__stories__/Chip.stories.tsx
index cdef920cc32..474cb80b6d5 100644
--- a/packages/twenty-ui/src/data-display/Chip/__stories__/Chip.stories.tsx
+++ b/packages/twenty-ui/src/data-display/Chip/__stories__/Chip.stories.tsx
@@ -1,3 +1,4 @@
+import { expect, fn, userEvent, within } from 'storybook/test';
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { IconUser, IconX } from '@ui/icon';
import { Avatar } from '@ui/data-display/Avatar/Avatar';
@@ -9,12 +10,9 @@ import {
ComponentDecorator,
} from '@ui/testing';
-import {
- Chip,
- ChipAccent,
- ChipSize,
- ChipVariant,
-} from '@ui/data-display/Chip/Chip';
+import { Chip } from '@ui/data-display/Chip/Chip';
+import { type ChipSize } from '@ui/data-display/Chip/types/ChipSize';
+import { type ChipVariant } from '@ui/data-display/Chip/types/ChipVariant';
const meta: Meta<typeof Chip> = {
title: 'UI/Data Display/Chip',
@@ -26,23 +24,29 @@ type Story = StoryObj<typeof Chip>;
export const Default: Story = {
args: {
- label: 'Chip test',
- size: ChipSize.Small,
- variant: ChipVariant.Highlighted,
- accent: ChipAccent.TextPrimary,
+ children: 'Chip test',
+ size: 'sm',
+ variant: 'soft',
+ color: 'primary',
disabled: false,
- clickable: true,
maxWidth: 200,
},
decorators: [ComponentDecorator],
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();
+ await expect(
+ getComputedStyle(canvas.getByText('Chip test')).cursor,
+ ).not.toBe('pointer');
+ },
};
export const WithLeftAvatar: Story = {
args: {
- label: 'John Doe',
+ children: 'John Doe',
clickable: true,
- variant: ChipVariant.Regular,
- leftComponent: (
+ variant: 'ghost',
+ startElement: (
<Avatar name="JD" colorSeed="John Doe" size="sm" shape="circle" />
),
},
@@ -51,10 +55,10 @@ export const WithLeftAvatar: Story = {
export const WithLeftIcon: Story = {
args: {
- label: 'Company',
+ children: 'Company',
clickable: true,
- variant: ChipVariant.Regular,
- leftComponent: <IconUser size={14} />,
+ variant: 'ghost',
+ startElement: <IconUser size={14} />,
},
decorators: [ComponentDecorator],
};
@@ -62,38 +66,39 @@ export const WithLeftIcon: Story = {
export const EmptyLabel: Story = {
parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
args: {
- label: '',
+ children: '',
clickable: true,
- variant: ChipVariant.Regular,
- leftComponent: <Avatar name="?" colorSeed="empty" size="sm" />,
+ variant: 'ghost',
+ startElement: <Avatar name="?" colorSeed="empty" size="sm" />,
},
decorators: [ComponentDecorator],
};
export const Catalog: CatalogStory<Story, typeof Chip> = {
- args: { clickable: true, label: 'Hello' },
+ args: { clickable: true, children: 'Hello' },
argTypes: {
size: { control: false },
variant: { control: false },
- accent: { control: false },
+ color: { control: false },
disabled: { control: false },
className: { control: false },
- rightComponent: { control: false },
- leftComponent: { control: false },
+ endElement: { control: false },
+ startElement: { control: false },
},
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
pseudo: { hover: ['.hover'], active: ['.active'] },
catalog: {
+ options: { elementContainer: { style: { width: 110 } } },
dimensions: [
{
name: 'variants',
- values: Object.values(ChipVariant),
+ values: ['ghost', 'soft', 'solid'],
props: (variant: ChipVariant) => ({ variant }),
},
{
name: 'sizes',
- values: Object.values(ChipSize),
+ values: ['sm', 'md'],
props: (size: ChipSize) => ({ size }),
},
{
@@ -111,11 +116,6 @@ export const Catalog: CatalogStory<Story, typeof Chip> = {
}
},
},
- {
- name: 'accents',
- values: Object.values(ChipAccent),
- props: (accent: ChipAccent) => ({ accent }),
- },
],
},
},
@@ -125,33 +125,34 @@ export const Catalog: CatalogStory<Story, typeof Chip> = {
export const WithAvatarCatalog: CatalogStory<Story, typeof Chip> = {
args: {
clickable: true,
- label: 'John Doe',
- leftComponent: (
+ children: 'John Doe',
+ startElement: (
<Avatar name="JD" colorSeed="John Doe" size="sm" shape="circle" />
),
},
argTypes: {
size: { control: false },
variant: { control: false },
- accent: { control: false },
+ color: { control: false },
disabled: { control: false },
className: { control: false },
- rightComponent: { control: false },
- leftComponent: { control: false },
+ endElement: { control: false },
+ startElement: { control: false },
},
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
pseudo: { hover: ['.hover'], active: ['.active'] },
catalog: {
+ options: { elementContainer: { style: { width: 110 } } },
dimensions: [
{
name: 'variants',
- values: Object.values(ChipVariant),
+ values: ['ghost', 'soft', 'solid'],
props: (variant: ChipVariant) => ({ variant }),
},
{
name: 'sizes',
- values: Object.values(ChipSize),
+ values: ['sm', 'md'],
props: (size: ChipSize) => ({ size }),
},
{
@@ -177,14 +178,70 @@ export const WithAvatarCatalog: CatalogStory<Story, typeof Chip> = {
export const WithRightComponentDivider: Story = {
args: {
- label: 'document.pdf',
- variant: ChipVariant.Static,
- clickable: false,
- leftComponent: (
+ children: 'document.pdf',
+ variant: 'soft',
+ startElement: (
<Avatar name="D" colorSeed="document" size="sm" shape="square" />
),
- rightComponent: <IconX size={14} />,
- rightComponentDivider: true,
+ endElement: <IconX size={14} />,
+ endElementDivider: true,
+ },
+ decorators: [ComponentDecorator],
+};
+
+export const CatalogDark: typeof Catalog = {
+ ...Catalog,
+ tags: ['!autodocs'],
+ globals: { colorScheme: 'dark' },
+};
+
+export const PointerAndKeyboard: Story = {
+ decorators: [ComponentDecorator],
+ args: { children: 'Open details', onClick: fn() },
+ play: async ({ canvasElement, args }) => {
+ const control = within(canvasElement).getByRole('button', {
+ name: 'Open details',
+ });
+ await expect(getComputedStyle(control).cursor).toBe('pointer');
+ await userEvent.click(control);
+ await userEvent.keyboard('{Enter}');
+ await userEvent.keyboard(' ');
+ await expect(args.onClick).toHaveBeenCalledTimes(3);
+ await expect(control).toHaveFocus();
+ await expect(args.onClick).toHaveBeenLastCalledWith(
+ expect.objectContaining({ type: 'click' }),
+ );
},
+};
+
+export const Disabled: Story = {
decorators: [ComponentDecorator],
+ args: { children: 'Unavailable', disabled: true, onClick: fn() },
+ play: async ({ canvasElement, args }) => {
+ const control = within(canvasElement).getByRole('button', {
+ name: 'Unavailable',
+ });
+ await expect(control).toBeDisabled();
+ await userEvent.click(control);
+ await expect(args.onClick).not.toHaveBeenCalled();
+ },
+};
+
+export const ContentAndSlots: Story = {
+ decorators: [ComponentDecorator],
+ args: {
+ children: <strong>Rich content</strong>,
+ startElement: <IconUser />,
+ endElement: (
+ <button type="button" onClick={fn()}>
+ Remove
+ </button>
+ ),
+ endElementDivider: true,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(canvas.getByText('Rich content')).toBeVisible();
+ await userEvent.click(canvas.getByRole('button', { name: 'Remove' }));
+ },
};
diff --git a/packages/twenty-ui/src/data-display/Chip/__tests__/Chip.test.tsx b/packages/twenty-ui/src/data-display/Chip/__tests__/Chip.test.tsx
new file mode 100644
index 00000000000..a189987f8d5
--- /dev/null
+++ b/packages/twenty-ui/src/data-display/Chip/__tests__/Chip.test.tsx
@@ -0,0 +1,11 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+
+import { Chip } from '../Chip';
+import styles from '../Chip.module.scss';
+
+runComponentConformance({
+ name: 'Chip',
+ element: <Chip>Label</Chip>,
+ ownClassName: styles.chip,
+ refInstanceOf: HTMLDivElement,
+});
diff --git a/packages/twenty-ui/src/data-display/Chip/types/ChipProps.ts b/packages/twenty-ui/src/data-display/Chip/types/ChipProps.ts
new file mode 100644
index 00000000000..ca71bfd8b39
--- /dev/null
+++ b/packages/twenty-ui/src/data-display/Chip/types/ChipProps.ts
@@ -0,0 +1,28 @@
+import { type useRender } from '@base-ui/react/use-render';
+import { type ReactNode } from 'react';
+
+import { type TooltipPosition } from '@ui/surfaces/AppTooltip/AppTooltip';
+
+import { type ChipSize } from './ChipSize';
+import { type ChipVariant } from './ChipVariant';
+
+export type ChipProps = Omit<useRender.ComponentProps<'div'>, 'color'> & {
+ size?: ChipSize;
+ variant?: ChipVariant;
+ color?: 'primary' | 'secondary';
+ shape?: 'square' | 'round';
+ weight?: 'regular' | 'medium';
+ disabled?: boolean;
+ clickable?: boolean;
+ nativeButton?: boolean;
+ startElement?: ReactNode;
+ endElement?: ReactNode;
+ endElementDivider?: boolean;
+ maxWidth?: number;
+ tooltipLabel?: string;
+ tooltipPlace?: TooltipPosition;
+ alwaysShowTooltip?: boolean;
+ isLabelHidden?: boolean;
+ forceEmptyText?: boolean;
+ emptyLabel?: string;
+};
diff --git a/packages/twenty-ui/src/data-display/Chip/types/ChipSize.ts b/packages/twenty-ui/src/data-display/Chip/types/ChipSize.ts
new file mode 100644
index 00000000000..e5d527d2395
--- /dev/null
+++ b/packages/twenty-ui/src/data-display/Chip/types/ChipSize.ts
@@ -0,0 +1 @@
+export type ChipSize = 'sm' | 'md';
diff --git a/packages/twenty-ui/src/data-display/Chip/types/ChipVariant.ts b/packages/twenty-ui/src/data-display/Chip/types/ChipVariant.ts
new file mode 100644
index 00000000000..3ff90b789c4
--- /dev/null
+++ b/packages/twenty-ui/src/data-display/Chip/types/ChipVariant.ts
@@ -0,0 +1 @@
+export type ChipVariant = 'solid' | 'soft' | 'ghost';
diff --git a/packages/twenty-ui/src/data-display/LinkChip/LinkChip.tsx b/packages/twenty-ui/src/data-display/LinkChip/LinkChip.tsx
index 92a7a67675a..6c6d8ea009a 100644
--- a/packages/twenty-ui/src/data-display/LinkChip/LinkChip.tsx
+++ b/packages/twenty-ui/src/data-display/LinkChip/LinkChip.tsx
@@ -1,87 +1,56 @@
-import {
- Chip,
- ChipAccent,
- type ChipProps,
- ChipSize,
- ChipVariant,
-} from '@ui/data-display/Chip/Chip';
+import { type ComponentPropsWithRef, type MouseEvent } from 'react';
+import { Link } from 'react-router-dom';
+
+import { Chip } from '@ui/data-display/Chip/Chip';
+import { type ChipProps } from '@ui/data-display/Chip/types/ChipProps';
import { LINK_CHIP_CLICK_OUTSIDE_ID } from '@ui/data-display/Chip/constants/LinkChipClickOutsideId';
import { type TriggerEventType, useMouseDownNavigation } from '@ui/utilities';
-import { type MouseEvent } from 'react';
-import { Link } from 'react-router-dom';
import styles from './LinkChip.module.scss';
export type LinkChipProps = Omit<
ChipProps,
- 'onClick' | 'disabled' | 'clickable'
-> & {
- to: string;
- onClick?: (event: MouseEvent<HTMLElement>) => void;
- onMouseDown?: (event: MouseEvent<HTMLElement>) => void;
- triggerEvent?: TriggerEventType;
- target?: '_blank' | '_self';
-};
+ 'render' | 'ref' | 'onClick' | 'onMouseDown' | 'disabled' | 'nativeButton'
+> &
+ Pick<ComponentPropsWithRef<typeof Link>, 'target' | 'ref'> & {
+ to: string;
+ onClick?: (event: MouseEvent<HTMLElement>) => void;
+ onMouseDown?: (event: MouseEvent<HTMLElement>) => void;
+ triggerEvent?: TriggerEventType;
+ };
export const LinkChip = ({
to,
- size = ChipSize.Small,
- label,
- tooltipLabel,
- tooltipPlace,
- alwaysShowTooltip,
- isLabelHidden = false,
- isBold = false,
- variant = ChipVariant.Regular,
- leftComponent = null,
- rightComponent = null,
- rightComponentDivider = false,
- accent = ChipAccent.TextPrimary,
- className,
- maxWidth,
+ target,
onClick,
+ onMouseDown,
triggerEvent,
- target,
- emptyLabel,
+ ref,
+ ...props
}: LinkChipProps) => {
const { onClick: onClickHandler, onMouseDown: onMouseDownHandler } =
- useMouseDownNavigation({
- to: to,
- onClick: onClick,
- triggerEvent,
- });
+ useMouseDownNavigation({ to, onClick, triggerEvent });
return (
<span className={styles.linkContainer}>
<Link
to={to}
+ ref={ref}
onClick={(event) => {
event.stopPropagation();
onClickHandler(event);
}}
- onMouseDown={onMouseDownHandler}
+ onMouseDown={(event) => {
+ onMouseDown?.(event);
+ if (!event.defaultPrevented) {
+ onMouseDownHandler(event);
+ }
+ }}
data-click-outside-id={LINK_CHIP_CLICK_OUTSIDE_ID}
target={target}
rel={target === '_blank' ? 'noopener noreferrer' : undefined}
>
- <Chip
- size={size}
- label={label}
- tooltipLabel={tooltipLabel}
- tooltipPlace={tooltipPlace}
- alwaysShowTooltip={alwaysShowTooltip}
- isLabelHidden={isLabelHidden}
- isBold={isBold}
- clickable={true}
- variant={variant}
- leftComponent={leftComponent}
- rightComponent={rightComponent}
- rightComponentDivider={rightComponentDivider}
- accent={accent}
- className={className}
- maxWidth={maxWidth}
- emptyLabel={emptyLabel}
- />
+ <Chip clickable {...props} />
</Link>
</span>
);
diff --git a/packages/twenty-ui/src/data-display/LinkChip/__stories__/LinkChip.stories.tsx b/packages/twenty-ui/src/data-display/LinkChip/__stories__/LinkChip.stories.tsx
index d9431cdeaac..748f746f961 100644
--- a/packages/twenty-ui/src/data-display/LinkChip/__stories__/LinkChip.stories.tsx
+++ b/packages/twenty-ui/src/data-display/LinkChip/__stories__/LinkChip.stories.tsx
@@ -9,7 +9,8 @@ import {
} from '@ui/testing';
import { MemoryRouter } from 'react-router-dom';
-import { ChipAccent, ChipSize, ChipVariant } from '@ui/data-display/Chip/Chip';
+import { type ChipSize } from '@ui/data-display/Chip/types/ChipSize';
+import { type ChipVariant } from '@ui/data-display/Chip/types/ChipVariant';
import { LinkChip } from '@ui/data-display/LinkChip/LinkChip';
const meta: Meta<typeof LinkChip> = {
@@ -29,21 +30,21 @@ type Story = StoryObj<typeof LinkChip>;
export const Default: Story = {
args: {
- label: 'Link Chip',
+ children: 'Link Chip',
to: '/example',
- size: ChipSize.Small,
- variant: ChipVariant.Regular,
- accent: ChipAccent.TextPrimary,
+ size: 'sm',
+ variant: 'ghost',
+ color: 'primary',
},
decorators: [ComponentDecorator],
};
export const WithAvatar: Story = {
args: {
- label: 'John Doe',
+ children: 'John Doe',
to: '/users/john-doe',
- variant: ChipVariant.Regular,
- leftComponent: (
+ variant: 'ghost',
+ startElement: (
<Avatar name="JD" colorSeed="John Doe" size="sm" shape="circle" />
),
},
@@ -52,23 +53,23 @@ export const WithAvatar: Story = {
export const WithIcon: Story = {
args: {
- label: 'Company',
+ children: 'Company',
to: '/companies/1',
- variant: ChipVariant.Regular,
- leftComponent: <IconUser size={14} />,
+ variant: 'ghost',
+ startElement: <IconUser size={14} />,
},
decorators: [ComponentDecorator],
};
export const Catalog: CatalogStory<Story, typeof LinkChip> = {
- args: { label: 'Link Chip', to: '/example' },
+ args: { children: 'Link Chip', to: '/example' },
argTypes: {
size: { control: false },
variant: { control: false },
- accent: { control: false },
+ color: { control: false },
className: { control: false },
- rightComponent: { control: false },
- leftComponent: { control: false },
+ endElement: { control: false },
+ startElement: { control: false },
},
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
@@ -77,12 +78,12 @@ export const Catalog: CatalogStory<Story, typeof LinkChip> = {
dimensions: [
{
name: 'variants',
- values: Object.values(ChipVariant),
+ values: ['ghost', 'soft', 'solid'],
props: (variant: ChipVariant) => ({ variant }),
},
{
name: 'sizes',
- values: Object.values(ChipSize),
+ values: ['sm', 'md'],
props: (size: ChipSize) => ({ size }),
},
{
@@ -98,11 +99,6 @@ export const Catalog: CatalogStory<Story, typeof LinkChip> = {
}
},
},
- {
- name: 'accents',
- values: Object.values(ChipAccent),
- props: (accent: ChipAccent) => ({ accent }),
- },
],
},
},
@@ -111,19 +107,19 @@ export const Catalog: CatalogStory<Story, typeof LinkChip> = {
export const WithAvatarCatalog: CatalogStory<Story, typeof LinkChip> = {
args: {
- label: 'John Doe',
+ children: 'John Doe',
to: '/users/john-doe',
- leftComponent: (
+ startElement: (
<Avatar name="JD" colorSeed="John Doe" size="sm" shape="circle" />
),
},
argTypes: {
size: { control: false },
variant: { control: false },
- accent: { control: false },
+ color: { control: false },
className: { control: false },
- rightComponent: { control: false },
- leftComponent: { control: false },
+ endElement: { control: false },
+ startElement: { control: false },
},
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
@@ -132,12 +128,12 @@ export const WithAvatarCatalog: CatalogStory<Story, typeof LinkChip> = {
dimensions: [
{
name: 'variants',
- values: Object.values(ChipVariant),
+ values: ['ghost', 'soft', 'solid'],
props: (variant: ChipVariant) => ({ variant }),
},
{
name: 'sizes',
- values: Object.values(ChipSize),
+ values: ['sm', 'md'],
props: (size: ChipSize) => ({ size }),
},
{
@@ -161,14 +157,14 @@ export const WithAvatarCatalog: CatalogStory<Story, typeof LinkChip> = {
export const WithRightComponentDivider: Story = {
args: {
- label: 'document.pdf',
+ children: 'document.pdf',
to: '/files/document.pdf',
- variant: ChipVariant.Static,
- leftComponent: (
+ variant: 'soft',
+ startElement: (
<Avatar name="D" colorSeed="document" size="sm" shape="square" />
),
- rightComponent: <IconX size={14} />,
- rightComponentDivider: true,
+ endElement: <IconX size={14} />,
+ endElementDivider: true,
},
decorators: [ComponentDecorator],
};
diff --git a/packages/twenty-ui/src/data-display/index.ts b/packages/twenty-ui/src/data-display/index.ts
index b2b12a10439..28eb091bc0a 100644
--- a/packages/twenty-ui/src/data-display/index.ts
+++ b/packages/twenty-ui/src/data-display/index.ts
@@ -20,9 +20,11 @@ export type { AvatarOrIconProps } from './AvatarOrIcon/types/AvatarOrIconProps';
export { AvatarOrIcon } from './AvatarOrIcon/AvatarOrIcon';
export type { CheckmarkProps } from './Checkmark/Checkmark';
export { Checkmark } from './Checkmark/Checkmark';
-export type { ChipProps } from './Chip/Chip';
-export { ChipSize, ChipAccent, ChipVariant, Chip } from './Chip/Chip';
+export { Chip } from './Chip/Chip';
export { LINK_CHIP_CLICK_OUTSIDE_ID } from './Chip/constants/LinkChipClickOutsideId';
+export type { ChipProps } from './Chip/types/ChipProps';
+export type { ChipSize } from './Chip/types/ChipSize';
+export type { ChipVariant } from './Chip/types/ChipVariant';
export type {
ColorSampleVariant,
ColorSampleProps,