Skip to content

The open alternative to Salesforce, designed for AI.

Consolidate animated buttons (#26276)

Raphaël Bosi5db7ada08d12
diff --git a/packages/twenty-docs/ui/primitives/input/button.mdx b/packages/twenty-docs/ui/primitives/input/button.mdx
index 740540ca2a9..b1d9ede40b7 100644
--- a/packages/twenty-docs/ui/primitives/input/button.mdx
+++ b/packages/twenty-docs/ui/primitives/input/button.mdx
@@ -3,6 +3,7 @@ title: Button
description: Trigger actions or navigate with styled buttons.
---
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import ButtonReference from '/snippets/ui/generated/input/button.mdx';
Use `Button` for an action. Supply its visible label as children, and give icon-only buttons an `aria-label`.
@@ -70,6 +71,46 @@ Choose `solid`, `outline`, `soft`, or `ghost` independently of the `neutral`, `a
`disabled`, `loading`, and `soon` prevent activation. Loading keeps the label accessible and preserves the button's width while showing a spinner. Customize the upcoming-feature label with `soonLabel`.
+## Animated icons
+
+Compose `Button` with `AnimatedIconCrossfade` to change its icon when application state changes. Pass the animated element to `startIcon` and the label as children.
+
+```tsx
+import { useState } from 'react';
+import { IconPencil, IconX } from 'twenty-ui/icon';
+import { Button } from 'twenty-ui/primitives/input';
+import { AnimatedIconCrossfade } from 'twenty-ui/primitives/layout';
+
+export const EditActions = () => {
+ const [isEditing, setIsEditing] = useState(false);
+
+ return (
+ <Button
+ size="sm"
+ aria-expanded={isEditing}
+ onClick={() => setIsEditing(!isEditing)}
+ startIcon={
+ <AnimatedIconCrossfade
+ isActive={isEditing}
+ ActiveIcon={IconX}
+ InactiveIcon={IconPencil}
+ />
+ }
+ >
+ Edit actions
+ </Button>
+ );
+};
+```
+
+When an icon is itself an action, use `IconButton` or `LightIconButton` and animate its icon content. When a disclosure header owns expansion, keep its chevron decorative and expose `aria-expanded` on the header control. Keep animation styles with the feature and respect `prefers-reduced-motion`.
+
+<StoryEmbed
+ title="Button with an animated icon"
+ storyId="ui-input-button-button--animated-icon-documentation"
+ height={120}
+/>
+
## Links and forms
```tsx
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 041d78e4dbc..197a5f5b178 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
@@ -8,16 +8,32 @@ import {
} from 'twenty-ui/components';
import { Button, ButtonGroup } from 'twenty-ui/primitives/input';
import { MenuItem, MenuItemDraggable } from 'twenty-ui/primitives/navigation';
-import { IconPlus } from 'twenty-ui/icon';
+import { IconPencil, IconPlus, IconX } from 'twenty-ui/icon';
+import { AnimatedIconCrossfade } from 'twenty-ui/primitives/layout';
import { ThemeProvider } from 'twenty-ui/theme-constants';
import 'twenty-ui/style.css';
const ButtonControls = () => {
const [activations, setActivations] = useState(0);
const [loading, setLoading] = useState(false);
+ const [isEditing, setIsEditing] = useState(false);
const handleClick = () => setActivations((count) => count + 1);
return (
<ThemeProvider colorScheme="light">
+ <Button
+ size="sm"
+ aria-expanded={isEditing ? 'true' : 'false'}
+ onClick={() => setIsEditing(!isEditing)}
+ startIcon={
+ <AnimatedIconCrossfade
+ isActive={isEditing}
+ ActiveIcon={IconX}
+ InactiveIcon={IconPencil}
+ />
+ }
+ >
+ Edit actions
+ </Button>
<Button
color="accent"
variant="solid"
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx
index a72bc031bf4..e98a7e9b6ab 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-input-gallery.front-component.tsx
@@ -9,8 +9,6 @@ import {
import { IconPlus, IconSearch, IconStar, IconTrash } from 'twenty-ui/icon';
import { CodeEditorHeader } from 'twenty-ui/components/code-editor';
import {
- AnimatedButton,
- AnimatedLightIconButton,
Button,
ButtonGroup,
ColorPickerButton,
@@ -36,19 +34,6 @@ import {
} from '../shared/front-components/component-gallery';
const INPUT_ENTRIES: GalleryEntry[] = [
- {
- name: 'AnimatedButton',
- node: (
- <AnimatedButton
- title="Animated"
- animatedSvg={<svg width={16} height={16} />}
- />
- ),
- },
- {
- name: 'AnimatedLightIconButton',
- node: <AnimatedLightIconButton Icon={IconStar} />,
- },
{
name: 'Button',
node: <Button onClick={() => {}}>{'Button'}</Button>,
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonControlsTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonControlsTest.ts
index c7c9ada7bef..796f62661cd 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonControlsTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/buttonControlsTest.ts
@@ -5,6 +5,24 @@ export const buttonControlsTest: TwentyUiGalleryPlayFunction = async (
context,
) => {
const canvas = within(context.canvasElement);
+ const editActions = await canvas.findByRole(
+ 'button',
+ { name: 'Edit actions' },
+ { timeout: 10000 },
+ );
+ await waitFor(() =>
+ expect(editActions.getBoundingClientRect().height).toBe(24),
+ );
+ await expect(editActions).toHaveAttribute('aria-expanded', 'false');
+ editActions.focus();
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() =>
+ expect(editActions).toHaveAttribute('aria-expanded', 'true'),
+ );
+ await userEvent.keyboard(' ');
+ await waitFor(() =>
+ expect(editActions).toHaveAttribute('aria-expanded', 'false'),
+ );
const button = await canvas.findByRole(
'button',
{ name: 'Create record' },
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 8f743f4f267..88c71d7be08 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
@@ -8,7 +8,7 @@ import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomState
import { useLingui } from '@lingui/react/macro';
import { SidePanelPages } from 'twenty-shared/types';
import { IconPencil, IconX } from 'twenty-ui/icon';
-import { AnimatedButton } from 'twenty-ui/primitives/input';
+import { Button } from 'twenty-ui/primitives/input';
export const CommandMenuItemEditButton = () => {
const { t } = useLingui();
@@ -44,18 +44,20 @@ export const CommandMenuItemEditButton = () => {
};
return (
- <AnimatedButton
- animatedSvg={
+ <Button
+ startIcon={
<AnimatedIconCrossfade
isActive={isCommandMenuEditPageActive}
ActiveIcon={IconX}
InactiveIcon={IconPencil}
/>
}
- title={t`Edit actions`}
- variant="secondary"
- size="small"
+ variant="outline"
+ size="sm"
onClick={handleClick}
- />
+ aria-expanded={isCommandMenuEditPageActive}
+ >
+ {t`Edit actions`}
+ </Button>
);
};
diff --git a/packages/twenty-front/src/modules/command-menu-item/edit/components/__stories__/CommandMenuItemEditButton.stories.tsx b/packages/twenty-front/src/modules/command-menu-item/edit/components/__stories__/CommandMenuItemEditButton.stories.tsx
new file mode 100644
index 00000000000..044e2ae2368
--- /dev/null
+++ b/packages/twenty-front/src/modules/command-menu-item/edit/components/__stories__/CommandMenuItemEditButton.stories.tsx
@@ -0,0 +1,75 @@
+import { CommandMenuItemEditButton } from '@/command-menu-item/edit/components/CommandMenuItemEditButton';
+import { isLayoutCustomizationModeEnabledState } from '@/layout-customization/states/isLayoutCustomizationModeEnabledState';
+import { isSidePanelClosingState } from '@/side-panel/states/isSidePanelClosingState';
+import { isSidePanelOpenedState } from '@/side-panel/states/isSidePanelOpenedState';
+import { sidePanelNavigationStackState } from '@/side-panel/states/sidePanelNavigationStackState';
+import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { Provider as JotaiProvider } from 'jotai';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+import { RouterDecorator } from 'twenty-ui/testing';
+import { ContextStoreDecorator } from '~/testing/decorators/ContextStoreDecorator';
+import { ObjectMetadataItemsDecorator } from '~/testing/decorators/ObjectMetadataItemsDecorator';
+
+const meta: Meta<typeof CommandMenuItemEditButton> = {
+ title: 'Modules/CommandMenu/CommandMenuItemEditButton',
+ component: CommandMenuItemEditButton,
+ decorators: [
+ (Story) => {
+ jotaiStore.set(isLayoutCustomizationModeEnabledState.atom, true);
+ jotaiStore.set(isSidePanelOpenedState.atom, false);
+ jotaiStore.set(isSidePanelClosingState.atom, false);
+ jotaiStore.set(sidePanelNavigationStackState.atom, []);
+
+ return (
+ <JotaiProvider store={jotaiStore}>
+ <Story />
+ </JotaiProvider>
+ );
+ },
+ ContextStoreDecorator,
+ ObjectMetadataItemsDecorator,
+ RouterDecorator,
+ ],
+};
+
+export default meta;
+type Story = StoryObj<typeof CommandMenuItemEditButton>;
+
+export const Default: Story = {};
+
+export const KeyboardToggle: Story = {
+ play: async ({ canvasElement }) => {
+ const button = await within(canvasElement).findByRole('button', {
+ name: 'Edit actions',
+ });
+
+ await expect(button).toHaveAttribute('type', 'button');
+ await expect(button).toHaveAttribute('aria-expanded', 'false');
+ button.focus();
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() =>
+ expect(button).toHaveAttribute('aria-expanded', 'true'),
+ );
+ await userEvent.keyboard(' ');
+ await waitFor(() =>
+ expect(button).toHaveAttribute('aria-expanded', 'false'),
+ );
+ await userEvent.tab();
+ },
+};
+
+export const LayoutCustomizationDisabled: Story = {
+ decorators: [
+ (Story) => {
+ jotaiStore.set(isLayoutCustomizationModeEnabledState.atom, false);
+
+ return <Story />;
+ },
+ ],
+ play: async ({ canvasElement }) => {
+ await expect(
+ within(canvasElement).findByRole('button', { name: 'Edit actions' }),
+ ).rejects.toThrow();
+ },
+};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowOutputSchemaBuilder.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowOutputSchemaBuilder.tsx
index 44a1c95943a..5e0b7076944 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowOutputSchemaBuilder.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowOutputSchemaBuilder.tsx
@@ -3,21 +3,18 @@ import { FormTextFieldInput } from '@/object-record/record-field/ui/form-types/c
import { type OutputSchemaField } from '@/ai/constants/OutputFieldTypeOptions';
import { createDefaultOutputSchemaField } from '@/ai/utils/createDefaultOutputSchemaField';
-import {
- InputLabel,
- AnimatedLightIconButton,
-} from 'twenty-ui/primitives/input';
-import { LightIconButton } from 'twenty-ui/components';
+import { InputLabel } from 'twenty-ui/primitives/input';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
-import { useContext, useState } from 'react';
+import { useState } from 'react';
import { isNonEmptyString } from '@sniptt/guards';
import { isValidAgentResponseSchemaPropertyKey } from 'twenty-shared/ai';
-import { IconChevronDown, IconPlus, IconVariable, IconX } from 'twenty-ui/icon';
+import { IconPlus } from 'twenty-ui/icon';
import { AnimatedExpandableContainer } from 'twenty-ui/primitives/layout';
import { MenuItem } from 'twenty-ui/primitives/navigation';
-import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
+import { themeCssVariables } from 'twenty-ui/theme-constants';
import { WorkflowOutputFieldTypeSelector } from './WorkflowOutputFieldTypeSelector';
+import { WorkflowOutputSchemaFieldHeader } from './WorkflowOutputSchemaFieldHeader';
type WorkflowOutputSchemaBuilderProps = {
fields: OutputSchemaField[];
onChange: (fields: OutputSchemaField[]) => void;
@@ -53,33 +50,6 @@ const StyledSettingsContent = styled.div`
padding-top: ${themeCssVariables.spacing[2]};
`;
-const StyledSettingsHeader = styled.div<{
- showRemoveFieldButton: boolean;
- isExpanded: boolean;
-}>`
- align-items: center;
- border-bottom: ${({ isExpanded }) =>
- isExpanded ? `1px solid ${themeCssVariables.border.color.medium}` : 'none'};
- cursor: pointer;
- display: grid;
- gap: ${themeCssVariables.spacing[1]};
- grid-template-columns: ${({ showRemoveFieldButton }) =>
- showRemoveFieldButton
- ? `1fr ${themeCssVariables.spacing[6]} ${themeCssVariables.spacing[6]}`
- : `1fr ${themeCssVariables.spacing[6]}`};
- height: ${themeCssVariables.spacing[8]};
- padding-left: ${themeCssVariables.spacing[2]};
- padding-right: ${themeCssVariables.spacing[1]};
-`;
-
-const StyledTitleContainer = styled.div`
- align-items: center;
- color: ${themeCssVariables.font.color.primary};
- display: flex;
- flex-direction: row;
- gap: ${themeCssVariables.spacing[1]};
-`;
-
const StyledAddFieldButtonContainer = styled.div`
margin-top: ${themeCssVariables.spacing[2]};
`;
@@ -103,7 +73,6 @@ export const WorkflowOutputSchemaBuilder = ({
onChange,
readonly,
}: WorkflowOutputSchemaBuilderProps) => {
- const { theme } = useContext(ThemeContext);
const [expandedFieldIds, setExpandedFieldIds] = useState<Set<string>>(
() => new Set(fields.map((field) => field.id)),
);
@@ -185,33 +154,16 @@ export const WorkflowOutputSchemaBuilder = ({
return (
<StyledOutputSchemaFieldContainer key={field.id}>
- <StyledSettingsHeader
- showRemoveFieldButton={showRemoveFieldButton}
- onClick={() => toggleField(field.id)}
+ <WorkflowOutputSchemaFieldHeader
+ name={field.name}
isExpanded={isExpanded}
- >
- <StyledTitleContainer>
- <IconVariable size={theme.icon.size.sm} />
- <span>{field.name || t`Untitled field`}</span>
- </StyledTitleContainer>
- <AnimatedLightIconButton
- Icon={IconChevronDown}
- size="small"
- rotate={isExpanded ? -180 : 0}
- />
- {showRemoveFieldButton && (
- <LightIconButton
- data-testid="remove-output-field-button"
- size="sm"
- onClick={() => {
- removeField(field.id);
- }}
- aria-label={t`Remove output field`}
- >
- <IconX />
- </LightIconButton>
- )}
- </StyledSettingsHeader>
+ onToggle={() => toggleField(field.id)}
+ onRemove={
+ showRemoveFieldButton
+ ? () => removeField(field.id)
+ : undefined
+ }
+ />
<AnimatedExpandableContainer
isExpanded={isExpanded}
initial={false}
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowOutputSchemaFieldHeader.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowOutputSchemaFieldHeader.tsx
new file mode 100644
index 00000000000..6892bf9c362
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowOutputSchemaFieldHeader.tsx
@@ -0,0 +1,124 @@
+import { styled } from '@linaria/react';
+import { t } from '@lingui/core/macro';
+import { isNonEmptyString } from '@sniptt/guards';
+import { isDefined } from 'twenty-shared/utils';
+import { LightIconButton } from 'twenty-ui/components';
+import { IconChevronDown, IconVariable, IconX } from 'twenty-ui/icon';
+import { themeCssVariables, useTheme } from 'twenty-ui/theme-constants';
+
+type WorkflowOutputSchemaFieldHeaderProps = {
+ name: string;
+ isExpanded: boolean;
+ onToggle: () => void;
+ onRemove?: () => void;
+};
+
+const StyledHeader = styled.div`
+ align-items: center;
+ display: flex;
+ gap: ${themeCssVariables.spacing[1]};
+ padding-right: ${themeCssVariables.spacing[1]};
+
+ &[data-expanded='true'] {
+ box-shadow: inset 0 -1px 0 ${themeCssVariables.border.color.medium};
+ }
+`;
+
+const StyledToggle = styled.button`
+ align-items: center;
+ border-radius: ${themeCssVariables.border.radius.sm};
+ color: ${themeCssVariables.font.color.primary};
+ display: flex;
+ flex: 1;
+ gap: ${themeCssVariables.spacing[1]};
+ height: ${themeCssVariables.spacing[8]};
+ justify-content: space-between;
+ min-width: 0;
+ padding-left: ${themeCssVariables.spacing[2]};
+ text-align: left;
+
+ &:hover {
+ background: ${themeCssVariables.background.transparent.light};
+ }
+
+ &:active {
+ background: ${themeCssVariables.background.transparent.medium};
+ }
+
+ &:focus-visible {
+ outline: 2px solid ${themeCssVariables.color.blue};
+ outline-offset: 1px;
+ }
+`;
+
+const StyledTitle = styled.span`
+ align-items: center;
+ display: flex;
+ gap: ${themeCssVariables.spacing[1]};
+ min-width: 0;
+
+ & > svg {
+ flex-shrink: 0;
+ }
+`;
+
+const StyledName = styled.span`
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+`;
+
+const StyledChevron = styled.span`
+ align-items: center;
+ color: ${themeCssVariables.font.color.secondary};
+ display: flex;
+ flex-shrink: 0;
+ height: ${themeCssVariables.spacing[6]};
+ justify-content: center;
+ transition: transform
+ calc(${themeCssVariables.animation.duration.normal} * 1s) ease;
+ width: ${themeCssVariables.spacing[6]};
+
+ &[data-expanded='true'] {
+ transform: rotate(-180deg);
+ }
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
+`;
+
+export const WorkflowOutputSchemaFieldHeader = ({
+ name,
+ isExpanded,
+ onToggle,
+ onRemove,
+}: WorkflowOutputSchemaFieldHeaderProps) => {
+ const theme = useTheme();
+
+ return (
+ <StyledHeader data-expanded={isExpanded}>
+ <StyledToggle type="button" aria-expanded={isExpanded} onClick={onToggle}>
+ <StyledTitle>
+ <IconVariable size={theme.icon.size.sm} aria-hidden />
+ <StyledName>
+ {isNonEmptyString(name) ? name : t`Untitled field`}
+ </StyledName>
+ </StyledTitle>
+ <StyledChevron data-expanded={isExpanded} aria-hidden>
+ <IconChevronDown size={theme.icon.size.sm} />
+ </StyledChevron>
+ </StyledToggle>
+ {isDefined(onRemove) && (
+ <LightIconButton
+ data-testid="remove-output-field-button"
+ size="sm"
+ onClick={onRemove}
+ aria-label={t`Remove output field`}
+ >
+ <IconX />
+ </LightIconButton>
+ )}
+ </StyledHeader>
+ );
+};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/__stories__/WorkflowOutputSchemaFieldHeader.stories.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/__stories__/WorkflowOutputSchemaFieldHeader.stories.tsx
new file mode 100644
index 00000000000..f2007ed4de1
--- /dev/null
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/ai-agent-action/components/__stories__/WorkflowOutputSchemaFieldHeader.stories.tsx
@@ -0,0 +1,113 @@
+import { WorkflowOutputSchemaFieldHeader } from '@/workflow/workflow-steps/workflow-actions/ai-agent-action/components/WorkflowOutputSchemaFieldHeader';
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { useState } from 'react';
+import { expect, fn, userEvent, within } from 'storybook/test';
+import { ComponentDecorator } from 'twenty-ui/testing';
+
+const meta: Meta<typeof WorkflowOutputSchemaFieldHeader> = {
+ title: 'Modules/Workflow/WorkflowOutputSchemaFieldHeader',
+ component: WorkflowOutputSchemaFieldHeader,
+ decorators: [ComponentDecorator],
+ parameters: { container: { width: 320 } },
+ args: {
+ name: 'Summary',
+ isExpanded: true,
+ onToggle: fn(),
+ onRemove: fn(),
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof WorkflowOutputSchemaFieldHeader>;
+
+const expectRowHeight = async (canvasElement: HTMLElement) => {
+ const header = within(canvasElement).getByRole('button', {
+ name: 'Summary',
+ }).parentElement;
+
+ await expect(header?.getBoundingClientRect().height).toBe(32);
+};
+
+export const Expanded: Story = {
+ play: async ({ canvasElement }) => {
+ await expectRowHeight(canvasElement);
+ },
+};
+
+export const Collapsed: Story = {
+ args: { isExpanded: false },
+ play: async ({ canvasElement }) => {
+ await expectRowHeight(canvasElement);
+ },
+};
+
+export const KeyboardExpansion: Story = {
+ render: function Render(args) {
+ const [isExpanded, setIsExpanded] = useState(args.isExpanded);
+
+ return (
+ <WorkflowOutputSchemaFieldHeader
+ {...args}
+ isExpanded={isExpanded}
+ onToggle={() => {
+ args.onToggle();
+ setIsExpanded((previousIsExpanded) => !previousIsExpanded);
+ }}
+ />
+ );
+ },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const toggle = canvas.getByRole('button', { name: 'Summary' });
+
+ await expect(toggle).toHaveAttribute('type', 'button');
+ await expect(toggle).toHaveAttribute('aria-expanded', 'true');
+ toggle.focus();
+ await userEvent.keyboard('{Enter}');
+ await expect(toggle).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.keyboard(' ');
+ await expect(toggle).toHaveAttribute('aria-expanded', 'true');
+ await expect(args.onToggle).toHaveBeenCalledTimes(2);
+ await userEvent.tab();
+ await expect(
+ canvas.getByRole('button', { name: 'Remove output field' }),
+ ).toHaveFocus();
+ await userEvent.tab();
+ },
+};
+
+export const RemoveWithoutToggling: Story = {
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+ const remove = canvas.getByRole('button', { name: 'Remove output field' });
+
+ await userEvent.click(remove);
+ await expect(args.onRemove).toHaveBeenCalledOnce();
+ await expect(args.onToggle).not.toHaveBeenCalled();
+ },
+};
+
+export const WithoutRemove: Story = {
+ args: { name: '', onRemove: undefined },
+ play: async ({ canvasElement, args }) => {
+ const canvas = within(canvasElement);
+
+ await expect(canvas.getAllByRole('button')).toHaveLength(1);
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Untitled field' }),
+ );
+ await expect(args.onToggle).toHaveBeenCalledOnce();
+ },
+};
+
+export const LongName: Story = {
+ args: { name: 'customer_sentiment_summary_and_next_best_action_rationale' },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const header = canvas.getByRole('button', {
+ name: /customer_sentiment/,
+ }).parentElement;
+
+ await expect(header?.scrollWidth).toBe(header?.clientWidth);
+ },
+};
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.module.scss b/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.module.scss
deleted file mode 100644
index 87f015860d6..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.module.scss
+++ /dev/null
@@ -1,131 +0,0 @@
-// Static rules from the legacy Linaria StyledButton. The dynamic
-// variant/accent/inverted/disabled/focus colors stay computed at runtime in
-// AnimatedButton.tsx (computeAnimatedButtonDynamicStyles) and arrive through
-// the --abtn-* inline custom properties, exactly like the deprecated source.
-.button {
- align-items: center;
- background: var(--abtn-bg);
- border-color: var(--abtn-border-color);
- border-radius: var(--abtn-radius, var(--t-border-radius-md));
- border-style: solid;
- border-width: var(--abtn-border-width);
- box-shadow: var(--abtn-box-shadow);
- color: var(--abtn-color);
- cursor: pointer;
- display: flex;
- flex-direction: row;
- font-family: var(--t-font-family);
- font-size: var(--t-font-size-md);
- font-weight: 500;
- gap: var(--t-spacing-1);
- justify-content: var(--abtn-justify, flex-start);
- padding: 0 var(--t-spacing-2);
- text-decoration: none;
- transition: background 0.1s ease;
- white-space: nowrap;
- width: auto;
-
- &:hover {
- background: var(--abtn-hover-bg);
- }
-
- &:active {
- background: var(--abtn-active-bg);
- }
-
- &:focus {
- outline: none;
- }
-
- @include focus-ring;
-
- &[data-disabled] {
- cursor: not-allowed;
- }
-}
-
-// position only reshapes the radius; standalone uses the .button fallback.
-// These rules only assign the custom property so the border-radius
-// declaration stays on the flat .button class for overridability.
-.button[data-position='left'] {
- --abtn-radius: var(--t-border-radius-md) 0px 0px var(--t-border-radius-md);
-}
-
-.button[data-position='middle'] {
- --abtn-radius: 0px;
-}
-
-.button[data-position='right'] {
- --abtn-radius: 0px var(--t-border-radius-md) var(--t-border-radius-md) 0px;
-}
-
-// --abtn-square-size keeps the square width declaration flat on .square.
-.small {
- --abtn-square-size: 24px;
-
- height: 24px;
-}
-
-.medium {
- --abtn-square-size: 32px;
-
- height: 32px;
-}
-
-.fullWidth {
- width: 100%;
-}
-
-// Square icon-only mode. Declared after .button and .fullWidth so its
-// justify-content, padding and width win the cascade at equal specificity,
-// matching the legacy ternary precedence (square beats fullWidth).
-.square {
- justify-content: center;
- padding: 0;
- width: var(--abtn-square-size);
-}
-
-.motion {
- display: flex;
-}
-
-.separator {
- background: var(--t-font-color-light);
- height: var(--t-spacing-4);
- margin: 0;
- width: 1px;
-
- &[data-size='small'] {
- height: var(--t-spacing-2);
- }
-
- &[data-accent='blue'] {
- background: var(--t-border-color-blue);
- }
-
- &[data-accent='danger'] {
- background: var(--t-border-color-danger);
- }
-}
-
-.shortcutLabel {
- color: var(--t-font-color-light);
- font-weight: var(--t-font-weight-medium);
-
- &[data-accent='blue'] {
- color: var(--t-border-color-blue);
- }
-
- &[data-accent='danger'] {
- color: var(--t-color-red8);
- }
-
- &[data-accent='danger'][data-variant='primary'] {
- color: var(--t-border-color-danger);
- }
-}
-
-.soonPillContainer {
- display: flex;
- margin-left: auto;
-}
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.module.scss.d.ts b/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.module.scss.d.ts
deleted file mode 100644
index 77d187e2b1f..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.module.scss.d.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-declare const classNames: {
- readonly button: 'button';
- readonly small: 'small';
- readonly medium: 'medium';
- readonly fullWidth: 'fullWidth';
- readonly square: 'square';
- readonly motion: 'motion';
- readonly separator: 'separator';
- readonly shortcutLabel: 'shortcutLabel';
- readonly soonPillContainer: 'soonPillContainer';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.tsx b/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.tsx
deleted file mode 100644
index a32d9774325..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedButton/AnimatedButton.tsx
+++ /dev/null
@@ -1,418 +0,0 @@
-import { clsx } from 'clsx';
-import React, { useMemo } from 'react';
-import { Link } from 'react-router-dom';
-
-import { Pill } from '@ui/primitives/data-display/Pill/Pill';
-import { themeCssVariables, useTheme } from '@ui/theme-constants';
-import { GRAY_SCALE_LIGHT } from '@ui/theme/constants/GrayScaleLight';
-import { useIsMobile } from '@ui/utilities';
-import { getOsShortcutSeparator } from '@ui/utilities/device/getOsShortcutSeparator';
-import { type AnimatedButtonAccent } from './internal/AnimatedButtonAccent';
-import { type AnimatedButtonPosition } from './internal/AnimatedButtonPosition';
-import { type AnimatedButtonProps } from './types/AnimatedButtonProps';
-import { type AnimatedButtonVariant } from './internal/AnimatedButtonVariant';
-
-import styles from './AnimatedButton.module.scss';
-
-type AnimatedButtonDynamicStyles = {
- background: string;
- borderColor: string;
- borderWidthOverride: string;
- boxShadow: string;
- color: string;
- hoverBackground: string;
- activeBackground: string;
-};
-
-const computeAnimatedButtonDynamicStyles = ({
- variant,
- inverted,
- accent,
- disabled,
- focus,
- position,
-}: {
- variant: AnimatedButtonVariant;
- inverted: boolean;
- accent: AnimatedButtonAccent;
- disabled: boolean;
- focus: boolean;
- position: AnimatedButtonPosition;
-}): AnimatedButtonDynamicStyles => {
- const result: AnimatedButtonDynamicStyles = {
- background: 'transparent',
- borderColor: 'transparent',
- borderWidthOverride: '',
- boxShadow: 'none',
- color: themeCssVariables.font.color.secondary,
- hoverBackground: 'transparent',
- activeBackground: 'transparent',
- };
-
- switch (variant) {
- case 'primary':
- switch (accent) {
- case 'default':
- result.background = !inverted
- ? themeCssVariables.background.secondary
- : themeCssVariables.background.primary;
- result.borderColor = !inverted
- ? !disabled && focus
- ? themeCssVariables.color.blue
- : themeCssVariables.background.transparent.light
- : themeCssVariables.background.transparent.light;
- result.borderWidthOverride = '1px 1px 1px 1px';
- result.boxShadow =
- !disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? themeCssVariables.accent.tertiary
- : themeCssVariables.background.transparent.medium
- }`
- : 'none';
- result.color = !inverted
- ? !disabled
- ? themeCssVariables.font.color.secondary
- : themeCssVariables.font.color.extraLight
- : themeCssVariables.font.color.secondary;
- if (!disabled) {
- result.hoverBackground = !inverted
- ? themeCssVariables.background.tertiary
- : themeCssVariables.background.secondary;
- result.activeBackground = !inverted
- ? themeCssVariables.background.quaternary
- : themeCssVariables.background.tertiary;
- } else {
- result.hoverBackground = result.background;
- result.activeBackground = result.background;
- }
- break;
- case 'blue':
- result.background = !inverted
- ? themeCssVariables.color.blue
- : themeCssVariables.background.primary;
- result.borderColor = !inverted
- ? focus
- ? themeCssVariables.color.blue
- : themeCssVariables.background.transparent.light
- : themeCssVariables.background.transparent.light;
- result.borderWidthOverride = '1px 1px 1px 1px';
- result.boxShadow =
- !disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? themeCssVariables.accent.tertiary
- : themeCssVariables.background.transparent.medium
- }`
- : 'none';
- result.color = !inverted
- ? GRAY_SCALE_LIGHT.gray1
- : themeCssVariables.color.blue;
- if (!disabled) {
- result.hoverBackground = !inverted
- ? themeCssVariables.color.blue10
- : themeCssVariables.background.secondary;
- result.activeBackground = !inverted
- ? themeCssVariables.color.blue12
- : themeCssVariables.background.tertiary;
- } else {
- result.hoverBackground = result.background;
- result.activeBackground = result.background;
- }
- break;
- case 'danger':
- result.background = !inverted
- ? themeCssVariables.color.red
- : themeCssVariables.background.primary;
- result.borderColor = !inverted
- ? focus
- ? themeCssVariables.color.red
- : themeCssVariables.background.transparent.light
- : themeCssVariables.background.transparent.light;
- result.borderWidthOverride = '1px 1px';
- result.boxShadow =
- !disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? themeCssVariables.color.red3
- : themeCssVariables.background.transparent.medium
- }`
- : 'none';
- result.color = !inverted
- ? themeCssVariables.background.primary
- : themeCssVariables.color.red;
- if (!disabled) {
- result.hoverBackground = !inverted
- ? themeCssVariables.color.red8
- : themeCssVariables.background.secondary;
- result.activeBackground = !inverted
- ? themeCssVariables.color.red10
- : themeCssVariables.background.tertiary;
- } else {
- result.hoverBackground = result.background;
- result.activeBackground = result.background;
- }
- break;
- }
- break;
- case 'secondary':
- case 'tertiary':
- switch (accent) {
- case 'default':
- result.background = 'transparent';
- result.borderColor = !inverted
- ? variant === 'secondary'
- ? !disabled && focus
- ? themeCssVariables.color.blue
- : themeCssVariables.background.transparent.medium
- : focus
- ? themeCssVariables.color.blue
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? GRAY_SCALE_LIGHT.gray1
- : themeCssVariables.background.transparent.primary
- : focus
- ? GRAY_SCALE_LIGHT.gray1
- : 'transparent';
- result.borderWidthOverride = '1px 1px 1px 1px';
- result.boxShadow =
- !disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? themeCssVariables.accent.tertiary
- : themeCssVariables.background.transparent.medium
- }`
- : 'none';
- result.color = !inverted
- ? !disabled
- ? themeCssVariables.font.color.secondary
- : themeCssVariables.font.color.extraLight
- : themeCssVariables.font.color.inverted;
- result.hoverBackground = !inverted
- ? !disabled
- ? themeCssVariables.background.transparent.light
- : 'transparent'
- : themeCssVariables.background.transparent.light;
- result.activeBackground = !inverted
- ? !disabled
- ? themeCssVariables.background.transparent.light
- : 'transparent'
- : themeCssVariables.background.transparent.medium;
- break;
- case 'blue':
- result.background = 'transparent';
- result.borderColor = !inverted
- ? variant === 'secondary'
- ? focus
- ? themeCssVariables.color.blue
- : themeCssVariables.accent.primary
- : focus
- ? themeCssVariables.color.blue
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? GRAY_SCALE_LIGHT.gray1
- : themeCssVariables.background.transparent.primary
- : focus
- ? GRAY_SCALE_LIGHT.gray1
- : 'transparent';
- result.borderWidthOverride = '1px 1px 1px 1px';
- result.boxShadow =
- !disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? themeCssVariables.accent.tertiary
- : themeCssVariables.background.transparent.medium
- }`
- : 'none';
- result.color = !inverted
- ? !disabled
- ? themeCssVariables.color.blue
- : themeCssVariables.accent.accent4060
- : themeCssVariables.font.color.inverted;
- result.hoverBackground = !inverted
- ? !disabled
- ? themeCssVariables.accent.tertiary
- : 'transparent'
- : themeCssVariables.background.transparent.light;
- result.activeBackground = !inverted
- ? !disabled
- ? themeCssVariables.accent.secondary
- : 'transparent'
- : themeCssVariables.background.transparent.medium;
- break;
- case 'danger':
- result.background = 'transparent';
- result.borderColor = !inverted
- ? variant === 'secondary'
- ? focus
- ? themeCssVariables.color.red
- : themeCssVariables.border.color.danger
- : focus
- ? themeCssVariables.color.red
- : 'transparent'
- : variant === 'secondary'
- ? focus || disabled
- ? GRAY_SCALE_LIGHT.gray1
- : themeCssVariables.background.transparent.primary
- : focus
- ? GRAY_SCALE_LIGHT.gray1
- : 'transparent';
- result.borderWidthOverride = '1px 1px 1px 1px';
- result.boxShadow =
- !disabled && focus
- ? `0 0 0 3px ${
- !inverted
- ? themeCssVariables.color.red3
- : themeCssVariables.background.transparent.medium
- }`
- : 'none';
- result.color = !inverted
- ? themeCssVariables.font.color.danger
- : themeCssVariables.font.color.inverted;
- result.hoverBackground = !inverted
- ? !disabled
- ? themeCssVariables.background.danger
- : 'transparent'
- : themeCssVariables.background.transparent.light;
- result.activeBackground = !inverted
- ? !disabled
- ? themeCssVariables.background.danger
- : 'transparent'
- : themeCssVariables.background.transparent.medium;
- break;
- }
- break;
- }
-
- if (result.borderWidthOverride !== '' && position !== 'standalone') {
- switch (position) {
- case 'left':
- result.borderWidthOverride = '1px 0px 1px 1px';
- break;
- case 'middle':
- result.borderWidthOverride = '1px 0px 1px 0px';
- break;
- case 'right':
- result.borderWidthOverride = '1px 1px 1px 0px';
- break;
- }
- }
-
- return result;
-};
-
-export const AnimatedButton = ({
- className,
- Icon,
- animatedSvg,
- title,
- fullWidth = false,
- variant = 'primary',
- inverted = false,
- size = 'medium',
- accent = 'default',
- square = false,
- position = 'standalone',
- soon = false,
- disabled = false,
- justify = 'flex-start',
- focus = false,
- onClick,
- to,
- target,
- dataTestId,
- hotkeys,
- ariaLabel,
- dataClickOutsideId,
- dataGloballyPreventClickOutside,
- soonLabel = 'Soon',
-}: AnimatedButtonProps) => {
- const theme = useTheme();
- const isMobile = useIsMobile();
- const isDisabled = soon || disabled;
-
- const dynamicStyles = useMemo(() => {
- const computedStyles = computeAnimatedButtonDynamicStyles({
- variant,
- inverted,
- accent,
- disabled: isDisabled,
- focus,
- position,
- });
- return {
- '--abtn-bg': computedStyles.background,
- '--abtn-border-color': computedStyles.borderColor,
- '--abtn-border-width': computedStyles.borderWidthOverride || undefined,
- '--abtn-box-shadow': computedStyles.boxShadow,
- '--abtn-color': computedStyles.color,
- '--abtn-hover-bg': computedStyles.hoverBackground,
- '--abtn-active-bg': computedStyles.activeBackground,
- } as React.CSSProperties;
- }, [variant, inverted, accent, isDisabled, focus, position]);
-
- // Replaces the legacy Linaria `as` polymorphism: react-router Link when a
- // `to` is provided, a native button otherwise. Typed as any to forward all
- // props untyped, exactly like the legacy `as` prop did.
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const ButtonComponent: any = to ? Link : 'button';
-
- return (
- <ButtonComponent
- className={clsx(
- styles.button,
- styles[size],
- square && styles.square,
- fullWidth && styles.fullWidth,
- className,
- )}
- data-position={position}
- data-disabled={isDisabled || undefined}
- disabled={isDisabled}
- style={
- {
- ...dynamicStyles,
- '--abtn-justify': justify,
- } as React.CSSProperties
- }
- onClick={onClick}
- to={to}
- target={target}
- data-testid={dataTestId}
- aria-label={ariaLabel}
- data-click-outside-id={dataClickOutsideId}
- data-globally-prevent-click-outside={dataGloballyPreventClickOutside}
- >
- {Icon && (
- <div className={styles.motion}>
- <Icon size={theme.icon.size.sm} aria-hidden />
- </div>
- )}
- {animatedSvg && <div className={styles.motion}>{animatedSvg}</div>}
- {title}
- {hotkeys && !isMobile && (
- <>
- <div
- className={styles.separator}
- data-size={size}
- data-accent={accent}
- />
- <div
- className={styles.shortcutLabel}
- data-variant={variant}
- data-accent={accent}
- >
- {hotkeys.join(getOsShortcutSeparator())}
- </div>
- </>
- )}
- {soon && (
- <span className={styles.soonPillContainer}>
- <Pill label={soonLabel} />
- </span>
- )}
- </ButtonComponent>
- );
-};
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonAccent.ts b/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonAccent.ts
deleted file mode 100644
index 97d601de664..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonAccent.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type AnimatedButtonAccent = 'default' | 'blue' | 'danger' | 'green';
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonBaseProps.ts b/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonBaseProps.ts
deleted file mode 100644
index c4250d85dd3..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonBaseProps.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-import { type ComponentProps, type MouseEvent } from 'react';
-import { type IconComponent } from '@ui/icon';
-import { type ClickOutsideAttributes } from '@ui/utilities/types/ClickOutsideAttributes';
-import { type AnimatedButtonAccent } from './AnimatedButtonAccent';
-import { type AnimatedButtonVariant } from './AnimatedButtonVariant';
-import { type AnimatedButtonPosition } from './AnimatedButtonPosition';
-
-export type AnimatedButtonBaseProps = ClickOutsideAttributes & {
- id?: string;
- className?: string;
- Icon?: IconComponent;
- title?: string;
- fullWidth?: boolean;
- variant?: AnimatedButtonVariant;
- inverted?: boolean;
- size?: 'small' | 'medium';
- position?: AnimatedButtonPosition;
- accent?: AnimatedButtonAccent;
- soon?: boolean;
- justify?: 'center' | 'flex-start' | 'flex-end';
- disabled?: boolean;
- focus?: boolean;
- onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
- to?: string;
- target?: string;
- dataTestId?: string;
- hotkeys?: string[];
- ariaLabel?: string;
- isLoading?: boolean;
- type?: ComponentProps<'button'>['type'];
-};
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonPosition.ts b/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonPosition.ts
deleted file mode 100644
index cb8b83efd04..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonPosition.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type AnimatedButtonPosition = 'standalone' | 'left' | 'middle' | 'right';
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonVariant.ts b/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonVariant.ts
deleted file mode 100644
index 99a63fa83a1..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedButton/internal/AnimatedButtonVariant.ts
+++ /dev/null
@@ -1 +0,0 @@
-export type AnimatedButtonVariant = 'primary' | 'secondary' | 'tertiary';
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedButton/types/AnimatedButtonProps.ts b/packages/twenty-ui/src/primitives/input/AnimatedButton/types/AnimatedButtonProps.ts
deleted file mode 100644
index 4ef9a8422d2..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedButton/types/AnimatedButtonProps.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { type ReactNode } from 'react';
-import { type AnimatedButtonBaseProps } from '../internal/AnimatedButtonBaseProps';
-
-export type AnimatedButtonProps = AnimatedButtonBaseProps & {
- animatedSvg: ReactNode;
- soonLabel?: string;
- square?: boolean;
-};
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.module.scss b/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.module.scss
deleted file mode 100644
index d2a9e140f41..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.module.scss
+++ /dev/null
@@ -1,80 +0,0 @@
-// Color/border/shadow rules replicate the legacy Linaria ternaries. Order
-// matters at equal specificity: accent base, then disabled, then focus and
-// active last (active || focus beats disabled, matching the legacy switch).
-.button {
- align-items: center;
- background: transparent;
- border: none;
- border-radius: var(--t-border-radius-md);
- box-shadow: none;
- color: var(--t-font-color-secondary);
- cursor: pointer;
- display: flex;
- flex-direction: row;
- font-family: var(--t-font-family);
- font-weight: var(--t-font-weight-regular);
- gap: var(--t-spacing-1);
- justify-content: center;
- padding: var(--t-spacing-1);
- transition: background 0.1s ease;
- white-space: nowrap;
-
- &:hover {
- background: var(--t-background-transparent-light);
- }
-
- &:focus {
- outline: none;
- }
-
- @include focus-ring;
-
- &:active {
- background: var(--t-background-transparent-medium);
- }
-
- &[data-accent='tertiary'] {
- color: var(--t-font-color-tertiary);
- }
-
- &[data-disabled] {
- color: var(--t-font-color-extra-light);
- cursor: not-allowed;
-
- &:hover,
- &:active {
- background: transparent;
- }
- }
-
- // data-focus is only set when enabled, so disabled+focus stays unstyled,
- // matching the legacy focus={focus && !disabled} gating.
- &[data-focus] {
- border: 1px solid var(--t-color-blue);
- box-shadow: 0 0 0 3px var(--t-color-blue3);
- color: var(--t-color-blue);
- }
-
- &[data-active] {
- color: var(--t-color-blue);
- }
-}
-
-.small {
- height: 24px;
- min-width: 24px;
- width: 24px;
-}
-
-.medium {
- height: 32px;
- min-width: 32px;
- width: 32px;
-}
-
-.iconContainer {
- align-items: center;
- display: flex;
- justify-content: center;
- transition: transform duration(normal) ease;
-}
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.module.scss.d.ts b/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.module.scss.d.ts
deleted file mode 100644
index 8acffa9bd74..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.module.scss.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-declare const classNames: {
- readonly button: 'button';
- readonly small: 'small';
- readonly medium: 'medium';
- readonly iconContainer: 'iconContainer';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.tsx b/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.tsx
deleted file mode 100644
index 63631ad2791..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton.tsx
+++ /dev/null
@@ -1,69 +0,0 @@
-import { clsx } from 'clsx';
-import { type ComponentProps, type MouseEvent } from 'react';
-
-import { type IconComponent } from '@ui/icon';
-import { useTheme } from '@ui/theme-constants';
-
-import styles from './AnimatedLightIconButton.module.scss';
-
-export type AnimatedLightIconButtonProps = {
- className?: string;
- testId?: string;
- Icon?: IconComponent;
- title?: string;
- size?: 'small' | 'medium';
- accent?: 'secondary' | 'tertiary';
- active?: boolean;
- disabled?: boolean;
- focus?: boolean;
- rotate?: number;
- onClick?: (event: MouseEvent<HTMLButtonElement>) => void;
-} & Pick<ComponentProps<'button'>, 'aria-label' | 'title'>;
-
-export const AnimatedLightIconButton = ({
- 'aria-label': ariaLabel,
- className,
- testId,
- Icon,
- active = false,
- size = 'small',
- accent = 'secondary',
- disabled = false,
- focus = false,
- rotate,
- onClick,
- title,
-}: AnimatedLightIconButtonProps) => {
- const theme = useTheme();
-
- return (
- <button
- data-testid={testId}
- aria-label={ariaLabel}
- onClick={onClick}
- disabled={disabled}
- data-disabled={disabled || undefined}
- data-focus={(focus && !disabled) || undefined}
- data-accent={accent}
- data-active={active || undefined}
- className={clsx(styles.button, styles[size], className)}
- title={title}
- >
- <div
- className={styles.iconContainer}
- style={
- rotate !== undefined
- ? { transform: `rotate(${rotate}deg)` }
- : undefined
- }
- >
- {Icon && (
- <Icon
- size={size === 'medium' ? theme.icon.size.md : theme.icon.size.sm}
- aria-hidden={!!ariaLabel}
- />
- )}
- </div>
- </button>
- );
-};
diff --git a/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/__stories__/AnimatedLightIconButton.stories.tsx b/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/__stories__/AnimatedLightIconButton.stories.tsx
deleted file mode 100644
index b23fc667380..00000000000
--- a/packages/twenty-ui/src/primitives/input/AnimatedLightIconButton/__stories__/AnimatedLightIconButton.stories.tsx
+++ /dev/null
@@ -1,109 +0,0 @@
-import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { IconSearch } from '@ui/icon';
-import {
- A11Y_DEFER_COLOR_CONTRAST,
- CatalogDecorator,
- type CatalogStory,
- ComponentDecorator,
-} from '@ui/testing';
-import {
- AnimatedLightIconButton,
- type AnimatedLightIconButtonProps,
-} from '@ui/primitives/input/AnimatedLightIconButton/AnimatedLightIconButton';
-
-const meta: Meta<typeof AnimatedLightIconButton> = {
- title: 'UI/Input/Button/AnimatedLightIconButton',
- component: AnimatedLightIconButton,
-};
-
-export default meta;
-type Story = StoryObj<typeof AnimatedLightIconButton>;
-
-export const Default: Story = {
- args: {
- title: 'Filter',
- accent: 'secondary',
- disabled: false,
- active: false,
- focus: false,
- Icon: IconSearch,
- },
- argTypes: {
- Icon: { control: false },
- },
- decorators: [ComponentDecorator],
-};
-
-export const Catalog: CatalogStory<Story, typeof AnimatedLightIconButton> = {
- args: {
- title: 'Filter',
- Icon: IconSearch,
- },
- argTypes: {
- accent: { control: false },
- disabled: { control: false },
- active: { control: false },
- focus: { control: false },
- },
- parameters: {
- a11y: A11Y_DEFER_COLOR_CONTRAST,
- pseudo: { hover: ['.hover'], active: ['.pressed'] },
- catalog: {
- dimensions: [
- {
- name: 'states',
- values: [
- 'default',
- 'hover',
- 'pressed',
- 'disabled',
- 'active',
- 'focus',
- 'disabled+focus',
- 'disabled+active',
- ],
- props: (state: string) => {
- switch (state) {
- case 'default':
- return {};
- case 'hover':
- case 'pressed':
- return { className: state };
- case 'focus':
- return { focus: true };
- case 'disabled':
- return { disabled: true };
- case 'active':
- return { active: true };
- case 'disabled+focus':
- return { disabled: true, focus: true };
- case 'disabled+active':
- return { disabled: true, active: true };
- default:
- return {};
- }
- },
- },
- {
- name: 'accents',
- values: [
- 'secondary',
- 'tertiary',
- ] satisfies AnimatedLightIconButtonProps['accent'][],
- props: (accent: AnimatedLightIconButtonProps['accent']) => ({
- accent,
- }),
- },
- {
- name: 'sizes',
- values: [
- 'small',
- 'medium',
- ] satisfies AnimatedLightIconButtonProps['size'][],
- props: (size: AnimatedLightIconButtonProps['size']) => ({ size }),
- },
- ],
- },
- },
- decorators: [CatalogDecorator],
-};
diff --git a/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx b/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
index 5dc6cb3703e..2d8f0baf8f7 100644
--- a/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
+++ b/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
@@ -1,8 +1,9 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
import { useState } from 'react';
-import { expect, fn, userEvent, within } from 'storybook/test';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
-import { IconArrowRight, IconPlus } from '@ui/icon';
+import { IconArrowRight, IconPencil, IconPlus, IconX } from '@ui/icon';
+import { AnimatedIconCrossfade } from '@ui/primitives/layout/AnimatedIconCrossfade/AnimatedIconCrossfade';
import {
A11Y_DEFER_COLOR_CONTRAST,
CatalogDecorator,
@@ -23,6 +24,58 @@ export default meta;
type Story = StoryObj<typeof Button>;
export const Default: Story = { decorators: [ComponentDecorator] };
+export const AnimatedIcon: Story = {
+ ...Default,
+ render: function Render() {
+ const [isEditing, setIsEditing] = useState(false);
+
+ return (
+ <Button
+ size="sm"
+ aria-expanded={isEditing}
+ onClick={() => setIsEditing(!isEditing)}
+ startIcon={
+ <AnimatedIconCrossfade
+ isActive={isEditing}
+ ActiveIcon={IconX}
+ InactiveIcon={IconPencil}
+ />
+ }
+ >
+ Edit actions
+ </Button>
+ );
+ },
+ play: async ({ canvasElement }) => {
+ const button = within(canvasElement).getByRole('button', {
+ name: 'Edit actions',
+ });
+ await document.fonts.load('500 1em Inter');
+ await document.fonts.ready;
+ const [pencil, cross] = button.querySelectorAll('svg');
+ const originalWidth = button.getBoundingClientRect().width;
+
+ await expect(button.getBoundingClientRect().height).toBe(24);
+ await expect(pencil.getBoundingClientRect().width).toBe(14);
+ button.focus();
+ await userEvent.keyboard('{Enter}');
+ await expect(button).toHaveAttribute('aria-expanded', 'true');
+ await waitFor(() => {
+ expect(getComputedStyle(pencil.parentElement!).opacity).toBe('0');
+ expect(getComputedStyle(cross.parentElement!).opacity).toBe('1');
+ });
+ await waitFor(() =>
+ expect(button.getBoundingClientRect().width).toBe(originalWidth),
+ );
+ await userEvent.keyboard(' ');
+ await expect(button).toHaveAttribute('aria-expanded', 'false');
+ await userEvent.tab();
+ },
+};
+export const AnimatedIconDocumentation: Story = {
+ ...AnimatedIcon,
+ play: undefined,
+};
export const Keyboard: Story = {
...Default,
args: { onClick: fn(), onFocus: fn(), onBlur: fn() },
diff --git a/packages/twenty-ui/src/primitives/input/index.ts b/packages/twenty-ui/src/primitives/input/index.ts
index 2265ff27b1f..9d21c6eff3e 100644
--- a/packages/twenty-ui/src/primitives/input/index.ts
+++ b/packages/twenty-ui/src/primitives/input/index.ts
@@ -7,10 +7,6 @@
* |___/
*/
-export { AnimatedButton } from './AnimatedButton/AnimatedButton';
-export type { AnimatedButtonProps } from './AnimatedButton/types/AnimatedButtonProps';
-export type { AnimatedLightIconButtonProps } from './AnimatedLightIconButton/AnimatedLightIconButton';
-export { AnimatedLightIconButton } from './AnimatedLightIconButton/AnimatedLightIconButton';
export { Button } from './Button/Button';
export type { ButtonColor } from './Button/types/ButtonColor';
export type { ButtonProps } from './Button/types/ButtonProps';
diff --git a/packages/twenty-ui/src/primitives/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.module.scss b/packages/twenty-ui/src/primitives/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.module.scss
index d6735352e03..5cce0773f0b 100644
--- a/packages/twenty-ui/src/primitives/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.module.scss
+++ b/packages/twenty-ui/src/primitives/layout/AnimatedIconCrossfade/AnimatedIconCrossfade.module.scss
@@ -14,6 +14,10 @@
transition:
opacity duration(fast) ease-in-out,
transform duration(fast) ease-in-out;
+
+ @media (prefers-reduced-motion: reduce) {
+ transition: none;
+ }
}
.visible {