Skip to content

The open alternative to Salesforce, designed for AI.

Migrate Tag to the new twenty-ui API (#25786)

Raphaël Bosib25c8d248dfe
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 019571e0573..a961b9ff4dc 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -13,7 +13,10 @@ import {
sliderTest,
toastTest,
} from '@/__stories__/twenty-ui-gallery/utils/componentInteractionTests';
-import { statusControlsTest } from '@/__stories__/twenty-ui-gallery/utils/displayControlTests';
+import {
+ statusControlsTest,
+ tagControlsTest,
+} from '@/__stories__/twenty-ui-gallery/utils/displayControlTests';
import { createGalleryStory } from '@/__stories__/twenty-ui-gallery/utils/createGalleryStory';
import {
codeEditorTest,
@@ -367,3 +370,15 @@ export const StatusControlsPreact: Story = createGalleryStory({
runtime: 'preact',
play: statusControlsTest,
});
+
+export const TagControlsReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-tag-controls',
+ runtime: 'react',
+ play: tagControlsTest,
+});
+
+export const TagControlsPreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-tag-controls',
+ runtime: 'preact',
+ play: tagControlsTest,
+});
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 0d9f680d422..dd96b4870ff 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
@@ -35,9 +35,15 @@ const TwentyUiComponent = () => {
description="The CRM's own component library with theme-aware styling."
/>
<div style={ROW_STYLE}>
- <Tag color="green" text="Badge" variant="solid" />
- <Tag color="purple" text="Styled" variant="solid" />
- <Tag color="blue" text="Themed" variant="outline" />
+ <Tag color="green" variant="soft">
+ Badge
+ </Tag>
+ <Tag color="purple" variant="soft">
+ Styled
+ </Tag>
+ <Tag color="blue" variant="outline" borderStyle="dashed">
+ Themed
+ </Tag>
</div>
<div style={ROW_STYLE}>
<Status color="green">Online</Status>
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 8a6becb7cc5..c1e245ebf88 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
@@ -93,7 +93,7 @@ const DATA_DISPLAY_ENTRIES: GalleryEntry[] = [
},
{
name: 'Tag',
- node: <Tag color="blue" text="Tag" />,
+ node: <Tag color="blue">Tag</Tag>,
},
{
name: 'TintedIconTile',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx
new file mode 100644
index 00000000000..de7690b5c06
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-tag-controls.front-component.tsx
@@ -0,0 +1,50 @@
+import { useState } from 'react';
+import { defineFrontComponent } from 'twenty-sdk/define';
+import { Tag } 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 TagControls = () => {
+ const [activations, setActivations] = useState(0);
+ const handleClick = () => setActivations((count) => count + 1);
+ return (
+ <ThemeProvider colorScheme="light">
+ <ComponentGallery
+ title="Tag controls"
+ entries={[
+ {
+ name: 'Tag',
+ node: (
+ <>
+ <Tag
+ color="blue"
+ onClick={handleClick}
+ startIcon={<IconStar />}
+ >
+ Open tag
+ </Tag>
+ <Tag color="blue" onClick={handleClick} disabled>
+ Disabled tag
+ </Tag>
+ <Tag color="green" variant="outline">
+ Static tag
+ </Tag>
+ </>
+ ),
+ },
+ ]}
+ />
+ <output aria-label="Activations">{activations}</output>
+ </ThemeProvider>
+ );
+};
+
+export default defineFrontComponent({
+ universalIdentifier: 'ce24297f-b8c4-4e55-85d2-032c21c9b85f',
+ name: 'twenty-ui-tag-controls',
+ description: 'Tag APIs and interactions in the sandbox',
+ component: TagControls,
+});
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 abb9514f04f..1b27b2a47e3 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
@@ -48,3 +48,9 @@ export const statusControlsTest = createDisplayControlTest({
disabledButtonName: 'Disabled status',
staticContent: 'Loading status',
});
+
+export const tagControlsTest = createDisplayControlTest({
+ buttonName: 'Open tag',
+ disabledButtonName: 'Disabled tag',
+ staticContent: 'Static tag',
+});
diff --git a/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx b/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx
index bd9d975b2ca..8503d26e291 100644
--- a/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/components/EmailThreadPreview.tsx
@@ -196,9 +196,7 @@ export const EmailThreadPreview = ({ thread }: EmailThreadPreviewProps) => {
)}
{visibility === MessageChannelVisibility.SHARE_EVERYTHING && (
<>
- {thread.lastMessageIsDraft && (
- <Tag color="orange" text={t`Draft`} />
- )}
+ {thread.lastMessageIsDraft && <Tag color="orange">{t`Draft`}</Tag>}
<StyledSubject>{thread.subject}</StyledSubject>
<StyledBody>{thread.lastMessageBody}</StyledBody>
</>
diff --git a/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx b/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx
index d484869119e..c465ed1cc4f 100644
--- a/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx
+++ b/packages/twenty-front/src/modules/ai/components/CodeExecutionDisplay.tsx
@@ -213,10 +213,11 @@ export const CodeExecutionDisplay = ({
? 'red'
: 'gray'
}
- text={statusText}
weight="medium"
preventShrink
- />
+ >
+ {statusText}
+ </Tag>
</StyledHeaderRight>
</StyledHeader>
diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionsListItem.tsx b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionsListItem.tsx
index dcabe80080c..4e3e456398c 100644
--- a/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionsListItem.tsx
+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/components/CoreWorkflowVersionsListItem.tsx
@@ -70,7 +70,7 @@ export const CoreWorkflowVersionsListItem = ({
day: 'numeric',
})}
</StyledDate>
- <Tag color={tagProps.color} text={t(tagProps.label)} />
+ <Tag color={tagProps.color}>{t(tagProps.label)}</Tag>
</StyledRow>
</SelectableListItem>
);
diff --git a/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionPage.tsx b/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionPage.tsx
index 41b22cb6135..b69949b6b0f 100644
--- a/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionPage.tsx
+++ b/packages/twenty-front/src/modules/object-core/workflows/versions/components/SidePanelCoreWorkflowVersionPage.tsx
@@ -45,7 +45,7 @@ export const SidePanelCoreWorkflowVersionPage = () => {
return (
<StyledContainer>
<StyledActions>
- <Tag color={tagProps.color} text={t(tagProps.label)} />
+ <Tag color={tagProps.color}>{t(tagProps.label)}</Tag>
<StyledSpacer />
<CoreWorkflowVersionRestoreButton
workflowId={coreWorkflowVersion.workspaceWorkflowId}
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MultiSelectFieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MultiSelectFieldDisplay.tsx
index aeebb5ad87f..9bacca7a389 100644
--- a/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MultiSelectFieldDisplay.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/meta-types/display/components/MultiSelectFieldDisplay.tsx
@@ -20,11 +20,9 @@ export const MultiSelectFieldDisplay = () => {
return (
<ExpandableList isChipCountDisplayed={isFocused}>
{selectedOptions.map((selectedOption, index) => (
- <Tag
- key={index}
- color={selectedOption.color}
- text={selectedOption.label}
- />
+ <Tag key={index} color={selectedOption.color}>
+ {selectedOption.label}
+ </Tag>
))}
</ExpandableList>
);
diff --git a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupAggregateDropdownButton.tsx b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupAggregateDropdownButton.tsx
index dc575ed834c..cd8baae1815 100644
--- a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupAggregateDropdownButton.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupAggregateDropdownButton.tsx
@@ -36,11 +36,9 @@ export const RecordGroupAggregateDropdownButton = ({
<StyledHeaderDropdownButton id={dropdownId} isUnfolded={isDropdownOpen}>
<>
<StyledTagContainer>
- <Tag
- text={isDefined(value) ? value.toString() : '-'}
- color="transparent"
- weight="regular"
- />
+ <Tag color="transparent" weight="regular">
+ {isDefined(value) ? value.toString() : '-'}
+ </Tag>
</StyledTagContainer>
{!isDropdownOpen && (
<AppTooltip
diff --git a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupChip.tsx b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupChip.tsx
index b0ace4c1cfc..8c1ca18415e 100644
--- a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupChip.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupChip.tsx
@@ -38,10 +38,12 @@ export const RecordGroupChip = ({
return (
<Tag
- variant={isValueGroup ? 'solid' : 'outline'}
+ variant={isValueGroup ? 'soft' : 'outline'}
+ borderStyle="dashed"
color={isValueGroup ? recordGroupDefinition.color : 'transparent'}
- text={recordGroupDefinition.title}
weight={isValueGroup ? valueTagWeight : 'medium'}
- />
+ >
+ {recordGroupDefinition.title}
+ </Tag>
);
};
diff --git a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupRelationChip.tsx b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupRelationChip.tsx
index 22e5f1347fa..76e493517e4 100644
--- a/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupRelationChip.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-group/components/RecordGroupRelationChip.tsx
@@ -29,11 +29,15 @@ export const RecordGroupRelationChip = ({
!isDefined(targetObjectNameSingular) ||
(!isDefined(record) && !loading)
) {
- return <Tag variant="outline" color="transparent" text={t`Deleted`} />;
+ return (
+ <Tag variant="outline" color="transparent" borderStyle="dashed">
+ {t`Deleted`}
+ </Tag>
+ );
}
if (!isDefined(record)) {
- return <Tag variant="outline" color="transparent" text="" />;
+ return <Tag variant="outline" color="transparent" borderStyle="dashed" />;
}
return (
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx b/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx
index 61c2ebc3691..c7196e47fbf 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/apps/components/SettingsAdminApps.tsx
@@ -371,10 +371,9 @@ const SettingsAdminAppsTableRow = ({
{registration.isListed ? t`Yes` : t`No`}
</TableCell>
<TableCell align="right">
- <Tag
- color={registration.isConfigured ? 'green' : 'red'}
- text={registration.isConfigured ? t`Yes` : t`No`}
- />
+ <Tag color={registration.isConfigured ? 'green' : 'red'}>
+ {registration.isConfigured ? t`Yes` : t`No`}
+ </Tag>
</TableCell>
<TableCell align="right">
<IconChevronRight
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/chats/components/SettingsAdminChatsTableRow.tsx b/packages/twenty-front/src/modules/settings/admin-panel/chats/components/SettingsAdminChatsTableRow.tsx
index dffd5e4c4f6..927110615eb 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/chats/components/SettingsAdminChatsTableRow.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/chats/components/SettingsAdminChatsTableRow.tsx
@@ -72,13 +72,9 @@ export const SettingsAdminChatsTableRow = ({
</TableCell>
<TableCell minWidth="0" overflow="hidden">
<StyledFlagsContainer>
- {thread.hasError && <Tag color="red" text={t`Error`} />}
- {isDefined(thread.deletedAt) && (
- <Tag color="gray" text={t`Archived`} />
- )}
- {thread.isOnboardingThread && (
- <Tag color="blue" text={t`Onboarding`} />
- )}
+ {thread.hasError && <Tag color="red">{t`Error`}</Tag>}
+ {isDefined(thread.deletedAt) && <Tag color="gray">{t`Archived`}</Tag>}
+ {thread.isOnboardingThread && <Tag color="blue">{t`Onboarding`}</Tag>}
</StyledFlagsContainer>
</TableCell>
<TableCell align="right">
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsPart.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsPart.tsx
index eb0198c3cc6..7348e1a1ae5 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsPart.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsPart.tsx
@@ -86,10 +86,9 @@ export const SettingsAdminChatAskQuestionsPart = ({
<IconHelpCircle size={14} />
{t`Questions`}
<StyledStatusTag>
- <Tag
- color={getStatusTagColor(result.status)}
- text={getStatusLabel(result.status)}
- />
+ <Tag color={getStatusTagColor(result.status)}>
+ {getStatusLabel(result.status)}
+ </Tag>
</StyledStatusTag>
</StyledCardHeader>
{result.questions.map((question, questionIndex) => (
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsQuestion.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsQuestion.tsx
index 854bd11dbc9..9cca116e1f0 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsQuestion.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatAskQuestionsQuestion.tsx
@@ -98,7 +98,9 @@ export const SettingsAdminChatAskQuestionsQuestion = ({
<StyledContainer>
<StyledHeaderRow>
{isNonEmptyString(question.header) && (
- <Tag color="transparent" text={question.header} variant="border" />
+ <Tag color="transparent" variant="outline">
+ {question.header}
+ </Tag>
)}
{question.allowMultiSelect === true && (
<StyledMultiSelectHint>{t`Multiple answers`}</StyledMultiSelectHint>
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatToolCallPart.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatToolCallPart.tsx
index a1e425240d8..3a0d946d01a 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatToolCallPart.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminChatToolCallPart.tsx
@@ -126,7 +126,7 @@ export const SettingsAdminChatToolCallPart = ({
<StyledToolLabel>
<IconTool size={14} />
{toolName}
- {hasToolError && <Tag color="red" text={t`Failed`} />}
+ {hasToolError && <Tag color="red">{t`Failed`}</Tag>}
</StyledToolLabel>
<StyledRightContent>
{isExpanded ? (
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceBillingContent.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceBillingContent.tsx
index 365199765c7..db83f30e5fe 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceBillingContent.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceBillingContent.tsx
@@ -264,10 +264,9 @@ export const SettingsAdminWorkspaceBillingContent = ({
Icon: IconStatusChange,
label: t`Status`,
value: (
- <Tag
- color={STATUS_COLORS[subscription.status]}
- text={STATUS_LABELS[subscription.status]}
- />
+ <Tag color={STATUS_COLORS[subscription.status]}>
+ {STATUS_LABELS[subscription.status]}
+ </Tag>
),
},
...(isDefined(planKey)
@@ -348,7 +347,7 @@ export const SettingsAdminWorkspaceBillingContent = ({
<StyledItemValue>
<span>{formatItemValue(item)}</span>
{isDefined(item.productKey) && (
- <Tag color="gray" text={item.productKey} />
+ <Tag color="gray">{item.productKey}</Tag>
)}
</StyledItemValue>
),
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceCreditGrantsTable.tsx b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceCreditGrantsTable.tsx
index a5440d42ba0..0e0817d6837 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceCreditGrantsTable.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/components/SettingsAdminWorkspaceCreditGrantsTable.tsx
@@ -130,10 +130,9 @@ export const SettingsAdminWorkspaceCreditGrantsTable = ({
{
label: t`Type`,
Cell: ({ item }) => (
- <Tag
- color={CREDIT_GRANT_TYPE_COLORS[item.current.type]}
- text={t(CREDIT_GRANT_TYPE_LABELS[item.current.type])}
- />
+ <Tag color={CREDIT_GRANT_TYPE_COLORS[item.current.type]}>
+ {t(CREDIT_GRANT_TYPE_LABELS[item.current.type])}
+ </Tag>
),
},
{
@@ -141,7 +140,7 @@ export const SettingsAdminWorkspaceCreditGrantsTable = ({
Cell: ({ item }) => {
const status = getStatus(item.current);
- return <Tag color={status.color} text={t(status.label)} />;
+ return <Tag color={status.color}>{t(status.label)}</Tag>;
},
},
{
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx b/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx
index 406a0357228..cd3f871602e 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/health-status/components/SettingsAdminJobStateBadge.tsx
@@ -34,17 +34,14 @@ export const SettingsAdminJobStateBadge = ({
return (
<StyledContainer>
- <Tag color={color} text={state} />
+ <Tag color={color}>{state}</Tag>
{showAttempts && (
- <Tag
- color="red"
- text={plural(attemptsMade, {
+ <Tag color="red" weight="medium" preventShrink>
+ {plural(attemptsMade, {
one: `${attemptsMade} attempt`,
other: `${attemptsMade} attempts`,
})}
- weight="medium"
- preventShrink
- />
+ </Tag>
)}
</StyledContainer>
);
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/signing-keys/components/SettingsAdminSigningKeysTable.tsx b/packages/twenty-front/src/modules/settings/admin-panel/signing-keys/components/SettingsAdminSigningKeysTable.tsx
index 831a409d6e6..4057fb526cb 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/signing-keys/components/SettingsAdminSigningKeysTable.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/signing-keys/components/SettingsAdminSigningKeysTable.tsx
@@ -142,7 +142,7 @@ export const SettingsAdminSigningKeysTable = () => {
)}
</TableCell>
<TableCell>
- <Tag text={status.text} color={status.color} />
+ <Tag color={status.color}>{status.text}</Tag>
</TableCell>
<TableCell align="right">
{signingKey.verifyCountInWindow}
@@ -175,7 +175,7 @@ export const SettingsAdminSigningKeysTable = () => {
</TableCell>
<TableCell>{EM_DASH}</TableCell>
<TableCell>
- <Tag text={t`Legacy`} color="gray" />
+ <Tag color="gray">{t`Legacy`}</Tag>
</TableCell>
<TableCell align="right">{legacyVerifyCountInWindow}</TableCell>
<TableCell align="right" />
diff --git a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationAboutSidebar.tsx b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationAboutSidebar.tsx
index 5801381f8e3..c8e6aecd7c1 100644
--- a/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationAboutSidebar.tsx
+++ b/packages/twenty-front/src/modules/settings/applications/components/SettingsApplicationAboutSidebar.tsx
@@ -167,11 +167,10 @@ export const SettingsApplicationAboutSidebar = ({
<Tag
key={entry.one}
color="gray"
- Icon={entry.icon}
- text={`${entry.count} ${
- entry.count === 1 ? entry.one : entry.many
- }`}
- />
+ startIcon={<entry.icon />}
+ >{`${entry.count} ${
+ entry.count === 1 ? entry.one : entry.many
+ }`}</Tag>
))}
</StyledContentList>
</StyledSidebarSection>
diff --git a/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx b/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx
index 143bcf53139..fbdaee492d3 100644
--- a/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx
+++ b/packages/twenty-front/src/modules/settings/billing/components/internal/PlansTags.tsx
@@ -23,8 +23,8 @@ export const PlansTags = ({ plan, isTrialPeriod = false }: PlansTagsProps) => {
return (
<StyledTagsWrapper>
- <Tag color={planDescriptor.color} text={planDescriptor.label} />
- {isTrialPeriod && <Tag color="blue" text={t`Trial`} preventShrink />}
+ <Tag color={planDescriptor.color}>{planDescriptor.label}</Tag>
+ {isTrialPeriod && <Tag color="blue" preventShrink>{t`Trial`}</Tag>}
</StyledTagsWrapper>
);
};
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
index dd1f87067df..134787761aa 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/dropdown-content/ChartManualSortSubMenuContent.tsx
@@ -104,11 +104,9 @@ export const ChartManualSortSubMenuContent = ({
gripMode="always"
isDragDisabled={sortedOptions.length === 1}
text={
- <Tag
- preventShrink
- color={option.color}
- text={option.label}
- />
+ <Tag preventShrink color={option.color}>
+ {option.label}
+ </Tag>
}
/>
}
diff --git a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/MatchColumnsStep/components/SubMatchingSelectDropdownButton.tsx b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/MatchColumnsStep/components/SubMatchingSelectDropdownButton.tsx
index a0b740deb61..9628f3845cf 100644
--- a/packages/twenty-front/src/modules/spreadsheet-import/steps/components/MatchColumnsStep/components/SubMatchingSelectDropdownButton.tsx
+++ b/packages/twenty-front/src/modules/spreadsheet-import/steps/components/MatchColumnsStep/components/SubMatchingSelectDropdownButton.tsx
@@ -37,10 +37,7 @@ export const SubMatchingSelectDropdownButton = ({
const value = options.find((opt) => opt.value === option.value);
return (
<SubMatchingSelectControlContainer cursor="pointer" id="control">
- <Tag
- text={value?.label ?? placeholder}
- color={value?.color as TagColor}
- />
+ <Tag color={value?.color as TagColor}>{value?.label ?? placeholder}</Tag>
<StyledIconChevronDownContainer>
<IconChevronDown size={theme.icon.size.md} />
</StyledIconChevronDownContainer>
diff --git a/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
index 9cf083c74ff..c2e55ee0dc1 100644
--- a/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
+++ b/packages/twenty-front/src/modules/ui/field/display/components/MultiSelectDisplay.tsx
@@ -37,9 +37,12 @@ export const MultiSelectDisplay = ({
preventShrink
key={index}
color={selectedOption.color ?? 'transparent'}
- text={selectedOption.label}
- Icon={selectedOption.Icon ?? undefined}
- />
+ startIcon={
+ isDefined(selectedOption.Icon) ? <selectedOption.Icon /> : undefined
+ }
+ >
+ {selectedOption.label}
+ </Tag>
))}
</StyledContainer>
);
diff --git a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__stories__/ExpandableList.stories.tsx b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__stories__/ExpandableList.stories.tsx
index 007f82ccaa5..294c2b4279e 100644
--- a/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__stories__/ExpandableList.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/layout/expandable-list/components/__stories__/ExpandableList.stories.tsx
@@ -22,9 +22,8 @@ const meta: Meta<typeof ExpandableList> = {
children: Array.from({ length: 7 }, (_, index) => (
<Tag
key={index}
- text={`Option ${index + 1}`}
color={MAIN_COLOR_NAMES[index]}
- />
+ >{`Option ${index + 1}`}</Tag>
)),
isChipCountDisplayed: false,
},
@@ -62,11 +61,7 @@ const OPTIONS_COUNT = 7;
const COLLAPSED_WIDTH_PX = 96;
const optionTags = Array.from({ length: OPTIONS_COUNT }, (_, index) => (
- <Tag
- key={index}
- text={`Option ${index + 1}`}
- color={MAIN_COLOR_NAMES[index]}
- />
+ <Tag key={index} color={MAIN_COLOR_NAMES[index]}>{`Option ${index + 1}`}</Tag>
));
const countRenderedOptions = (canvas: ReturnType<typeof within>) =>
diff --git a/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramCanvasBase.tsx b/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramCanvasBase.tsx
index 2117831d423..e30a72de0c9 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramCanvasBase.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-diagram/components/WorkflowDiagramCanvasBase.tsx
@@ -680,7 +680,7 @@ export const WorkflowDiagramCanvasBase = ({
)}
<StyledStatusTagContainer data-testid={tagContainerTestId}>
- <Tag color={tagColor} text={tagText} />
+ <Tag color={tagColor}>{tagText}</Tag>
</StyledStatusTagContainer>
</StyledResetReactflowStyles>
);
diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminApplicationRegistrationClaims.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminApplicationRegistrationClaims.tsx
index 23d08a54cd6..40fe7d67d48 100644
--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminApplicationRegistrationClaims.tsx
+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminApplicationRegistrationClaims.tsx
@@ -53,7 +53,7 @@ export const SettingsAdminApplicationRegistrationClaims = ({
{claim.workspaceDisplayName ?? claim.workspaceId}
</TableCell>
<TableCell>
- <Tag text={t`Owner`} color="green" />
+ <Tag color="green">{t`Owner`}</Tag>
</TableCell>
</TableRow>
))}
diff --git a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx
index d76852731bd..c1f0d2cb367 100644
--- a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationConnectionDetail.tsx
@@ -243,7 +243,9 @@ export const SettingsApplicationConnectionDetail = () => {
scopes.length > 0 ? (
<StyledScopeList>
{scopes.map((scope) => (
- <Tag key={scope} color="gray" text={scope} />
+ <Tag key={scope} color="gray">
+ {scope}
+ </Tag>
))}
</StyledScopeList>
) : (
diff --git a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationRegistrationDetails.tsx b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationRegistrationDetails.tsx
index 7689b665960..a4d11f62dfe 100644
--- a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationRegistrationDetails.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationRegistrationDetails.tsx
@@ -106,7 +106,7 @@ export const SettingsApplicationRegistrationDetails = () => {
placeholderColorSeed={registration.name}
/>
}
- tag={<Tag text={t`Owner`} color={'gray'} />}
+ tag={<Tag color="gray">{t`Owner`}</Tag>}
links={[
{
children: t`Workspace`,
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 b5bc3e43f66..06b9aa778f1 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationGeneralInfo.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationRegistrationGeneralInfo.tsx
@@ -126,7 +126,7 @@ export const SettingsApplicationRegistrationGeneralInfo = ({
label={ownerWorkspace.displayName}
/>
) : (
- <Tag color="orange" text={t`Unclaimed`} />
+ <Tag color="orange">{t`Unclaimed`}</Tag>
),
});
@@ -187,9 +187,9 @@ export const SettingsApplicationRegistrationGeneralInfo = ({
Icon: IconDownload,
label: t`Installed`,
value: isApplicationInstalled ? (
- <Tag color="green" text={t`Yes`} />
+ <Tag color="green">{t`Yes`}</Tag>
) : (
- <Tag color="orange" text={t`No`} />
+ <Tag color="orange">{t`No`}</Tag>
),
});
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx
index 529f5b3468f..4653ae48079 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationTableRow.tsx
@@ -59,7 +59,7 @@ export const SettingsApplicationTableRow = ({
<TableCell gap={themeCssVariables.spacing[2]} minWidth="0">
<OverflowingTextWithTooltip text={descriptionSummary} />
{hasUpdate === true && (
- <Tag color="blue" text={t`Update`} weight="medium" />
+ <Tag color="blue" weight="medium">{t`Update`}</Tag>
)}
</TableCell>
<TableCell
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationDistributionTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationDistributionTab.tsx
index 375e52c2cf1..b7c70ed65e0 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationDistributionTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationDistributionTab.tsx
@@ -42,7 +42,7 @@ export const SettingsApplicationRegistrationDistributionTab = ({
title={t`Ownership`}
description={t`This application's registration is claimed by your workspace`}
/>
- <Tag text={t`Claimed by this workspace`} color="green" />
+ <Tag color="green">{t`Claimed by this workspace`}</Tag>
</Section>
)}
<Section>
diff --git a/packages/twenty-ui/src/data-display/SelectDisplay/SelectDisplay.tsx b/packages/twenty-ui/src/data-display/SelectDisplay/SelectDisplay.tsx
index b9ed583962e..dff6156bb91 100644
--- a/packages/twenty-ui/src/data-display/SelectDisplay/SelectDisplay.tsx
+++ b/packages/twenty-ui/src/data-display/SelectDisplay/SelectDisplay.tsx
@@ -1,6 +1,7 @@
import { type IconComponent } from '@ui/icon/types/IconComponent';
import { Tag } from '@ui/data-display/Tag/Tag';
import { type ThemeColor } from '@ui/theme';
+import { isDefined } from '@ui/utilities/utils/isDefined';
type SelectDisplayProps = {
color: ThemeColor | 'transparent';
@@ -18,8 +19,9 @@ export const SelectDisplay = ({
<Tag
preventShrink
color={color}
- text={label}
- Icon={Icon}
+ startIcon={isDefined(Icon) ? <Icon /> : undefined}
preventPadding={preventPadding}
- />
+ >
+ {label}
+ </Tag>
);
diff --git a/packages/twenty-ui/src/data-display/Tag/Tag.module.scss b/packages/twenty-ui/src/data-display/Tag/Tag.module.scss
index 91449ac977c..d4d65a31388 100644
--- a/packages/twenty-ui/src/data-display/Tag/Tag.module.scss
+++ b/packages/twenty-ui/src/data-display/Tag/Tag.module.scss
@@ -1,63 +1,62 @@
.tag {
+ @include focus-ring;
box-sizing: content-box;
align-items: center;
- background: var(--tag-background);
+ background: var(--tw-tag-background);
border-radius: var(--t-border-radius-sm-round);
corner-shape: round;
- color: var(--tag-text);
+ color: var(--tw-tag-text);
display: inline-flex;
+ font-family: inherit;
font-size: var(--t-font-size-md);
- font-style: normal;
font-weight: var(--t-font-weight-regular);
- height: var(--t-spacing-5);
+ block-size: var(--t-spacing-5);
margin: 0;
overflow: hidden;
padding: 0 var(--t-spacing-2);
border: none;
gap: var(--t-spacing-1);
- // 'none' is not a valid min-width value; kept for byte-equivalence with the
- // deprecated Linaria styles where the declaration was equally inert.
- min-width: none;
-}
-
-.interactive {
- appearance: none;
- cursor: pointer;
- font-family: inherit;
+ min-inline-size: 0;
text-align: inherit;
-}
-
-.weightMedium {
- font-weight: var(--t-font-weight-medium);
-}
-
-.variantOutline {
- border: 1px dashed var(--t-border-color-strong);
-}
-.variantBorder {
- border: 1px solid var(--t-border-color-strong);
+ &[data-interactive] {
+ cursor: pointer;
+ }
+ &[data-weight='medium'] {
+ font-weight: var(--t-font-weight-medium);
+ }
+ &[data-variant='outline'] {
+ border: 1px var(--tw-tag-border-style) var(--t-border-color-strong);
+ }
+ &[data-variant='ghost'] {
+ background: transparent;
+ }
+ &[data-variant='solid'] {
+ background: var(--tw-tag-text);
+ color: var(--t-background-primary);
+ }
+ &[data-prevent-shrink] {
+ min-inline-size: fit-content;
+ }
+ &[data-prevent-padding] {
+ padding: 0;
+ }
+ &[data-disabled] {
+ cursor: not-allowed;
+ opacity: 0.5;
+ }
}
-
-.preventShrink {
- min-width: fit-content;
-}
-
-.preventPadding {
- padding: 0;
-}
-
.content {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
-
-.nonShrinkableText {
- white-space: nowrap;
- width: fit-content;
-}
-
.iconContainer {
display: flex;
+ flex-shrink: 0;
+ & > svg {
+ inline-size: calc(var(--t-icon-size-sm) * 1px);
+ block-size: calc(var(--t-icon-size-sm) * 1px);
+ stroke-width: var(--t-icon-stroke-sm);
+ }
}
diff --git a/packages/twenty-ui/src/data-display/Tag/Tag.module.scss.d.ts b/packages/twenty-ui/src/data-display/Tag/Tag.module.scss.d.ts
index f2cacafa2ad..c5669e0325e 100644
--- a/packages/twenty-ui/src/data-display/Tag/Tag.module.scss.d.ts
+++ b/packages/twenty-ui/src/data-display/Tag/Tag.module.scss.d.ts
@@ -1,13 +1,6 @@
declare const classNames: {
readonly tag: 'tag';
- readonly interactive: 'interactive';
- readonly weightMedium: 'weightMedium';
- readonly variantOutline: 'variantOutline';
- readonly variantBorder: 'variantBorder';
- readonly preventShrink: 'preventShrink';
- readonly preventPadding: 'preventPadding';
readonly content: 'content';
- readonly nonShrinkableText: 'nonShrinkableText';
readonly iconContainer: 'iconContainer';
};
export default classNames;
diff --git a/packages/twenty-ui/src/data-display/Tag/Tag.tsx b/packages/twenty-ui/src/data-display/Tag/Tag.tsx
index 3d74772527f..56866955e83 100644
--- a/packages/twenty-ui/src/data-display/Tag/Tag.tsx
+++ b/packages/twenty-ui/src/data-display/Tag/Tag.tsx
@@ -1,109 +1,114 @@
-import { type IconComponent } from '@ui/icon/types/IconComponent';
-import { OverflowingTextWithTooltip } from '@ui/surfaces/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
-import { type ThemeColor } from '@ui/theme';
-import { themeCssVariables, useTheme } from '@ui/theme-constants';
+import { Button as ButtonPrimitive } from '@base-ui/react/button';
+import { useRender } from '@base-ui/react/use-render';
import { clsx } from 'clsx';
+import {
+ type CSSProperties,
+ type KeyboardEvent,
+ type SyntheticEvent,
+} from 'react';
+
+import { OverflowingTextWithTooltip } from '@ui/surfaces/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
+import { themeCssVariables } from '@ui/theme-constants';
import { isDefined } from '@ui/utilities/utils/isDefined';
import styles from './Tag.module.scss';
+import { type TagProps } from './types/TagProps';
+
+const preventDisabledInteraction = (event: SyntheticEvent) => {
+ event.preventDefault();
+ event.stopPropagation();
+};
-type TagWeight = 'regular' | 'medium';
-type TagVariant = 'solid' | 'outline' | 'border';
-export type TagColor = ThemeColor | 'transparent';
+const preventDisabledKeyboardActivation = (event: KeyboardEvent) => {
+ if (event.key !== 'Enter' && event.key !== ' ') {
+ return;
+ }
-type TagProps = {
- className?: string;
- color: TagColor;
- text: string;
- Icon?: IconComponent;
- onClick?: () => void;
- weight?: TagWeight;
- variant?: TagVariant;
- preventShrink?: boolean;
- preventPadding?: boolean;
+ preventDisabledInteraction(event);
};
export const Tag = ({
- className,
+ children,
color,
- text,
- Icon,
- onClick,
weight = 'regular',
- variant = 'solid',
- preventShrink,
- preventPadding,
-}: TagProps) => {
- const theme = useTheme();
-
- const tagBackground =
- color === 'transparent'
- ? 'transparent'
- : (themeCssVariables.tag.background[color] ??
- themeCssVariables.tag.background.gray);
-
- const tagText =
- color === 'transparent'
- ? themeCssVariables.font.color.secondary
- : (themeCssVariables.tag.text[color] ??
- themeCssVariables.font.color.secondary);
-
- const isInteractive = isDefined(onClick);
-
- const tagContent = (
- <>
- {isDefined(Icon) ? (
- <div className={styles.iconContainer}>
- <Icon
- size={theme.icon.size.sm}
- stroke={theme.icon.stroke.sm}
- aria-hidden
- />
- </div>
- ) : (
- <></>
- )}
- {preventShrink ? (
- <span className={styles.nonShrinkableText}>{text}</span>
- ) : (
- <span className={styles.content}>
- <OverflowingTextWithTooltip text={text} />
- </span>
- )}
- </>
- );
-
- const sharedStyle = {
- '--tag-background': tagBackground,
- '--tag-text': tagText,
- } as React.CSSProperties;
-
- const sharedClassName = clsx(
- styles.tag,
- weight === 'medium' && styles.weightMedium,
- variant === 'outline' && styles.variantOutline,
- variant === 'border' && styles.variantBorder,
- preventShrink && styles.preventShrink,
- preventPadding && styles.preventPadding,
- className,
- );
-
- if (isInteractive) {
- return (
- <button
- type="button"
- className={clsx(sharedClassName, styles.interactive)}
- onClick={onClick}
- style={sharedStyle}
- >
- {tagContent}
- </button>
- );
- }
-
- return (
- <span className={sharedClassName} style={sharedStyle}>
- {tagContent}
- </span>
- );
-};
+ variant = 'soft',
+ startIcon,
+ preventShrink = false,
+ preventPadding = false,
+ borderStyle = 'solid',
+ disabled = false,
+ nativeButton = true,
+ onClick,
+ className,
+ style,
+ render,
+ ref,
+ ...props
+}: TagProps) =>
+ useRender({
+ defaultTagName: 'span',
+ render: isDefined(onClick) ? (
+ <ButtonPrimitive
+ render={render}
+ disabled={disabled}
+ nativeButton={nativeButton}
+ />
+ ) : (
+ render
+ ),
+ ref,
+ state: {
+ variant,
+ weight,
+ disabled,
+ interactive: isDefined(onClick),
+ preventShrink,
+ preventPadding,
+ },
+ props: {
+ ...props,
+ onClick,
+ ...(disabled && {
+ disabled: true,
+ 'aria-disabled': true,
+ tabIndex: -1,
+ onClickCapture: preventDisabledInteraction,
+ onPointerDownCapture: preventDisabledInteraction,
+ onKeyDownCapture: preventDisabledKeyboardActivation,
+ onKeyUpCapture: preventDisabledKeyboardActivation,
+ }),
+ className: clsx(styles.tag, className),
+ style: {
+ '--tw-tag-background':
+ color === 'transparent'
+ ? 'transparent'
+ : (themeCssVariables.tag.background[color] ??
+ themeCssVariables.tag.background.gray),
+ '--tw-tag-text':
+ color === 'transparent'
+ ? themeCssVariables.font.color.secondary
+ : (themeCssVariables.tag.text[color] ??
+ themeCssVariables.font.color.secondary),
+ '--tw-tag-border-style': borderStyle,
+ ...style,
+ } as CSSProperties,
+ children: (
+ <>
+ {isDefined(startIcon) &&
+ typeof startIcon !== 'boolean' &&
+ startIcon !== '' && (
+ <span className={styles.iconContainer} aria-hidden>
+ {startIcon}
+ </span>
+ )}
+ <span className={styles.content}>
+ {typeof children === 'string' && !preventShrink ? (
+ <OverflowingTextWithTooltip text={children} />
+ ) : (
+ children
+ )}
+ </span>
+ </>
+ ),
+ },
+ });
diff --git a/packages/twenty-ui/src/data-display/Tag/__stories__/Tag.stories.tsx b/packages/twenty-ui/src/data-display/Tag/__stories__/Tag.stories.tsx
index e9d0b644349..e707bf53c8f 100644
--- a/packages/twenty-ui/src/data-display/Tag/__stories__/Tag.stories.tsx
+++ b/packages/twenty-ui/src/data-display/Tag/__stories__/Tag.stories.tsx
@@ -16,7 +16,7 @@ const meta: Meta<typeof Tag> = {
title: 'UI/Data Display/Tag',
component: Tag,
args: {
- text: 'Urgent',
+ children: 'Urgent',
},
};
@@ -43,7 +43,7 @@ export const WithLongText: Story = {
decorators: [ComponentDecorator],
args: {
color: 'green',
- text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
+ children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
},
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
@@ -55,8 +55,8 @@ export const WithIcon: Story = {
decorators: [ComponentDecorator],
args: {
color: 'green',
- text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
- Icon: IconUser,
+ children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
+ startIcon: <IconUser />,
},
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
@@ -68,7 +68,7 @@ export const DontShrink: Story = {
decorators: [ComponentDecorator],
args: {
color: 'green',
- text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
+ children: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit',
preventShrink: true,
},
parameters: {
@@ -84,7 +84,15 @@ export const Catalog: CatalogStory<Story, typeof Tag> = {
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
catalog: {
+ options: { elementContainer: { style: { width: 80 } } },
dimensions: [
+ {
+ name: 'variants',
+ values: ['soft', 'solid', 'outline', 'ghost'],
+ props: (variant: 'soft' | 'solid' | 'outline' | 'ghost') => ({
+ variant,
+ }),
+ },
{
name: 'colors',
values: MAIN_COLOR_NAMES,
@@ -100,11 +108,54 @@ export const EmptyTag: Story = {
decorators: [ComponentDecorator],
args: {
color: 'transparent',
- text: 'No Value',
+ children: 'No Value',
variant: 'outline',
+ borderStyle: 'dashed',
weight: 'medium',
},
parameters: {
container: { width: 'auto' },
},
};
+
+export const CatalogDark: typeof Catalog = {
+ ...Catalog,
+ tags: ['!autodocs'],
+ globals: { colorScheme: 'dark' },
+};
+
+export const PointerAndKeyboard: Story = {
+ decorators: [ComponentDecorator],
+ args: { children: 'Open details', onClick: fn(), color: 'blue' },
+ play: async ({ canvasElement, args }) => {
+ const control = within(canvasElement).getByRole('button', {
+ name: 'Open details',
+ });
+ 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(),
+ color: 'blue',
+ },
+ 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();
+ },
+};
diff --git a/packages/twenty-ui/src/data-display/Tag/__tests__/Tag.test.tsx b/packages/twenty-ui/src/data-display/Tag/__tests__/Tag.test.tsx
new file mode 100644
index 00000000000..3772a5e3262
--- /dev/null
+++ b/packages/twenty-ui/src/data-display/Tag/__tests__/Tag.test.tsx
@@ -0,0 +1,91 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { expect, it, vi } from 'vitest';
+
+import { ThemeProvider } from '@ui/theme-constants/ThemeProvider';
+
+import { Tag } from '../Tag';
+import styles from '../Tag.module.scss';
+
+runComponentConformance({
+ name: 'Tag',
+ element: <Tag color="blue">Label</Tag>,
+ ownClassName: styles.tag,
+ refInstanceOf: HTMLSpanElement,
+});
+
+it('disables a custom button with its own click handler until re-enabled', async () => {
+ const user = userEvent.setup();
+ const handleClick = vi.fn();
+ const { rerender } = render(
+ <ThemeProvider colorScheme="light">
+ <Tag color="blue" disabled render={<button onClick={handleClick} />}>
+ Save
+ </Tag>
+ </ThemeProvider>,
+ );
+
+ const button = screen.getByRole('button', { name: 'Save' });
+
+ await user.click(button);
+ expect(handleClick).not.toHaveBeenCalled();
+ expect(button).toBeDisabled();
+
+ rerender(
+ <ThemeProvider colorScheme="light">
+ <Tag color="blue" render={<button onClick={handleClick} />}>
+ Save
+ </Tag>
+ </ThemeProvider>,
+ );
+
+ await user.click(button);
+ await user.keyboard('{Enter} ');
+ expect(handleClick).toHaveBeenCalledTimes(3);
+});
+
+it('blocks disabled render-function links without trapping keyboard focus', async () => {
+ const user = userEvent.setup();
+ const handleClick = vi.fn();
+ const handleKeyDown = vi.fn();
+ const handleKeyUp = vi.fn();
+
+ render(
+ <ThemeProvider colorScheme="light">
+ <Tag
+ color="blue"
+ disabled
+ nativeButton={false}
+ render={(props) => (
+ <a
+ {...props}
+ href="#details"
+ onClick={handleClick}
+ onKeyDown={handleKeyDown}
+ onKeyUp={handleKeyUp}
+ >
+ {props.children}
+ </a>
+ )}
+ >
+ Details
+ </Tag>
+ <button>Next</button>
+ </ThemeProvider>,
+ );
+
+ const link = screen.getByRole('link', { name: 'Details' });
+
+ await user.click(link);
+ link.focus();
+ await user.keyboard('{Enter} ');
+ expect(handleClick).not.toHaveBeenCalled();
+ expect(handleKeyDown).not.toHaveBeenCalled();
+ expect(handleKeyUp).not.toHaveBeenCalled();
+ expect(link).toHaveAttribute('aria-disabled', 'true');
+ expect(link).toHaveAttribute('tabindex', '-1');
+
+ await user.tab();
+ expect(screen.getByRole('button', { name: 'Next' })).toHaveFocus();
+});
diff --git a/packages/twenty-ui/src/data-display/Tag/types/TagColor.ts b/packages/twenty-ui/src/data-display/Tag/types/TagColor.ts
new file mode 100644
index 00000000000..d7f57a423c6
--- /dev/null
+++ b/packages/twenty-ui/src/data-display/Tag/types/TagColor.ts
@@ -0,0 +1,3 @@
+import { type ThemeColor } from '@ui/theme';
+
+export type TagColor = ThemeColor | 'transparent';
diff --git a/packages/twenty-ui/src/data-display/Tag/types/TagProps.ts b/packages/twenty-ui/src/data-display/Tag/types/TagProps.ts
new file mode 100644
index 00000000000..b8d7805580f
--- /dev/null
+++ b/packages/twenty-ui/src/data-display/Tag/types/TagProps.ts
@@ -0,0 +1,16 @@
+import { type useRender } from '@base-ui/react/use-render';
+import { type ReactNode } from 'react';
+
+import { type TagColor } from './TagColor';
+
+export type TagProps = Omit<useRender.ComponentProps<'span'>, 'color'> & {
+ color: TagColor;
+ weight?: 'regular' | 'medium';
+ disabled?: boolean;
+ nativeButton?: boolean;
+ variant?: 'solid' | 'soft' | 'outline' | 'ghost';
+ startIcon?: ReactNode;
+ preventShrink?: boolean;
+ preventPadding?: boolean;
+ borderStyle?: 'solid' | 'dashed';
+};
diff --git a/packages/twenty-ui/src/data-display/index.ts b/packages/twenty-ui/src/data-display/index.ts
index c46c1f78621..3bd3eddc289 100644
--- a/packages/twenty-ui/src/data-display/index.ts
+++ b/packages/twenty-ui/src/data-display/index.ts
@@ -40,8 +40,9 @@ export { SelectDisplay } from './SelectDisplay/SelectDisplay';
export { Status } from './Status/Status';
export type { StatusProps } from './Status/types/StatusProps';
export { StyledTintedIconTileContainer } from './StyledTintedIconTileContainer/StyledTintedIconTileContainer';
-export type { TagColor } from './Tag/Tag';
export { Tag } from './Tag/Tag';
+export type { TagColor } from './Tag/types/TagColor';
+export type { TagProps } from './Tag/types/TagProps';
export { TextDisplay } from './TextDisplay/TextDisplay';
export type { TintedIconTileProps } from './TintedIconTile/TintedIconTile';
export { TintedIconTile } from './TintedIconTile/TintedIconTile';
diff --git a/packages/twenty-ui/src/navigation/MenuItemMultiSelect/MenuItemMultiSelect.tsx b/packages/twenty-ui/src/navigation/MenuItemMultiSelect/MenuItemMultiSelect.tsx
index 0ae4861fd24..52697247593 100644
--- a/packages/twenty-ui/src/navigation/MenuItemMultiSelect/MenuItemMultiSelect.tsx
+++ b/packages/twenty-ui/src/navigation/MenuItemMultiSelect/MenuItemMultiSelect.tsx
@@ -4,6 +4,7 @@ import { MenuItemLeftContent } from '@ui/navigation/MenuItem/parts/MenuItemLeftC
import { MenuItemMultiSelectCheckbox } from '@ui/navigation/MenuItem/parts/MenuItemMultiSelectCheckbox';
import { type ThemeColor } from '@ui/theme';
import { StyledMenuItemBase } from '@ui/navigation/MenuItem/parts/StyledMenuItemBase';
+import { isDefined } from '@ui/utilities/utils/isDefined';
import styles from './MenuItemMultiSelect.module.scss';
@@ -47,7 +48,12 @@ export const MenuItemMultiSelect = ({
ariaLabel={text}
/>
{color ? (
- <Tag color={color} text={text} Icon={LeftIcon} />
+ <Tag
+ color={color}
+ startIcon={isDefined(LeftIcon) ? <LeftIcon /> : undefined}
+ >
+ {text}
+ </Tag>
) : (
<MenuItemLeftContent
LeftIcon={LeftIcon}
diff --git a/packages/twenty-ui/src/navigation/MenuItemMultiSelectTag/MenuItemMultiSelectTag.tsx b/packages/twenty-ui/src/navigation/MenuItemMultiSelectTag/MenuItemMultiSelectTag.tsx
index 5abe2ca233c..9e1c519a2bb 100644
--- a/packages/twenty-ui/src/navigation/MenuItemMultiSelectTag/MenuItemMultiSelectTag.tsx
+++ b/packages/twenty-ui/src/navigation/MenuItemMultiSelectTag/MenuItemMultiSelectTag.tsx
@@ -6,6 +6,7 @@ import {
StyledMenuItemBase,
StyledMenuItemLeftContent,
} from '@ui/navigation/MenuItem/parts/StyledMenuItemBase';
+import { isDefined } from '@ui/utilities/utils/isDefined';
type MenuItemMultiSelectTagProps = {
selected: boolean;
@@ -38,7 +39,9 @@ export const MenuItemMultiSelectTag = ({
onSelectChange={() => onClick?.()}
ariaLabel={text}
/>
- <Tag color={color} text={text} Icon={Icon} />
+ <Tag color={color} startIcon={isDefined(Icon) ? <Icon /> : undefined}>
+ {text}
+ </Tag>
</StyledMenuItemLeftContent>
</StyledMenuItemBase>
);
diff --git a/packages/twenty-ui/src/navigation/MenuItemSelectTag/MenuItemSelectTag.tsx b/packages/twenty-ui/src/navigation/MenuItemSelectTag/MenuItemSelectTag.tsx
index deab86ae533..17adf6eb1db 100644
--- a/packages/twenty-ui/src/navigation/MenuItemSelectTag/MenuItemSelectTag.tsx
+++ b/packages/twenty-ui/src/navigation/MenuItemSelectTag/MenuItemSelectTag.tsx
@@ -8,6 +8,7 @@ import { type IconComponent } from '@ui/icon';
import { type ThemeColor } from '@ui/theme';
import { useTheme } from '@ui/theme-constants';
import { StyledMenuItemSelect } from '@ui/navigation/MenuItemSelect/MenuItemSelect';
+import { isDefined } from '@ui/utilities/utils/isDefined';
type MenuItemSelectTagProps = {
selected?: boolean;
@@ -17,7 +18,7 @@ type MenuItemSelectTagProps = {
onClick?: () => void;
color: ThemeColor | 'transparent';
text: string;
- variant?: 'solid' | 'outline';
+ variant?: 'soft' | 'outline';
LeftIcon?: IconComponent | null;
};
@@ -29,7 +30,7 @@ export const MenuItemSelectTag = ({
className,
onClick,
text,
- variant = 'solid',
+ variant = 'soft',
LeftIcon,
}: MenuItemSelectTagProps) => {
const theme = useTheme();
@@ -43,11 +44,13 @@ export const MenuItemSelectTag = ({
>
<StyledMenuItemLeftContent>
<Tag
+ borderStyle="dashed"
variant={variant}
color={color}
- text={text}
- Icon={LeftIcon ?? undefined}
- />
+ startIcon={isDefined(LeftIcon) ? <LeftIcon /> : undefined}
+ >
+ {text}
+ </Tag>
</StyledMenuItemLeftContent>
{selected && <StyledMenuItemIconCheck size={theme.icon.size.md} />}
</StyledMenuItemSelect>