Skip to content

The open alternative to Salesforce, designed for AI.

Add outlined Chips for rounded links (#28393)

Raphaël Bosicb2e09dabad9
diff --git a/packages/twenty-docs/snippets/ui/generated/data-display/chip.mdx b/packages/twenty-docs/snippets/ui/generated/data-display/chip.mdx
index 0de84f53e35..2a92889aba3 100644
--- a/packages/twenty-docs/snippets/ui/generated/data-display/chip.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/data-display/chip.mdx
@@ -40,7 +40,7 @@
</ParamField>
<ParamField body="maxWidth" type="number">
- Maximum rendered chip width in pixels, including its leading and trailing padding.
+ Maximum rendered chip width in pixels, including its leading and trailing padding and any outline border.
</ParamField>
<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
@@ -75,8 +75,8 @@
Truncates overflowing content with an ellipsis. Defaults to true.
</ParamField>
-<ParamField body="variant" type="&quot;ghost&quot; | &quot;plain&quot; | &quot;soft&quot; | &quot;solid&quot;" default="ghost">
- Background treatment. Plain has no resting fill or leading padding, with ghost hover and pressed feedback when clickable.
+<ParamField body="variant" type="&quot;ghost&quot; | &quot;outline&quot; | &quot;plain&quot; | &quot;soft&quot; | &quot;solid&quot;" default="ghost">
+ Background and border treatment. Outline has a strong border, lighter resting fill and 8px inline padding. Plain has no resting fill or leading padding. Both use ghost hover and pressed feedback when clickable.
</ParamField>
<ParamField body="weight" type="&quot;medium&quot; | &quot;regular&quot;" default="regular">
diff --git a/packages/twenty-docs/ui/primitives/data-display/chip.mdx b/packages/twenty-docs/ui/primitives/data-display/chip.mdx
index e8c922a6d91..477336b8e5b 100644
--- a/packages/twenty-docs/ui/primitives/data-display/chip.mdx
+++ b/packages/twenty-docs/ui/primitives/data-display/chip.mdx
@@ -44,7 +44,7 @@ Chip never inserts a label. Supply a translated fallback from your application w
height={200}
/>
-`size` accepts `sm` or `md`. `variant` accepts `ghost`, `soft`, `solid`, or `plain`; `ghost` is the default. Plain chips have no resting fill or leading padding. Clickable plain chips retain the ghost hover and pressed backgrounds, pointer cursor, and focus ring. Use `shape="round"` for a pill, `weight="medium"` for emphasis, and `color="secondary"` for secondary text.
+`size` accepts `sm` or `md`, with total heights of 20px and 24px. `variant` accepts `ghost`, `soft`, `solid`, `plain`, or `outline`; `ghost` is the default. Plain chips have no resting fill or leading padding. Outline chips have a strong 1px border, a lighter resting fill, and 8px inline padding on each side, with the same total height as other variants. Clickable plain and outline chips use the ghost hover and pressed backgrounds, pointer cursor, and focus ring. Use `shape="round"` for a pill, `weight="medium"` for emphasis, and `color="secondary"` for secondary text.
## Buttons and links
@@ -81,7 +81,12 @@ Supplying `onClick` keeps the default `div`. Use `render` to compose an explicit
import { Chip } from 'twenty-ui/primitives/data-display';
export const DocumentationChip = () => (
- <Chip render={<a href="https://twenty.com/developers" />} clickable>
+ <Chip
+ variant="outline"
+ shape="round"
+ render={<a href="https://twenty.com/developers" />}
+ clickable
+ >
Documentation
</Chip>
);
@@ -101,7 +106,7 @@ export const FileChip = () => (
);
```
-`maxWidth` constrains the rendered chip width in pixels, including padding. The same limit applies to plain chips with asymmetric padding. Content truncates with an ellipsis by default; `truncate={false}` leaves it unconstrained by truncation. String children supply their own tooltip text. Set `tooltipContent` for custom text or node content, `tooltipDelay` for the opening delay, and `isTooltipMultiline` to preserve line breaks. `alwaysShowTooltip` also enables the tooltip when content fits. These options follow [OverflowingTextWithTooltip](/ui/primitives/typography/overflowing-text-with-tooltip). Keep essential information available without relying on hover.
+`maxWidth` constrains the rendered chip width in pixels, including padding and any outline border. The same limit applies to plain chips with asymmetric padding. Content truncates with an ellipsis by default; `truncate={false}` leaves it unconstrained by truncation. String children supply their own tooltip text. Set `tooltipContent` for custom text or node content, `tooltipDelay` for the opening delay, and `isTooltipMultiline` to preserve line breaks. `alwaysShowTooltip` also enables the tooltip when content fits. These options follow [OverflowingTextWithTooltip](/ui/primitives/typography/overflowing-text-with-tooltip). Keep essential information available without relying on hover.
## Migration
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
index c2350313f13..88be271c89d 100644
--- 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
@@ -38,6 +38,7 @@ const ChipControls = () => {
<Chip
render={<button type="button" disabled />}
onClick={handleClick}
+ variant="outline"
>
Disabled chip
</Chip>
@@ -84,6 +85,10 @@ const ChipControls = () => {
render={
<a href="#chip-documentation" data-composed="chip-link" />
}
+ variant="outline"
+ shape="round"
+ clickable
+ maxWidth={140}
aria-label="Chip documentation"
ref={(element) => {
element?.setAttribute('data-ref-target', 'chip-link');
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/chipControlsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/chipControlsTest.ts
index 62010f054e2..f0b26816656 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/chipControlsTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/chipControlsTest.ts
@@ -67,6 +67,11 @@ export const chipControlsTest: TwentyUiGalleryPlayFunction = async (
expect(link).toHaveAttribute('data-composed', 'chip-link');
expect(link).toHaveAttribute('data-ref-target', 'chip-link');
expect(link.querySelector('a')).toBeNull();
+ expect(link.getBoundingClientRect().width).toBe(140);
+ expect(link.getBoundingClientRect().height).toBe(20);
+ expect(getComputedStyle(link).paddingInlineStart).toBe('8px');
+ expect(getComputedStyle(link).paddingInlineEnd).toBe('8px');
+ expect(getComputedStyle(link).borderTopWidth).toBe('1px');
link.focus();
expect(link).toHaveFocus();
await waitFor(() =>
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/phoneCountryPickerTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/phoneCountryPickerTest.ts
index 1cd3de61e0c..9bd03afe1d2 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/phoneCountryPickerTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/phoneCountryPickerTest.ts
@@ -2,6 +2,7 @@ import { expect, userEvent, waitFor, within } from 'storybook/test';
import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
+import { INTERACTION_TIMEOUT } from '@/__stories__/shared/test-utils/timeouts';
import { waitForSandboxRoundTrip } from '@/__stories__/shared/test-utils/waitForSandboxRoundTrip';
import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
@@ -31,8 +32,12 @@ export const phoneCountryPickerTest: TwentyUiGalleryPlayFunction = async ({
expect(disabled).toHaveAttribute('aria-expanded', 'false');
await userEvent.click(primary);
- const japan = await page.findByRole('option', { name: 'Japan (+81)' });
- await waitFor(() => expect(japan).toBeVisible());
+ await waitFor(
+ () =>
+ expect(page.getByRole('option', { name: 'Japan (+81)' })).toBeVisible(),
+ { timeout: INTERACTION_TIMEOUT },
+ );
+ const japan = page.getByRole('option', { name: 'Japan (+81)' });
expect(japan).toBeDisabled();
await userEvent.click(japan);
await waitForSandboxRoundTrip();
@@ -47,16 +52,21 @@ export const phoneCountryPickerTest: TwentyUiGalleryPlayFunction = async ({
});
await userEvent.type(primarySearch, '+966');
await waitFor(() => expect(primarySearch).toHaveValue('+966'));
- const saudiArabia = await page.findByRole('option', {
- name: 'المملكة العربية السعودية (+966)',
- });
- expect(within(saudiArabia).getByText('+966')).toHaveAttribute('dir', 'ltr');
- expect(saudiArabia.closest('[data-phone-options="primary"]')?.tagName).toBe(
- 'SECTION',
- );
- expect(saudiArabia.closest('[data-phone-options="primary"]')).toHaveAttribute(
- 'dir',
- 'rtl',
+ await waitFor(
+ () => {
+ const saudiArabia = page.getByRole('option', {
+ name: 'المملكة العربية السعودية (+966)',
+ });
+ expect(saudiArabia).toBeVisible();
+ expect(within(saudiArabia).getByText('+966')).toHaveAttribute(
+ 'dir',
+ 'ltr',
+ );
+ const options = saudiArabia.closest('[data-phone-options="primary"]');
+ expect(options?.tagName).toBe('SECTION');
+ expect(options).toHaveAttribute('dir', 'rtl');
+ },
+ { timeout: INTERACTION_TIMEOUT },
);
await userEvent.clear(primarySearch);
diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/RoundedLink.tsx b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/RoundedLink.tsx
index 8932ac224a7..e5ac8462e89 100644
--- a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/RoundedLink.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/RoundedLink.tsx
@@ -1,55 +1,16 @@
import { isNonEmptyString } from '@sniptt/guards';
-import { styled } from '@linaria/react';
import { type MouseEvent } from 'react';
import { getSafeUrl } from 'twenty-shared/utils';
-const StyledLink = styled.a`
- align-items: center;
- background-color: var(--t-background-transparent-lighter);
- border: 1px solid var(--t-border-color-strong);
- border-radius: var(--t-border-radius-pill);
- box-sizing: content-box;
- color: var(--t-font-color-primary);
- corner-shape: round;
- cursor: pointer;
- display: inline-flex;
- flex-shrink: 0;
- font-weight: var(--t-font-size-md);
- gap: var(--t-spacing-1);
- height: 10px;
- justify-content: center;
- max-width: calc(100% - 2 * var(--t-spacing-2) - 2px);
- overflow: hidden;
- padding: var(--t-spacing-1) var(--t-spacing-2);
- text-decoration: none;
- text-overflow: ellipsis;
- user-select: none;
- white-space: nowrap;
-
- &[data-color='secondary'] {
- color: var(--t-font-color-secondary);
- }
-
- &:hover {
- background-color: var(--t-background-transparent-light);
- }
-
- &:active {
- background-color: var(--t-background-transparent-medium);
- }
-`;
-
-const StyledLabel = styled.span`
- overflow: hidden;
- text-overflow: ellipsis;
-`;
+import { Chip } from 'twenty-ui/primitives/data-display';
+import { OverflowingTextTooltipModeProvider } from 'twenty-ui/primitives/typography';
type RoundedLinkProps = {
href: string;
label?: string;
color?: 'primary' | 'secondary';
dir?: 'ltr' | 'rtl' | 'auto';
- onClick?: (event: React.MouseEvent<HTMLElement>) => void;
+ onClick?: (event: MouseEvent<HTMLElement>) => void;
className?: string;
};
@@ -71,16 +32,25 @@ export const RoundedLink = ({
};
return (
- <StyledLink
- href={getSafeUrl(href)}
- target="_blank"
- rel="noreferrer"
- dir={dir}
- onClick={handleClick}
- data-color={color}
- className={className}
- >
- <StyledLabel>{label}</StyledLabel>
- </StyledLink>
+ <OverflowingTextTooltipModeProvider mode="disabled">
+ <Chip
+ variant="outline"
+ shape="round"
+ color={color}
+ dir={dir}
+ onClick={handleClick}
+ render={
+ <a
+ href={getSafeUrl(href)}
+ target="_blank"
+ rel="noreferrer"
+ className={className}
+ style={{ flexShrink: 0, justifyContent: 'center' }}
+ />
+ }
+ >
+ <span dir={dir}>{label}</span>
+ </Chip>
+ </OverflowingTextTooltipModeProvider>
);
};
diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__stories__/RoundedLink.interactions.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__stories__/RoundedLink.interactions.stories.tsx
index ab4e70febbb..a918bb6ef3f 100644
--- a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__stories__/RoundedLink.interactions.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__stories__/RoundedLink.interactions.stories.tsx
@@ -3,6 +3,8 @@ import { type MouseEvent } from 'react';
import { expect, fn, userEvent, within } from 'storybook/test';
import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink/RoundedLink';
+import { isDefined } from 'twenty-shared/utils';
+import { Text } from 'twenty-ui/primitives/typography';
import { ComponentDecorator } from 'twenty-ui/testing';
const meta: Meta<typeof RoundedLink> = {
@@ -113,6 +115,7 @@ export const ClickAndKeyboard: Story = {
await expect(link).toHaveClass('caller-link');
await userEvent.tab();
await expect(link).toHaveFocus();
+ await expect(getComputedStyle(link).outlineStyle).toBe('solid');
await userEvent.keyboard('{Enter}');
await expect(handleLinkClick).toHaveBeenCalledTimes(1);
await userEvent.click(link);
@@ -120,3 +123,40 @@ export const ClickAndKeyboard: Story = {
await expect(handleParentClick).not.toHaveBeenCalled();
},
};
+
+const LONG_LINK_LABEL = '[email protected]';
+
+export const BoundedAndDirectional: Story = {
+ render: () => (
+ <Text dir="rtl" style={{ width: 180, fontSize: 15, fontWeight: 500 }}>
+ <RoundedLink
+ href={`mailto:${LONG_LINK_LABEL}`}
+ label={LONG_LINK_LABEL}
+ dir="ltr"
+ />
+ </Text>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const link = canvas.getByRole('link', { name: LONG_LINK_LABEL });
+ const label = canvas.getByText(LONG_LINK_LABEL);
+ const labelContainer = label.parentElement;
+
+ if (!isDefined(labelContainer)) {
+ throw new Error('The link label must have a truncation container');
+ }
+
+ await expect(link).toHaveAttribute('dir', 'ltr');
+ await expect(label).toHaveAttribute('dir', 'ltr');
+ await expect(link.getBoundingClientRect().width).toBe(180);
+ await expect(link.getBoundingClientRect().height).toBe(20);
+ await expect(getComputedStyle(link).fontSize).toBe('15px');
+ await expect(getComputedStyle(link).fontWeight).toBe('500');
+ await expect(getComputedStyle(labelContainer).textOverflow).toBe(
+ 'ellipsis',
+ );
+ await expect(labelContainer.scrollWidth).toBeGreaterThan(
+ labelContainer.clientWidth,
+ );
+ },
+};
diff --git a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__stories__/RoundedLink.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__stories__/RoundedLink.stories.tsx
index 8dc9aac53bd..f0616ae7fc8 100644
--- a/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__stories__/RoundedLink.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/link/components/RoundedLink/__stories__/RoundedLink.stories.tsx
@@ -29,6 +29,10 @@ export const Default: Story = {
await expect(link).toHaveStyle({ color: primaryColor });
await expect(link).toHaveStyle({ 'background-color': backgroundColor });
+ await expect(link.getBoundingClientRect().height).toBe(20);
+ await expect(linkStyle.paddingInlineStart).toBe('8px');
+ await expect(linkStyle.paddingInlineEnd).toBe('8px');
+ await expect(linkStyle.borderTopWidth).toBe('1px');
},
};
diff --git a/packages/twenty-ui/docs/chipPropDescriptions.ts b/packages/twenty-ui/docs/chipPropDescriptions.ts
index 15f437285ab..1b57d7da28f 100644
--- a/packages/twenty-ui/docs/chipPropDescriptions.ts
+++ b/packages/twenty-ui/docs/chipPropDescriptions.ts
@@ -5,7 +5,7 @@ export const CHIP_PROP_DESCRIPTIONS = {
'Caller-owned content. Missing or empty children add no fallback label.',
size: 'Visual size of the chip.',
variant:
- 'Background treatment. Plain has no resting fill or leading padding, with ghost hover and pressed feedback when clickable.',
+ 'Background and border treatment. Outline has a strong border, lighter resting fill and 8px inline padding. Plain has no resting fill or leading padding. Both use ghost hover and pressed feedback when clickable.',
color: 'Primary or secondary text color.',
shape: 'Square or round corners.',
weight: 'Font weight of the content.',
@@ -17,7 +17,7 @@ export const CHIP_PROP_DESCRIPTIONS = {
endElementDivider:
'Adds a divider before `endElement` when that slot has content.',
maxWidth:
- 'Maximum rendered chip width in pixels, including its leading and trailing padding.',
+ 'Maximum rendered chip width in pixels, including its leading and trailing padding and any outline border.',
truncate: 'Truncates overflowing content with an ellipsis. Defaults to true.',
tooltipContent:
'Tooltip text. Defaults to string children. Supply text explicitly for node content.',
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index 8b18ae77ccf..b661ed96aa7 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -11087,7 +11087,7 @@
"type": "number",
"required": false,
"defaultValue": null,
- "description": "Maximum rendered chip width in pixels, including its leading and trailing padding."
+ "description": "Maximum rendered chip width in pixels, including its leading and trailing padding and any outline border."
},
{
"name": "render",
@@ -11147,10 +11147,10 @@
},
{
"name": "variant",
- "type": "\"ghost\" | \"plain\" | \"soft\" | \"solid\"",
+ "type": "\"ghost\" | \"outline\" | \"plain\" | \"soft\" | \"solid\"",
"required": false,
"defaultValue": "ghost",
- "description": "Background treatment. Plain has no resting fill or leading padding, with ghost hover and pressed feedback when clickable."
+ "description": "Background and border treatment. Outline has a strong border, lighter resting fill and 8px inline padding. Plain has no resting fill or leading padding. Both use ghost hover and pressed feedback when clickable."
},
{
"name": "weight",
diff --git a/packages/twenty-ui/src/components/feedback/Toaster/__stories__/Toaster.stories.tsx b/packages/twenty-ui/src/components/feedback/Toaster/__stories__/Toaster.stories.tsx
index c6d66d1d6c9..19231d81957 100644
--- a/packages/twenty-ui/src/components/feedback/Toaster/__stories__/Toaster.stories.tsx
+++ b/packages/twenty-ui/src/components/feedback/Toaster/__stories__/Toaster.stories.tsx
@@ -456,11 +456,11 @@ export const ReopenDuringExit: Story = {
await waitFor(() =>
expect(region.getAnimations({ subtree: true })).toHaveLength(0),
);
+ await waitFor(() => expect(toast).not.toBeInTheDocument());
const restoredToasts = body.getAllByRole('status');
expect(
restoredToasts.slice(0, 2).map((notification) => notification.id),
).toEqual([secondToast.id, thirdToast.id]);
- expect(toast).not.toBeInTheDocument();
expect(restoredToasts[2]?.id).not.toBe(id);
expect(restoredToasts[2]).toHaveTextContent('Already saved');
expect(restoredToasts[2]).toBeVisible();
diff --git a/packages/twenty-ui/src/primitives/data-display/Chip/Chip.module.scss b/packages/twenty-ui/src/primitives/data-display/Chip/Chip.module.scss
index 86f900518c6..2e678e91ae1 100644
--- a/packages/twenty-ui/src/primitives/data-display/Chip/Chip.module.scss
+++ b/packages/twenty-ui/src/primitives/data-display/Chip/Chip.module.scss
@@ -3,17 +3,19 @@
--tw-chip-padding-start: var(--t-spacing-1);
--tw-chip-padding-end: var(--t-spacing-1);
+ --tw-chip-border-width: 0px;
+ --tw-chip-default-max-width: calc(
+ 100% + var(--tw-chip-padding-start) + var(--tw-chip-padding-end)
+ );
box-sizing: content-box;
align-items: center;
display: inline-flex;
gap: var(--t-spacing-1);
- block-size: var(--t-spacing-3);
+ block-size: calc(var(--t-spacing-3) - 2 * var(--tw-chip-border-width));
max-inline-size: calc(
- var(
- --tw-chip-max-width,
- calc(100% + var(--tw-chip-padding-start) + var(--tw-chip-padding-end))
- ) -
- var(--tw-chip-padding-start) - var(--tw-chip-padding-end)
+ var(--tw-chip-max-width, var(--tw-chip-default-max-width)) -
+ var(--tw-chip-padding-start) - var(--tw-chip-padding-end) - 2 *
+ var(--tw-chip-border-width)
);
padding-block: var(--t-spacing-1);
padding-inline: var(--tw-chip-padding-start) var(--tw-chip-padding-end);
@@ -33,7 +35,7 @@
min-inline-size: 0;
}
&[data-size='md'] {
- block-size: var(--t-spacing-4);
+ block-size: calc(var(--t-spacing-4) - 2 * var(--tw-chip-border-width));
}
&[data-shape='round'] {
border-radius: var(--t-border-radius-pill);
@@ -54,6 +56,14 @@
&[data-variant='solid'] {
background: var(--t-background-transparent-medium);
}
+ &[data-variant='outline'] {
+ --tw-chip-padding-start: var(--t-spacing-2);
+ --tw-chip-padding-end: var(--t-spacing-2);
+ --tw-chip-border-width: 1px;
+ --tw-chip-default-max-width: 100%;
+ background: var(--t-background-transparent-lighter);
+ border: var(--tw-chip-border-width) solid var(--t-border-color-strong);
+ }
&:disabled,
&[aria-disabled='true'],
&[data-disabled] {
diff --git a/packages/twenty-ui/src/primitives/data-display/Chip/__stories__/Chip.stories.tsx b/packages/twenty-ui/src/primitives/data-display/Chip/__stories__/Chip.stories.tsx
index 75d6f08d322..7a04228cd6c 100644
--- a/packages/twenty-ui/src/primitives/data-display/Chip/__stories__/Chip.stories.tsx
+++ b/packages/twenty-ui/src/primitives/data-display/Chip/__stories__/Chip.stories.tsx
@@ -89,7 +89,7 @@ export const Catalog: CatalogStory<Story, typeof Chip> = {
dimensions: [
{
name: 'variants',
- values: ['ghost', 'soft', 'solid', 'plain'],
+ values: ['ghost', 'soft', 'solid', 'plain', 'outline'],
props: (variant: ChipVariant) => ({ variant }),
},
{
@@ -127,7 +127,7 @@ export const WithAvatarCatalog: CatalogStory<Story, typeof Chip> = {
dimensions: [
{
name: 'variants',
- values: ['ghost', 'soft', 'solid', 'plain'],
+ values: ['ghost', 'soft', 'solid', 'plain', 'outline'],
props: (variant: ChipVariant) => ({ variant }),
},
{
@@ -202,6 +202,7 @@ export const Disabled: Story = {
decorators: [ComponentDecorator],
args: {
children: 'Unavailable',
+ variant: 'outline',
render: <button type="button" disabled />,
onClick: fn(),
},
@@ -279,6 +280,8 @@ export const ExplicitLink: Story = {
decorators: [ComponentDecorator],
args: {
render: <a href="#chip-link" aria-label="https://twenty.com" />,
+ variant: 'outline',
+ shape: 'round',
children: 'https://twenty.com',
clickable: true,
},
@@ -367,27 +370,90 @@ export const Plain: Story = {
},
};
+export const Outline: Story = {
+ decorators: [ComponentDecorator],
+ args: {
+ children: 'Open outlined chip',
+ variant: 'outline',
+ size: 'md',
+ render: <button type="button" />,
+ onClick: fn(),
+ },
+ play: async ({ canvasElement, args }) => {
+ const chip = within(canvasElement).getByRole('button', {
+ name: 'Open outlined chip',
+ });
+ const chipStyle = getComputedStyle(chip);
+
+ await expect(chip.getBoundingClientRect().height).toBe(24);
+ await expect(chipStyle.paddingInlineStart).toBe('8px');
+ await expect(chipStyle.paddingInlineEnd).toBe('8px');
+ await expect(chipStyle.borderTopWidth).toBe('1px');
+ await expect(chipStyle.borderStyle).toBe('solid');
+ await expect(chip).toHaveStyle({
+ backgroundColor: chipStyle.getPropertyValue(
+ '--t-background-transparent-lighter',
+ ),
+ borderColor: chipStyle.getPropertyValue('--t-border-color-strong'),
+ });
+ await userEvent.tab();
+ await expect(chip).toHaveFocus();
+ await expect(getComputedStyle(chip).outlineStyle).toBe('solid');
+ await userEvent.keyboard('{Enter}');
+ await userEvent.click(chip);
+ await expect(args.onClick).toHaveBeenCalledTimes(2);
+ },
+};
+
+export const OutlineFlexLayout: Story = {
+ decorators: [ComponentDecorator],
+ render: () => (
+ <Text style={{ display: 'flex', width: 160 }}>
+ <Chip
+ variant="outline"
+ maxWidth={120}
+ aria-label="Flexible outline"
+ style={{ minWidth: 0 }}
+ >
+ Long outline label
+ </Chip>
+ <Text style={{ flexShrink: 0, width: 80 }}>Neighbor</Text>
+ </Text>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const chip = canvas.getByLabelText('Flexible outline');
+ const label = canvas.getByText('Long outline label');
+
+ await expect(chip.getBoundingClientRect().width).toBe(80);
+ await expect(chip.getBoundingClientRect().height).toBe(20);
+ await expect(label.scrollWidth).toBeGreaterThan(label.clientWidth);
+ },
+};
+
export const ExactMaximumWidth: Story = {
decorators: [ComponentDecorator],
render: () => (
<Text style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
- {(['ghost', 'soft', 'solid', 'plain'] as const).map((variant) => (
- <Chip
- key={variant}
- variant={variant}
- maxWidth={120}
- aria-label={variant}
- startElement={<Avatar name="Jane" size="sm" />}
- >
- A long label that needs to be truncated
- </Chip>
- ))}
+ {(['ghost', 'soft', 'solid', 'plain', 'outline'] as const).map(
+ (variant) => (
+ <Chip
+ key={variant}
+ variant={variant}
+ maxWidth={120}
+ aria-label={variant}
+ startElement={<Avatar name="Jane" size="sm" />}
+ >
+ A long label that needs to be truncated
+ </Chip>
+ ),
+ )}
</Text>
),
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- for (const variant of ['ghost', 'soft', 'solid', 'plain']) {
+ for (const variant of ['ghost', 'soft', 'solid', 'plain', 'outline']) {
const chip = canvas.getByLabelText(variant);
await expect(chip.getBoundingClientRect().width).toBe(120);
diff --git a/packages/twenty-ui/src/primitives/data-display/Chip/__tests__/Chip.test.tsx b/packages/twenty-ui/src/primitives/data-display/Chip/__tests__/Chip.test.tsx
index a45dbe6f971..09f634af7f6 100644
--- a/packages/twenty-ui/src/primitives/data-display/Chip/__tests__/Chip.test.tsx
+++ b/packages/twenty-ui/src/primitives/data-display/Chip/__tests__/Chip.test.tsx
@@ -71,6 +71,7 @@ describe('Chip content and composition', () => {
render(
<Chip
ref={ref}
+ variant="outline"
render={
<a
href="https://twenty.com"
@@ -88,6 +89,7 @@ describe('Chip content and composition', () => {
const link = screen.getByRole('link', { name: 'Open Twenty' });
expect(ref.current).toBe(link);
+ expect(link).toHaveAttribute('data-variant', 'outline');
expect(link).toHaveAttribute('href', 'https://twenty.com');
expect(link).toHaveAttribute('target', '_blank');
expect(link).toHaveAttribute('title', 'Documentation');
diff --git a/packages/twenty-ui/src/primitives/data-display/Chip/types/ChipVariant.ts b/packages/twenty-ui/src/primitives/data-display/Chip/types/ChipVariant.ts
index 1e68903ccdd..382ba77b2eb 100644
--- a/packages/twenty-ui/src/primitives/data-display/Chip/types/ChipVariant.ts
+++ b/packages/twenty-ui/src/primitives/data-display/Chip/types/ChipVariant.ts
@@ -1 +1 @@
-export type ChipVariant = 'solid' | 'soft' | 'ghost' | 'plain';
+export type ChipVariant = 'solid' | 'soft' | 'ghost' | 'plain' | 'outline';