The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Add a shared reaction button (#28571)
Raphaรซl Bosi520e93040c02
diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.jsonindex f536030b802..a67520371fa 100644--- a/packages/twenty-docs/docs.json+++ b/packages/twenty-docs/docs.json@@ -651,6 +651,7 @@"ui/components/input/light-button","ui/components/input/icon-button","ui/components/input/light-icon-button",+ "ui/components/input/reaction-button","ui/components/input/country-select","ui/components/input/currency-picker","ui/components/input/phone-country-picker",diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.jsonindex d9c7177d117..1077b02732d 100644--- a/packages/twenty-docs/navigation/base-structure.json+++ b/packages/twenty-docs/navigation/base-structure.json@@ -672,6 +672,7 @@"ui/components/input/light-button","ui/components/input/icon-button","ui/components/input/light-icon-button",+ "ui/components/input/reaction-button","ui/components/input/country-select","ui/components/input/currency-picker","ui/components/input/phone-country-picker",diff --git a/packages/twenty-docs/snippets/ui/generated/components/input/reaction-button.mdx b/packages/twenty-docs/snippets/ui/generated/components/input/reaction-button.mdxnew file mode 100644index 00000000000..8ed41960a21--- /dev/null+++ b/packages/twenty-docs/snippets/ui/generated/components/input/reaction-button.mdx@@ -0,0 +1,52 @@+{/*+ * _____ _+ *|_ _|_ _____ _ __ | |_ _ _+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file+ * | | \ V V / __/ | | | |_| |_| | DO NOT EDIT - changes will be overwritten+ * |_| \_/\_/ \___|_| |_|\__|\__, | Generated by: npx nx generate:ui twenty-docs+ * |___/+ *+ * This file is generated from the documentation data in packages/twenty-ui/generated.+ * To update it, edit the component prop types or design tokens in twenty-ui and run:+ * npx nx generate:ui twenty-docs+ */}++<ParamField body="aria-label" type="string">+ Accessible name describing the reaction. Required unless `aria-labelledby` supplies the name.+</ParamField>++<ParamField body="aria-labelledby" type="string">+ ID of the element supplying the accessible name. Can be used instead of `aria-label`.+</ParamField>++<ParamField body="count" type="string | number" required>+ Displayed count. Pass a string for localized or abbreviated formatting. Hidden from assistive technology.+</ParamField>++<ParamField body="disabled" type="boolean" default="false">+ Disables the native button and prevents activation.+</ParamField>++<ParamField body="emoji" type="string" required>+ Emoji displayed beside the count. Hidden from assistive technology.+</ParamField>++<ParamField body="loading" type="boolean" default="false">+ Shows a loading indicator, sets `aria-busy`, and prevents activation without changing the supplied pressed state.+</ParamField>++<ParamField body="onClick" type="MouseEventHandler<HTMLButtonElement>">+ Native click handler called before `onPressedChange`. Calling `preventDefault()` cancels the change request.+</ParamField>++<ParamField body="onPressedChange" type="(pressed: boolean) => void" required>+ Requests the next pressed state after activation. The caller updates `pressed` and `count`.+</ParamField>++<ParamField body="pressed" type="boolean" required>+ Controlled selection state. Sets the selected appearance and `aria-pressed`.+</ParamField>++<ParamField body="title" type="string">+ Optional native tooltip text supplied by the caller.+</ParamField>diff --git a/packages/twenty-docs/ui/components/input/reaction-button.mdx b/packages/twenty-docs/ui/components/input/reaction-button.mdxnew file mode 100644index 00000000000..918d497a6c4--- /dev/null+++ b/packages/twenty-docs/ui/components/input/reaction-button.mdx@@ -0,0 +1,105 @@+---+title: ReactionButton+description: Toggle an emoji reaction with a count and controlled pressed state.+---++import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';+import ReactionButtonReference from '/snippets/ui/generated/components/input/reaction-button.mdx';++`ReactionButton` composes [Button](/ui/primitives/input/button) into a compact emoji reaction with a count. Your application supplies the pressed state, accessible name, and change handler.++<StoryEmbed+ storyId="ui-components-reactionbutton--display"+ title="Controlled helpful reaction with a tooltip and reset action"+ height={160}+/>++## Usage++```tsx+import { useState } from 'react';+import {+ ReactionButton,+ type ReactionButtonProps,+} from 'twenty-ui/components/input';+import { Button } from 'twenty-ui/primitives/input';+import { Tooltip } from 'twenty-ui/primitives/surfaces';+import { Text } from 'twenty-ui/primitives/typography';+import { themeCssVariables } from 'twenty-ui/theme';++export const ReactionButtonExample = ({+ emoji = '๐',+ disabled,+ loading,+}: Partial<Pick<ReactionButtonProps, 'emoji' | 'disabled' | 'loading'>>) => {+ const [pressed, setPressed] = useState(false);+ const count = pressed ? 3 : 2;++ return (+ <Text+ style={{+ display: 'flex',+ flexDirection: 'column',+ gap: themeCssVariables.spacing[2],+ }}+ >+ <Text>Was this helpful?</Text>+ <Text+ render={<span />}+ style={{+ display: 'flex',+ alignItems: 'center',+ gap: themeCssVariables.spacing[1],+ }}+ >+ <Tooltip content={`${count} people found this helpful`}>+ <ReactionButton+ aria-label="Helpful"+ emoji={emoji}+ count={count}+ pressed={pressed}+ onPressedChange={setPressed}+ disabled={disabled}+ loading={loading}+ />+ </Tooltip>+ <Button size="sm" variant="ghost" onClick={() => setPressed(false)}>+ Reset+ </Button>+ </Text>+ </Text>+ );+};+```++## Appearance++The control is 24px tall, with rounded corners, a 16px emoji, and a small count. Pressed reactions use the theme's accent surface and text. Unpressed reactions use a transparent surface and secondary text.++`count` accepts a number or a caller-formatted string. Your application owns number formatting, abbreviation, and whether to display a reaction with a zero count.++<StoryEmbed+ storyId="ui-components-reactionbutton--catalog"+ title="Reaction selection, counts, and unavailable states"+ height={300}+/>++## State ownership++`pressed` is required and controlled by your application. Activation calls `onPressedChange` with the requested next value. The component keeps showing the supplied `pressed` and `count` until your application updates them.++Set `loading` while a mutation is pending to show Button's loading indicator and prevent repeated activation. It preserves the supplied `pressed` value and marks the control busy. Use `disabled` when the reaction is unavailable. Selection, counts, permissions, persistence, and any optimistic updates stay in the application.++Native `onClick` runs before the change request. Calling `event.preventDefault()` in that handler cancels the request. Other native button attributes, handlers, styles, class names, and refs pass through to the button. The control always uses `type="button"`.++## Accessibility and tooltips++Provide `aria-label` or `aria-labelledby` with a localized reaction name. Emoji and count are decorative and hidden from assistive technology, so include count or participant information in the supplied name or description when needed. Keep the reaction name stable as its state changes; `aria-pressed` communicates selection.++The native button supports Tab focus and activation with Enter or Space. Both `disabled` and `loading` prevent activation. The ref points to the native button.++Compose [Tooltip](/ui/primitives/surfaces/tooltip) for participant details on hover and keyboard focus, as shown above, or pass a native `title`. Tooltip content belongs to the caller and does not replace the accessible name. Long accessible labels do not enlarge the visible control.++## Props++<ReactionButtonReference />diff --git a/packages/twenty-docs/ui/components/overview.mdx b/packages/twenty-docs/ui/components/overview.mdxindex c9165f864f9..11b9de7da63 100644--- a/packages/twenty-docs/ui/components/overview.mdx+++ b/packages/twenty-docs/ui/components/overview.mdx@@ -18,6 +18,7 @@ Import from `twenty-ui/components/input`.| [LightButton](/ui/components/input/light-button) | Lightweight actions with standard or subtle emphasis. || [IconButton](/ui/components/input/icon-button) | Square or round icon actions built on Button. || [LightIconButton](/ui/components/input/light-icon-button) | Lightweight icon actions with standard or subtle emphasis. |+| [ReactionButton](/ui/components/input/reaction-button) | Emoji reactions with a count and controlled pressed state. || [PhoneCountryPicker](/ui/components/input/phone-country-picker) | Searchable country flags and calling-code selection. || [NumberStepper](/ui/components/input/number-stepper) | Compact numeric input with optional step buttons. || [SearchInput](/ui/components/input/search-input) | Search text and optional filter controls. |diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.tsindex c648b51faff..b156b012ae3 100644--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts@@ -161,6 +161,7 @@ export const DOCUMENTATION_PATHS = {UI_COMPONENTS_INPUT_NUMBER_STEPPER: '/ui/components/input/number-stepper',UI_COMPONENTS_INPUT_PHONE_COUNTRY_PICKER:'/ui/components/input/phone-country-picker',+ UI_COMPONENTS_INPUT_REACTION_BUTTON: '/ui/components/input/reaction-button',UI_COMPONENTS_INPUT_SEARCH_INPUT: '/ui/components/input/search-input',UI_COMPONENTS_INPUT_SEGMENTED_CONTROL:'/ui/components/input/segmented-control',diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.tsindex 4fbafa97ad5..bf0b5cc64c0 100644--- a/packages/twenty-ui/docs/components.ts+++ b/packages/twenty-ui/docs/components.ts@@ -66,6 +66,7 @@ import { HEADING_PROP_DESCRIPTIONS } from './headingPropDescriptions';import { SEPARATOR_PROP_DESCRIPTIONS } from './separatorPropDescriptions';import { ICON_BUTTON_PROP_DESCRIPTIONS } from './iconButtonPropDescriptions';import { LIGHT_BUTTON_PROP_DESCRIPTIONS } from './lightButtonPropDescriptions';+import { REACTION_BUTTON_PROP_DESCRIPTIONS } from './reactionButtonPropDescriptions';import { LIGHT_ICON_BUTTON_PROP_DESCRIPTIONS } from './lightIconButtonPropDescriptions';import { LOADER_PROP_DESCRIPTIONS } from './loaderPropDescriptions';import { SKELETON_PROP_DESCRIPTIONS } from './skeletonPropDescriptions';@@ -341,6 +342,14 @@ export const DOCUMENTED_COMPONENTS = [propDescriptions: LIGHT_BUTTON_PROP_DESCRIPTIONS,propDefaults: { variant: 'ghost', size: 'sm' },},+ {+ name: 'ReactionButton',+ source: 'components/input/ReactionButton/ReactionButton.tsx',+ entryPoint: 'twenty-ui/components/input',+ slug: 'components/input/reaction-button',+ propDescriptions: REACTION_BUTTON_PROP_DESCRIPTIONS,+ propDefaults: { loading: 'false', disabled: 'false' },+ },{name: 'Button',source: 'primitives/input/Button/Button.tsx',diff --git a/packages/twenty-ui/docs/label-ownership.md b/packages/twenty-ui/docs/label-ownership.mdindex f2511c69786..a97c7283e3f 100644--- a/packages/twenty-ui/docs/label-ownership.md+++ b/packages/twenty-ui/docs/label-ownership.md@@ -11,6 +11,7 @@ This covers production exports under components, primitives, and icons, includin| CurrencyPicker | Caller-owned catalogue, option content, selected content, placeholders, and trigger and popup names. `searchLabel` defaults to `Search`; native `searchProps` can override its attributes. `emptyLabel` defaults to `No results`. The listbox inherits the registered Dropdown title or trigger name; `listLabel` names only that selection listbox. Native Options accessible labels stay on its own wrapper div. || Button, MainButton, LightButton | Children and native accessible attributes. Applications compose upcoming-feature labels with Badge. Loading preserves the supplied name and marks the button busy; its spinner is decorative. Button hints use the shared Shortcut presentation and remain decorative. `shortcutJoinLabel` supplies the sequence join label. || IconButton and LightIconButton | Caller-supplied accessible label and optional tooltip. Native `aria-labelledby` remains available and takes precedence. |+| ReactionButton | Caller-supplied emoji, count formatting, accessible name, and optional native title or composed Tooltip content. The emoji and count are decorative; `pressed` supplies the accessible selection state. || SearchInput | Caller-owned placeholder, native accessible name and action labels. Referenced labels take precedence over explicit labels and placeholder fallback. || CountrySelect | Root owns caller-supplied country labels and `noCountryLabel` (default `No country`). Trigger accepts `label`, native accessible names, and custom children. Options owns `searchLabel` (default `Search`) and `noResultsLabel` (default `No results`). The shorthand exposes the same labels. Applications own translations, stable identifiers, and persistence conversions. || PhoneCountryPicker | Callers supply country labels and the trigger name. The selected label describes the trigger; the popup uses its trigger name unless named explicitly. Options defaults are `Search` (`searchLabel`), `Countries` (`listLabel`) and `No results` (`emptyLabel`), also available through shorthand `optionsProps`. Calling codes omit the plus sign in caller data and display with LTR isolation. |diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.jsonindex 5c9dc553818..7b43d17629c 100644--- a/packages/twenty-ui/docs/module-ownership.json+++ b/packages/twenty-ui/docs/module-ownership.json@@ -68,6 +68,7 @@"NumberStepper","OverflowingList","PhoneCountryPicker",+ "ReactionButton","SearchInput","Section","SegmentedControl",diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.jsonindex 3fbc18d3b61..66f4deafbfb 100644--- a/packages/twenty-ui/docs/public-exports.json+++ b/packages/twenty-ui/docs/public-exports.json@@ -99,6 +99,7 @@"MainButton": "components/input/MainButton/MainButton","NumberStepper": "components/input/NumberStepper/NumberStepper","PhoneCountryPicker": "components/input/PhoneCountryPicker/PhoneCountryPicker",+ "ReactionButton": "components/input/ReactionButton/ReactionButton","SearchInput": "components/input/SearchInput/SearchInput","SegmentedControl": "components/input/SegmentedControl/SegmentedControl"},@@ -127,6 +128,7 @@"PhoneCountryPickerProps": "components/input/PhoneCountryPicker/types/PhoneCountryPickerProps","PhoneCountryPickerRootProps": "components/input/PhoneCountryPicker/types/PhoneCountryPickerRootProps","PhoneCountryPickerTriggerProps": "components/input/PhoneCountryPicker/types/PhoneCountryPickerTriggerProps",+ "ReactionButtonProps": "components/input/ReactionButton/types/ReactionButtonProps","SearchInputProps": "components/input/SearchInput/types/SearchInputProps","SegmentedControlOption": "components/input/SegmentedControl/types/SegmentedControlOption","SegmentedControlProps": "components/input/SegmentedControl/types/SegmentedControlProps",diff --git a/packages/twenty-ui/docs/reactionButtonPropDescriptions.ts b/packages/twenty-ui/docs/reactionButtonPropDescriptions.tsnew file mode 100644index 00000000000..c02b00d7c66--- /dev/null+++ b/packages/twenty-ui/docs/reactionButtonPropDescriptions.ts@@ -0,0 +1,21 @@+import { type ReactionButtonProps } from '../src/components/input/ReactionButton/types/ReactionButtonProps';++export const REACTION_BUTTON_PROP_DESCRIPTIONS = {+ emoji: 'Emoji displayed beside the count. Hidden from assistive technology.',+ count:+ 'Displayed count. Pass a string for localized or abbreviated formatting. Hidden from assistive technology.',+ pressed:+ 'Controlled selection state. Sets the selected appearance and `aria-pressed`.',+ onPressedChange:+ 'Requests the next pressed state after activation. The caller updates `pressed` and `count`.',+ loading:+ 'Shows a loading indicator, sets `aria-busy`, and prevents activation without changing the supplied pressed state.',+ disabled: 'Disables the native button and prevents activation.',+ onClick:+ 'Native click handler called before `onPressedChange`. Calling `preventDefault()` cancels the change request.',+ 'aria-label':+ 'Accessible name describing the reaction. Required unless `aria-labelledby` supplies the name.',+ 'aria-labelledby':+ 'ID of the element supplying the accessible name. Can be used instead of `aria-label`.',+ title: 'Optional native tooltip text supplied by the caller.',+} satisfies Partial<Record<keyof ReactionButtonProps, string>>;diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.jsonindex 8df2f497288..679dec31135 100644--- a/packages/twenty-ui/generated/components.docs.json+++ b/packages/twenty-ui/generated/components.docs.json@@ -3239,6 +3239,83 @@}]},+ {+ "name": "ReactionButton",+ "entryPoint": "twenty-ui/components/input",+ "slug": "components/input/reaction-button",+ "props": [+ {+ "name": "aria-label",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Accessible name describing the reaction. Required unless `aria-labelledby` supplies the name."+ },+ {+ "name": "aria-labelledby",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "ID of the element supplying the accessible name. Can be used instead of `aria-label`."+ },+ {+ "name": "count",+ "type": "string | number",+ "required": true,+ "defaultValue": null,+ "description": "Displayed count. Pass a string for localized or abbreviated formatting. Hidden from assistive technology."+ },+ {+ "name": "disabled",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Disables the native button and prevents activation."+ },+ {+ "name": "emoji",+ "type": "string",+ "required": true,+ "defaultValue": null,+ "description": "Emoji displayed beside the count. Hidden from assistive technology."+ },+ {+ "name": "loading",+ "type": "boolean",+ "required": false,+ "defaultValue": "false",+ "description": "Shows a loading indicator, sets `aria-busy`, and prevents activation without changing the supplied pressed state."+ },+ {+ "name": "onClick",+ "type": "MouseEventHandler<HTMLButtonElement>",+ "required": false,+ "defaultValue": null,+ "description": "Native click handler called before `onPressedChange`. Calling `preventDefault()` cancels the change request."+ },+ {+ "name": "onPressedChange",+ "type": "(pressed: boolean) => void",+ "required": true,+ "defaultValue": null,+ "description": "Requests the next pressed state after activation. The caller updates `pressed` and `count`."+ },+ {+ "name": "pressed",+ "type": "boolean",+ "required": true,+ "defaultValue": null,+ "description": "Controlled selection state. Sets the selected appearance and `aria-pressed`."+ },+ {+ "name": "title",+ "type": "string",+ "required": false,+ "defaultValue": null,+ "description": "Optional native tooltip text supplied by the caller."+ }+ ]+ },{"name": "Button","entryPoint": "twenty-ui/primitives/input",diff --git a/packages/twenty-ui/src/components/input/ReactionButton/ReactionButton.module.scss b/packages/twenty-ui/src/components/input/ReactionButton/ReactionButton.module.scssnew file mode 100644index 00000000000..d75d6e9e8e5--- /dev/null+++ b/packages/twenty-ui/src/components/input/ReactionButton/ReactionButton.module.scss@@ -0,0 +1,27 @@+.button[data-variant='ghost'][data-color='neutral'] {+ --tw-button-padding-inline: var(--t-spacing-1);+ --tw-button-radius: var(--t-border-radius-md-round);++ border: 0;+ corner-shape: round;+ font-size: var(--t-font-size-sm);++ &[aria-pressed='true'] {+ --tw-button-background: var(--t-accent-tertiary);+ --tw-button-color: var(--t-accent-accent10);+ --tw-button-hover: var(--t-accent-secondary);+ --tw-button-active: var(--t-accent-secondary);+ }+}++.content {+ align-items: center;+ display: inline-flex;+ gap: var(--t-spacing-1);+}++.emoji {+ font-size: var(--t-font-size-lg);+ font-weight: var(--t-font-weight-regular);+ line-height: 1;+}diff --git a/packages/twenty-ui/src/components/input/ReactionButton/ReactionButton.tsx b/packages/twenty-ui/src/components/input/ReactionButton/ReactionButton.tsxnew file mode 100644index 00000000000..dc8eca3d679--- /dev/null+++ b/packages/twenty-ui/src/components/input/ReactionButton/ReactionButton.tsx@@ -0,0 +1,41 @@+import { clsx } from 'clsx';++import { Button } from '@ui/primitives/input/Button/Button';++import styles from './ReactionButton.module.scss';+import { type ReactionButtonProps } from './types/ReactionButtonProps';++export const ReactionButton = ({+ emoji,+ count,+ pressed,+ onPressedChange,+ onClick,+ className,+ ...props+}: ReactionButtonProps) => (+ <Button+ // oxlint-disable-next-line react/jsx-props-no-spreading+ {...props}+ type="button"+ size="sm"+ variant="ghost"+ color="neutral"+ aria-pressed={pressed}+ className={clsx(styles.button, className)}+ onClick={(event) => {+ onClick?.(event);++ if (event.defaultPrevented) {+ return;+ }++ onPressedChange(!pressed);+ }}+ >+ <span className={styles.content} aria-hidden>+ <span className={styles.emoji}>{emoji}</span>+ <span>{count}</span>+ </span>+ </Button>+);diff --git a/packages/twenty-ui/src/components/input/ReactionButton/__stories__/ReactionButton.stories.tsx b/packages/twenty-ui/src/components/input/ReactionButton/__stories__/ReactionButton.stories.tsxnew file mode 100644index 00000000000..a4150128b40--- /dev/null+++ b/packages/twenty-ui/src/components/input/ReactionButton/__stories__/ReactionButton.stories.tsx@@ -0,0 +1,208 @@+import { type Meta, type StoryObj } from '@storybook/react-vite';+import { expect, fn, userEvent, within } from 'storybook/test';++import { Tooltip } from '@ui/primitives/surfaces/Tooltip/Tooltip';+import { Text } from '@ui/primitives/typography/Text/Text';+import {+ A11Y_DEFER_COLOR_CONTRAST,+ CatalogDecorator,+ type CatalogStory,+ ComponentDecorator,+ GroupedCatalog,+} from '@ui/testing';++import { ReactionButton } from '../ReactionButton';+import { type ReactionButtonProps } from '../types/ReactionButtonProps';+import { ReactionButtonExample } from './ReactionButtonExample';++const meta: Meta<typeof ReactionButton> = {+ id: 'ui-components-reactionbutton',+ title: 'UI/Components/Input/ReactionButton',+ component: ReactionButton,+ decorators: [ComponentDecorator],+ args: {+ emoji: '๐',+ count: 2,+ pressed: false,+ 'aria-label': 'Helpful',+ onPressedChange: fn(),+ },+};++export default meta;+type Story = StoryObj<typeof ReactionButton>;++export const Display: Story = {+ argTypes: {+ count: { control: false },+ pressed: { control: false },+ 'aria-label': { control: false },+ },+ render: ({ emoji, disabled, loading }) => (+ <ReactionButtonExample+ emoji={emoji}+ disabled={disabled}+ loading={loading}+ />+ ),+};++const REACTION_STATES: {+ label: string;+ props: Partial<ReactionButtonProps>;+}[] = [+ { label: 'Unselected', props: {} },+ { label: 'Selected', props: { pressed: true, count: 3 } },+ { label: 'Disabled', props: { disabled: true } },+ { label: 'Loading', props: { pressed: true, loading: true } },+ { label: 'Zero', props: { count: 0 } },+ { label: 'Formatted count', props: { count: '1,234' } },+];++export const Catalog: Story = {+ parameters: { container: { width: 540 } },+ render: (args) => (+ <GroupedCatalog+ groups={[{ label: 'States and counts', examples: REACTION_STATES }]}+ renderExample={({ label, props }) => (+ <>+ <Text>{label}</Text>+ <ReactionButton+ // oxlint-disable-next-line react/jsx-props-no-spreading+ {...args}+ pressed={props.pressed ?? args.pressed}+ count={props.count ?? args.count}+ disabled={props.disabled}+ loading={props.loading}+ />+ </>+ )}+ />+ ),+};++export const Keyboard: Story = {+ ...Display,+ play: async ({ canvasElement }) => {+ const canvas = within(canvasElement);+ const reaction = canvas.getByRole('button', { name: 'Helpful' });++ reaction.focus();+ await expect(reaction).toHaveFocus();+ await userEvent.keyboard('{Enter}');+ await expect(reaction).toHaveAttribute('aria-pressed', 'true');+ await expect(reaction).toHaveTextContent('3');+ await userEvent.keyboard(' ');+ await expect(reaction).toHaveAttribute('aria-pressed', 'false');+ await expect(reaction).toHaveTextContent('2');+ await userEvent.tab();+ await expect(canvas.getByRole('button', { name: 'Reset' })).toHaveFocus();+ },+};++export const ControlledRequest: Story = {+ args: { onClick: fn() },+ play: async ({ canvasElement, args }) => {+ const reaction = within(canvasElement).getByRole('button');++ await userEvent.click(reaction);+ await expect(args.onClick).toHaveBeenCalledOnce();+ await expect(args.onPressedChange).toHaveBeenCalledOnce();+ await expect(args.onPressedChange).toHaveBeenCalledWith(true);+ await expect(reaction).toHaveAttribute('aria-pressed', 'false');+ await expect(reaction).toHaveTextContent('2');+ },+};++export const CancelledRequest: Story = {+ args: { onClick: fn((event) => event.preventDefault()) },+ play: async ({ canvasElement, args }) => {+ await userEvent.click(within(canvasElement).getByRole('button'));+ await expect(args.onClick).toHaveBeenCalledOnce();+ await expect(args.onPressedChange).not.toHaveBeenCalled();+ },+};++export const Disabled: Story = {+ args: { disabled: true, onClick: fn() },+ play: async ({ canvasElement, args }) => {+ const reaction = within(canvasElement).getByRole('button');++ await expect(reaction).toBeDisabled();+ await userEvent.click(reaction);+ await expect(args.onClick).not.toHaveBeenCalled();+ await expect(args.onPressedChange).not.toHaveBeenCalled();+ },+};++export const PendingMutation: Story = {+ args: { pressed: true, loading: true },+ play: async ({ canvasElement, args }) => {+ const reaction = within(canvasElement).getByRole('button');++ await expect(reaction).toHaveAttribute('aria-busy', 'true');+ await expect(reaction).toHaveAttribute('aria-pressed', 'true');+ await expect(reaction).toBeDisabled();+ await userEvent.click(reaction);+ await expect(args.onPressedChange).not.toHaveBeenCalled();+ },+};++export const LongAccessibleLabel: Story = {+ args: {+ 'aria-label':+ 'Celebration, 24 reactions from teammates across the design, engineering, and customer support teams',+ emoji: '๐',+ count: 24,+ pressed: true,+ },+ render: (args) => (+ <Tooltip content={args['aria-label']} delay={0}>+ <ReactionButton+ // oxlint-disable-next-line react/jsx-props-no-spreading+ {...args}+ />+ </Tooltip>+ ),+ play: async ({ canvasElement, args }) => {+ const reaction = within(canvasElement).getByRole('button', {+ name: args['aria-label'],+ });+ const body = within(canvasElement.ownerDocument.body);++ reaction.focus();+ await expect(await body.findByRole('tooltip')).toHaveTextContent(+ args['aria-label'] ?? '',+ );+ await expect(reaction.getBoundingClientRect().height).toBe(24);+ await expect(reaction.getBoundingClientRect().width).toBeLessThan(80);+ await userEvent.keyboard('{Enter}');+ await expect(args.onPressedChange).toHaveBeenCalledOnce();+ await expect(args.onPressedChange).toHaveBeenCalledWith(false);+ },+};++export const VisualRegression: CatalogStory<Story, typeof ReactionButton> = {+ tags: ['!autodocs'],+ decorators: [CatalogDecorator],+ parameters: {+ a11y: A11Y_DEFER_COLOR_CONTRAST,+ catalog: {+ dimensions: [+ {+ name: 'state',+ values: REACTION_STATES.map(({ label }) => label),+ props: (state: string) =>+ REACTION_STATES.find(({ label }) => label === state)?.props ?? {},+ },+ ],+ options: { elementContainer: { style: { width: 100 } } },+ },+ },+};++export const VisualRegressionDark: CatalogStory<Story, typeof ReactionButton> =+ {+ ...VisualRegression,+ globals: { colorScheme: 'dark' },+ };diff --git a/packages/twenty-ui/src/components/input/ReactionButton/__stories__/ReactionButtonExample.tsx b/packages/twenty-ui/src/components/input/ReactionButton/__stories__/ReactionButtonExample.tsxnew file mode 100644index 00000000000..da240805045--- /dev/null+++ b/packages/twenty-ui/src/components/input/ReactionButton/__stories__/ReactionButtonExample.tsx@@ -0,0 +1,53 @@+import { useState } from 'react';++import { Button } from '@ui/primitives/input/Button/Button';+import { Tooltip } from '@ui/primitives/surfaces/Tooltip/Tooltip';+import { Text } from '@ui/primitives/typography/Text/Text';+import { themeCssVariables } from '@ui/theme';++import { ReactionButton } from '../ReactionButton';+import { type ReactionButtonProps } from '../types/ReactionButtonProps';++export const ReactionButtonExample = ({+ emoji = '๐',+ disabled,+ loading,+}: Partial<Pick<ReactionButtonProps, 'emoji' | 'disabled' | 'loading'>>) => {+ const [pressed, setPressed] = useState(false);+ const count = pressed ? 3 : 2;++ return (+ <Text+ style={{+ display: 'flex',+ flexDirection: 'column',+ gap: themeCssVariables.spacing[2],+ }}+ >+ <Text>Was this helpful?</Text>+ <Text+ render={<span />}+ style={{+ display: 'flex',+ alignItems: 'center',+ gap: themeCssVariables.spacing[1],+ }}+ >+ <Tooltip content={`${count} people found this helpful`}>+ <ReactionButton+ aria-label="Helpful"+ emoji={emoji}+ count={count}+ pressed={pressed}+ onPressedChange={setPressed}+ disabled={disabled}+ loading={loading}+ />+ </Tooltip>+ <Button size="sm" variant="ghost" onClick={() => setPressed(false)}>+ Reset+ </Button>+ </Text>+ </Text>+ );+};diff --git a/packages/twenty-ui/src/components/input/ReactionButton/__tests__/ReactionButton.test.tsx b/packages/twenty-ui/src/components/input/ReactionButton/__tests__/ReactionButton.test.tsxnew file mode 100644index 00000000000..85d8848ac55--- /dev/null+++ b/packages/twenty-ui/src/components/input/ReactionButton/__tests__/ReactionButton.test.tsx@@ -0,0 +1,69 @@+import { render, screen } from '@testing-library/react';+import { describe, expect, it, vi } from 'vitest';++import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';+import { ButtonGroup } from '@ui/primitives/input/ButtonGroup/ButtonGroup';++import { ReactionButton } from '../ReactionButton';+import styles from '../ReactionButton.module.scss';++runComponentConformance({+ name: 'ReactionButton',+ element: (+ <ReactionButton+ aria-label="Helpful"+ emoji="๐"+ count={2}+ pressed={false}+ onPressedChange={vi.fn()}+ />+ ),+ refInstanceOf: HTMLButtonElement,+ ownClassName: styles.button,+ skip: ['renderProp'],+});++describe('ReactionButton native contract', () => {+ it('keeps its compact button appearance inside a differently styled group', () => {+ render(+ <ButtonGroup variant="solid" color="danger" size="md">+ <ReactionButton+ aria-label="Helpful"+ emoji="๐"+ count={0}+ pressed={false}+ onPressedChange={vi.fn()}+ />+ </ButtonGroup>,+ );++ const reaction = screen.getByRole('button', { name: 'Helpful' });++ expect(reaction).toHaveAttribute('type', 'button');+ expect(reaction).toHaveAttribute('data-variant', 'ghost');+ expect(reaction).toHaveAttribute('data-color', 'neutral');+ expect(reaction).toHaveAttribute('data-size', 'sm');+ expect(reaction).toHaveAttribute('aria-pressed', 'false');+ expect(reaction).toHaveTextContent('0');+ });++ it('accepts external accessible names and caller-formatted counts', () => {+ render(+ <>+ <span id="reaction-label">Helpful</span>+ <ReactionButton+ aria-labelledby="reaction-label"+ emoji="๐"+ count="1,234"+ pressed+ onPressedChange={vi.fn()}+ />+ </>,+ );++ const reaction = screen.getByRole('button', { name: 'Helpful' });++ expect(reaction).toHaveAttribute('aria-pressed', 'true');+ expect(reaction).toHaveTextContent('1,234');+ });+});diff --git a/packages/twenty-ui/src/components/input/ReactionButton/types/ReactionButtonProps.ts b/packages/twenty-ui/src/components/input/ReactionButton/types/ReactionButtonProps.tsnew file mode 100644index 00000000000..559450f584c--- /dev/null+++ b/packages/twenty-ui/src/components/input/ReactionButton/types/ReactionButtonProps.ts@@ -0,0 +1,22 @@+import { type ComponentPropsWithRef } from 'react';++import { type ButtonProps } from '@ui/primitives/input/Button/types/ButtonProps';++export type ReactionButtonProps = Omit<+ ComponentPropsWithRef<'button'>,+ | 'aria-label'+ | 'aria-labelledby'+ | 'aria-pressed'+ | 'children'+ | 'color'+ | 'type'+> &+ Pick<ButtonProps, 'loading'> & {+ emoji: string;+ count: number | string;+ pressed: boolean;+ onPressedChange: (pressed: boolean) => void;+ } & (+ | { 'aria-label': string; 'aria-labelledby'?: string }+ | { 'aria-label'?: string; 'aria-labelledby': string }+ );diff --git a/packages/twenty-ui/src/components/input/index.ts b/packages/twenty-ui/src/components/input/index.tsindex c8b188c7d6d..32657fa137c 100644--- a/packages/twenty-ui/src/components/input/index.ts+++ b/packages/twenty-ui/src/components/input/index.ts@@ -40,6 +40,8 @@ export type { PhoneCountryPickerOptionsProps } from './PhoneCountryPicker/types/export type { PhoneCountryPickerProps } from './PhoneCountryPicker/types/PhoneCountryPickerProps';export type { PhoneCountryPickerRootProps } from './PhoneCountryPicker/types/PhoneCountryPickerRootProps';export type { PhoneCountryPickerTriggerProps } from './PhoneCountryPicker/types/PhoneCountryPickerTriggerProps';+export { ReactionButton } from './ReactionButton/ReactionButton';+export type { ReactionButtonProps } from './ReactionButton/types/ReactionButtonProps';export { SearchInput } from './SearchInput/SearchInput';export type { SearchInputProps } from './SearchInput/types/SearchInputProps';export { SegmentedControl } from './SegmentedControl/SegmentedControl';