Skip to content

The open alternative to Salesforce, designed for AI.

Use node slots for icon presentation (#27393)

Raphaël Bosi70bdd4fdc140
diff --git a/packages/twenty-docs/snippets/ui/generated/components/data-display/metric-row.mdx b/packages/twenty-docs/snippets/ui/generated/components/data-display/metric-row.mdx
index 7610b75abca..33e44921ac8 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/data-display/metric-row.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/data-display/metric-row.mdx
@@ -11,8 +11,8 @@
* npx nx generate:ui twenty-docs
*/}
-<ParamField body="children" type="string" required>
- Required nonempty text label that also names the optional progress ring.
+<ParamField body="children" type="ReactNode" required>
+ Label content whose accessible text also names the optional progress ring.
</ParamField>
<ParamField body="className" type="string">
@@ -35,8 +35,8 @@
Replaces the row root element while preserving its contents.
</ParamField>
-<ParamField body="startIcon" type="IconComponent">
- Decorative icon before the label, rendered at 14px.
+<ParamField body="startIcon" type="ReactNode">
+ Decorative node content before the label. The caller controls icon geometry.
</ParamField>
<ParamField body="style" type="CSSProperties">
diff --git a/packages/twenty-docs/snippets/ui/generated/components/data-display/tinted-icon-tile.mdx b/packages/twenty-docs/snippets/ui/generated/components/data-display/tinted-icon-tile.mdx
index 8e4cf3b6d91..f4ca6e48fe7 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/data-display/tinted-icon-tile.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/data-display/tinted-icon-tile.mdx
@@ -11,18 +11,22 @@
* npx nx generate:ui twenty-docs
*/}
+<ParamField body="className" type="string">
+ CSS class applied to the tile root.
+</ParamField>
+
<ParamField body="color" type="string | null" default="gray">
- Theme palette name used to derive the background and icon shades. Invalid names use the default theme color.
+ Theme palette name used to derive the background and foreground shades. Invalid names use the default theme color.
</ParamField>
-<ParamField body="Icon" type="IconComponent" required>
- Icon component rendered inside the tinted tile.
+<ParamField body="icon" type="ReactNode" required>
+ Decorative icon content. The caller controls its dimensions and stroke.
</ParamField>
-<ParamField body="size" type="number">
- Icon and tile dimension in pixels. When omitted, the icon uses the medium theme size.
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
+ Replaces the div root while preserving icon content and native props.
</ParamField>
-<ParamField body="stroke" type="number">
- Icon stroke width. Defaults to the medium theme stroke.
+<ParamField body="style" type="CSSProperties">
+ Inline styles override tile geometry and palette defaults.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/layout/animated-icon-crossfade.mdx b/packages/twenty-docs/snippets/ui/generated/components/layout/animated-icon-crossfade.mdx
index 0b1ef89d5b4..6a226bf55ff 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/layout/animated-icon-crossfade.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/layout/animated-icon-crossfade.mdx
@@ -11,18 +11,26 @@
* npx nx generate:ui twenty-docs
*/}
-<ParamField body="ActiveIcon" type="IconComponent" required>
- Icon component for the active state.
+<ParamField body="activeIcon" type="ReactNode" required>
+ Decorative node content for the active state.
</ParamField>
-<ParamField body="InactiveIcon" type="IconComponent" required>
- Icon component for the inactive state.
+<ParamField body="className" type="string">
+ CSS class applied to the inline span root.
+</ParamField>
+
+<ParamField body="inactiveIcon" type="ReactNode" required>
+ Decorative node content for the inactive state.
</ParamField>
<ParamField body="isActive" type="boolean" required>
- Shows ActiveIcon when true and InactiveIcon otherwise.
+ Shows activeIcon when true and inactiveIcon otherwise.
+</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
+ Replaces the span root while preserving both transition layers.
</ParamField>
-<ParamField body="size" type="number">
- Icon dimension in pixels. Defaults to the small theme icon size.
+<ParamField body="style" type="CSSProperties">
+ Inline styles applied to the root, including width and height.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx
index b2a1b707d06..399c862755d 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/navigation/menu-item-avatar.mdx
@@ -15,7 +15,7 @@
Default, danger, or placeholder row styling.
</ParamField>
-<ParamField body="avatar" type="Pick&lt;AvatarProps, &quot;size&quot; | &quot;name&quot; | &quot;shape&quot; | &quot;src&quot; | &quot;colorSeed&quot;&gt; | null">
+<ParamField body="avatar" type="Pick&lt;AvatarProps, &quot;name&quot; | &quot;size&quot; | &quot;shape&quot; | &quot;src&quot; | &quot;colorSeed&quot;&gt; | null">
Avatar name, source, color seed, size, and shape. Omit to hide the avatar.
</ParamField>
diff --git a/packages/twenty-docs/ui/components/data-display/metric-row.mdx b/packages/twenty-docs/ui/components/data-display/metric-row.mdx
index 2f49f0166d2..e3e019f7e41 100644
--- a/packages/twenty-docs/ui/components/data-display/metric-row.mdx
+++ b/packages/twenty-docs/ui/components/data-display/metric-row.mdx
@@ -23,7 +23,11 @@ import { MetricRow } from 'twenty-ui/components/data-display';
import { IconDatabase } from 'twenty-ui/icon';
export const StorageMetric = () => (
- <MetricRow startIcon={IconDatabase} value="12 / 20 GB" progress={60}>
+ <MetricRow
+ startIcon={<IconDatabase size={14} />}
+ value="12 / 20 GB"
+ progress={60}
+ >
Storage
</MetricRow>
);
@@ -45,7 +49,7 @@ export const CompletedMetric = () => (
## Composition and accessibility
-The required text label names the progress ring. A string value is also exposed as its accessible value text. For formatted value content, supply `progressValueText` when a percentage does not describe the metric fully. This text overrides the string value fallback. Without it, other content keeps the ring's percentage value text. The optional `startIcon` is decorative and renders at 14px.
+Label content accepts nodes. Its accessible text names the progress ring through `aria-labelledby`, including nested text. Provide a meaningful visible label. A string value is also exposed as its accessible value text. For formatted value content, supply `progressValueText` when a percentage does not describe the metric fully. This text overrides the string value fallback. Without it, other content keeps the ring's percentage value text. The optional `startIcon` node is decorative. The caller controls its dimensions and stroke.
```tsx
import { MetricRow } from 'twenty-ui/components/data-display';
@@ -57,11 +61,13 @@ export const FormattedStorageMetric = () => (
progress={60}
progressValueText="12 of 20 gigabytes used"
>
- Storage
+ <Text render={<strong />}>Storage</Text>
</MetricRow>
);
```
+Replace `startIcon={IconDatabase}` with `startIcon={<IconDatabase size={14} />}`. Values stay preformatted by the application.
+
Native attributes, `className`, `style`, and `ref` target the outer row. `render` can replace that element. Progress stays controlled and bounded to 0 to 100, with the same reduced-motion behavior as `ProgressRing`.
## Props
diff --git a/packages/twenty-docs/ui/components/data-display/tinted-icon-tile.mdx b/packages/twenty-docs/ui/components/data-display/tinted-icon-tile.mdx
index f195a01240d..c408ab337f7 100644
--- a/packages/twenty-docs/ui/components/data-display/tinted-icon-tile.mdx
+++ b/packages/twenty-docs/ui/components/data-display/tinted-icon-tile.mdx
@@ -5,7 +5,7 @@ description: An icon on a tinted background derived from a theme color.
import TintedIconTileReference from '/snippets/ui/generated/components/data-display/tinted-icon-tile.mdx';
-Pass an icon component through `Icon`. The tile derives its background and foreground shades from the theme palette. Keep a text label beside it; the tile is not an interactive control.
+Pass icon content through the lowercase `icon` node slot. The tile derives its background and inherited foreground color from the theme palette. Icon content is decorative. Keep a visible label beside it, or give the root `role="img"` and an accessible name for a standalone labeled image.
```tsx
import { TintedIconTile } from 'twenty-ui/components/data-display';
@@ -14,13 +14,38 @@ import { Text } from 'twenty-ui/primitives/typography';
export const CompanyLabel = () => (
<>
- <TintedIconTile Icon={IconBuildingSkyscraper} color="blue" />
+ <TintedIconTile icon={<IconBuildingSkyscraper size={16} />} color="blue" />
<Text>Companies</Text>
</>
);
```
-`size` sets both the icon and tile dimension in pixels. Without it, the tile uses its standard dimensions and the icon uses the medium theme size. `stroke` overrides the icon stroke width.
+## Geometry and native composition
+
+The tile defaults to 16px through the spacing token and uses the small border-radius token. Set icon dimensions and stroke on the node itself. Root `style` or `className` controls tile width, height, border, shape, and colors; explicit styles override palette defaults. Custom artwork should inherit `currentColor` when it uses the palette foreground.
+
+```tsx
+import { TintedIconTile } from 'twenty-ui/components/data-display';
+
+export const CustomCompanyTile = () => (
+ <TintedIconTile
+ icon={
+ <svg width="20" height="20" viewBox="0 0 20 20" fill="currentColor">
+ <path d="M2 2h16v16H2z" />
+ </svg>
+ }
+ color="blue"
+ role="img"
+ aria-label="Companies"
+ render={<span />}
+ style={{ width: 32, height: 32 }}
+ />
+);
+```
+
+Native attributes, events, `className`, `style`, and `ref` target the outer div. `render` replaces that target through Base UI composition while preserving the decorative icon content. Name the surrounding control when composing a tile into an action.
+
+Replace `Icon={CompanyIcon}` with `icon={<CompanyIcon size={16} />}`. Move the former `size` and `stroke` options to the icon node, and use root styles for custom tile dimensions.
## Props
diff --git a/packages/twenty-docs/ui/components/layout/animated-icon-crossfade.mdx b/packages/twenty-docs/ui/components/layout/animated-icon-crossfade.mdx
index bfd4ca96151..be5144de534 100644
--- a/packages/twenty-docs/ui/components/layout/animated-icon-crossfade.mdx
+++ b/packages/twenty-docs/ui/components/layout/animated-icon-crossfade.mdx
@@ -6,7 +6,7 @@ description: Crossfade between two icons as application state changes.
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import AnimatedIconCrossfadeReference from '/snippets/ui/generated/components/layout/animated-icon-crossfade.mdx';
-`AnimatedIconCrossfade` displays one of two icon components according to `isActive`. It does not own the action or state. Compose it inside a labeled [Button](/ui/primitives/input/button).
+`AnimatedIconCrossfade` crossfades between `activeIcon` and `inactiveIcon` node content according to `isActive`. It does not own the action or state. Compose it inside a labeled [Button](/ui/primitives/input/button).
```tsx
import { useState } from 'react';
@@ -23,8 +23,8 @@ export const EditToggle = () => {
startIcon={
<AnimatedIconCrossfade
isActive={isEditing}
- ActiveIcon={IconX}
- InactiveIcon={IconPencil}
+ activeIcon={<IconX size={14} />}
+ inactiveIcon={<IconPencil size={14} />}
/>
}
>
@@ -34,7 +34,11 @@ export const EditToggle = () => {
};
```
-`size` defaults to the small theme icon size. Keep the accessible action name on the surrounding control. The icons communicate its state visually.
+Both nodes stay mounted as `isActive` changes, preserving their local state. The layers animate opacity and scale, and disable transitions for reduced motion. Both layers are decorative; keep the accessible action name on the surrounding control. For a standalone labeled image, set `role="img"` and `aria-label` on the root.
+
+Native attributes, events, `className`, `style`, and `ref` target an inline span, which can sit inside a button. `render` replaces that target through Base UI composition. The root dimensions default to the small icon theme token. Size each icon node explicitly, and use root width and height styles for larger artwork.
+
+Replace `ActiveIcon` and `InactiveIcon` constructors with lowercase `activeIcon` and `inactiveIcon` nodes. Move the former `size` option to the node dimensions and root styles.
<StoryEmbed
storyId="ui-components-layout-animatediconcrossfade--animated-icon-documentation"
diff --git a/packages/twenty-docs/ui/primitives/input/button.mdx b/packages/twenty-docs/ui/primitives/input/button.mdx
index e5beb23f6c6..a7c257b7004 100644
--- a/packages/twenty-docs/ui/primitives/input/button.mdx
+++ b/packages/twenty-docs/ui/primitives/input/button.mdx
@@ -124,8 +124,8 @@ export const EditActions = () => {
startIcon={
<AnimatedIconCrossfade
isActive={isEditing}
- ActiveIcon={IconX}
- InactiveIcon={IconPencil}
+ activeIcon={<IconX size={14} />}
+ inactiveIcon={<IconPencil size={14} />}
/>
}
>
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 68e970bebbd..e6430d60a3f 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -10,6 +10,8 @@ import { overflowingListPopupTest } from '@/__stories__/twenty-ui-gallery/utils/
import { jsonTreeTest } from '@/__stories__/twenty-ui-gallery/utils/jsonTreeTest';
import { inlineBannerTest } from '@/__stories__/twenty-ui-gallery/utils/inlineBannerTest';
import { themeTokenTest } from '@/__stories__/twenty-ui-gallery/utils/themeTokenTest';
+import { tintedIconTileTest } from '@/__stories__/twenty-ui-gallery/utils/tintedIconTileTest';
+import { animatedIconCrossfadeTest } from '@/__stories__/twenty-ui-gallery/utils/animatedIconCrossfadeTest';
import { progressTest } from '@/__stories__/twenty-ui-gallery/utils/progressTest';
import { inputTest } from '@/__stories__/twenty-ui-gallery/utils/inputTest';
import { numberStepperTest } from '@/__stories__/twenty-ui-gallery/utils/numberStepperTest';
@@ -684,3 +686,27 @@ export const CurrencyPickerPreact: Story = createGalleryStory({
runtime: 'preact',
play: currencyPickerTest,
});
+
+export const TintedIconTileReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-data-display-gallery',
+ runtime: 'react',
+ play: tintedIconTileTest,
+});
+
+export const TintedIconTilePreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-data-display-gallery',
+ runtime: 'preact',
+ play: tintedIconTileTest,
+});
+
+export const AnimatedIconCrossfadeReact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-layout-gallery',
+ runtime: 'react',
+ play: animatedIconCrossfadeTest,
+});
+
+export const AnimatedIconCrossfadePreact: Story = createGalleryStory({
+ frontComponentBundleName: 'twenty-ui-layout-gallery',
+ runtime: 'preact',
+ play: animatedIconCrossfadeTest,
+});
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/animated-icon-crossfade-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/animated-icon-crossfade-example.tsx
new file mode 100644
index 00000000000..3f7e48aa9b4
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/animated-icon-crossfade-example.tsx
@@ -0,0 +1,54 @@
+import { createElement, useRef, useState } from 'react';
+import { AnimatedIconCrossfade } from 'twenty-ui/components/layout';
+import { Button } from 'twenty-ui/primitives/input';
+
+export const AnimatedIconCrossfadeExample = () => {
+ const iconRef = useRef<HTMLSpanElement>(null);
+ const [isActive, setIsActive] = useState(false);
+ const [target, setTarget] = useState('Uninspected');
+
+ return (
+ <>
+ <AnimatedIconCrossfade
+ ref={iconRef}
+ isActive={isActive}
+ activeIcon={
+ <svg
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ data-testid="active-artwork"
+ >
+ <circle cx="8" cy="8" r="6" fill="currentColor" />
+ </svg>
+ }
+ inactiveIcon={
+ <svg
+ width="16"
+ height="16"
+ viewBox="0 0 16 16"
+ data-testid="inactive-artwork"
+ >
+ <path d="M2 2h12v12H2z" fill="currentColor" />
+ </svg>
+ }
+ role="img"
+ aria-label={isActive ? 'Selection active' : 'Selection inactive'}
+ className="custom-crossfade"
+ style={{ width: 16, height: 16 }}
+ render={(props) =>
+ createElement('span', { ...props, 'data-composed': 'crossfade' })
+ }
+ />
+ <Button
+ onClick={() => {
+ setIsActive(!isActive);
+ setTarget(iconRef.current?.tagName ?? 'Missing');
+ }}
+ >
+ Toggle selection
+ </Button>
+ <output aria-label="Crossfade target">{target}</output>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tinted-icon-tile-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tinted-icon-tile-example.tsx
new file mode 100644
index 00000000000..e4879f74762
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/tinted-icon-tile-example.tsx
@@ -0,0 +1,40 @@
+import { useRef, useState } from 'react';
+import { TintedIconTile } from 'twenty-ui/components/data-display';
+import { IconStar } from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
+
+export const TintedIconTileExample = () => {
+ const tileRef = useRef<HTMLDivElement>(null);
+ const [target, setTarget] = useState('Uninspected');
+
+ return (
+ <>
+ <TintedIconTile icon={<IconStar size={16} />} />
+ <TintedIconTile
+ ref={tileRef}
+ icon={
+ <svg
+ width="20"
+ height="20"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ role="img"
+ aria-label="Internal artwork"
+ >
+ <path d="M2 2h16v16H2z" />
+ </svg>
+ }
+ color="blue"
+ role="img"
+ aria-label="Custom company tile"
+ className="custom-tile"
+ style={{ width: 32, height: 32 }}
+ render={<span data-composed="tile" />}
+ />
+ <Button onClick={() => setTarget(tileRef.current?.tagName ?? 'Missing')}>
+ Inspect tile
+ </Button>
+ <output aria-label="Tile target">{target}</output>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-controls.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-controls.front-component.tsx
index a1bb6334751..33e0940da71 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-controls.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-button-controls.front-component.tsx
@@ -27,8 +27,8 @@ const ButtonControls = () => {
startIcon={
<AnimatedIconCrossfade
isActive={isEditing}
- ActiveIcon={IconX}
- InactiveIcon={IconPencil}
+ activeIcon={<IconX size={14} />}
+ inactiveIcon={<IconPencil size={14} />}
/>
}
>
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 1c1afffc70f..f22187d7873 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
@@ -3,9 +3,10 @@ import {
AvatarGroup,
CommandBlock,
NotificationCounter,
- TintedIconTile,
} from 'twenty-ui/components/data-display';
import { IconStar } from 'twenty-ui/icon';
+
+import { TintedIconTileExample } from './tinted-icon-tile-example';
import {
Avatar,
Chip,
@@ -98,7 +99,7 @@ const DATA_DISPLAY_ENTRIES: GalleryEntry[] = [
},
{
name: 'TintedIconTile',
- node: <TintedIconTile Icon={IconStar} />,
+ node: <TintedIconTileExample />,
},
];
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-layout-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-layout-gallery.front-component.tsx
index 18aa4aa88f3..2894c76379a 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-layout-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-layout-gallery.front-component.tsx
@@ -1,11 +1,10 @@
import { defineFrontComponent } from 'twenty-sdk/define';
import 'twenty-ui/style.css';
-import { AnimatedIconCrossfade } from 'twenty-ui/components/layout';
-import { IconHeart, IconStar } from 'twenty-ui/icon';
import { Collapsible } from 'twenty-ui/primitives/layout';
import { ThemeProvider } from 'twenty-ui/theme';
import { SeparatorExample } from './separator-example';
import { ResizeHandleExample } from './resize-handle-example';
+import { AnimatedIconCrossfadeExample } from './animated-icon-crossfade-example';
import {
ComponentGallery,
@@ -19,14 +18,7 @@ const LAYOUT_ENTRIES: GalleryEntry[] = [
},
{
name: 'AnimatedIconCrossfade',
- node: (
- <AnimatedIconCrossfade
- isActive={true}
- ActiveIcon={IconStar}
- InactiveIcon={IconHeart}
- size={16}
- />
- ),
+ node: <AnimatedIconCrossfadeExample />,
},
{
name: 'Separator',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-progress.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-progress.front-component.tsx
index a8485c416f0..9efa91ccfb3 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-progress.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-progress.front-component.tsx
@@ -21,12 +21,12 @@ const ProgressExample = () => {
{progress} / 100
</ProgressRing>
<MetricRow
- startIcon={IconDatabase}
+ startIcon={<IconDatabase size={14} />}
value={<Text render={<bdi />}>{progress} / 100 GB</Text>}
progress={progress}
progressValueText={`${progress} of 100 gigabytes used`}
>
- Storage
+ <Text render={<strong />}>Storage</Text>
</MetricRow>
<MetricRow value={0}>Completed imports</MetricRow>
<ProgressRing value={-10} size="sm" aria-label="Empty progress" />
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/animatedIconCrossfadeTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/animatedIconCrossfadeTest.ts
new file mode 100644
index 00000000000..289935ac00f
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/animatedIconCrossfadeTest.ts
@@ -0,0 +1,43 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+import { galleryRenderTest } from '@/__stories__/twenty-ui-gallery/utils/galleryRenderTests';
+
+export const animatedIconCrossfadeTest: TwentyUiGalleryPlayFunction = async (
+ context,
+) => {
+ await galleryRenderTest(context);
+ const canvas = within(context.canvasElement);
+ const icon = canvas.getByRole('img', { name: 'Selection inactive' });
+ const active = canvas.getByTestId('active-artwork');
+ const inactive = canvas.getByTestId('inactive-artwork');
+ expect(icon).toHaveClass('custom-crossfade');
+ expect(icon).toHaveAttribute('data-composed', 'crossfade');
+ expect(icon.getBoundingClientRect().width).toBe(16);
+ expect(icon.getBoundingClientRect().height).toBe(16);
+ await waitFor(() => {
+ expect(getComputedStyle(active.parentElement!).opacity).toBe('0');
+ expect(getComputedStyle(inactive.parentElement!).opacity).toBe('1');
+ });
+
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Toggle selection' }),
+ );
+ await waitFor(() => {
+ expect(icon).toHaveAccessibleName('Selection active');
+ expect(getComputedStyle(active.parentElement!).opacity).toBe('1');
+ expect(getComputedStyle(inactive.parentElement!).opacity).toBe('0');
+ expect(canvas.getByLabelText('Crossfade target')).toHaveTextContent('SPAN');
+ });
+ expect(canvas.getByTestId('active-artwork')).toBe(active);
+ expect(canvas.getByTestId('inactive-artwork')).toBe(inactive);
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Toggle selection' }),
+ );
+ await waitFor(() => {
+ expect(icon).toHaveAccessibleName('Selection inactive');
+ expect(getComputedStyle(inactive.parentElement!).opacity).toBe('1');
+ });
+ expect(errorHandler).not.toHaveBeenCalled();
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tintedIconTileTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tintedIconTileTest.ts
new file mode 100644
index 00000000000..d815b8cde1f
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/tintedIconTileTest.ts
@@ -0,0 +1,24 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+import { galleryRenderTest } from '@/__stories__/twenty-ui-gallery/utils/galleryRenderTests';
+
+export const tintedIconTileTest: TwentyUiGalleryPlayFunction = async (
+ context,
+) => {
+ await galleryRenderTest(context);
+ const canvas = within(context.canvasElement);
+ const tile = canvas.getByRole('img', { name: 'Custom company tile' });
+ expect(tile).toHaveClass('custom-tile');
+ expect(tile).toHaveAttribute('data-composed', 'tile');
+ expect(tile.getBoundingClientRect().width).toBe(32);
+ expect(tile.getBoundingClientRect().height).toBe(32);
+ expect(tile.querySelector('svg')!.getBoundingClientRect().width).toBe(20);
+ expect(canvas.queryByRole('img', { name: 'Internal artwork' })).toBeNull();
+ await userEvent.click(canvas.getByRole('button', { name: 'Inspect tile' }));
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Tile target')).toHaveTextContent('SPAN'),
+ );
+ expect(errorHandler).not.toHaveBeenCalled();
+};
diff --git a/packages/twenty-front/src/modules/ai/components/AiModelTierInformationButton.tsx b/packages/twenty-front/src/modules/ai/components/AiModelTierInformationButton.tsx
index 37f2c78d708..fd65b993e11 100644
--- a/packages/twenty-front/src/modules/ai/components/AiModelTierInformationButton.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiModelTierInformationButton.tsx
@@ -13,7 +13,11 @@ import {
} from 'twenty-ui/icon';
import { Separator } from 'twenty-ui/primitives/layout';
import { MetricRow } from 'twenty-ui/components/data-display';
-import { themeCssVariables, useThemeContainer } from 'twenty-ui/theme';
+import {
+ themeCssVariables,
+ useTheme,
+ useThemeContainer,
+} from 'twenty-ui/theme';
import { useAiChatHoverCard } from '@/ai/hooks/useAiChatHoverCard';
import { type ResolvedAiModelTier } from '@/ai/types/ResolvedAiModelTier';
@@ -65,6 +69,7 @@ export const AiModelTierInformationButton = ({
resolvedTier,
}: AiModelTierInformationButtonProps) => {
const { t } = useLingui();
+ const theme = useTheme();
const themeContainer = useThemeContainer();
@@ -129,7 +134,7 @@ export const AiModelTierInformationButton = ({
// oxlint-disable-next-line react/jsx-props-no-spreading
{...getReferenceProps()}
>
- <IconInfoCircle size={14} />
+ <IconInfoCircle size={theme.icon.size.sm} />
</StyledTrigger>
{isOpen && (
<FloatingPortal root={themeContainer}>
@@ -140,14 +145,22 @@ export const AiModelTierInformationButton = ({
{...getFloatingProps()}
>
{rows.map(({ label, Icon, value }) => (
- <MetricRow key={label} startIcon={Icon} value={value}>
+ <MetricRow
+ key={label}
+ startIcon={<Icon size={theme.icon.size.sm} />}
+ value={value}
+ >
{label}
</MetricRow>
))}
<Separator />
<StyledHeading>{t`Vs Balanced mode`}</StyledHeading>
{comparisons.map(({ label, Icon, value }) => (
- <MetricRow key={label} startIcon={Icon} value={value}>
+ <MetricRow
+ key={label}
+ startIcon={<Icon size={theme.icon.size.sm} />}
+ value={value}
+ >
{label}
</MetricRow>
))}
diff --git a/packages/twenty-front/src/modules/ai/components/internal/AiChatContextUsageButton.tsx b/packages/twenty-front/src/modules/ai/components/internal/AiChatContextUsageButton.tsx
index b2e523db754..9646c856fe4 100644
--- a/packages/twenty-front/src/modules/ai/components/internal/AiChatContextUsageButton.tsx
+++ b/packages/twenty-front/src/modules/ai/components/internal/AiChatContextUsageButton.tsx
@@ -11,7 +11,7 @@ import { ProgressRing } from 'twenty-ui/primitives/feedback';
import { Button } from 'twenty-ui/primitives/input';
import { IconWindow, IconGauge } from 'twenty-ui/icon';
import { Separator } from 'twenty-ui/primitives/layout';
-import { themeCssVariables } from 'twenty-ui/theme';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
import { AiChatContextUsageDetails } from '@/ai/components/internal/AiChatContextUsageDetails';
import { useAiChatHoverCard } from '@/ai/hooks/useAiChatHoverCard';
@@ -57,6 +57,7 @@ const StyledFooter = styled.div`
export const AiChatContextUsageButton = () => {
const { t } = useLingui();
+ const theme = useTheme();
const shouldReduceMotion = useReducedMotion();
@@ -192,7 +193,7 @@ export const AiChatContextUsageButton = () => {
{...getFloatingProps()}
>
<MetricRow
- startIcon={IconWindow}
+ startIcon={<IconWindow size={theme.icon.size.sm} />}
progress={percentage}
value={
contextWindow > 0
@@ -210,7 +211,7 @@ export const AiChatContextUsageButton = () => {
</MetricRow>
{!isWorkspaceSetupChat && (
<MetricRow
- startIcon={IconGauge}
+ startIcon={<IconGauge size={theme.icon.size.sm} />}
progress={
loading || isDefined(error) ? 0 : (creditPercentage ?? 0)
}
diff --git a/packages/twenty-front/src/modules/ai/components/internal/AiChatContextUsageDetails.tsx b/packages/twenty-front/src/modules/ai/components/internal/AiChatContextUsageDetails.tsx
index 05002f17b59..5e2cfe068ea 100644
--- a/packages/twenty-front/src/modules/ai/components/internal/AiChatContextUsageDetails.tsx
+++ b/packages/twenty-front/src/modules/ai/components/internal/AiChatContextUsageDetails.tsx
@@ -10,7 +10,7 @@ import {
IconCoins,
IconHistory,
} from 'twenty-ui/icon';
-import { themeCssVariables } from 'twenty-ui/theme';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
import { agentChatUsageComponentFamilyState } from '@/ai/states/agentChatUsageComponentFamilyState';
import { currentAiChatThreadState } from '@/ai/states/currentAiChatThreadState';
@@ -35,6 +35,7 @@ const StyledSectionTitle = styled.span`
export const AiChatContextUsageDetails = () => {
const { t } = useLingui();
+ const theme = useTheme();
const currentAiChatThread = useAtomStateValue(currentAiChatThreadState);
const agentChatUsage = useAtomComponentFamilyStateValue(
agentChatUsageComponentFamilyState,
@@ -54,25 +55,25 @@ export const AiChatContextUsageDetails = () => {
<StyledSection>
<StyledSectionTitle>{t`Last message`}</StyledSectionTitle>
<MetricRow
- startIcon={IconArrowUp}
+ startIcon={<IconArrowUp size={theme.icon.size.sm} />}
value={formatAiChatTokens(lastMessage.inputTokens)}
>
{t`Input tokens`}
</MetricRow>
<MetricRow
- startIcon={IconHistory}
+ startIcon={<IconHistory size={theme.icon.size.sm} />}
value={formatAiChatTokens(lastMessage.cachedInputTokens)}
>
{t`Cached input`}
</MetricRow>
<MetricRow
- startIcon={IconArrowDown}
+ startIcon={<IconArrowDown size={theme.icon.size.sm} />}
value={formatAiChatTokens(lastMessage.outputTokens)}
>
{t`Output tokens`}
</MetricRow>
<MetricRow
- startIcon={IconCoins}
+ startIcon={<IconCoins size={theme.icon.size.sm} />}
value={formatNumber(
lastMessage.inputCredits + lastMessage.outputCredits,
{ decimals: 3 },
@@ -87,25 +88,25 @@ export const AiChatContextUsageDetails = () => {
<StyledSection>
<StyledSectionTitle>{t`Conversation`}</StyledSectionTitle>
<MetricRow
- startIcon={IconArrowUp}
+ startIcon={<IconArrowUp size={theme.icon.size.sm} />}
value={formatAiChatTokens(agentChatUsage.inputTokens)}
>
{t`Input tokens`}
</MetricRow>
<MetricRow
- startIcon={IconHistory}
+ startIcon={<IconHistory size={theme.icon.size.sm} />}
value={formatAiChatTokens(agentChatUsage.cachedInputTokens)}
>
{t`Cached input`}
</MetricRow>
<MetricRow
- startIcon={IconArrowDown}
+ startIcon={<IconArrowDown size={theme.icon.size.sm} />}
value={formatAiChatTokens(agentChatUsage.outputTokens)}
>
{t`Output tokens`}
</MetricRow>
<MetricRow
- startIcon={IconCoins}
+ startIcon={<IconCoins size={theme.icon.size.sm} />}
value={formatNumber(
agentChatUsage.inputCredits + agentChatUsage.outputCredits,
{ decimals: 3 },
diff --git a/packages/twenty-front/src/modules/command-menu-item/edit/components/CommandMenuItemEditButton.tsx b/packages/twenty-front/src/modules/command-menu-item/edit/components/CommandMenuItemEditButton.tsx
index 38aa0542720..deb69969559 100644
--- a/packages/twenty-front/src/modules/command-menu-item/edit/components/CommandMenuItemEditButton.tsx
+++ b/packages/twenty-front/src/modules/command-menu-item/edit/components/CommandMenuItemEditButton.tsx
@@ -9,9 +9,11 @@ import { SidePanelPages } from 'twenty-shared/types';
import { AnimatedIconCrossfade } from 'twenty-ui/components/layout';
import { IconPencil, IconX } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
+import { useTheme } from 'twenty-ui/theme';
export const CommandMenuItemEditButton = () => {
const { t } = useLingui();
+ const theme = useTheme();
const { navigateSidePanel } = useNavigateSidePanel();
const { closeSidePanelMenu } = useSidePanelMenu();
@@ -48,8 +50,8 @@ export const CommandMenuItemEditButton = () => {
startIcon={
<AnimatedIconCrossfade
isActive={isCommandMenuEditPageActive}
- ActiveIcon={IconX}
- InactiveIcon={IconPencil}
+ activeIcon={<IconX size={theme.icon.size.sm} />}
+ inactiveIcon={<IconPencil size={theme.icon.size.sm} />}
/>
}
variant="outline"
diff --git a/packages/twenty-front/src/modules/navigation-menu-item/edit/hooks/useNavigationMenuItemAddOptions.tsx b/packages/twenty-front/src/modules/navigation-menu-item/edit/hooks/useNavigationMenuItemAddOptions.tsx
index 1abf551491b..197b34563e9 100644
--- a/packages/twenty-front/src/modules/navigation-menu-item/edit/hooks/useNavigationMenuItemAddOptions.tsx
+++ b/packages/twenty-front/src/modules/navigation-menu-item/edit/hooks/useNavigationMenuItemAddOptions.tsx
@@ -13,6 +13,7 @@ import {
useIcons,
} from 'twenty-ui/icon';
import { Avatar } from 'twenty-ui/primitives/data-display';
+import { useTheme } from 'twenty-ui/theme';
import {
FindAllStandalonePageLayoutsDocument,
type NavigationMenuItem,
@@ -62,6 +63,7 @@ export const useNavigationMenuItemAddOptions = ({
selectObject,
}: UseNavigationMenuItemAddOptionsParams) => {
const { t } = useLingui();
+ const theme = useTheme();
const { getIcon } = useIcons();
const {
@@ -115,14 +117,16 @@ export const useNavigationMenuItemAddOptions = ({
{
id: 'object',
label: t`Object`,
- icon: <TintedIconTile Icon={IconBox} />,
+ icon: <TintedIconTile icon={<IconBox size={theme.icon.size.md} />} />,
onClick: () => navigateToStep('object'),
hasSubMenu: true,
},
{
id: 'view',
label: t`View`,
- icon: <TintedIconTile Icon={IconTable} />,
+ icon: (
+ <TintedIconTile icon={<IconTable size={theme.icon.size.md} />} />
+ ),
onClick: () => navigateToStep('view'),
hasSubMenu: true,
},
@@ -176,7 +180,11 @@ export const useNavigationMenuItemAddOptions = ({
{
id: 'page',
label: t`Page`,
- icon: <TintedIconTile Icon={IconPerspective} />,
+ icon: (
+ <TintedIconTile
+ icon={<IconPerspective size={theme.icon.size.md} />}
+ />
+ ),
onClick: () => navigateToStep('page'),
hasSubMenu: true,
},
@@ -255,7 +263,7 @@ export const useNavigationMenuItemAddOptions = ({
return {
id: view.id,
label: view.name,
- icon: <TintedIconTile Icon={Icon} />,
+ icon: <TintedIconTile icon={<Icon size={theme.icon.size.md} />} />,
isDisabled: viewIdsAlreadyAdded.has(view.id),
isAlreadyInSidebar: viewIdsAlreadyAdded.has(view.id),
onClick: () =>
@@ -289,7 +297,9 @@ export const useNavigationMenuItemAddOptions = ({
icon: isDefined(navigationItem) ? (
<NavigationMenuItemIcon navigationMenuItem={navigationItem} />
) : (
- <TintedIconTile Icon={IconPerspective} />
+ <TintedIconTile
+ icon={<IconPerspective size={theme.icon.size.md} />}
+ />
),
isDisabled: pageLayoutIdsAlreadyAdded.has(page.id),
isAlreadyInSidebar: pageLayoutIdsAlreadyAdded.has(page.id),
diff --git a/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPopoverContent.tsx b/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPopoverContent.tsx
index fde8f965b18..6cb5f4cecad 100644
--- a/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPopoverContent.tsx
+++ b/packages/twenty-front/src/modules/onboarding/components/free-credits/OnboardingFreeCreditsPopoverContent.tsx
@@ -101,7 +101,7 @@ export const OnboardingFreeCreditsPopoverContent = ({
<StyledSection>
<StyledSectionTitle>{t`Free credits`}</StyledSectionTitle>
<MetricRow
- startIcon={IconCoins}
+ startIcon={<IconCoins size={theme.icon.size.sm} />}
value={plural(earnedCredits, {
one: `${formattedEarnedCredits} credit`,
other: `${formattedEarnedCredits} credits`,
@@ -115,19 +115,23 @@ export const OnboardingFreeCreditsPopoverContent = ({
<Separator />
<StyledSection>
<StyledSectionTitle>{t`Breakdown`}</StyledSectionTitle>
- {earnedCreditsByStep.map(({ step, credits, rewardCredits }) => (
- <MetricRow
- key={step}
- startIcon={creditsSteps[step].Icon}
- value={
- credits < rewardCredits
- ? `${formatOnboardingCredits(credits, numberFormat)}/${formatOnboardingCredits(rewardCredits, numberFormat)}`
- : formatOnboardingCredits(credits, numberFormat)
- }
- >
- {creditsSteps[step].label}
- </MetricRow>
- ))}
+ {earnedCreditsByStep.map(({ step, credits, rewardCredits }) => {
+ const { Icon } = creditsSteps[step];
+
+ return (
+ <MetricRow
+ key={step}
+ startIcon={<Icon size={theme.icon.size.sm} />}
+ value={
+ credits < rewardCredits
+ ? `${formatOnboardingCredits(credits, numberFormat)}/${formatOnboardingCredits(rewardCredits, numberFormat)}`
+ : formatOnboardingCredits(credits, numberFormat)
+ }
+ >
+ {creditsSteps[step].label}
+ </MetricRow>
+ );
+ })}
</StyledSection>
</>
)}
@@ -138,20 +142,26 @@ export const OnboardingFreeCreditsPopoverContent = ({
? t`Enough for one of these on average`
: t`1 credit is enough for one of these on average`}
</StyledSectionTitle>
- <MetricRow startIcon={IconSparkles} value={formatNumber(aiActions)}>
+ <MetricRow
+ startIcon={<IconSparkles size={theme.icon.size.sm} />}
+ value={formatNumber(aiActions)}
+ >
{t`AI actions`}
</MetricRow>
<MetricRow
- startIcon={IconSettingsAutomation}
+ startIcon={<IconSettingsAutomation size={theme.icon.size.sm} />}
value={formatNumber(workflowSteps)}
>
{t`Workflow steps`}
</MetricRow>
- <MetricRow startIcon={IconWand} value={formatNumber(enrichments)}>
+ <MetricRow
+ startIcon={<IconWand size={theme.icon.size.sm} />}
+ value={formatNumber(enrichments)}
+ >
{t`Enrichments`}
</MetricRow>
<MetricRow
- startIcon={IconVideo}
+ startIcon={<IconVideo size={theme.icon.size.sm} />}
value={plural(callRecordingHours, {
one: `${formattedCallRecordingHours} hour`,
other: `${formattedCallRecordingHours} hours`,
@@ -159,7 +169,10 @@ export const OnboardingFreeCreditsPopoverContent = ({
>
{t`Call recording`}
</MetricRow>
- <MetricRow startIcon={IconMail} value={formatNumber(emailsSent)}>
+ <MetricRow
+ startIcon={<IconMail size={theme.icon.size.sm} />}
+ value={formatNumber(emailsSent)}
+ >
{t`Shared inbox emails`}
</MetricRow>
</StyledSection>
diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx
index 16949c62356..a6c00393cfd 100644
--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx
+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelObjectFilterDropdownContent.tsx
@@ -10,7 +10,7 @@ import { TintedIconTile } from 'twenty-ui/components/data-display';
import { Dropdown } from 'twenty-ui/components/navigation';
import { SettingsRow } from 'twenty-ui/components/settings';
import { IconCube } from 'twenty-ui/icon';
-import { themeCssVariables } from 'twenty-ui/theme';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme';
const StyledHeader = styled.div`
border-bottom: 1px solid ${themeCssVariables.border.color.light};
@@ -30,6 +30,7 @@ export const SidePanelObjectFilterDropdownContent = ({
onSelectObject,
}: SidePanelObjectFilterDropdownContentProps) => {
const { t } = useLingui();
+ const theme = useTheme();
const [filterSearch, setFilterSearch] = useState('');
const [sidePanelShowHiddenObjects, setSidePanelShowHiddenObjects] =
useAtomState(sidePanelShowHiddenObjectsState);
@@ -74,7 +75,9 @@ export const SidePanelObjectFilterDropdownContent = ({
<Dropdown.OptionItem
onSelect={() => onSelectObject(null)}
selected={selectedObjectNameSingular === null}
- startIcon={<TintedIconTile Icon={IconCube} />}
+ startIcon={
+ <TintedIconTile icon={<IconCube size={theme.icon.size.md} />} />
+ }
>
{allObjectsLabel}
</Dropdown.OptionItem>
diff --git a/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockPage.tsx b/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockPage.tsx
index bb14264af37..b8df728f36b 100644
--- a/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockPage.tsx
+++ b/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockPage.tsx
@@ -9,6 +9,7 @@ import {
IconPlus,
} from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
+import { useTheme } from 'twenty-ui/theme';
import { BackgroundMockTable } from '@/sign-in-background-mock/components/BackgroundMockTable';
import { BackgroundMockViewBar } from '@/sign-in-background-mock/components/BackgroundMockViewBar';
@@ -25,11 +26,18 @@ const StyledTableContainer = styled.div`
`;
export const BackgroundMockPage = () => {
+ const theme = useTheme();
+
return (
<PageCardLayout
header={
<PageCardHeader
- icon={<TintedIconTile Icon={IconBuildingSkyscraper} color="blue" />}
+ icon={
+ <TintedIconTile
+ icon={<IconBuildingSkyscraper size={theme.icon.size.md} />}
+ color="blue"
+ />
+ }
title={t`Companies`}
actionButton={
<>
diff --git a/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockViewBar.tsx b/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockViewBar.tsx
index 35173b232a4..f6f5caa8ed9 100644
--- a/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockViewBar.tsx
+++ b/packages/twenty-front/src/modules/sign-in-background-mock/components/BackgroundMockViewBar.tsx
@@ -36,7 +36,10 @@ export const BackgroundMockViewBar = () => {
<TopBar
leftComponent={
<StyledViewPicker>
- <TintedIconTile Icon={IconBuildingSkyscraper} color="blue" />
+ <TintedIconTile
+ icon={<IconBuildingSkyscraper size={theme.icon.size.md} />}
+ color="blue"
+ />
<span>All Companies</span>
<StyledViewPickerCount>· 599</StyledViewPickerCount>
<IconChevronDown
diff --git a/packages/twenty-front/src/modules/ui/input/components/MultiSelectControl.tsx b/packages/twenty-front/src/modules/ui/input/components/MultiSelectControl.tsx
index b99b3cbd56a..85777d5ddae 100644
--- a/packages/twenty-front/src/modules/ui/input/components/MultiSelectControl.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/MultiSelectControl.tsx
@@ -60,10 +60,14 @@ export const MultiSelectControl = ({
) : isDefined(firstSelectedOption?.Icon) ? (
isDefined(firstSelectedOption.iconThemeColor) ? (
<TintedIconTile
- Icon={firstSelectedOption.Icon}
+ icon={
+ <firstSelectedOption.Icon
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ }
color={firstSelectedOption.iconThemeColor}
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
+ style={{ width: theme.icon.size.md, height: theme.icon.size.md }}
/>
) : (
<firstSelectedOption.Icon
diff --git a/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx b/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx
index 5fd44487036..e36474a2a86 100644
--- a/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/SelectControl.tsx
@@ -147,10 +147,17 @@ export const SelectControl = ({
{isDefined(selectedOption?.Icon) ? (
isDefined(selectedOption.iconThemeColor) ? (
<TintedIconTile
- Icon={selectedOption.Icon}
+ icon={
+ <selectedOption.Icon
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ }
color={selectedOption.iconThemeColor}
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
+ style={{
+ width: theme.icon.size.md,
+ height: theme.icon.size.md,
+ }}
/>
) : (
<selectedOption.Icon
diff --git a/packages/twenty-front/src/modules/ui/input/components/SelectOptionIcon.tsx b/packages/twenty-front/src/modules/ui/input/components/SelectOptionIcon.tsx
index 1e3a869c70b..f47cd0d9662 100644
--- a/packages/twenty-front/src/modules/ui/input/components/SelectOptionIcon.tsx
+++ b/packages/twenty-front/src/modules/ui/input/components/SelectOptionIcon.tsx
@@ -18,10 +18,9 @@ export const SelectOptionIcon = ({ Icon, color }: SelectOptionIconProps) => {
if (isDefined(color)) {
return (
<TintedIconTile
- Icon={Icon}
+ icon={<Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />}
color={color}
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
+ style={{ width: theme.icon.size.md, height: theme.icon.size.md }}
/>
);
}
diff --git a/packages/twenty-ui/docs/animatedIconCrossfadePropDescriptions.ts b/packages/twenty-ui/docs/animatedIconCrossfadePropDescriptions.ts
index cdc120329a0..fd92e479adb 100644
--- a/packages/twenty-ui/docs/animatedIconCrossfadePropDescriptions.ts
+++ b/packages/twenty-ui/docs/animatedIconCrossfadePropDescriptions.ts
@@ -3,10 +3,12 @@ import { type ComponentProps } from 'react';
import { type AnimatedIconCrossfade } from '../src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade';
export const ANIMATED_ICON_CROSSFADE_PROP_DESCRIPTIONS = {
- isActive: 'Shows ActiveIcon when true and InactiveIcon otherwise.',
- ActiveIcon: 'Icon component for the active state.',
- InactiveIcon: 'Icon component for the inactive state.',
- size: 'Icon dimension in pixels. Defaults to the small theme icon size.',
+ isActive: 'Shows activeIcon when true and inactiveIcon otherwise.',
+ activeIcon: 'Decorative node content for the active state.',
+ inactiveIcon: 'Decorative node content for the inactive state.',
+ className: 'CSS class applied to the inline span root.',
+ style: 'Inline styles applied to the root, including width and height.',
+ render: 'Replaces the span root while preserving both transition layers.',
} satisfies Partial<
Record<keyof ComponentProps<typeof AnimatedIconCrossfade>, string>
>;
diff --git a/packages/twenty-ui/docs/metricRowPropDescriptions.ts b/packages/twenty-ui/docs/metricRowPropDescriptions.ts
index 765ae45943d..4a847799943 100644
--- a/packages/twenty-ui/docs/metricRowPropDescriptions.ts
+++ b/packages/twenty-ui/docs/metricRowPropDescriptions.ts
@@ -4,8 +4,9 @@ import { type MetricRow } from '../src/components/data-display/MetricRow/MetricR
export const METRIC_ROW_PROP_DESCRIPTIONS = {
children:
- 'Required nonempty text label that also names the optional progress ring.',
- startIcon: 'Decorative icon before the label, rendered at 14px.',
+ 'Label content whose accessible text also names the optional progress ring.',
+ startIcon:
+ 'Decorative node content before the label. The caller controls icon geometry.',
value:
'Preformatted value displayed at the end of the row. String values also supply the progress ring accessible value text.',
progress:
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 0101c75461b..14d6838e937 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -116,6 +116,7 @@
"Section": "components/layout/Section/Section"
},
"types": {
+ "AnimatedIconCrossfadeProps": "components/layout/AnimatedIconCrossfade/types/AnimatedIconCrossfadeProps",
"OverflowingListProps": "components/layout/OverflowingList/types/OverflowingListProps",
"SectionHeaderProps": "components/layout/Section/types/SectionHeaderProps",
"SectionRootProps": "components/layout/Section/types/SectionRootProps"
diff --git a/packages/twenty-ui/docs/tintedIconTilePropDescriptions.ts b/packages/twenty-ui/docs/tintedIconTilePropDescriptions.ts
index 62c3e18dd4f..55cf0f37936 100644
--- a/packages/twenty-ui/docs/tintedIconTilePropDescriptions.ts
+++ b/packages/twenty-ui/docs/tintedIconTilePropDescriptions.ts
@@ -3,11 +3,13 @@ import { type ComponentProps } from 'react';
import { type TintedIconTile } from '../src/components/data-display/TintedIconTile/TintedIconTile';
export const TINTED_ICON_TILE_PROP_DESCRIPTIONS = {
- Icon: 'Icon component rendered inside the tinted tile.',
+ icon: 'Decorative icon content. The caller controls its dimensions and stroke.',
color:
- 'Theme palette name used to derive the background and icon shades. Invalid names use the default theme color.',
- size: 'Icon and tile dimension in pixels. When omitted, the icon uses the medium theme size.',
- stroke: 'Icon stroke width. Defaults to the medium theme stroke.',
+ 'Theme palette name used to derive the background and foreground shades. Invalid names use the default theme color.',
+ className: 'CSS class applied to the tile root.',
+ style: 'Inline styles override tile geometry and palette defaults.',
+ render:
+ 'Replaces the div root while preserving icon content and native props.',
} satisfies Partial<
Record<keyof ComponentProps<typeof TintedIconTile>, string>
>;
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index c656f4742c3..0d24ef18d51 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -325,10 +325,10 @@
"props": [
{
"name": "children",
- "type": "string",
+ "type": "ReactNode",
"required": true,
"defaultValue": null,
- "description": "Required nonempty text label that also names the optional progress ring."
+ "description": "Label content whose accessible text also names the optional progress ring."
},
{
"name": "className",
@@ -367,10 +367,10 @@
},
{
"name": "startIcon",
- "type": "IconComponent",
+ "type": "ReactNode",
"required": false,
"defaultValue": null,
- "description": "Decorative icon before the label, rendered at 14px."
+ "description": "Decorative node content before the label. The caller controls icon geometry."
},
{
"name": "style",
@@ -9669,33 +9669,40 @@
"entryPoint": "twenty-ui/components/data-display",
"slug": "components/data-display/tinted-icon-tile",
"props": [
+ {
+ "name": "className",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the tile root."
+ },
{
"name": "color",
"type": "string | null",
"required": false,
"defaultValue": "gray",
- "description": "Theme palette name used to derive the background and icon shades. Invalid names use the default theme color."
+ "description": "Theme palette name used to derive the background and foreground shades. Invalid names use the default theme color."
},
{
- "name": "Icon",
- "type": "IconComponent",
+ "name": "icon",
+ "type": "ReactNode",
"required": true,
"defaultValue": null,
- "description": "Icon component rendered inside the tinted tile."
+ "description": "Decorative icon content. The caller controls its dimensions and stroke."
},
{
- "name": "size",
- "type": "number",
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
"required": false,
"defaultValue": null,
- "description": "Icon and tile dimension in pixels. When omitted, the icon uses the medium theme size."
+ "description": "Replaces the div root while preserving icon content and native props."
},
{
- "name": "stroke",
- "type": "number",
+ "name": "style",
+ "type": "CSSProperties",
"required": false,
"defaultValue": null,
- "description": "Icon stroke width. Defaults to the medium theme stroke."
+ "description": "Inline styles override tile geometry and palette defaults."
}
]
},
@@ -10125,32 +10132,46 @@
"slug": "components/layout/animated-icon-crossfade",
"props": [
{
- "name": "ActiveIcon",
- "type": "IconComponent",
+ "name": "activeIcon",
+ "type": "ReactNode",
"required": true,
"defaultValue": null,
- "description": "Icon component for the active state."
+ "description": "Decorative node content for the active state."
},
{
- "name": "InactiveIcon",
- "type": "IconComponent",
+ "name": "className",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the inline span root."
+ },
+ {
+ "name": "inactiveIcon",
+ "type": "ReactNode",
"required": true,
"defaultValue": null,
- "description": "Icon component for the inactive state."
+ "description": "Decorative node content for the inactive state."
},
{
"name": "isActive",
"type": "boolean",
"required": true,
"defaultValue": null,
- "description": "Shows ActiveIcon when true and InactiveIcon otherwise."
+ "description": "Shows activeIcon when true and inactiveIcon otherwise."
},
{
- "name": "size",
- "type": "number",
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Replaces the span root while preserving both transition layers."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties",
"required": false,
"defaultValue": null,
- "description": "Icon dimension in pixels. Defaults to the small theme icon size."
+ "description": "Inline styles applied to the root, including width and height."
}
]
},
@@ -10357,7 +10378,7 @@
},
{
"name": "avatar",
- "type": "Pick<AvatarProps, \"size\" | \"name\" | \"shape\" | \"src\" | \"colorSeed\"> | null",
+ "type": "Pick<AvatarProps, \"name\" | \"size\" | \"shape\" | \"src\" | \"colorSeed\"> | null",
"required": false,
"defaultValue": null,
"description": "Avatar name, source, color seed, size, and shape. Omit to hide the avatar."
diff --git a/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.module.scss b/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.module.scss
index d863b48fbee..45bd40d8be8 100644
--- a/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.module.scss
+++ b/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.module.scss
@@ -16,3 +16,8 @@
gap: var(--t-spacing-1);
min-width: 0;
}
+
+.icon {
+ display: flex;
+ flex-shrink: 0;
+}
diff --git a/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.module.scss.d.ts b/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.module.scss.d.ts
index bf78aea9b92..13be9f33315 100644
--- a/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.module.scss.d.ts
+++ b/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.module.scss.d.ts
@@ -1,5 +1,6 @@
declare const classNames: {
readonly row: 'row';
readonly label: 'label';
+ readonly icon: 'icon';
};
export default classNames;
diff --git a/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.tsx b/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.tsx
index dc28356eaea..387a85dc15d 100644
--- a/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.tsx
+++ b/packages/twenty-ui/src/components/data-display/MetricRow/MetricRow.tsx
@@ -11,7 +11,7 @@ import { type MetricRowProps } from './types/MetricRowProps';
export const MetricRow = ({
children,
- startIcon: StartIcon,
+ startIcon,
value,
progress,
progressColor,
@@ -32,7 +32,11 @@ export const MetricRow = ({
children: (
<>
<div className={styles.label}>
- {isDefined(StartIcon) && <StartIcon size={14} aria-hidden={true} />}
+ {isDefined(startIcon) && (
+ <span className={styles.icon} aria-hidden="true">
+ {startIcon}
+ </span>
+ )}
<span id={labelId}>{children}</span>
</div>
{isDefined(progress) ? (
diff --git a/packages/twenty-ui/src/components/data-display/MetricRow/__stories__/MetricRow.stories.tsx b/packages/twenty-ui/src/components/data-display/MetricRow/__stories__/MetricRow.stories.tsx
index 41ccb5874b9..92aa868e301 100644
--- a/packages/twenty-ui/src/components/data-display/MetricRow/__stories__/MetricRow.stories.tsx
+++ b/packages/twenty-ui/src/components/data-display/MetricRow/__stories__/MetricRow.stories.tsx
@@ -22,7 +22,7 @@ const meta: Meta<typeof MetricRow> = {
children: 'Imported files',
value: '75 of 100',
progress: 75,
- startIcon: IconFiles,
+ startIcon: <IconFiles size={14} />,
},
argTypes: {
startIcon: { control: false },
@@ -57,7 +57,11 @@ export const InCard: Story = {
render: () => (
<Card.Root>
<Card.Content>
- <MetricRow startIcon={IconFiles} value="75 of 100" progress={75}>
+ <MetricRow
+ startIcon={<IconFiles size={14} />}
+ value="75 of 100"
+ progress={75}
+ >
Imported files
</MetricRow>
<MetricRow value="24 of 80" progress={30}>
@@ -119,7 +123,7 @@ const ControlledMetricRow = () => {
return (
<>
<MetricRow
- startIcon={IconFiles}
+ startIcon={<IconFiles size={14} />}
value={completed ? '100 of 100' : '25 of 100'}
progress={completed ? 100 : 25}
>
@@ -181,3 +185,22 @@ export const RightToLeft: Story = {
);
},
};
+
+export const NodeLabel: Story = {
+ args: {
+ children: <Text render={<strong />}>Imported files</Text>,
+ startIcon: (
+ <svg width="14" height="14" viewBox="0 0 14 14">
+ <path d="M1 1h12v12H1z" fill="currentColor" />
+ </svg>
+ ),
+ },
+ play: async ({ canvasElement }) => {
+ const progress = within(canvasElement).getByRole('progressbar', {
+ name: 'Imported files',
+ });
+
+ await expect(progress).toHaveAttribute('aria-valuenow', '75');
+ await expect(progress).toHaveAttribute('aria-valuetext', '75 of 100');
+ },
+};
diff --git a/packages/twenty-ui/src/components/data-display/MetricRow/__tests__/MetricRow.test.tsx b/packages/twenty-ui/src/components/data-display/MetricRow/__tests__/MetricRow.test.tsx
index bec33d7b847..bb6e241df97 100644
--- a/packages/twenty-ui/src/components/data-display/MetricRow/__tests__/MetricRow.test.tsx
+++ b/packages/twenty-ui/src/components/data-display/MetricRow/__tests__/MetricRow.test.tsx
@@ -1,8 +1,8 @@
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
-import { type ComponentProps } from 'react';
-import { expectTypeOf, it } from 'vitest';
+import { render, screen } from '@testing-library/react';
+import { expect, it } from 'vitest';
-import { MetricRow } from '@ui/components';
+import { MetricRow } from '../MetricRow';
runComponentConformance({
name: 'MetricRow',
@@ -14,8 +14,31 @@ runComponentConformance({
refInstanceOf: HTMLDivElement,
});
-it('requires a text label for the progress accessible name', () => {
- expectTypeOf<ComponentProps<typeof MetricRow>>()
- .pick<'children'>()
- .toEqualTypeOf<{ children: string }>();
+it('names progress from nested label content while keeping the icon decorative', () => {
+ const { rerender } = render(
+ <MetricRow
+ startIcon={<svg role="img" aria-label="Internal artwork" />}
+ value={<bdi>42 of 100</bdi>}
+ progress={42}
+ progressValueText="42 files imported"
+ >
+ <strong>Imported</strong> files
+ </MetricRow>,
+ );
+
+ expect(
+ screen.getByRole('progressbar', { name: 'Imported files' }),
+ ).toHaveAttribute('aria-valuetext', '42 files imported');
+ expect(screen.queryByRole('img')).toBeNull();
+
+ rerender(
+ <MetricRow value={0} progress={0}>
+ <strong>Reviewed</strong> files
+ </MetricRow>,
+ );
+
+ expect(
+ screen.getByRole('progressbar', { name: 'Reviewed files' }),
+ ).toHaveAttribute('aria-valuenow', '0');
+ expect(screen.getByText('0')).toBeInTheDocument();
});
diff --git a/packages/twenty-ui/src/components/data-display/MetricRow/types/MetricRowProps.ts b/packages/twenty-ui/src/components/data-display/MetricRow/types/MetricRowProps.ts
index 86daf090023..cb2547389d2 100644
--- a/packages/twenty-ui/src/components/data-display/MetricRow/types/MetricRowProps.ts
+++ b/packages/twenty-ui/src/components/data-display/MetricRow/types/MetricRowProps.ts
@@ -1,14 +1,12 @@
import { type useRender } from '@base-ui/react/use-render';
import { type ReactNode } from 'react';
-import { type IconComponent } from '@ui/icon';
-
export type MetricRowProps = Omit<
useRender.ComponentProps<'div'>,
'children'
> & {
- children: string;
- startIcon?: IconComponent;
+ children: ReactNode;
+ startIcon?: ReactNode;
value: ReactNode;
progress?: number;
progressColor?: string;
diff --git a/packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.module.scss b/packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.module.scss
new file mode 100644
index 00000000000..08fd6d14399
--- /dev/null
+++ b/packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.module.scss
@@ -0,0 +1,14 @@
+.root {
+ box-sizing: border-box;
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ justify-content: center;
+ width: var(--t-spacing-4);
+ height: var(--t-spacing-4);
+ border-radius: var(--t-border-radius-sm);
+
+ & > span {
+ display: flex;
+ }
+}
diff --git a/packages/twenty-ui/src/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer.module.scss.d.ts b/packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.module.scss.d.ts
similarity index 100%
rename from packages/twenty-ui/src/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer.module.scss.d.ts
rename to packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.module.scss.d.ts
diff --git a/packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.tsx b/packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.tsx
index 675e9e71426..92864bb3205 100644
--- a/packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.tsx
+++ b/packages/twenty-ui/src/components/data-display/TintedIconTile/TintedIconTile.tsx
@@ -1,30 +1,35 @@
-import { StyledTintedIconTileContainer } from '@ui/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer';
+import { useRender } from '@base-ui/react/use-render';
+import { clsx } from 'clsx';
+
import { getIconTileColorShades } from '@ui/components/data-display/TintedIconTile/utils/getIconTileColorShades';
-import { DEFAULT_THEME_COLOR_FALLBACK, useTheme } from '@ui/theme';
+import { DEFAULT_THEME_COLOR_FALLBACK } from '@ui/theme';
-import { isDefined } from '@ui/utilities/utils/isDefined';
+import styles from './TintedIconTile.module.scss';
import { type TintedIconTileProps } from './types/TintedIconTileProps';
export const TintedIconTile = ({
- Icon,
+ icon,
color = DEFAULT_THEME_COLOR_FALLBACK,
- size: sizeFromProps,
- stroke: strokeFromProps,
+ className,
+ style,
+ render,
+ ref,
+ ...props
}: TintedIconTileProps) => {
- const theme = useTheme();
- const style = getIconTileColorShades(color);
- const iconSize = sizeFromProps ?? theme.icon.size.md;
- const iconStroke = strokeFromProps ?? theme.icon.stroke.md;
- const tileDimension = isDefined(sizeFromProps)
- ? `${sizeFromProps}px`
- : undefined;
+ const colorShades = getIconTileColorShades(color);
- return (
- <StyledTintedIconTileContainer
- $backgroundColor={style.backgroundColor}
- $dimension={tileDimension}
- >
- <Icon size={iconSize} stroke={iconStroke} color={style.iconColor} />
- </StyledTintedIconTileContainer>
- );
+ return useRender({
+ render,
+ ref,
+ props: {
+ ...props,
+ className: clsx(styles.root, className),
+ style: {
+ backgroundColor: colorShades.backgroundColor,
+ color: colorShades.iconColor,
+ ...style,
+ },
+ children: <span aria-hidden="true">{icon}</span>,
+ },
+ });
};
diff --git a/packages/twenty-ui/src/components/data-display/TintedIconTile/__stories__/TintedIconTile.stories.tsx b/packages/twenty-ui/src/components/data-display/TintedIconTile/__stories__/TintedIconTile.stories.tsx
new file mode 100644
index 00000000000..b6783711afd
--- /dev/null
+++ b/packages/twenty-ui/src/components/data-display/TintedIconTile/__stories__/TintedIconTile.stories.tsx
@@ -0,0 +1,79 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, within } from 'storybook/test';
+
+import { IconBuildingSkyscraper } from '@ui/icon';
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
+
+import { TintedIconTile } from '../TintedIconTile';
+
+const meta = {
+ title: 'UI/Components/Data display/TintedIconTile',
+ component: TintedIconTile,
+ decorators: [ComponentDecorator],
+ parameters: { a11y: A11Y_DEFER_COLOR_CONTRAST },
+ args: { icon: <IconBuildingSkyscraper size={16} />, color: 'blue' },
+} satisfies Meta<typeof TintedIconTile>;
+
+export default meta;
+
+type Story = StoryObj<typeof meta>;
+
+export const Default: Story = {
+ render: (args) => (
+ <>
+ <TintedIconTile {...args} />
+ <Text>Companies</Text>
+ </>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const icon = canvasElement.querySelector('svg')!;
+ const tile = icon.parentElement!.parentElement!;
+
+ await expect(canvas.getByText('Companies')).toBeVisible();
+ await expect(canvas.queryByRole('img')).not.toBeInTheDocument();
+ await expect(tile.getBoundingClientRect().width).toBe(16);
+ await expect(tile.getBoundingClientRect().height).toBe(16);
+ await expect(icon.getBoundingClientRect().width).toBe(16);
+ },
+};
+
+export const CustomNode: Story = {
+ args: {
+ icon: (
+ <svg
+ width="20"
+ height="20"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ role="img"
+ aria-label="Internal artwork"
+ >
+ <path d="M2 2h16v16H2z" />
+ </svg>
+ ),
+ role: 'img',
+ 'aria-label': 'Custom company tile',
+ className: 'custom-tile',
+ style: { width: 32, height: 32, borderRadius: 8 },
+ render: <span data-composed="tile" />,
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const tile = canvas.getByRole('img', { name: 'Custom company tile' });
+
+ await expect(tile.tagName).toBe('SPAN');
+ await expect(tile).toHaveClass('custom-tile');
+ await expect(tile).toHaveAttribute('data-composed', 'tile');
+ await expect(tile.getBoundingClientRect().width).toBe(32);
+ await expect(tile.getBoundingClientRect().height).toBe(32);
+ await expect(tile.querySelector('svg')!.getBoundingClientRect().width).toBe(
+ 20,
+ );
+ await expect(canvas.getAllByRole('img')).toHaveLength(1);
+ await expect(getComputedStyle(tile.querySelector('svg')!).color).toBe(
+ getComputedStyle(tile).color,
+ );
+ },
+};
diff --git a/packages/twenty-ui/src/components/data-display/TintedIconTile/__tests__/TintedIconTile.test.tsx b/packages/twenty-ui/src/components/data-display/TintedIconTile/__tests__/TintedIconTile.test.tsx
new file mode 100644
index 00000000000..87896ecda3a
--- /dev/null
+++ b/packages/twenty-ui/src/components/data-display/TintedIconTile/__tests__/TintedIconTile.test.tsx
@@ -0,0 +1,54 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
+import { TintedIconTile } from '../TintedIconTile';
+
+runComponentConformance({
+ name: 'TintedIconTile',
+ element: (
+ <TintedIconTile
+ icon={
+ <svg>
+ <path d="M0 0h8v8H0z" />
+ </svg>
+ }
+ />
+ ),
+ refInstanceOf: HTMLDivElement,
+});
+
+describe('TintedIconTile content', () => {
+ it('keeps custom icon nodes decorative and lets the root carry a label', () => {
+ render(
+ <TintedIconTile
+ icon={<svg role="img" aria-label="Internal artwork" />}
+ role="img"
+ aria-label="Companies"
+ />,
+ );
+
+ expect(screen.getByRole('img', { name: 'Companies' })).toBeInTheDocument();
+ expect(screen.queryByRole('img', { name: 'Internal artwork' })).toBeNull();
+ });
+
+ it('allows styles to override palette defaults and tile geometry', () => {
+ render(
+ <TintedIconTile
+ icon={<svg width="20" height="20" />}
+ color="blue"
+ data-testid="tile"
+ style={{
+ width: 32,
+ height: 32,
+ color: 'red',
+ backgroundColor: 'black',
+ }}
+ />,
+ );
+
+ expect(screen.getByTestId('tile')).toHaveStyle(
+ 'width: 32px; height: 32px; color: rgb(255, 0, 0); background-color: rgb(0, 0, 0)',
+ );
+ });
+});
diff --git a/packages/twenty-ui/src/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer.module.scss b/packages/twenty-ui/src/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer.module.scss
deleted file mode 100644
index 22d77de8fc6..00000000000
--- a/packages/twenty-ui/src/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer.module.scss
+++ /dev/null
@@ -1,12 +0,0 @@
-.root {
- box-sizing: border-box;
- display: flex;
- flex-shrink: 0;
- align-items: center;
- justify-content: center;
- width: var(--tinted-icon-tile-dimension, var(--t-spacing-4));
- height: var(--tinted-icon-tile-dimension, var(--t-spacing-4));
- border: var(--tinted-icon-tile-border, none);
- border-radius: var(--t-border-radius-sm);
- background-color: var(--tinted-icon-tile-background-color, transparent);
-}
diff --git a/packages/twenty-ui/src/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer.tsx b/packages/twenty-ui/src/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer.tsx
deleted file mode 100644
index fc690a4f76d..00000000000
--- a/packages/twenty-ui/src/components/data-display/TintedIconTile/internal/StyledTintedIconTileContainer/StyledTintedIconTileContainer.tsx
+++ /dev/null
@@ -1,34 +0,0 @@
-import { clsx } from 'clsx';
-
-import styles from './StyledTintedIconTileContainer.module.scss';
-
-type StyledTintedIconTileContainerProps =
- React.ComponentPropsWithoutRef<'div'> & {
- $backgroundColor?: string;
- $borderColor?: string;
- $dimension?: string;
- };
-
-export const StyledTintedIconTileContainer = ({
- $backgroundColor,
- $borderColor,
- $dimension,
- className,
- style,
- ...rest
-}: StyledTintedIconTileContainerProps) => (
- <div
- {...rest}
- className={clsx(styles.root, className)}
- style={
- {
- '--tinted-icon-tile-background-color': $backgroundColor,
- '--tinted-icon-tile-border': $borderColor
- ? `1px solid ${$borderColor}`
- : undefined,
- '--tinted-icon-tile-dimension': $dimension,
- ...style,
- } as React.CSSProperties
- }
- />
-);
diff --git a/packages/twenty-ui/src/components/data-display/TintedIconTile/types/TintedIconTileProps.ts b/packages/twenty-ui/src/components/data-display/TintedIconTile/types/TintedIconTileProps.ts
index ac5b51b4cae..0bf6c88e422 100644
--- a/packages/twenty-ui/src/components/data-display/TintedIconTile/types/TintedIconTileProps.ts
+++ b/packages/twenty-ui/src/components/data-display/TintedIconTile/types/TintedIconTileProps.ts
@@ -1,8 +1,10 @@
-import { type IconComponent } from '@ui/icon/types/IconComponent';
+import { type useRender } from '@base-ui/react/use-render';
+import { type ReactNode } from 'react';
-export type TintedIconTileProps = {
- Icon: IconComponent;
+export type TintedIconTileProps = Omit<
+ useRender.ComponentProps<'div'>,
+ 'children' | 'color'
+> & {
+ icon: ReactNode;
color?: string | null;
- size?: number;
- stroke?: number;
};
diff --git a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.module.scss b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.module.scss
index 5cce0773f0b..96b0ee49c02 100644
--- a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.module.scss
+++ b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.module.scss
@@ -1,8 +1,9 @@
.container {
- height: var(--animated-icon-crossfade-size);
+ display: inline-block;
+ height: calc(var(--t-icon-size-sm) * 1px);
overflow: hidden;
position: relative;
- width: var(--animated-icon-crossfade-size);
+ width: calc(var(--t-icon-size-sm) * 1px);
}
.layer {
diff --git a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.tsx b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.tsx
index 039feda14d6..a3271eae0ec 100644
--- a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.tsx
+++ b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.tsx
@@ -1,52 +1,47 @@
+import { useRender } from '@base-ui/react/use-render';
import { clsx } from 'clsx';
-import { type IconComponent } from '@ui/icon/types/IconComponent';
-import { useTheme } from '@ui/theme';
-
import styles from './AnimatedIconCrossfade.module.scss';
-
-type AnimatedIconCrossfadeProps = {
- isActive: boolean;
- ActiveIcon: IconComponent;
- InactiveIcon: IconComponent;
- size?: number;
-};
+import { type AnimatedIconCrossfadeProps } from './types/AnimatedIconCrossfadeProps';
export const AnimatedIconCrossfade = ({
isActive,
- ActiveIcon,
- InactiveIcon,
- size,
+ activeIcon,
+ inactiveIcon,
+ className,
+ render,
+ ref,
+ ...props
}: AnimatedIconCrossfadeProps) => {
- const theme = useTheme();
-
- const iconSize = size ?? theme.icon.size.sm;
-
- return (
- <div
- className={styles.container}
- style={
- {
- '--animated-icon-crossfade-size': `${iconSize}px`,
- } as React.CSSProperties
- }
- >
- <div
- className={clsx(
- styles.layer,
- isActive ? styles.hidden : styles.visible,
- )}
- >
- <InactiveIcon size={iconSize} />
- </div>
- <div
- className={clsx(
- styles.layer,
- isActive ? styles.visible : styles.hidden,
- )}
- >
- <ActiveIcon size={iconSize} />
- </div>
- </div>
- );
+ return useRender({
+ defaultTagName: 'span',
+ render,
+ ref,
+ props: {
+ ...props,
+ className: clsx(styles.container, className),
+ children: (
+ <>
+ <span
+ aria-hidden="true"
+ className={clsx(
+ styles.layer,
+ isActive ? styles.hidden : styles.visible,
+ )}
+ >
+ {inactiveIcon}
+ </span>
+ <span
+ aria-hidden="true"
+ className={clsx(
+ styles.layer,
+ isActive ? styles.visible : styles.hidden,
+ )}
+ >
+ {activeIcon}
+ </span>
+ </>
+ ),
+ },
+ });
};
diff --git a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__stories__/AnimatedIconCrossfade.stories.tsx b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__stories__/AnimatedIconCrossfade.stories.tsx
index 92042c59c83..155931c3ceb 100644
--- a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__stories__/AnimatedIconCrossfade.stories.tsx
+++ b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__stories__/AnimatedIconCrossfade.stories.tsx
@@ -12,7 +12,11 @@ const meta = {
title: 'UI/Components/Layout/AnimatedIconCrossfade',
component: AnimatedIconCrossfade,
tags: ['!autodocs'],
- args: { isActive: false, ActiveIcon: IconX, InactiveIcon: IconPencil },
+ args: {
+ isActive: false,
+ activeIcon: <IconX size={14} />,
+ inactiveIcon: <IconPencil size={14} />,
+ },
} satisfies Meta<typeof AnimatedIconCrossfade>;
export default meta;
@@ -32,8 +36,8 @@ export const AnimatedIcon: Story = {
startIcon={
<AnimatedIconCrossfade
isActive={isEditing}
- ActiveIcon={IconX}
- InactiveIcon={IconPencil}
+ activeIcon={<IconX size={14} />}
+ inactiveIcon={<IconPencil size={14} />}
/>
}
>
diff --git a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__tests__/AnimatedIconCrossfade.test.tsx b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__tests__/AnimatedIconCrossfade.test.tsx
new file mode 100644
index 00000000000..ec16aa0a80e
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/__tests__/AnimatedIconCrossfade.test.tsx
@@ -0,0 +1,50 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+import { render, screen } from '@testing-library/react';
+import { expect, it } from 'vitest';
+
+import { AnimatedIconCrossfade } from '../AnimatedIconCrossfade';
+
+runComponentConformance({
+ name: 'AnimatedIconCrossfade',
+ element: (
+ <AnimatedIconCrossfade
+ isActive={false}
+ activeIcon={<svg />}
+ inactiveIcon={<svg />}
+ />
+ ),
+ refInstanceOf: HTMLSpanElement,
+ renderPropTagName: 'div',
+});
+
+it('keeps both custom nodes mounted and decorative when the active state changes', () => {
+ const activeIcon = <svg role="img" aria-label="Active artwork" />;
+ const inactiveIcon = <svg role="img" aria-label="Inactive artwork" />;
+ const { rerender } = render(
+ <AnimatedIconCrossfade
+ isActive={false}
+ activeIcon={activeIcon}
+ inactiveIcon={inactiveIcon}
+ role="img"
+ aria-label="Editing inactive"
+ />,
+ );
+ const activeNode = screen.getByLabelText('Active artwork');
+ const inactiveNode = screen.getByLabelText('Inactive artwork');
+
+ rerender(
+ <AnimatedIconCrossfade
+ isActive={true}
+ activeIcon={activeIcon}
+ inactiveIcon={inactiveIcon}
+ role="img"
+ aria-label="Editing active"
+ />,
+ );
+
+ expect(screen.getByLabelText('Active artwork')).toBe(activeNode);
+ expect(screen.getByLabelText('Inactive artwork')).toBe(inactiveNode);
+ expect(screen.getAllByRole('img')).toEqual([
+ screen.getByRole('img', { name: 'Editing active' }),
+ ]);
+});
diff --git a/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/types/AnimatedIconCrossfadeProps.ts b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/types/AnimatedIconCrossfadeProps.ts
new file mode 100644
index 00000000000..f30f61bfd84
--- /dev/null
+++ b/packages/twenty-ui/src/components/layout/AnimatedIconCrossfade/types/AnimatedIconCrossfadeProps.ts
@@ -0,0 +1,11 @@
+import { type useRender } from '@base-ui/react/use-render';
+import { type ReactNode } from 'react';
+
+export type AnimatedIconCrossfadeProps = Omit<
+ useRender.ComponentProps<'span'>,
+ 'children'
+> & {
+ isActive: boolean;
+ activeIcon: ReactNode;
+ inactiveIcon: ReactNode;
+};
diff --git a/packages/twenty-ui/src/components/layout/index.ts b/packages/twenty-ui/src/components/layout/index.ts
index 60ba793ada2..624e27e0ce5 100644
--- a/packages/twenty-ui/src/components/layout/index.ts
+++ b/packages/twenty-ui/src/components/layout/index.ts
@@ -8,6 +8,7 @@
*/
export { AnimatedIconCrossfade } from './AnimatedIconCrossfade/AnimatedIconCrossfade';
+export type { AnimatedIconCrossfadeProps } from './AnimatedIconCrossfade/types/AnimatedIconCrossfadeProps';
export { OverflowingList } from './OverflowingList/OverflowingList';
export type { OverflowingListProps } from './OverflowingList/types/OverflowingListProps';
export { Section } from './Section/Section';
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIcon.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIcon.tsx
index 8ee8df65f1f..d7233542d35 100644
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIcon.tsx
+++ b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIcon.tsx
@@ -27,10 +27,9 @@ export const MenuItemIcon = ({
if (isDefined(iconThemeColor)) {
return (
<TintedIconTile
- Icon={Icon}
+ icon={<Icon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />}
color={iconThemeColor}
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
+ style={{ width: theme.icon.size.md, height: theme.icon.size.md }}
/>
);
}
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.tsx
index 4c792cb0089..a4454c9cab4 100644
--- a/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.tsx
+++ b/packages/twenty-ui/src/components/navigation/MenuItem/parts/MenuItemIconWithGripSwap.tsx
@@ -32,10 +32,14 @@ export const MenuItemIconWithGripSwap = ({
<div className={clsx(styles.defaultIcon, 'grip-swap-default-icon')}>
{isDefined(iconThemeColor) ? (
<TintedIconTile
- Icon={LeftIcon}
+ icon={
+ <LeftIcon
+ size={theme.icon.size.md}
+ stroke={theme.icon.stroke.sm}
+ />
+ }
color={iconThemeColor}
- size={theme.icon.size.md}
- stroke={theme.icon.stroke.sm}
+ style={{ width: theme.icon.size.md, height: theme.icon.size.md }}
/>
) : (
<LeftIcon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />