Skip to content

The open alternative to Salesforce, designed for AI.

Align Banner and InlineBanner feedback APIs (#27396)

Raphaël Bosia189eb960b3d
diff --git a/packages/twenty-companion/src/renderer/components/Notice.tsx b/packages/twenty-companion/src/renderer/components/Notice.tsx
index bf028c48b9d..3840900be8d 100644
--- a/packages/twenty-companion/src/renderer/components/Notice.tsx
+++ b/packages/twenty-companion/src/renderer/components/Notice.tsx
@@ -18,7 +18,7 @@ export const Notice = ({ state, command }: ActionProps) =>
</div>
) : state.error || state.notice ? (
<div className="notice" role={state.error ? 'alert' : 'status'}>
- <Banner color={state.error ? 'danger' : 'blue'}>
+ <Banner status={state.error ? 'error' : 'info'}>
<span className="notice-text">
{state.error?.message ??
(state.notice && noticeMessage(state.notice))}
diff --git a/packages/twenty-docs/snippets/ui/generated/components/feedback/inline-banner.mdx b/packages/twenty-docs/snippets/ui/generated/components/feedback/inline-banner.mdx
index fec61c10d3e..fd5eee6208a 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/feedback/inline-banner.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/feedback/inline-banner.mdx
@@ -11,44 +11,106 @@
* npx nx generate:ui twenty-docs
*/}
-<ParamField body="button" type="InlineBannerButtonProps">
- Optional button or destination link. All fields are optional:
-
- - `title` (`string`): visible action label.
- - `onClick` (`(event: BaseUIEvent<React.MouseEvent<HTMLButtonElement>>) => void`): activation handler, including keyboard activation.
- - `href` (`string`): destination URL; selects native link semantics.
- - `render` (`ReactElement | ((props: HTMLProps, state: { disabled: boolean }) => ReactElement)`): custom root element or renderer. Preserve an anchor when `href` is set, or a native button otherwise. `HTMLProps` includes native element attributes and its ref.
- - `target` (`string`): link browsing context, such as `_blank`.
- - `rel` (`string`): link relationship, such as `noopener noreferrer`.
- - `download` (native anchor attribute): use `true` to download the destination or a `string` to suggest a filename.
- - `disabled` (`boolean`): prevents activation.
- - `hidden` (`boolean`): omits the action from the banner.
- - `aria-label` (`string`): accessible action name, needed when no visible title is supplied.
- - `Icon` (`IconComponent`): decorative icon component displayed before the title.
+<ParamField body="action" type="ReactNode">
+ Optional trailing ReactNode. InlineBanner.Action supplies the shared banner action preset and inherits the resolved banner color; arbitrary controls are also accepted.
+</ParamField>
- Action and link fields use the corresponding [Button props](/ui/primitives/input/button). `BaseUIEvent` extends the React event with `preventBaseUIHandler()` and `baseUIHandlerPrevented`.
+<ParamField body="children" type="ReactNode">
+ Caller-provided content. Standard plain strings truncate with a focusable tooltip; rich nodes render directly. Compact content wraps.
</ParamField>
<ParamField body="className" type="string">
- Class applied to the banner.
+ Class merged onto the root div or composed element.
</ParamField>
-<ParamField body="color" type="&quot;blue&quot; | &quot;danger&quot;" default="blue">
- Banner palette color. An omitted color uses Banner’s default.
+<ParamField body="color" type="&quot;blue&quot; | &quot;gray&quot; | &quot;green&quot; | &quot;orange&quot; | &quot;red&quot;" default="status palette">
+ Gray, blue, green, orange or red palette override. An omitted color follows status.
</ParamField>
<ParamField body="embedded" type="boolean" default="false">
- Removes the bottom margin from standard banners. Compact banners have no bottom margin.
+ Removes the standard bottom margin. Compact layouts have no bottom margin.
+</ParamField>
+
+<ParamField body="icon" type="ReactNode" default="decorative information icon">
+ Leading ReactNode. Defaults to a decorative information icon. Pass null to omit it.
+</ParamField>
+
+<ParamField body="layout" type="&quot;compact&quot; | &quot;standard&quot;" default="standard">
+ Standard full-width layout or compact wrapping layout with a 512px maximum content width. Defaults to standard.
+</ParamField>
+
+<ParamField body="ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the root div, or to the DOM element supplied through render.
+</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, BannerState&gt;">
+ Base UI root element or render callback, receiving native props/ref and resolved Banner state.
+</ParamField>
+
+<ParamField body="status" type="&quot;error&quot; | &quot;info&quot; | &quot;neutral&quot; | &quot;success&quot; | &quot;warning&quot;" default="info">
+ Feedback meaning: neutral, info, success, warning or error. Defaults to info. Roles and announcements remain caller-owned.
+</ParamField>
+
+<ParamField body="style" type="CSSProperties">
+ Inline styles applied to the root div or composed element.
+</ParamField>
+
+<ParamField body="variant" type="&quot;soft&quot; | &quot;solid&quot;" default="soft">
+ Solid or soft appearance, independently of status and layout. Defaults to soft.
+</ParamField>
+
+### InlineBanner.Action
+
+<ParamField body="Action.className" type="string | ((state: ButtonState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
+</ParamField>
+
+<ParamField body="Action.elevated" type="boolean">
+ Adds a shadow and backdrop blur. Neutral outline buttons also use elevated surface colors.
+</ParamField>
+
+<ParamField body="Action.endIcon" type="ReactNode">
+ Decorative content displayed after the label.
+</ParamField>
+
+<ParamField body="Action.focusableWhenDisabled" type="boolean" default="false">
+ Whether the button should be focusable when disabled.
+</ParamField>
+
+<ParamField body="Action.fullWidth" type="boolean">
+ Expands the button to fill its container width.
+</ParamField>
+
+<ParamField body="Action.href" type="string">
+ Destination URL. Enables native link semantics instead of button semantics.
+</ParamField>
+
+<ParamField body="Action.loading" type="boolean">
+ Shows a loading indicator and disables activation.
+</ParamField>
+
+<ParamField body="Action.loadingPosition" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;">
+ Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner.
+</ParamField>
+
+<ParamField body="Action.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
+ Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="Action.shortcut" type="ShortcutDefinition">
+ Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Displayed on non-mobile screens.
</ParamField>
-<ParamField body="LeftIcon" type="IconComponent">
- Leading icon component. Defaults to the information icon.
+<ParamField body="Action.shortcutJoinLabel" type="string">
+ Localized text between sequence steps. Defaults to then.
</ParamField>
-<ParamField body="message" type="string" required>
- Message text. Standard banners truncate with a focusable tooltip; compact banners wrap.
+<ParamField body="Action.startIcon" type="ReactNode">
+ Decorative content displayed before the label.
</ParamField>
-<ParamField body="variant" type="&quot;compact&quot; | &quot;standard&quot;" default="standard">
- Standard full-width banner or compact wrapping message with a 512px maximum content width.
+<ParamField body="Action.style" type="CSSProperties | ((state: ButtonState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/feedback/banner.mdx b/packages/twenty-docs/snippets/ui/generated/feedback/banner.mdx
index d013cdf015b..28102be5607 100644
--- a/packages/twenty-docs/snippets/ui/generated/feedback/banner.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/feedback/banner.mdx
@@ -11,18 +11,98 @@
* npx nx generate:ui twenty-docs
*/}
-<ParamField body="children" type="ReactNode" required>
- Message and optional actions displayed inside the banner.
+<ParamField body="action" type="ReactNode">
+ Optional trailing ReactNode. Banner.Action supplies a small outline action that inherits the resolved banner color; arbitrary controls are also accepted.
+</ParamField>
+
+<ParamField body="children" type="ReactNode">
+ Caller-provided content, including text, links and controls.
</ParamField>
<ParamField body="className" type="string">
- CSS class applied to the banner.
+ Class merged onto the root div or composed element.
+</ParamField>
+
+<ParamField body="color" type="&quot;blue&quot; | &quot;gray&quot; | &quot;green&quot; | &quot;orange&quot; | &quot;red&quot;" default="status palette">
+ Palette override: gray, blue, green, orange or red. When omitted, status selects the corresponding palette.
+</ParamField>
+
+<ParamField body="icon" type="ReactNode">
+ Optional leading ReactNode. The caller supplies decorative or accessible icon semantics.
+</ParamField>
+
+<ParamField body="ref" type="Ref&lt;HTMLDivElement&gt;">
+ Ref to the root div, or to the DOM element supplied through render.
+</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, BannerState&gt;">
+ Base UI element or render callback. The callback receives native props/ref and resolved status, variant and color state.
+</ParamField>
+
+<ParamField body="status" type="&quot;error&quot; | &quot;info&quot; | &quot;neutral&quot; | &quot;success&quot; | &quot;warning&quot;" default="info">
+ Feedback meaning: neutral, info, success, warning or error. Defaults to info. Does not assign a role or live region.
+</ParamField>
+
+<ParamField body="style" type="CSSProperties">
+ Inline styles applied to the root div or composed element.
+</ParamField>
+
+<ParamField body="variant" type="&quot;soft&quot; | &quot;solid&quot;" default="solid">
+ Solid or soft appearance. Defaults to solid, independently of status.
+</ParamField>
+
+### Banner.Action
+
+<ParamField body="Action.className" type="string | ((state: ButtonState) =&gt; string | undefined)">
+ CSS class applied to the element, or a function that
+ returns a class based on the component's state.
+</ParamField>
+
+<ParamField body="Action.elevated" type="boolean">
+ Adds a shadow and backdrop blur. Neutral outline buttons also use elevated surface colors.
+</ParamField>
+
+<ParamField body="Action.endIcon" type="ReactNode">
+ Decorative content displayed after the label.
+</ParamField>
+
+<ParamField body="Action.focusableWhenDisabled" type="boolean" default="false">
+ Whether the button should be focusable when disabled.
+</ParamField>
+
+<ParamField body="Action.fullWidth" type="boolean">
+ Expands the button to fill its container width.
+</ParamField>
+
+<ParamField body="Action.href" type="string">
+ Destination URL. Enables native link semantics instead of button semantics.
+</ParamField>
+
+<ParamField body="Action.loading" type="boolean">
+ Shows a loading indicator and disables activation.
+</ParamField>
+
+<ParamField body="Action.loadingPosition" type="&quot;center&quot; | &quot;end&quot; | &quot;start&quot;">
+ Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner.
+</ParamField>
+
+<ParamField body="Action.render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, ButtonState&gt;">
+ Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.
+</ParamField>
+
+<ParamField body="Action.shortcut" type="ShortcutDefinition">
+ Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Displayed on non-mobile screens.
+</ParamField>
+
+<ParamField body="Action.shortcutJoinLabel" type="string">
+ Localized text between sequence steps. Defaults to then.
</ParamField>
-<ParamField body="color" type="&quot;blue&quot; | &quot;danger&quot;" default="blue">
- Blue information treatment or danger treatment.
+<ParamField body="Action.startIcon" type="ReactNode">
+ Decorative content displayed before the label.
</ParamField>
-<ParamField body="variant" type="&quot;primary&quot; | &quot;secondary&quot;" default="primary">
- Primary solid treatment or secondary translucent treatment.
+<ParamField body="Action.style" type="CSSProperties | ((state: ButtonState) =&gt; CSSProperties | undefined)">
+ Style applied to the element, or a function that
+ returns a style object based on the component's state.
</ParamField>
diff --git a/packages/twenty-docs/ui/components/feedback/inline-banner.mdx b/packages/twenty-docs/ui/components/feedback/inline-banner.mdx
index 501d161f6c2..c40a09cdeb2 100644
--- a/packages/twenty-docs/ui/components/feedback/inline-banner.mdx
+++ b/packages/twenty-docs/ui/components/feedback/inline-banner.mdx
@@ -1,22 +1,27 @@
---
title: InlineBanner
-description: A compact banner with a message, icon, and optional button or link.
+description: Inline feedback with node content, icons, and actions.
---
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import InlineBannerReference from '/snippets/ui/generated/components/feedback/inline-banner.mdx';
-`InlineBanner` builds on [Banner](/ui/primitives/feedback/banner). Its standard appearance fills the available width and truncates the message. Keyboard focus, pointer hover, or touch reveals the full message in a tooltip. Your application owns whether the banner is rendered.
+`InlineBanner` composes [Banner](/ui/primitives/feedback/banner) with a rounded inline layout and a decorative information icon. It shares Banner's independent `status`, `variant`, `color`, `icon` and `action` contracts. Its default appearance is `soft` and its default status is `info`.
+
+The `standard` layout fills the available width. Plain string children truncate, with keyboard focus, pointer hover or touch revealing the full string in a tooltip. Rich node children render directly, so embedded links and controls retain their own semantics. Compose explicit typography when rich content needs truncation.
```tsx
import { InlineBanner } from 'twenty-ui/components/feedback';
export const SyncBanner = ({ onRetry }: { onRetry: () => void }) => (
<InlineBanner
- color="danger"
- message="Contact sync could not finish."
- button={{ title: 'Retry sync', onClick: onRetry }}
- />
+ status="error"
+ action={
+ <InlineBanner.Action onClick={onRetry}>Retry sync</InlineBanner.Action>
+ }
+ >
+ Contact sync could not finish.
+ </InlineBanner>
);
```
@@ -26,17 +31,26 @@ export const SyncBanner = ({ onRetry }: { onRetry: () => void }) => (
height={280}
/>
-Use `variant="compact"` for wrapping text, closer spacing, and a maximum content width of 512px. This appearance has no bottom margin. Both appearances support `color="blue"` and `color="danger"`.
+Use `layout="compact"` for wrapping content, closer spacing and a maximum content width of 512px. It has no bottom margin. Layout is independent of `solid` or `soft` appearance. `embedded` removes the standard layout's bottom margin.
```tsx
import { InlineBanner } from 'twenty-ui/components/feedback';
+import { IconInfoCircle } from 'twenty-ui/icon';
export const ConnectionBanner = () => (
<InlineBanner
- variant="compact"
- message="Connect your account to sync contacts."
- button={{ title: 'Connection settings', href: '/settings/accounts' }}
- />
+ layout="compact"
+ status="warning"
+ color="blue"
+ icon={<IconInfoCircle aria-hidden="true" />}
+ action={
+ <InlineBanner.Action href="/settings/accounts">
+ Connection settings
+ </InlineBanner.Action>
+ }
+ >
+ Connect your account to sync contacts.
+ </InlineBanner>
);
```
@@ -46,9 +60,15 @@ export const ConnectionBanner = () => (
height={280}
/>
-`button` accepts `title`, `onClick`, `disabled`, `hidden`, and an `Icon` component. Supply `href` for a native destination link, with optional `target`, `rel`, and `download`. Pair `href` with `render` for an application-owned router link. An action without `href` remains a native button. Use `aria-label` when the action has no visible title.
+`InlineBanner.Action` provides a small outline button that inherits the banner’s displayed color, including explicit palette overrides and solid appearances. It supports Button interactions, links, refs and custom rendering. The `action` slot also accepts arbitrary controls.
+
+The root target is a `div`. Native props, `className`, `style` and `ref` target that root; Base UI `render` can compose another element and receives resolved Banner state. `action` accepts any ReactNode, including multiple controls with their complete Button or link APIs. `icon={null}` removes the default icon.
+
+The caller owns whether the banner is rendered and whether changes should be announced. Supply `role="status"` and `aria-live="polite"`, or an appropriate live-region wrapper, when needed. Status does not assign live-region semantics. Name action controls and mark decorative custom icons with `aria-hidden`.
+
+## Migration
-`LeftIcon` changes the leading icon. `embedded` removes the standard banner's bottom margin. Use a separate live-region wrapper when changes should be announced.
+Replace `message` with `children`, `LeftIcon={Icon}` with `icon={<Icon />}`, and `button` configuration with an `action` node. Use `InlineBanner.Action` to keep action styling aligned with the banner. Replace `variant="compact"` with `layout="compact"`; standard is now the default layout. Use `status="error"` for error meaning or `color="red"` for a palette override.
## Props
diff --git a/packages/twenty-docs/ui/primitives/feedback/banner.mdx b/packages/twenty-docs/ui/primitives/feedback/banner.mdx
index 1e3b6651262..503308aa3b7 100644
--- a/packages/twenty-docs/ui/primitives/feedback/banner.mdx
+++ b/packages/twenty-docs/ui/primitives/feedback/banner.mdx
@@ -1,50 +1,60 @@
---
title: Banner
-description: Display a prominent information or error message with optional actions.
+description: Feedback content with independent status, appearance, and palette.
---
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
-
import BannerReference from '/snippets/ui/generated/feedback/banner.mdx';
-`Banner` lays out a message and optional controls across its container. Use `color="blue"` for information and `color="danger"` for errors. The `primary` variant uses a solid background; `secondary` uses a translucent background.
+`Banner` lays out caller-provided content, an optional `icon` node and an optional `action` node. `status` describes feedback meaning: `neutral`, `info`, `success`, `warning` or `error`. `variant` selects `solid` or `soft` appearance. An explicit `color` overrides the status palette without changing its meaning.
-<StoryEmbed storyId="ui-feedback-banner--default" title="Banner example" />
+Defaults are `status="info"` and `variant="solid"`. The default status palettes are gray, blue, green, orange and red, respectively.
-## Usage
+<StoryEmbed storyId="ui-feedback-banner--default" title="Banner example" />
```tsx
import { Banner } from 'twenty-ui/primitives/feedback';
-import { Button } from 'twenty-ui/primitives/input';
-import { Text } from 'twenty-ui/primitives/typography';
-
-type ImportFailureProps = { onRetry: () => void };
-
-export const ImportFailure = ({ onRetry }: ImportFailureProps) => (
- <Banner color="danger" variant="secondary">
- <Text>Some records could not be imported.</Text>
- <Button onClick={onRetry}>Retry import</Button>
+import { IconInfoCircle } from 'twenty-ui/icon';
+
+export const SyncBanner = ({ onRetry }: { onRetry: () => void }) => (
+ <Banner
+ status="error"
+ variant="soft"
+ color="blue"
+ icon={<IconInfoCircle aria-hidden="true" />}
+ action={<Banner.Action onClick={onRetry}>Retry sync</Banner.Action>}
+ >
+ Contact sync could not finish.
</Banner>
);
```
-## Visibility and announcements
+`Banner.Action` provides a small outline button that inherits the banner’s displayed color, including explicit palette overrides and solid appearances. It supports Button interactions, links, refs and custom rendering. The `action` slot also accepts arbitrary controls.
-The application owns the message, action handlers, and whether the banner is rendered. `Banner` has no open state or built-in close button.
+The root target is a `div`. Native attributes, event handlers, `className`, `style` and `ref` apply to that root. `render` accepts a Base UI element or callback; the callback receives native props and ref plus resolved `status`, `variant` and `color` state. Preserve the supplied props and ref when composing another element.
```tsx
import { Banner } from 'twenty-ui/primitives/feedback';
-type ImportNoticeProps = { message: string | null };
-
-export const ImportNotice = ({ message }: ImportNoticeProps) => (
- <div role="status">
- {message !== null && <Banner variant="secondary">{message}</Banner>}
- </div>
+export const SyncResult = () => (
+ <Banner
+ status="success"
+ variant="soft"
+ role="status"
+ aria-live="polite"
+ aria-atomic="true"
+ render={<section aria-label="Sync result" />}
+ >
+ Contacts are up to date.
+ </Banner>
);
```
-Keep the live-region wrapper mounted before updating its message. Use `role="alert"` only for urgent messages that need immediate attention. The banner itself does not add a live region or forward `role` and other native attributes.
+Status does not automatically assign `role`, `aria-live` or announcements. Choose them at the caller when updates should be announced. Supply accessible names for controls and mark decorative icon nodes with `aria-hidden`. The caller owns visibility and dismissal.
+
+## Migration
+
+Replace `variant="primary"` with `variant="solid"` and `variant="secondary"` with `variant="soft"`. Replace `color="danger"` with `status="error"`, or `color="red"` when only the palette should change. Blue information banners can use `status="info"`.
## Props
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 ee7cd10d73f..b1f64bafd34 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -64,7 +64,7 @@ import { sliderTest } from '@/__stories__/twenty-ui-gallery/utils/sliderTest';
import { toastTest } from '@/__stories__/twenty-ui-gallery/utils/toastTest';
import { avatarImageTest } from '@/__stories__/twenty-ui-gallery/utils/avatarImageTest';
import { colorSampleTest } from '@/__stories__/twenty-ui-gallery/utils/colorSampleTest';
-import { loaderTest } from '@/__stories__/twenty-ui-gallery/utils/loaderTest';
+import { bannerTest } from '@/__stories__/twenty-ui-gallery/utils/bannerTest';
const meta: Meta<typeof FrontComponentRenderer> = {
title: 'FrontComponent/Twenty UI Gallery',
@@ -92,12 +92,12 @@ export const DataDisplayPreact: Story = createGalleryStory({
export const FeedbackReact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-feedback-gallery',
runtime: 'react',
- play: loaderTest,
+ play: bannerTest,
});
export const FeedbackPreact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-feedback-gallery',
runtime: 'preact',
- play: loaderTest,
+ play: bannerTest,
});
export const ProgressReact: Story = createGalleryStory({
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-feedback-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-feedback-gallery.front-component.tsx
index f6ddafeefae..9b3d8e22784 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-feedback-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-feedback-gallery.front-component.tsx
@@ -20,7 +20,20 @@ const FEEDBACK_ENTRIES: GalleryEntry[] = [
{
name: 'Banner',
node: (
- <Banner color="blue" variant="primary">
+ <Banner
+ status="error"
+ color="blue"
+ variant="soft"
+ role="status"
+ aria-live="polite"
+ aria-label="Banner result"
+ className="custom-banner"
+ style={{ marginTop: 7 }}
+ render={<section data-composed="true" />}
+ ref={(element) => {
+ if (isDefined(element)) element.dataset.refTag = element.tagName;
+ }}
+ >
Heads up
</Banner>
),
@@ -35,15 +48,20 @@ const FEEDBACK_ENTRIES: GalleryEntry[] = [
name: 'InlineBanner compact link',
node: (
<InlineBanner
- variant="compact"
- message="Connect your account to keep your contacts in sync."
- button={{ title: 'Connection settings', href: '#connection-settings' }}
- />
+ layout="compact"
+ action={
+ <InlineBanner.Action href={'#connection-settings'}>
+ {'Connection settings'}
+ </InlineBanner.Action>
+ }
+ >
+ {'Connect your account to keep your contacts in sync.'}
+ </InlineBanner>
),
},
{
name: 'InlineBanner',
- node: <InlineBanner color="blue" message="Inline message" />,
+ node: <InlineBanner status="info">{'Inline message'}</InlineBanner>,
},
{
name: 'Loader',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-inline-banner.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-inline-banner.front-component.tsx
index 4777429c8ac..f5998ad4745 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-inline-banner.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-inline-banner.front-component.tsx
@@ -1,4 +1,6 @@
-import { useState } from 'react';
+import { Button } from 'twenty-ui/primitives/input';
+import { createElement, useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
import { defineFrontComponent } from 'twenty-sdk/define';
import { InlineBanner } from 'twenty-ui/components/feedback';
import { Text } from 'twenty-ui/primitives/typography';
@@ -11,32 +13,61 @@ const InlineBannerExample = () => {
return (
<TwentyUiGalleryCard title="Inline banner actions">
<InlineBanner
- variant="compact"
- color="danger"
- message="Contact sync could not finish. Retry to reconnect your account."
- button={{
- title: 'Retry sync',
- onClick: () => setRetryCount((count) => count + 1),
+ layout="compact"
+ status="error"
+ color="blue"
+ variant="solid"
+ role="status"
+ aria-live="polite"
+ aria-label="Inline sync result"
+ className="custom-inline-banner"
+ style={{ marginTop: 7 }}
+ render={(props, state) =>
+ createElement('section', {
+ ...props,
+ 'data-render-status': state.status,
+ })
+ }
+ ref={(element) => {
+ if (isDefined(element)) element.dataset.refTag = element.tagName;
}}
- />
+ action={
+ <InlineBanner.Action
+ onClick={() => setRetryCount((count) => count + 1)}
+ >
+ {'Retry sync'}
+ </InlineBanner.Action>
+ }
+ >
+ {'Contact sync could not finish. Retry to reconnect your account.'}
+ </InlineBanner>
<Text>Retry count: {retryCount}</Text>
<InlineBanner
- variant="compact"
- message="Connect your account to keep your contacts in sync."
- button={{
- title: 'Connection settings',
- href: 'https://twenty.com',
- target: '_blank',
- rel: 'noopener noreferrer',
- render: (
- <a
- href="https://twenty.com"
- aria-label="Open connection settings"
- />
- ),
- }}
- />
- <InlineBanner message="Mailbox needs attention." />
+ layout="compact"
+ action={
+ <InlineBanner.Action
+ href={'https://twenty.com'}
+ target={'_blank'}
+ rel={'noopener noreferrer'}
+ render={
+ <a
+ href="https://twenty.com"
+ aria-label="Open connection settings"
+ />
+ }
+ >
+ {'Connection settings'}
+ </InlineBanner.Action>
+ }
+ >
+ {'Connect your account to keep your contacts in sync.'}
+ </InlineBanner>
+ <InlineBanner>{'Mailbox needs attention.'}</InlineBanner>
+ <InlineBanner status="warning" color="red" icon={null}>
+ <Button variant="link" href="#sync-history">
+ Review sync history
+ </Button>
+ </InlineBanner>
</TwentyUiGalleryCard>
);
};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/bannerTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/bannerTest.ts
new file mode 100644
index 00000000000..b92e2cc65a6
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/bannerTest.ts
@@ -0,0 +1,28 @@
+import { expect, waitFor, within } from 'storybook/test';
+
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+import { loaderTest } from '@/__stories__/twenty-ui-gallery/utils/loaderTest';
+
+export const bannerTest: TwentyUiGalleryPlayFunction = async (context) => {
+ await loaderTest(context);
+ const canvas = within(context.canvasElement);
+ const banner = canvas.getByRole('status', { name: 'Banner result' });
+ await waitFor(() =>
+ expect(banner).toHaveAttribute('data-ref-tag', 'HTML-SECTION'),
+ );
+ await expect(banner.tagName).toBe('SECTION');
+ await expect(banner).toHaveAttribute('data-status', 'error');
+ await expect(banner).toHaveAttribute('data-color', 'blue');
+ await expect(banner).toHaveAttribute('data-variant', 'soft');
+ await expect(banner).toHaveAttribute('data-composed', 'true');
+ await expect(banner).toHaveAttribute('aria-live', 'polite');
+ await expect(banner).toHaveClass('custom-banner');
+ await expect(banner).toHaveStyle({ marginTop: '7px' });
+ const inlineBanner = canvas.getByTestId('gallery-item-InlineBanner');
+ await expect(inlineBanner.querySelector('[data-status]')).not.toHaveAttribute(
+ 'role',
+ );
+ await expect(inlineBanner.querySelector('[data-status]')).not.toHaveAttribute(
+ 'aria-live',
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/inlineBannerTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/inlineBannerTest.ts
index df509ca52c8..7b0def09ec9 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/inlineBannerTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/inlineBannerTest.ts
@@ -1,4 +1,4 @@
-import { expect, userEvent, within } from 'storybook/test';
+import { expect, userEvent, waitFor, within } from 'storybook/test';
import { errorHandler } from '@/__stories__/shared/test-utils/createFrontComponentStoryMeta';
import { expectFrontComponentMounted } from '@/__stories__/shared/test-utils/matchers/expectFrontComponentMounted';
@@ -9,8 +9,24 @@ export const inlineBannerTest: TwentyUiGalleryPlayFunction = async ({
}) => {
const canvas = within(canvasElement);
await expectFrontComponentMounted(canvas);
+ const banner = canvas.getByRole('status', { name: 'Inline sync result' });
+ await waitFor(() =>
+ expect(banner).toHaveAttribute('data-ref-tag', 'HTML-SECTION'),
+ );
+ await expect(banner.tagName).toBe('SECTION');
+ await expect(banner).toHaveAttribute('data-status', 'error');
+ await expect(banner).toHaveAttribute('data-render-status', 'error');
+ await expect(banner).toHaveAttribute('data-color', 'blue');
+ await expect(banner).toHaveAttribute('data-variant', 'solid');
+ await expect(banner).toHaveAttribute('aria-live', 'polite');
+ await expect(banner).toHaveClass('custom-inline-banner');
+ await expect(banner).toHaveStyle({ marginTop: '7px' });
const button = canvas.getByRole('button', { name: 'Retry sync' });
+ await expect(getComputedStyle(button).color).toBe(
+ getComputedStyle(banner).color,
+ );
+
await userEvent.click(button);
await expect(await canvas.findByText('Retry count: 1')).toBeVisible();
await expect(button).toHaveFocus();
@@ -28,7 +44,15 @@ export const inlineBannerTest: TwentyUiGalleryPlayFunction = async ({
await expect(link).toHaveAttribute('rel', 'noopener noreferrer');
await expect(errorHandler).not.toHaveBeenCalled();
await userEvent.tab();
- await expect(canvas.getByText('Mailbox needs attention.')).toHaveFocus();
+ const plainMessage = canvas.getByText('Mailbox needs attention.');
+ await expect(plainMessage).toHaveFocus();
+ const plainBanner = plainMessage.closest('[data-layout]');
+ await expect(plainBanner).not.toHaveAttribute('role');
+ await expect(plainBanner).not.toHaveAttribute('aria-live');
+ await userEvent.tab();
+ await expect(
+ canvas.getByRole('link', { name: 'Review sync history' }),
+ ).toHaveFocus();
await expect(errorHandler).not.toHaveBeenCalled();
};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListPopupTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListPopupTest.ts
index b4b35a7a8ff..9e4a93e05c4 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListPopupTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/overflowingListPopupTest.ts
@@ -126,7 +126,10 @@ const expectAddedTargetAppearsInTargetsPopup = async ({
await expect(within(updatedTargetsPopup).getAllByRole('button')).toHaveLength(
5,
);
- await userEvent.keyboard('{Escape}');
+ await expectEscapeClosesPopupAndRestoresTriggerFocus({
+ popup: updatedTargetsPopup,
+ trigger: targetsTrigger,
+ });
};
const openReviewersPopupWhileTargetsPopupStaysClosed = async ({
diff --git a/packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx b/packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx
index f46fae5620d..fff67988eb5 100644
--- a/packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx
+++ b/packages/twenty-front/src/modules/activities/emails/components/CampaignDetailsFields.tsx
@@ -120,10 +120,14 @@ export const CampaignDetailsFields = ({
<StyledWarningContainer>
<InlineBanner
embedded
- color="danger"
- LeftIcon={IconAlertTriangle}
- message={t`No sending address. Connect a verified domain in Settings.`}
- />
+ status="error"
+ icon={
+ <IconAlertTriangle
+ size={themeCssVariables.icon.size.md}
+ aria-hidden="true"
+ />
+ }
+ >{t`No sending address. Connect a verified domain in Settings.`}</InlineBanner>
</StyledWarningContainer>
)
}
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatApiKeyNotConfiguredMessage.tsx b/packages/twenty-front/src/modules/ai/components/AiChatApiKeyNotConfiguredMessage.tsx
index 30c5adf9991..9fc67c3ff54 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatApiKeyNotConfiguredMessage.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatApiKeyNotConfiguredMessage.tsx
@@ -1,3 +1,4 @@
+import { InlineBanner } from 'twenty-ui/components/feedback';
import { AiChatInlineBanner } from '@/ai/components/AiChatInlineBanner';
import { currentWorkspaceMemberState } from '@/auth/states/currentWorkspaceMemberState';
import { getDocumentationUrl } from '@/support/utils/getDocumentationUrl';
@@ -19,12 +20,12 @@ export const AiChatApiKeyNotConfiguredMessage = () => {
return (
<AiChatInlineBanner
- message={t`Add an API key to enable AI.`}
- button={{
- title: t`View Docs`,
- Icon: IconExternalLink,
- onClick: handleDocsClick,
- }}
- />
+ action={
+ <InlineBanner.Action
+ startIcon={<IconExternalLink />}
+ onClick={handleDocsClick}
+ >{t`View Docs`}</InlineBanner.Action>
+ }
+ >{t`Add an API key to enable AI.`}</AiChatInlineBanner>
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx b/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx
index 2a8222cfa6d..271327e6ac3 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatEditorSection.tsx
@@ -196,9 +196,7 @@ const EditableAiChatEditorSection = () => {
<StyledInputArea isMobile={isMobile}>
<AgentChatContextPreview />
{hasNoEnabledModels && (
- <AiChatInlineBanner
- message={t`No AI provider is configured on this instance.`}
- />
+ <AiChatInlineBanner>{t`No AI provider is configured on this instance.`}</AiChatInlineBanner>
)}
{hasReachedAiChatCreditsCap && <AiChatNoMoreBillingCreditsBanner />}
{shouldShowUsageLimitBanner && <AiChatUsageLimitReachedBanner />}
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatErrorMessage.tsx b/packages/twenty-front/src/modules/ai/components/AiChatErrorMessage.tsx
index ffbdc8ad589..0c20c11bd84 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatErrorMessage.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatErrorMessage.tsx
@@ -1,8 +1,7 @@
import { CombinedGraphQLErrors } from '@apollo/client/errors';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
-import { type ComponentProps } from 'react';
-import { type InlineBanner } from 'twenty-ui/components/feedback';
+import { type ReactNode } from 'react';
import { IconAlertCircle, IconRefresh } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
import { isDefined } from 'twenty-shared/utils';
@@ -50,14 +49,14 @@ type AiChatErrorMessageProps = {
error: AiChatError;
hint?: string;
onRetry?: () => void;
- button?: ComponentProps<typeof InlineBanner>['button'];
+ action?: ReactNode;
};
export const AiChatErrorMessage = ({
error,
hint,
onRetry,
- button,
+ action,
}: AiChatErrorMessageProps) => {
const theme = useTheme();
const errorMessage = CombinedGraphQLErrors.is(error)
@@ -84,17 +83,7 @@ export const AiChatErrorMessage = ({
variant="outline"
>{t`Retry`}</Button>
)}
- {isDefined(button) && !button.hidden && (
- <Button
- size="sm"
- startIcon={isDefined(button.Icon) ? <button.Icon /> : undefined}
- onClick={button.onClick}
- disabled={button.disabled}
- variant="outline"
- >
- {button.title}
- </Button>
- )}
+ {action}
</StyledErrorContainer>
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatInlineBanner.tsx b/packages/twenty-front/src/modules/ai/components/AiChatInlineBanner.tsx
index 264423a5808..dd4c72bc28f 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatInlineBanner.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatInlineBanner.tsx
@@ -1,14 +1,15 @@
-import { type ComponentProps } from 'react';
-import { InlineBanner } from 'twenty-ui/components/feedback';
+import {
+ type InlineBannerProps,
+ InlineBanner,
+} from 'twenty-ui/components/feedback';
-type AiChatInlineBannerProps = Pick<
- ComponentProps<typeof InlineBanner>,
- 'message' | 'button'
->;
+type AiChatInlineBannerProps = Pick<InlineBannerProps, 'children' | 'action'>;
export const AiChatInlineBanner = ({
- message,
- button,
+ children,
+ action,
}: AiChatInlineBannerProps) => (
- <InlineBanner embedded color="danger" message={message} button={button} />
+ <InlineBanner embedded status="error" action={action}>
+ {children}
+ </InlineBanner>
);
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatNoMoreBillingCreditsBanner.tsx b/packages/twenty-front/src/modules/ai/components/AiChatNoMoreBillingCreditsBanner.tsx
index b6adc85c05b..adabe21f564 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatNoMoreBillingCreditsBanner.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatNoMoreBillingCreditsBanner.tsx
@@ -1,3 +1,4 @@
+import { InlineBanner } from 'twenty-ui/components/feedback';
import { AiChatInlineBanner } from '@/ai/components/AiChatInlineBanner';
import { useAiChatEndTrialPeriod } from '@/ai/hooks/useAiChatEndTrialPeriod';
import { AddCreditCardModal } from '@/settings/billing/components/AddCreditCardModal';
@@ -49,9 +50,7 @@ export const AiChatNoMoreBillingCreditsBanner = () => {
if (!hasPermissionToManageBilling) {
return (
- <AiChatInlineBanner
- message={t`AI usage limit reached. Ask an admin to upgrade the plan.`}
- />
+ <AiChatInlineBanner>{t`AI usage limit reached. Ask an admin to upgrade the plan.`}</AiChatInlineBanner>
);
}
@@ -72,23 +71,24 @@ export const AiChatNoMoreBillingCreditsBanner = () => {
return (
<>
<AiChatInlineBanner
- message={
- isTrialing || isDefined(nextPrice)
- ? t`You’ve reached your AI usage limit.`
- : t`AI usage limit reached. Contact support to upgrade.`
- }
- button={
- isDefined(buttonTitle) && isDefined(handleButtonClick)
- ? {
- title: buttonTitle,
- onClick: handleButtonClick,
- disabled:
- (isTrialing && isEndTrialLoading) ||
- (!isTrialing && isUpgrading),
+ action={
+ isDefined(buttonTitle) && isDefined(handleButtonClick) ? (
+ <InlineBanner.Action
+ onClick={handleButtonClick}
+ disabled={
+ (isTrialing && isEndTrialLoading) ||
+ (!isTrialing && isUpgrading)
}
- : undefined
+ >
+ {buttonTitle}
+ </InlineBanner.Action>
+ ) : undefined
}
- />
+ >
+ {isTrialing || isDefined(nextPrice)
+ ? t`You’ve reached your AI usage limit.`
+ : t`AI usage limit reached. Contact support to upgrade.`}
+ </AiChatInlineBanner>
{isTrialing &&
(hasPaymentMethod === false ? (
<AddCreditCardModal
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatQuotaLimitExhaustedMessage.tsx b/packages/twenty-front/src/modules/ai/components/AiChatQuotaLimitExhaustedMessage.tsx
index e51f7a95ea7..ee5c3903a34 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatQuotaLimitExhaustedMessage.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatQuotaLimitExhaustedMessage.tsx
@@ -24,7 +24,7 @@ export const AiChatQuotaLimitExhaustedMessage = ({
? undefined
: t`Ask an admin to raise the limit.`
}
- button={manageLimitsButton}
+ action={manageLimitsButton}
/>
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatUsageLimitReachedBanner.tsx b/packages/twenty-front/src/modules/ai/components/AiChatUsageLimitReachedBanner.tsx
index 76c183c9542..004c939e589 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatUsageLimitReachedBanner.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatUsageLimitReachedBanner.tsx
@@ -10,13 +10,10 @@ export const AiChatUsageLimitReachedBanner = () => {
const manageLimitsButton = useManageUsageLimitsButton();
return (
- <AiChatInlineBanner
- message={
- isDefined(manageLimitsButton)
- ? t`AI usage limit reached for this period.`
- : t`AI usage limit reached. Ask an admin to raise the limit.`
- }
- button={manageLimitsButton}
- />
+ <AiChatInlineBanner action={manageLimitsButton}>
+ {isDefined(manageLimitsButton)
+ ? t`AI usage limit reached for this period.`
+ : t`AI usage limit reached. Ask an admin to raise the limit.`}
+ </AiChatInlineBanner>
);
};
diff --git a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatInlineBanner.stories.tsx b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatInlineBanner.stories.tsx
index 7b4949e100a..5de0842f02c 100644
--- a/packages/twenty-front/src/modules/ai/components/__stories__/AiChatInlineBanner.stories.tsx
+++ b/packages/twenty-front/src/modules/ai/components/__stories__/AiChatInlineBanner.stories.tsx
@@ -1,9 +1,15 @@
+import { InlineBanner } from 'twenty-ui/components/feedback';
import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
import { IconExternalLink } from 'twenty-ui/icon';
import { ComponentDecorator } from 'twenty-ui/testing';
import { AiChatInlineBanner } from '@/ai/components/AiChatInlineBanner';
+const onConfigureModels = fn();
+const onUpgrade = fn();
+const onViewDocs = fn();
+
const meta: Meta<typeof AiChatInlineBanner> = {
title: 'Modules/AI/AiChatInlineBanner',
component: AiChatInlineBanner,
@@ -18,56 +24,136 @@ type Story = StoryObj<typeof AiChatInlineBanner>;
export const NoEnabledModels: Story = {
args: {
- message: 'No AI models are enabled.',
- button: { title: 'Configure models', onClick: () => {} },
+ children: 'No AI models are enabled.',
+ action: (
+ <InlineBanner.Action onClick={onConfigureModels}>
+ Configure models
+ </InlineBanner.Action>
+ ),
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(canvas.getByText('No AI models are enabled.')).toBeVisible();
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Configure models' }),
+ );
+ await expect(onConfigureModels).toHaveBeenCalledTimes(1);
},
};
export const NoSettingsPermission: Story = {
args: {
- message: 'Ask your workspace admin to enable an AI model.',
+ children: 'Ask your workspace admin to enable an AI model.',
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(
+ canvas.getByText('Ask your workspace admin to enable an AI model.'),
+ ).toBeVisible();
+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();
},
};
export const UsageLimit: Story = {
args: {
- message: 'You’ve reached your AI usage limit.',
- button: { title: 'Upgrade', onClick: () => {} },
+ children: 'You’ve reached your AI usage limit.',
+ action: (
+ <InlineBanner.Action onClick={onUpgrade}>Upgrade</InlineBanner.Action>
+ ),
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const message = canvas.getByText('You’ve reached your AI usage limit.');
+ const button = canvas.getByRole('button', { name: 'Upgrade' });
+
+ await expect(message).toBeVisible();
+ await userEvent.tab();
+ await expect(message).toHaveFocus();
+ await userEvent.tab();
+ await expect(button).toHaveFocus();
+ await userEvent.keyboard('{Enter}');
+ await expect(onUpgrade).toHaveBeenCalledTimes(1);
},
};
export const UsageLimitLoading: Story = {
args: {
- message: 'You’ve reached your AI usage limit.',
- button: { title: 'Upgrade', onClick: () => {}, disabled: true },
+ children: 'You’ve reached your AI usage limit.',
+ action: (
+ <InlineBanner.Action onClick={onUpgrade} disabled>
+ Upgrade
+ </InlineBanner.Action>
+ ),
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const button = canvas.getByRole('button', { name: 'Upgrade' });
+
+ await expect(button).toBeDisabled();
+ await userEvent.click(button);
+ await expect(onUpgrade).not.toHaveBeenCalled();
},
};
export const NoBillingPermission: Story = {
args: {
- message: 'AI usage limit reached. Ask an admin to upgrade the plan.',
+ children: 'AI usage limit reached. Ask an admin to upgrade the plan.',
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(
+ canvas.getByText(
+ 'AI usage limit reached. Ask an admin to upgrade the plan.',
+ ),
+ ).toBeVisible();
+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();
},
};
export const ApiKeyNotConfigured: Story = {
args: {
- message: 'Add an API key to enable AI.',
- button: {
- title: 'View Docs',
- Icon: IconExternalLink,
- onClick: () => {},
- },
+ children: 'Add an API key to enable AI.',
+ action: (
+ <InlineBanner.Action
+ startIcon={<IconExternalLink />}
+ onClick={onViewDocs}
+ >
+ View Docs
+ </InlineBanner.Action>
+ ),
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await expect(
+ canvas.getByText('Add an API key to enable AI.'),
+ ).toBeVisible();
+ await userEvent.click(canvas.getByRole('button', { name: 'View Docs' }));
+ await expect(onViewDocs).toHaveBeenCalledTimes(1);
},
};
export const NarrowComposer: Story = {
- args: {
- message: 'Add an API key to enable AI.',
- button: {
- title: 'View Docs',
- Icon: IconExternalLink,
- onClick: () => {},
- },
- },
+ args: ApiKeyNotConfigured.args,
parameters: { container: { width: 320 } },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const message = canvas.getByText('Add an API key to enable AI.');
+ const body = within(canvasElement.ownerDocument.body);
+
+ await expect(message.scrollWidth).toBeGreaterThan(message.clientWidth);
+ await userEvent.hover(message);
+ await expect(await body.findByRole('tooltip')).toHaveTextContent(
+ 'Add an API key to enable AI.',
+ );
+ await userEvent.unhover(message);
+ await waitFor(async () => {
+ await expect(body.queryByRole('tooltip')).not.toBeInTheDocument();
+ });
+ await userEvent.click(canvas.getByRole('button', { name: 'View Docs' }));
+ await expect(onViewDocs).toHaveBeenCalledTimes(1);
+ },
};
diff --git a/packages/twenty-front/src/modules/information-banner/components/InformationBanner.tsx b/packages/twenty-front/src/modules/information-banner/components/InformationBanner.tsx
index 8eeac7fd6ab..1c0bf94355f 100644
--- a/packages/twenty-front/src/modules/information-banner/components/InformationBanner.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/InformationBanner.tsx
@@ -1,6 +1,5 @@
import { InformationBannerComponentInstanceContext } from '@/information-banner/states/contexts/InformationBannerComponentInstanceContext';
import { informationBannerIsOpenComponentState } from '@/information-banner/states/informationBannerIsOpenComponentState';
-import { BUTTON_INVERTED_CLASS_NAME } from '@/ui/input/styles/ButtonInvertedClassName';
import { useAtomComponentStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentStateValue';
import { css } from '@linaria/core';
import { styled } from '@linaria/react';
@@ -12,17 +11,19 @@ import { type IconComponent, IconX } from 'twenty-ui/icon';
import {
Banner,
type BannerColor,
+ type BannerStatus,
type BannerVariant,
} from 'twenty-ui/primitives/feedback';
-import { Button } from 'twenty-ui/primitives/input';
import { themeCssVariables } from 'twenty-ui/theme';
const StyledText = styled.div`
min-width: 0;
`;
-const INVERTED_ICON_BUTTON_CLASS_NAME = css`
- color: ${themeCssVariables.font.color.inverted} !important;
+const BANNER_ICON_BUTTON_CLASS_NAME = css`
+ &[data-variant='ghost'] {
+ color: inherit;
+ }
`;
const StyledContent = styled.div<{ hasCloseButton: boolean }>`
@@ -37,8 +38,9 @@ const StyledContent = styled.div<{ hasCloseButton: boolean }>`
export const InformationBanner = ({
message,
- color = 'blue',
- variant = 'primary',
+ color,
+ status = 'info',
+ variant = 'solid',
buttonTitle,
buttonIcon: ButtonIcon,
buttonOnClick,
@@ -48,6 +50,7 @@ export const InformationBanner = ({
}: {
message: string;
color?: BannerColor;
+ status?: BannerStatus;
variant?: BannerVariant;
buttonTitle?: string;
buttonIcon?: IconComponent;
@@ -61,9 +64,6 @@ export const InformationBanner = ({
componentInstanceId,
);
- const isPrimary = variant === 'primary';
- const buttonColor = color === 'danger' ? 'danger' : 'accent';
-
return (
<InformationBannerComponentInstanceContext.Provider
value={{
@@ -71,8 +71,8 @@ export const InformationBanner = ({
}}
>
{informationBannerIsOpen && (
- <Banner color={color} variant={variant}>
- <StyledContent hasCloseButton={!!onClose}>
+ <Banner color={color} status={status} variant={variant}>
+ <StyledContent hasCloseButton={isDefined(onClose)}>
<StyledText>
<OverflowingTextWithTooltip
isFocusable
@@ -81,41 +81,26 @@ export const InformationBanner = ({
/>
</StyledText>
{buttonTitle && buttonOnClick && (
- <Button
- className={isPrimary ? BUTTON_INVERTED_CLASS_NAME : undefined}
+ <Banner.Action
startIcon={isDefined(ButtonIcon) ? <ButtonIcon /> : undefined}
- size="sm"
onClick={buttonOnClick}
disabled={isButtonDisabled}
- variant="outline"
- color={isPrimary ? 'neutral' : buttonColor}
>
{buttonTitle}
- </Button>
+ </Banner.Action>
)}
</StyledContent>
- {onClose &&
- (isPrimary ? (
- <IconButton
- className={INVERTED_ICON_BUTTON_CLASS_NAME}
- size="sm"
- variant="ghost"
- onClick={onClose}
- aria-label={t`Close banner`}
- >
- <IconX />
- </IconButton>
- ) : (
- <IconButton
- size="sm"
- variant="ghost"
- color={buttonColor}
- onClick={onClose}
- aria-label={t`Close banner`}
- >
- <IconX />
- </IconButton>
- ))}
+ {isDefined(onClose) && (
+ <IconButton
+ className={BANNER_ICON_BUTTON_CLASS_NAME}
+ size="sm"
+ variant="ghost"
+ onClick={onClose}
+ aria-label={t`Close banner`}
+ >
+ <IconX />
+ </IconButton>
+ )}
</Banner>
)}
</InformationBannerComponentInstanceContext.Provider>
diff --git a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerBillingSubscriptionPaused.tsx b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerBillingSubscriptionPaused.tsx
index c0a88c3eacf..a3844f4e72e 100644
--- a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerBillingSubscriptionPaused.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerBillingSubscriptionPaused.tsx
@@ -36,8 +36,8 @@ export const InformationBannerBillingSubscriptionPaused = () => {
<ToastOnQueryErrorEffect error={error} />
<InformationBanner
componentInstanceId="information-banner-billing-subscription-paused"
- color="danger"
- variant="secondary"
+ status="error"
+ variant="soft"
message={
hasPermissionToUpdateBillingDetails
? t`Trial expired. Please update your billing details.`
diff --git a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerEndTrialPeriod.tsx b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerEndTrialPeriod.tsx
index 3ff742eace9..96d8730dddd 100644
--- a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerEndTrialPeriod.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerEndTrialPeriod.tsx
@@ -29,8 +29,8 @@ export const InformationBannerEndTrialPeriod = () => {
<>
<InformationBanner
componentInstanceId="information-banner-end-trial-period"
- color="danger"
- variant="secondary"
+ status="error"
+ variant="soft"
message={
hasPermissionToEndTrialPeriod
? t`End trial period to continue using Workflow or AI features.`
diff --git a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerFailPaymentInfo.tsx b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerFailPaymentInfo.tsx
index 4105ea38b04..629ddbbd0cd 100644
--- a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerFailPaymentInfo.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerFailPaymentInfo.tsx
@@ -40,8 +40,8 @@ export const InformationBannerFailPaymentInfo = () => {
<>
<InformationBanner
componentInstanceId="information-banner-fail-payment-info"
- color="danger"
- variant="secondary"
+ status="error"
+ variant="soft"
message={getMessage()}
buttonTitle={getButtonTitle()}
buttonOnClick={openPaymentMethodFlow}
diff --git a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerNoBillingSubscription.tsx b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerNoBillingSubscription.tsx
index 610a1c3b997..354e69eb218 100644
--- a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerNoBillingSubscription.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerNoBillingSubscription.tsx
@@ -22,8 +22,8 @@ export const InformationBannerNoBillingSubscription = () => {
return (
<InformationBanner
componentInstanceId="information-banner-no-billing-subscription"
- color="danger"
- variant="secondary"
+ status="error"
+ variant="soft"
message={
hasPermissionToSubscribe
? t`Your workspace doesn't have an active subscription.`
diff --git a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerNoMoreCredits.tsx b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerNoMoreCredits.tsx
index b5ac443f114..030c535c841 100644
--- a/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerNoMoreCredits.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/billing/InformationBannerNoMoreCredits.tsx
@@ -53,8 +53,8 @@ export const InformationBannerNoMoreCredits = () => {
<>
<InformationBanner
componentInstanceId={COMPONENT_INSTANCE_ID}
- color="danger"
- variant="secondary"
+ status="error"
+ variant="soft"
message={
hasPermissionToUpdateCreditPlan
? t`Credit limit reached. Update your credit plan to keep workflows, AI, and apps running.`
diff --git a/packages/twenty-front/src/modules/information-banner/components/deleted-record/InformationBannerDeletedRecord.tsx b/packages/twenty-front/src/modules/information-banner/components/deleted-record/InformationBannerDeletedRecord.tsx
index 09be97e68f3..59bdff5d583 100644
--- a/packages/twenty-front/src/modules/information-banner/components/deleted-record/InformationBannerDeletedRecord.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/deleted-record/InformationBannerDeletedRecord.tsx
@@ -28,7 +28,7 @@ export const InformationBannerDeletedRecord = ({
<StyledInformationBannerDeletedRecord>
<InformationBanner
componentInstanceId="information-banner-deleted-record"
- color="danger"
+ status="error"
message={t`This record has been deleted`}
buttonTitle={t`Restore`}
buttonIcon={IconRefresh}
diff --git a/packages/twenty-front/src/modules/information-banner/components/enterprise/InformationBannerNonProductionInstance.tsx b/packages/twenty-front/src/modules/information-banner/components/enterprise/InformationBannerNonProductionInstance.tsx
index 38fb92cd2c2..bf342bd6194 100644
--- a/packages/twenty-front/src/modules/information-banner/components/enterprise/InformationBannerNonProductionInstance.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/enterprise/InformationBannerNonProductionInstance.tsx
@@ -18,7 +18,7 @@ export const InformationBannerNonProductionInstance = () => {
return (
<InformationBanner
componentInstanceId="information-banner-non-production-instance"
- variant="secondary"
+ variant="soft"
message={t`This is a non-production instance.`}
/>
);
diff --git a/packages/twenty-front/src/modules/information-banner/components/maintenance/InformationBannerMaintenance.tsx b/packages/twenty-front/src/modules/information-banner/components/maintenance/InformationBannerMaintenance.tsx
index f7b8cb1ca3f..be7d3b42c44 100644
--- a/packages/twenty-front/src/modules/information-banner/components/maintenance/InformationBannerMaintenance.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/maintenance/InformationBannerMaintenance.tsx
@@ -53,7 +53,7 @@ export const InformationBannerMaintenance = () => {
return (
<InformationBanner
componentInstanceId="information-banner-maintenance"
- variant="secondary"
+ variant="soft"
message={message}
buttonTitle={isDefined(maintenanceLink) ? t`Learn more` : undefined}
buttonIcon={isDefined(maintenanceLink) ? IconExternalLink : undefined}
diff --git a/packages/twenty-front/src/modules/information-banner/components/reconnect-account/InformationBannerReconnectAccountEmailAliases.tsx b/packages/twenty-front/src/modules/information-banner/components/reconnect-account/InformationBannerReconnectAccountEmailAliases.tsx
index b456e4ffaf8..eb997d208b5 100644
--- a/packages/twenty-front/src/modules/information-banner/components/reconnect-account/InformationBannerReconnectAccountEmailAliases.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/reconnect-account/InformationBannerReconnectAccountEmailAliases.tsx
@@ -32,7 +32,7 @@ export const InformationBannerReconnectAccountEmailAliases = () => {
return (
<InformationBanner
componentInstanceId={COMPONENT_INSTANCE_ID}
- variant="secondary"
+ variant="soft"
message={t`Please reconnect your mailbox ${mailboxHandle} to update your email aliases:`}
buttonTitle={t`Reconnect`}
buttonIcon={IconRefresh}
diff --git a/packages/twenty-front/src/modules/information-banner/components/reconnect-account/InformationBannerReconnectAccountInsufficientPermissions.tsx b/packages/twenty-front/src/modules/information-banner/components/reconnect-account/InformationBannerReconnectAccountInsufficientPermissions.tsx
index ed545223032..d1ca5cf3cd5 100644
--- a/packages/twenty-front/src/modules/information-banner/components/reconnect-account/InformationBannerReconnectAccountInsufficientPermissions.tsx
+++ b/packages/twenty-front/src/modules/information-banner/components/reconnect-account/InformationBannerReconnectAccountInsufficientPermissions.tsx
@@ -32,7 +32,7 @@ export const InformationBannerReconnectAccountInsufficientPermissions = () => {
return (
<InformationBanner
componentInstanceId={COMPONENT_INSTANCE_ID}
- variant="secondary"
+ variant="soft"
message={t`Sync lost with mailbox ${mailboxHandle}. Please reconnect for updates:`}
buttonTitle={t`Reconnect`}
buttonIcon={IconRefresh}
diff --git a/packages/twenty-front/src/modules/settings/billing/components/AddPaymentMethodForm.tsx b/packages/twenty-front/src/modules/settings/billing/components/AddPaymentMethodForm.tsx
index d8bbae21ec6..ba8c40e3880 100644
--- a/packages/twenty-front/src/modules/settings/billing/components/AddPaymentMethodForm.tsx
+++ b/packages/twenty-front/src/modules/settings/billing/components/AddPaymentMethodForm.tsx
@@ -171,10 +171,9 @@ export const AddPaymentMethodForm = ({
return (
<StyledFormContainer>
<InlineBanner
- variant="compact"
- color="danger"
- message={t`Card payment is currently unavailable. Please verify your Stripe configuration or contact your workspace admin.`}
- />
+ layout="compact"
+ status="error"
+ >{t`Card payment is currently unavailable. Please verify your Stripe configuration or contact your workspace admin.`}</InlineBanner>
</StyledFormContainer>
);
}
diff --git a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTrialNoPaymentMethodBanner.tsx b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTrialNoPaymentMethodBanner.tsx
index b546703f192..b1dae39e118 100644
--- a/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTrialNoPaymentMethodBanner.tsx
+++ b/packages/twenty-front/src/modules/settings/billing/components/SettingsBillingTrialNoPaymentMethodBanner.tsx
@@ -65,14 +65,17 @@ export const SettingsBillingTrialNoPaymentMethodBanner = ({
<>
<ToastOnQueryErrorEffect error={error} />
<InlineBanner
- color="blue"
- message={message}
- button={{
- title: t`Add card`,
- hidden: !hasPermissionToManageBilling,
- onClick: openPaymentMethodUpdate,
- }}
- />
+ status="info"
+ action={
+ hasPermissionToManageBilling && (
+ <InlineBanner.Action
+ onClick={openPaymentMethodUpdate}
+ >{t`Add card`}</InlineBanner.Action>
+ )
+ }
+ >
+ {message}
+ </InlineBanner>
</>
);
};
diff --git a/packages/twenty-front/src/modules/settings/billing/hooks/useManageUsageLimitsButton.ts b/packages/twenty-front/src/modules/settings/billing/hooks/useManageUsageLimitsButton.tsx
similarity index 64%
rename from packages/twenty-front/src/modules/settings/billing/hooks/useManageUsageLimitsButton.ts
rename to packages/twenty-front/src/modules/settings/billing/hooks/useManageUsageLimitsButton.tsx
index e02868ec28c..f65e51084ab 100644
--- a/packages/twenty-front/src/modules/settings/billing/hooks/useManageUsageLimitsButton.ts
+++ b/packages/twenty-front/src/modules/settings/billing/hooks/useManageUsageLimitsButton.tsx
@@ -1,16 +1,14 @@
import { useLingui } from '@lingui/react/macro';
-import { type ComponentProps } from 'react';
+import { type ReactNode } from 'react';
import { SettingsPath } from 'twenty-shared/types';
-import { type InlineBanner } from 'twenty-ui/components/feedback';
+import { InlineBanner } from 'twenty-ui/components/feedback';
import { IconSettings } from 'twenty-ui/icon';
import { useHasPermissionFlag } from '@/settings/roles/hooks/useHasPermissionFlag';
import { PermissionFlagType } from '~/generated-metadata/graphql';
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
-export const useManageUsageLimitsButton = (): ComponentProps<
- typeof InlineBanner
->['button'] => {
+export const useManageUsageLimitsButton = (): ReactNode => {
const { t } = useLingui();
const hasPermissionToManageUsageLimits = useHasPermissionFlag(
@@ -23,9 +21,10 @@ export const useManageUsageLimitsButton = (): ComponentProps<
return undefined;
}
- return {
- title: t`Manage limits`,
- Icon: IconSettings,
- onClick: () => navigateSettings(SettingsPath.BillingLimits),
- };
+ return (
+ <InlineBanner.Action
+ startIcon={<IconSettings />}
+ onClick={() => navigateSettings(SettingsPath.BillingLimits)}
+ >{t`Manage limits`}</InlineBanner.Action>
+ );
};
diff --git a/packages/twenty-front/src/modules/settings/data-model/objects/forms/components/SettingsDataModelObjectAboutForm.tsx b/packages/twenty-front/src/modules/settings/data-model/objects/forms/components/SettingsDataModelObjectAboutForm.tsx
index b2881756ec7..71d17f3eea4 100644
--- a/packages/twenty-front/src/modules/settings/data-model/objects/forms/components/SettingsDataModelObjectAboutForm.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/objects/forms/components/SettingsDataModelObjectAboutForm.tsx
@@ -264,17 +264,18 @@ export const SettingsDataModelObjectAboutForm = ({
<StyledAdvancedSettingsSectionInputWrapper>
{isDefined(conflictingObjectMetadataItem) && (
<InlineBanner
- color={'blue'}
- message={t`An object with this name already exists`}
- button={{
- title: t`Open`,
- onClick: () =>
- navigateSettings(SettingsPath.ObjectDetail, {
- objectNamePlural:
- conflictingObjectMetadataItem.namePlural,
- }),
- }}
- />
+ status="info"
+ action={
+ <InlineBanner.Action
+ onClick={() =>
+ navigateSettings(SettingsPath.ObjectDetail, {
+ objectNamePlural:
+ conflictingObjectMetadataItem.namePlural,
+ })
+ }
+ >{t`Open`}</InlineBanner.Action>
+ }
+ >{t`An object with this name already exists`}</InlineBanner>
)}
{[
{
diff --git a/packages/twenty-front/src/modules/settings/data-model/objects/forms/components/__stories__/SettingsDataModelObjectAboutForm.stories.tsx b/packages/twenty-front/src/modules/settings/data-model/objects/forms/components/__stories__/SettingsDataModelObjectAboutForm.stories.tsx
index e5a05fd7ec2..2174ba07d9e 100644
--- a/packages/twenty-front/src/modules/settings/data-model/objects/forms/components/__stories__/SettingsDataModelObjectAboutForm.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/objects/forms/components/__stories__/SettingsDataModelObjectAboutForm.stories.tsx
@@ -1,10 +1,13 @@
import { styled } from '@linaria/react';
import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, waitFor, within } from 'storybook/test';
import { FormProviderDecorator } from '~/testing/decorators/FormProviderDecorator';
import { IconsProviderDecorator } from '~/testing/decorators/IconsProviderDecorator';
import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
import { SettingsDataModelObjectAboutForm } from '@/settings/data-model/objects/forms/components/SettingsDataModelObjectAboutForm';
+import { isAdvancedModeEnabledState } from '@/ui/navigation/navigation-drawer/states/isAdvancedModeEnabledState';
+import { jotaiStore } from '@/ui/utilities/state/jotai/jotaiStore';
import { ComponentDecorator } from 'twenty-ui/testing';
import { getTestEnrichedObjectMetadataItemsMock } from '~/testing/utils/getTestEnrichedObjectMetadataItemsMock';
@@ -35,6 +38,21 @@ const meta: Meta<typeof SettingsDataModelObjectAboutForm> = {
parameters: {
container: { width: 520 },
},
+ beforeEach: () => {
+ jotaiStore.set(isAdvancedModeEnabledState.atom, true);
+
+ return () => {
+ jotaiStore.set(isAdvancedModeEnabledState.atom, false);
+ };
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ await waitFor(() => {
+ expect(canvas.getByText('API Name (Singular)')).toBeVisible();
+ expect(canvas.getByText('API Name (Plural)')).toBeVisible();
+ });
+ },
};
export default meta;
diff --git a/packages/twenty-front/src/modules/settings/legal/components/DpaNotice.tsx b/packages/twenty-front/src/modules/settings/legal/components/DpaNotice.tsx
index 3b2451461e3..bb0a5a09da2 100644
--- a/packages/twenty-front/src/modules/settings/legal/components/DpaNotice.tsx
+++ b/packages/twenty-front/src/modules/settings/legal/components/DpaNotice.tsx
@@ -13,6 +13,8 @@ type DpaNoticeProps = {
export const DpaNotice = ({ text }: DpaNoticeProps) => (
<StyledFullWidthBanner>
- <InlineBanner variant="compact" color="danger" message={text} />
+ <InlineBanner layout="compact" status="warning">
+ {text}
+ </InlineBanner>
</StyledFullWidthBanner>
);
diff --git a/packages/twenty-front/src/pages/onboarding/UpgradeFreeTrial.tsx b/packages/twenty-front/src/pages/onboarding/UpgradeFreeTrial.tsx
index e865119f20a..baa6d5cee9f 100644
--- a/packages/twenty-front/src/pages/onboarding/UpgradeFreeTrial.tsx
+++ b/packages/twenty-front/src/pages/onboarding/UpgradeFreeTrial.tsx
@@ -249,10 +249,9 @@ const UpgradeFreeTrialContent = ({
/>
) : (
<InlineBanner
- variant="compact"
- color="danger"
- message={t`Card payment is currently unavailable. Please verify your Stripe configuration or contact your workspace admin.`}
- />
+ layout="compact"
+ status="error"
+ >{t`Card payment is currently unavailable. Please verify your Stripe configuration or contact your workspace admin.`}</InlineBanner>
))}
</OnboardingPlanCard>
diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx
index 197d3751619..5a3ee33b64c 100644
--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx
+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx
@@ -344,19 +344,21 @@ export const SettingsAdminNewAiModel = () => {
<SettingsPageContainer>
{!hasCustomAiProviderAccess && (
<InlineBanner
- variant="compact"
- color="danger"
- message={customAiProviderGateDescription}
- button={{
- title: t`Activate`,
- href: getSettingsPath(SettingsPath.AdminPanelOrganization),
- render: (
- <Link
- to={getSettingsPath(SettingsPath.AdminPanelOrganization)}
- />
- ),
- }}
- />
+ layout="compact"
+ status="error"
+ action={
+ <InlineBanner.Action
+ href={getSettingsPath(SettingsPath.AdminPanelOrganization)}
+ render={
+ <Link
+ to={getSettingsPath(SettingsPath.AdminPanelOrganization)}
+ />
+ }
+ >{t`Activate`}</InlineBanner.Action>
+ }
+ >
+ {customAiProviderGateDescription}
+ </InlineBanner>
)}
<Section.Root>
diff --git a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx
index 61eee7518bf..1bddd486fc4 100644
--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx
+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx
@@ -269,19 +269,21 @@ export const SettingsAdminNewAiProvider = () => {
<SettingsPageContainer>
{!hasCustomAiProviderAccess && (
<InlineBanner
- variant="compact"
- color="danger"
- message={customAiProviderGateDescription}
- button={{
- title: t`Activate`,
- href: getSettingsPath(SettingsPath.AdminPanelOrganization),
- render: (
- <Link
- to={getSettingsPath(SettingsPath.AdminPanelOrganization)}
- />
- ),
- }}
- />
+ layout="compact"
+ status="error"
+ action={
+ <InlineBanner.Action
+ href={getSettingsPath(SettingsPath.AdminPanelOrganization)}
+ render={
+ <Link
+ to={getSettingsPath(SettingsPath.AdminPanelOrganization)}
+ />
+ }
+ >{t`Activate`}</InlineBanner.Action>
+ }
+ >
+ {customAiProviderGateDescription}
+ </InlineBanner>
)}
<Section.Root>
@@ -311,10 +313,9 @@ export const SettingsAdminNewAiProvider = () => {
{isModelsDevWithoutNativeSdk && (
<InlineBanner
- variant="compact"
- color="blue"
- message={t`This provider doesn't have a native SDK yet — it will use OpenAI-compatible mode. Need native support? Reach out to us.`}
- />
+ layout="compact"
+ status="info"
+ >{t`This provider doesn't have a native SDK yet — it will use OpenAI-compatible mode. Need native support? Reach out to us.`}</InlineBanner>
)}
{hasSelected && (
diff --git a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationDetails.tsx b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationDetails.tsx
index 2d0857ce0d6..06e443bb75d 100644
--- a/packages/twenty-front/src/pages/settings/applications/SettingsApplicationDetails.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/SettingsApplicationDetails.tsx
@@ -1,3 +1,4 @@
+import { themeCssVariables } from 'twenty-ui/theme';
import { AppChip } from '@/applications/components/AppChip';
import { CurrentApplicationContext } from '@/applications/contexts/CurrentApplicationContext';
import { useRefetchOnApplicationOperation } from '@/applications/hooks/useRefetchOnApplicationOperation';
@@ -358,10 +359,14 @@ export const SettingsApplicationDetails = () => {
)}
{isApplicationStopped && (
<InlineBanner
- color="danger"
- LeftIcon={IconAlertTriangle}
- message={t`We are currently encountering issues with this app, its behavior may be degraded while we work on a fix.`}
- />
+ status="warning"
+ icon={
+ <IconAlertTriangle
+ size={themeCssVariables.icon.size.md}
+ aria-hidden="true"
+ />
+ }
+ >{t`We are currently encountering issues with this app, its behavior may be degraded while we work on a fix.`}</InlineBanner>
)}
{renderActiveTabContent()}
</SettingsPageContainer>
diff --git a/packages/twenty-front/src/pages/settings/applications/SettingsAvailableApplicationDetails.tsx b/packages/twenty-front/src/pages/settings/applications/SettingsAvailableApplicationDetails.tsx
index b4e03c71f96..f864c5173cc 100644
--- a/packages/twenty-front/src/pages/settings/applications/SettingsAvailableApplicationDetails.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/SettingsAvailableApplicationDetails.tsx
@@ -1,3 +1,4 @@
+import { themeCssVariables } from 'twenty-ui/theme';
import { AppChip } from '@/applications/components/AppChip';
import { CurrentApplicationContext } from '@/applications/contexts/CurrentApplicationContext';
import { SettingsApplicationInstallPermissionValidationModal } from '@/marketplace/components/SettingsApplicationInstallPermissionValidationModal';
@@ -241,9 +242,13 @@ export const SettingsAvailableApplicationDetails = () => {
<SettingsPageContainer overflow="visible">
{isUnlisted && (
<InlineBanner
- LeftIcon={IconEyeOff}
- message={t`Application not listed on the marketplace. It was shared via a direct link`}
- />
+ icon={
+ <IconEyeOff
+ size={themeCssVariables.icon.size.md}
+ aria-hidden="true"
+ />
+ }
+ >{t`Application not listed on the marketplace. It was shared via a direct link`}</InlineBanner>
)}
{renderActiveTabContent()}
</SettingsPageContainer>
diff --git a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationMissingConfigurationBanner.tsx b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationMissingConfigurationBanner.tsx
index 89c6b1d70ab..0284b8c8cb2 100644
--- a/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationMissingConfigurationBanner.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/components/SettingsApplicationMissingConfigurationBanner.tsx
@@ -1,3 +1,4 @@
+import { themeCssVariables } from 'twenty-ui/theme';
import { t } from '@lingui/core/macro';
import { InlineBanner } from 'twenty-ui/components/feedback';
import { IconAlertCircle } from 'twenty-ui/icon';
@@ -19,10 +20,18 @@ export const SettingsApplicationMissingConfigurationBanner = ({
return (
<InlineBanner
- color="danger"
- LeftIcon={IconAlertCircle}
- message={t`Missing configuration: ${missingLabels}`}
- button={{ title: t`Configure`, onClick: onConfigure }}
- />
+ status="error"
+ icon={
+ <IconAlertCircle
+ size={themeCssVariables.icon.size.md}
+ aria-hidden="true"
+ />
+ }
+ action={
+ <InlineBanner.Action
+ onClick={onConfigure}
+ >{t`Configure`}</InlineBanner.Action>
+ }
+ >{t`Missing configuration: ${missingLabels}`}</InlineBanner>
);
};
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx
index a47bde9e4be..9913ea4d3d4 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx
@@ -79,10 +79,9 @@ export const SettingsApplicationConnectionsSection = ({
/>
{isOAuth && !isClientCredentialsConfigured && (
<InlineBanner
- variant="compact"
- color="danger"
- message={t`${provider.displayName} OAuth is not yet set up by your server administrator. They need to fill in the OAuth client ID and secret on the application registration before you can add a connection.`}
- />
+ layout="compact"
+ status="error"
+ >{t`${provider.displayName} OAuth is not yet set up by your server administrator. They need to fill in the OAuth client ID and secret on the application registration before you can add a connection.`}</InlineBanner>
)}
{providerConnections.length > 0 && (
<Table>
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationGeneralTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationGeneralTab.tsx
index e927349dae0..fa8937ebaac 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationGeneralTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationGeneralTab.tsx
@@ -1,7 +1,7 @@
import { type ApplicationRegistration } from '~/generated-metadata/graphql';
import { useLingui } from '@lingui/react/macro';
-import { useLocation, useNavigate } from 'react-router-dom';
+import { Link, useLocation } from 'react-router-dom';
import { InlineBanner } from 'twenty-ui/components/feedback';
import { SettingsApplicationRegistrationGeneralInfo } from '~/pages/settings/applications/components/SettingsApplicationRegistrationGeneralInfo';
@@ -19,23 +19,24 @@ export const SettingsApplicationRegistrationGeneralTab = ({
}) => {
const { t } = useLingui();
const location = useLocation();
- const navigate = useNavigate();
return (
<>
{!registration.isConfigured && fromAdmin && (
<InlineBanner
- color="danger"
- message={t`This app is not fully configured. Users won't be able to install it until all required server variables are set, and — for apps exposing a server route — until the app is claimed and installed on its owner workspace.`}
- button={{
- title: t`Configure`,
- onClick: () =>
- navigate(
- { search: location.search, hash: '#config' },
- { state: location.state },
- ),
- }}
- />
+ status="error"
+ action={
+ <InlineBanner.Action
+ href={`${location.pathname}${location.search}#config`}
+ render={
+ <Link
+ to={{ search: location.search, hash: '#config' }}
+ state={location.state}
+ />
+ }
+ >{t`Configure`}</InlineBanner.Action>
+ }
+ >{t`This app is not fully configured. Users won't be able to install it until all required server variables are set, and — for apps exposing a server route — until the app is claimed and installed on its owner workspace.`}</InlineBanner>
)}
<SettingsApplicationRegistrationGeneralInfo registration={registration} />
{fromAdmin && (
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx
index 6d224ada4eb..81019c5ef07 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsAvailableTab.tsx
@@ -146,10 +146,7 @@ export const SettingsApplicationsAvailableTab = () => {
{!showVettedOnly && nonVettedApplications.length > 0 && (
<StyledNotVettedContainer>
- <InlineBanner
- color={'danger'}
- message={t`Applications below are not vetted. Use at your own risk.`}
- />
+ <InlineBanner status="warning">{t`Applications below are not vetted. Use at your own risk.`}</InlineBanner>
<StyledCardsGrid>
{nonVettedApplications.map((application) => (
<SettingsAvailableApplicationCard
diff --git a/packages/twenty-ui/docs/bannerPropDescriptions.ts b/packages/twenty-ui/docs/bannerPropDescriptions.ts
index da744044f19..55e0b731836 100644
--- a/packages/twenty-ui/docs/bannerPropDescriptions.ts
+++ b/packages/twenty-ui/docs/bannerPropDescriptions.ts
@@ -1,10 +1,20 @@
import { type ComponentProps } from 'react';
-
import { type Banner } from '../src/primitives/feedback/Banner/Banner';
export const BANNER_PROP_DESCRIPTIONS = {
- children: 'Message and optional actions displayed inside the banner.',
- color: 'Blue information treatment or danger treatment.',
- variant: 'Primary solid treatment or secondary translucent treatment.',
- className: 'CSS class applied to the banner.',
+ children: 'Caller-provided content, including text, links and controls.',
+ status:
+ 'Feedback meaning: neutral, info, success, warning or error. Defaults to info. Does not assign a role or live region.',
+ variant:
+ 'Solid or soft appearance. Defaults to solid, independently of status.',
+ color:
+ 'Palette override: gray, blue, green, orange or red. When omitted, status selects the corresponding palette.',
+ icon: 'Optional leading ReactNode. The caller supplies decorative or accessible icon semantics.',
+ action:
+ 'Optional trailing ReactNode. Banner.Action supplies a small outline action that inherits the resolved banner color; arbitrary controls are also accepted.',
+ className: 'Class merged onto the root div or composed element.',
+ style: 'Inline styles applied to the root div or composed element.',
+ ref: 'Ref to the root div, or to the DOM element supplied through render.',
+ render:
+ 'Base UI element or render callback. The callback receives native props/ref and resolved status, variant and color state.',
} satisfies Partial<Record<keyof ComponentProps<typeof Banner>, string>>;
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 1aabd49c2d7..28823a2d1eb 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -143,6 +143,9 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/primitives/feedback',
slug: 'feedback/banner',
propDescriptions: BANNER_PROP_DESCRIPTIONS,
+ propDefaults: { color: 'status palette', status: 'info', variant: 'solid' },
+ parts: ['Action'],
+ partPropDescriptions: { Action: BUTTON_PROP_DESCRIPTIONS },
},
{
name: 'Loader',
@@ -649,6 +652,16 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/components/feedback',
slug: 'components/feedback/inline-banner',
propDescriptions: INLINE_BANNER_PROP_DESCRIPTIONS,
+ parts: ['Action'],
+ partPropDescriptions: { Action: BUTTON_PROP_DESCRIPTIONS },
+ propDefaults: {
+ color: 'status palette',
+ status: 'info',
+ variant: 'soft',
+ layout: 'standard',
+ embedded: 'false',
+ icon: 'decorative information icon',
+ },
},
{
name: 'ToastProvider',
diff --git a/packages/twenty-ui/docs/inlineBannerPropDescriptions.ts b/packages/twenty-ui/docs/inlineBannerPropDescriptions.ts
index a98681e71cb..3038e185887 100644
--- a/packages/twenty-ui/docs/inlineBannerPropDescriptions.ts
+++ b/packages/twenty-ui/docs/inlineBannerPropDescriptions.ts
@@ -1,32 +1,25 @@
import { type ComponentProps } from 'react';
-
import { type InlineBanner } from '../src/components/feedback/InlineBanner/InlineBanner';
export const INLINE_BANNER_PROP_DESCRIPTIONS = {
- color: 'Banner palette color. An omitted color uses Banner’s default.',
- message:
- 'Message text. Standard banners truncate with a focusable tooltip; compact banners wrap.',
+ children:
+ 'Caller-provided content. Standard plain strings truncate with a focusable tooltip; rich nodes render directly. Compact content wraps.',
+ status:
+ 'Feedback meaning: neutral, info, success, warning or error. Defaults to info. Roles and announcements remain caller-owned.',
variant:
- 'Standard full-width banner or compact wrapping message with a 512px maximum content width.',
+ 'Solid or soft appearance, independently of status and layout. Defaults to soft.',
+ color:
+ 'Gray, blue, green, orange or red palette override. An omitted color follows status.',
+ layout:
+ 'Standard full-width layout or compact wrapping layout with a 512px maximum content width. Defaults to standard.',
embedded:
- 'Removes the bottom margin from standard banners. Compact banners have no bottom margin.',
- button: [
- 'Optional button or destination link. All fields are optional:',
- '',
- '- `title` (`string`): visible action label.',
- '- `onClick` (`(event: BaseUIEvent<React.MouseEvent<HTMLButtonElement>>) => void`): activation handler, including keyboard activation.',
- '- `href` (`string`): destination URL; selects native link semantics.',
- '- `render` (`ReactElement | ((props: HTMLProps, state: { disabled: boolean }) => ReactElement)`): custom root element or renderer. Preserve an anchor when `href` is set, or a native button otherwise. `HTMLProps` includes native element attributes and its ref.',
- '- `target` (`string`): link browsing context, such as `_blank`.',
- '- `rel` (`string`): link relationship, such as `noopener noreferrer`.',
- '- `download` (native anchor attribute): use `true` to download the destination or a `string` to suggest a filename.',
- '- `disabled` (`boolean`): prevents activation.',
- '- `hidden` (`boolean`): omits the action from the banner.',
- '- `aria-label` (`string`): accessible action name, needed when no visible title is supplied.',
- '- `Icon` (`IconComponent`): decorative icon component displayed before the title.',
- '',
- 'Action and link fields use the corresponding [Button props](/ui/primitives/input/button). `BaseUIEvent` extends the React event with `preventBaseUIHandler()` and `baseUIHandlerPrevented`.',
- ].join('\n'),
- LeftIcon: 'Leading icon component. Defaults to the information icon.',
- className: 'Class applied to the banner.',
+ 'Removes the standard bottom margin. Compact layouts have no bottom margin.',
+ icon: 'Leading ReactNode. Defaults to a decorative information icon. Pass null to omit it.',
+ action:
+ 'Optional trailing ReactNode. InlineBanner.Action supplies the shared banner action preset and inherits the resolved banner color; arbitrary controls are also accepted.',
+ className: 'Class merged onto the root div or composed element.',
+ style: 'Inline styles applied to the root div or composed element.',
+ ref: 'Ref to the root div, or to the DOM element supplied through render.',
+ render:
+ 'Base UI root element or render callback, receiving native props/ref and resolved Banner state.',
} satisfies Partial<Record<keyof ComponentProps<typeof InlineBanner>, string>>;
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 5a3720db148..93f9dbd5204 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -68,7 +68,7 @@
"types": {
"CalloutProps": "components/feedback/Callout/types/CalloutProps",
"CalloutVariant": "components/feedback/Callout/types/CalloutVariant",
- "InlineBannerButtonProps": "components/feedback/InlineBanner/types/InlineBannerButtonProps",
+ "InlineBannerLayout": "components/feedback/InlineBanner/types/InlineBannerLayout",
"InlineBannerProps": "components/feedback/InlineBanner/types/InlineBannerProps",
"ToasterProps": "components/feedback/Toaster/types/ToasterProps",
"ToastNotification": "components/feedback/Toast/types/ToastNotification",
@@ -744,8 +744,12 @@
"SKELETON_HEIGHT_SIZES": "primitives/feedback/Skeleton/constants/SKELETON_HEIGHT_SIZES"
},
"types": {
- "BannerColor": "primitives/feedback/Banner/Banner",
- "BannerVariant": "primitives/feedback/Banner/Banner",
+ "BannerActionProps": "primitives/feedback/Banner/types/BannerActionProps",
+ "BannerColor": "primitives/feedback/Banner/types/BannerColor",
+ "BannerProps": "primitives/feedback/Banner/types/BannerProps",
+ "BannerState": "primitives/feedback/Banner/types/BannerState",
+ "BannerStatus": "primitives/feedback/Banner/types/BannerStatus",
+ "BannerVariant": "primitives/feedback/Banner/types/BannerVariant",
"LoaderProps": "primitives/feedback/Loader/types/LoaderProps",
"ProgressBarProps": "primitives/feedback/ProgressBar/types/ProgressBarProps",
"ProgressRingProps": "primitives/feedback/ProgressRing/types/ProgressRingProps",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index afb951d1c1d..d924b7426d1 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -575,33 +575,173 @@
"entryPoint": "twenty-ui/primitives/feedback",
"slug": "feedback/banner",
"props": [
+ {
+ "name": "action",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional trailing ReactNode. Banner.Action supplies a small outline action that inherits the resolved banner color; arbitrary controls are also accepted."
+ },
{
"name": "children",
"type": "ReactNode",
- "required": true,
+ "required": false,
"defaultValue": null,
- "description": "Message and optional actions displayed inside the banner."
+ "description": "Caller-provided content, including text, links and controls."
},
{
"name": "className",
"type": "string",
"required": false,
"defaultValue": null,
- "description": "CSS class applied to the banner."
+ "description": "Class merged onto the root div or composed element."
},
{
"name": "color",
- "type": "\"blue\" | \"danger\"",
+ "type": "\"blue\" | \"gray\" | \"green\" | \"orange\" | \"red\"",
+ "required": false,
+ "defaultValue": "status palette",
+ "description": "Palette override: gray, blue, green, orange or red. When omitted, status selects the corresponding palette."
+ },
+ {
+ "name": "icon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional leading ReactNode. The caller supplies decorative or accessible icon semantics."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Ref to the root div, or to the DOM element supplied through render."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, BannerState>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Base UI element or render callback. The callback receives native props/ref and resolved status, variant and color state."
+ },
+ {
+ "name": "status",
+ "type": "\"error\" | \"info\" | \"neutral\" | \"success\" | \"warning\"",
+ "required": false,
+ "defaultValue": "info",
+ "description": "Feedback meaning: neutral, info, success, warning or error. Defaults to info. Does not assign a role or live region."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties",
"required": false,
- "defaultValue": "blue",
- "description": "Blue information treatment or danger treatment."
+ "defaultValue": null,
+ "description": "Inline styles applied to the root div or composed element."
},
{
"name": "variant",
- "type": "\"primary\" | \"secondary\"",
+ "type": "\"soft\" | \"solid\"",
"required": false,
- "defaultValue": "primary",
- "description": "Primary solid treatment or secondary translucent treatment."
+ "defaultValue": "solid",
+ "description": "Solid or soft appearance. Defaults to solid, independently of status."
+ }
+ ],
+ "parts": [
+ {
+ "name": "Action",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ButtonState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "elevated",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Adds a shadow and backdrop blur. Neutral outline buttons also use elevated surface colors."
+ },
+ {
+ "name": "endIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Decorative content displayed after the label."
+ },
+ {
+ "name": "focusableWhenDisabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether the button should be focusable when disabled."
+ },
+ {
+ "name": "fullWidth",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Expands the button to fill its container width."
+ },
+ {
+ "name": "href",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Destination URL. Enables native link semantics instead of button semantics."
+ },
+ {
+ "name": "loading",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Shows a loading indicator and disables activation."
+ },
+ {
+ "name": "loadingPosition",
+ "type": "\"center\" | \"end\" | \"start\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ },
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Displayed on non-mobile screens."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Localized text between sequence steps. Defaults to then."
+ },
+ {
+ "name": "startIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Decorative content displayed before the label."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: ButtonState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
}
]
},
@@ -9950,53 +10090,186 @@
"slug": "components/feedback/inline-banner",
"props": [
{
- "name": "button",
- "type": "InlineBannerButtonProps",
+ "name": "action",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional trailing ReactNode. InlineBanner.Action supplies the shared banner action preset and inherits the resolved banner color; arbitrary controls are also accepted."
+ },
+ {
+ "name": "children",
+ "type": "ReactNode",
"required": false,
"defaultValue": null,
- "description": "Optional button or destination link. All fields are optional:\n\n- `title` (`string`): visible action label.\n- `onClick` (`(event: BaseUIEvent<React.MouseEvent<HTMLButtonElement>>) => void`): activation handler, including keyboard activation.\n- `href` (`string`): destination URL; selects native link semantics.\n- `render` (`ReactElement | ((props: HTMLProps, state: { disabled: boolean }) => ReactElement)`): custom root element or renderer. Preserve an anchor when `href` is set, or a native button otherwise. `HTMLProps` includes native element attributes and its ref.\n- `target` (`string`): link browsing context, such as `_blank`.\n- `rel` (`string`): link relationship, such as `noopener noreferrer`.\n- `download` (native anchor attribute): use `true` to download the destination or a `string` to suggest a filename.\n- `disabled` (`boolean`): prevents activation.\n- `hidden` (`boolean`): omits the action from the banner.\n- `aria-label` (`string`): accessible action name, needed when no visible title is supplied.\n- `Icon` (`IconComponent`): decorative icon component displayed before the title.\n\nAction and link fields use the corresponding [Button props](/ui/primitives/input/button). `BaseUIEvent` extends the React event with `preventBaseUIHandler()` and `baseUIHandlerPrevented`."
+ "description": "Caller-provided content. Standard plain strings truncate with a focusable tooltip; rich nodes render directly. Compact content wraps."
},
{
"name": "className",
"type": "string",
"required": false,
"defaultValue": null,
- "description": "Class applied to the banner."
+ "description": "Class merged onto the root div or composed element."
},
{
"name": "color",
- "type": "\"blue\" | \"danger\"",
+ "type": "\"blue\" | \"gray\" | \"green\" | \"orange\" | \"red\"",
"required": false,
- "defaultValue": "blue",
- "description": "Banner palette color. An omitted color uses Banner’s default."
+ "defaultValue": "status palette",
+ "description": "Gray, blue, green, orange or red palette override. An omitted color follows status."
},
{
"name": "embedded",
"type": "boolean",
"required": false,
"defaultValue": "false",
- "description": "Removes the bottom margin from standard banners. Compact banners have no bottom margin."
+ "description": "Removes the standard bottom margin. Compact layouts have no bottom margin."
},
{
- "name": "LeftIcon",
- "type": "IconComponent",
+ "name": "icon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": "decorative information icon",
+ "description": "Leading ReactNode. Defaults to a decorative information icon. Pass null to omit it."
+ },
+ {
+ "name": "layout",
+ "type": "\"compact\" | \"standard\"",
+ "required": false,
+ "defaultValue": "standard",
+ "description": "Standard full-width layout or compact wrapping layout with a 512px maximum content width. Defaults to standard."
+ },
+ {
+ "name": "ref",
+ "type": "Ref<HTMLDivElement>",
"required": false,
"defaultValue": null,
- "description": "Leading icon component. Defaults to the information icon."
+ "description": "Ref to the root div, or to the DOM element supplied through render."
},
{
- "name": "message",
- "type": "string",
- "required": true,
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, BannerState>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Base UI root element or render callback, receiving native props/ref and resolved Banner state."
+ },
+ {
+ "name": "status",
+ "type": "\"error\" | \"info\" | \"neutral\" | \"success\" | \"warning\"",
+ "required": false,
+ "defaultValue": "info",
+ "description": "Feedback meaning: neutral, info, success, warning or error. Defaults to info. Roles and announcements remain caller-owned."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties",
+ "required": false,
"defaultValue": null,
- "description": "Message text. Standard banners truncate with a focusable tooltip; compact banners wrap."
+ "description": "Inline styles applied to the root div or composed element."
},
{
"name": "variant",
- "type": "\"compact\" | \"standard\"",
+ "type": "\"soft\" | \"solid\"",
"required": false,
- "defaultValue": "standard",
- "description": "Standard full-width banner or compact wrapping message with a 512px maximum content width."
+ "defaultValue": "soft",
+ "description": "Solid or soft appearance, independently of status and layout. Defaults to soft."
+ }
+ ],
+ "parts": [
+ {
+ "name": "Action",
+ "props": [
+ {
+ "name": "className",
+ "type": "string | ((state: ButtonState) => string | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "CSS class applied to the element, or a function that\nreturns a class based on the component's state."
+ },
+ {
+ "name": "elevated",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Adds a shadow and backdrop blur. Neutral outline buttons also use elevated surface colors."
+ },
+ {
+ "name": "endIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Decorative content displayed after the label."
+ },
+ {
+ "name": "focusableWhenDisabled",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Whether the button should be focusable when disabled."
+ },
+ {
+ "name": "fullWidth",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Expands the button to fill its container width."
+ },
+ {
+ "name": "href",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Destination URL. Enables native link semantics instead of button semantics."
+ },
+ {
+ "name": "loading",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": null,
+ "description": "Shows a loading indicator and disables activation."
+ },
+ {
+ "name": "loadingPosition",
+ "type": "\"center\" | \"end\" | \"start\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Where the loading indicator appears. `center` hides the content while preserving its layout space; `start` and `end` keep children and the opposite icon visible and replace the corresponding icon with the spinner."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, ButtonState>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller."
+ },
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Displayed on non-mobile screens."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Localized text between sequence steps. Defaults to then."
+ },
+ {
+ "name": "startIcon",
+ "type": "ReactNode",
+ "required": false,
+ "defaultValue": null,
+ "description": "Decorative content displayed before the label."
+ },
+ {
+ "name": "style",
+ "type": "CSSProperties | ((state: ButtonState) => CSSProperties | undefined)",
+ "required": false,
+ "defaultValue": null,
+ "description": "Style applied to the element, or a function that\nreturns a style object based on the component's state."
+ }
+ ]
}
]
},
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.module.scss b/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.module.scss
index 0d6b95638a8..fb6408939bd 100644
--- a/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.module.scss
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.module.scss
@@ -13,10 +13,12 @@
flex: 1;
gap: var(--t-spacing-2);
min-width: 0;
+}
- > svg {
- flex-shrink: 0;
- }
+.icon {
+ align-items: center;
+ display: flex;
+ flex-shrink: 0;
}
.bannerText {
@@ -40,14 +42,14 @@
.bannerContent {
flex: initial;
}
-}
-.compactBlue {
- background: var(--t-color-blue5);
- color: var(--t-color-blue10);
-}
+ &[data-variant='soft'][data-color='blue'] {
+ background: var(--t-color-blue5);
+ color: var(--t-color-blue10);
+ }
-.compactDanger {
- background: var(--t-color-red3);
- color: var(--t-color-red);
+ &[data-variant='soft'][data-color='red'] {
+ background: var(--t-color-red3);
+ color: var(--t-color-red);
+ }
}
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.module.scss.d.ts b/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.module.scss.d.ts
index 5cc7af193e2..f211f2a4a47 100644
--- a/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.module.scss.d.ts
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.module.scss.d.ts
@@ -2,9 +2,8 @@ declare const classNames: {
readonly banner: 'banner';
readonly embedded: 'embedded';
readonly bannerContent: 'bannerContent';
+ readonly icon: 'icon';
readonly bannerText: 'bannerText';
readonly compact: 'compact';
- readonly compactBlue: 'compactBlue';
- readonly compactDanger: 'compactDanger';
};
export default classNames;
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.tsx b/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.tsx
index 02b82f18469..4726c372ef2 100644
--- a/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.tsx
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/InlineBanner.tsx
@@ -1,55 +1,7 @@
-import { clsx } from 'clsx';
-
-import { IconInfoCircle } from '@ui/icon/components/TablerIcons';
import { Banner } from '@ui/primitives/feedback/Banner/Banner';
-import { OverflowingTextWithTooltip } from '@ui/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
-import { useTheme } from '@ui/theme';
-import { isDefined } from '@ui/utilities/utils/isDefined';
-
-import styles from './InlineBanner.module.scss';
-import { InlineBannerButton } from './internal/InlineBannerButton';
-import { type InlineBannerProps } from './types/InlineBannerProps';
-export const InlineBanner = ({
- color = 'blue',
- message,
- variant = 'standard',
- embedded = false,
- button,
- LeftIcon = IconInfoCircle,
- className,
-}: InlineBannerProps) => {
- const theme = useTheme();
- const isCompact = variant === 'compact';
+import { InlineBannerComponent } from './internal/InlineBannerComponent';
- return (
- <Banner
- className={clsx(
- styles.banner,
- isCompact && styles.compact,
- isCompact &&
- (color === 'danger' ? styles.compactDanger : styles.compactBlue),
- embedded && styles.embedded,
- className,
- )}
- color={color}
- variant="secondary"
- >
- <div className={styles.bannerContent}>
- <LeftIcon size={theme.icon.size.md} />
- <div className={styles.bannerText}>
- {isCompact ? (
- message
- ) : (
- <OverflowingTextWithTooltip
- isFocusable
- text={<>{message}</>}
- tooltipContent={message}
- />
- )}
- </div>
- </div>
- {isDefined(button) && <InlineBannerButton {...button} color={color} />}
- </Banner>
- );
-};
+export const InlineBanner = Object.assign(InlineBannerComponent, {
+ Action: Banner.Action,
+});
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/__stories__/InlineBanner.stories.tsx b/packages/twenty-ui/src/components/feedback/InlineBanner/__stories__/InlineBanner.stories.tsx
index 8e4d054bb05..9f893dd7ec0 100644
--- a/packages/twenty-ui/src/components/feedback/InlineBanner/__stories__/InlineBanner.stories.tsx
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/__stories__/InlineBanner.stories.tsx
@@ -5,6 +5,15 @@ import { InlineBanner } from '@ui/components/feedback/InlineBanner/InlineBanner'
import { IconExternalLink } from '@ui/icon';
import { A11Y_DEFER_COLOR_CONTRAST, ComponentDecorator } from '@ui/testing';
+const NO_AI_MODELS_MESSAGE = 'No AI models are enabled.';
+const MAILBOX_SYNC_LOST_MESSAGE =
+ 'Sync lost with mailbox [email protected]. Please reconnect for updates:';
+const CARD_PAYMENT_UNAVAILABLE_MESSAGE =
+ 'Card payment is currently unavailable. Please verify your Stripe configuration or contact your workspace admin.';
+
+const onAction = fn();
+const onLinkAction = fn((event) => event.preventDefault());
+
const meta: Meta<typeof InlineBanner> = {
id: 'ui-feedback-inlinebanner',
title: 'UI/Components/Feedback/InlineBanner',
@@ -21,26 +30,30 @@ type Story = StoryObj<typeof InlineBanner>;
export const Default: Story = {
args: {
- color: 'danger',
- message: 'No AI models are enabled.',
- button: { title: 'Configure models', onClick: fn() },
+ status: 'error',
+ children: NO_AI_MODELS_MESSAGE,
+ action: (
+ <InlineBanner.Action onClick={onAction}>
+ {'Configure models'}
+ </InlineBanner.Action>
+ ),
},
};
export const KeyboardAction: Story = {
args: Default.args,
- play: async ({ canvasElement, args }) => {
+ play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const button = await canvas.findByRole('button', {
name: /Configure models/,
});
- await userEvent.hover(canvas.getByText(args.message));
+ await userEvent.hover(canvas.getByText(NO_AI_MODELS_MESSAGE));
await expect(
within(canvasElement.ownerDocument.body).queryByRole('tooltip'),
).not.toBeInTheDocument();
await userEvent.tab();
- await expect(canvas.getByText(args.message)).toHaveFocus();
+ await expect(canvas.getByText(NO_AI_MODELS_MESSAGE)).toHaveFocus();
await expect(
within(canvasElement.ownerDocument.body).queryByRole('tooltip'),
).not.toBeInTheDocument();
@@ -48,88 +61,107 @@ export const KeyboardAction: Story = {
await expect(button).toHaveFocus();
await expect(button).toBeEnabled();
await userEvent.click(button);
- await expect(args.button?.onClick).toHaveBeenCalledTimes(1);
+ await expect(onAction).toHaveBeenCalledTimes(1);
},
};
export const DisabledAction: Story = {
args: {
- color: 'danger',
- message: 'You’ve reached your AI usage limit.',
- button: { title: 'Upgrade', onClick: fn(), disabled: true },
+ status: 'error',
+ children: 'You’ve reached your AI usage limit.',
+ action: (
+ <InlineBanner.Action onClick={onAction} disabled={true}>
+ {'Upgrade'}
+ </InlineBanner.Action>
+ ),
},
- play: async ({ canvasElement, args }) => {
+ play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const button = await canvas.findByRole('button', { name: /Upgrade/ });
await expect(button).toBeDisabled();
await userEvent.click(button);
- await expect(args.button?.onClick).not.toHaveBeenCalled();
+ await expect(onAction).not.toHaveBeenCalled();
},
};
export const WithoutAction: Story = {
args: {
- color: 'danger',
- message: 'Ask your workspace admin to enable an AI model.',
+ status: 'error',
+ children: 'Ask your workspace admin to enable an AI model.',
},
};
export const DocumentationAction: Story = {
args: {
- color: 'danger',
- message: 'Add an API key to enable AI.',
- button: { title: 'View Docs', Icon: IconExternalLink, onClick: fn() },
+ status: 'error',
+ children: 'Add an API key to enable AI.',
+ action: (
+ <InlineBanner.Action onClick={onAction} startIcon={<IconExternalLink />}>
+ {'View Docs'}
+ </InlineBanner.Action>
+ ),
},
};
export const Narrow: Story = {
args: {
- color: 'danger',
- message: 'No AI models are enabled.',
- button: { title: 'Configure models', onClick: fn() },
+ status: 'error',
+ children: NO_AI_MODELS_MESSAGE,
+ action: (
+ <InlineBanner.Action onClick={onAction}>
+ {'Configure models'}
+ </InlineBanner.Action>
+ ),
},
parameters: { container: { width: 320 } },
};
export const Embedded: Story = {
args: {
- color: 'danger',
- message: 'No AI models are enabled.',
- button: { title: 'Configure models', onClick: fn() },
+ status: 'error',
+ children: NO_AI_MODELS_MESSAGE,
+ action: (
+ <InlineBanner.Action onClick={onAction}>
+ {'Configure models'}
+ </InlineBanner.Action>
+ ),
embedded: true,
},
};
export const TruncatedMessage: Story = {
args: {
- color: 'blue',
- message:
- 'Sync lost with mailbox [email protected]. Please reconnect for updates:',
- button: { title: 'Reconnect', onClick: fn() },
+ status: 'info',
+ children: MAILBOX_SYNC_LOST_MESSAGE,
+ action: (
+ <InlineBanner.Action onClick={onAction}>
+ {'Reconnect'}
+ </InlineBanner.Action>
+ ),
},
parameters: { container: { width: 320 } },
- play: async ({ canvasElement, args }) => {
+ play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const message = canvas.getByText(args.message);
+ const message = canvas.getByText(MAILBOX_SYNC_LOST_MESSAGE);
await expect(message.scrollWidth).toBeGreaterThan(message.clientWidth);
await expect(getComputedStyle(message).whiteSpace).toBe('nowrap');
await userEvent.hover(message);
await expect(
await within(canvasElement.ownerDocument.body).findByRole('tooltip'),
- ).toHaveTextContent(args.message);
+ ).toHaveTextContent(MAILBOX_SYNC_LOST_MESSAGE);
await userEvent.unhover(message);
await userEvent.tab();
await expect(message).toHaveFocus();
await expect(
await within(canvasElement.ownerDocument.body).findByRole('tooltip'),
- ).toHaveTextContent(args.message);
+ ).toHaveTextContent(MAILBOX_SYNC_LOST_MESSAGE);
await userEvent.hover(message);
await userEvent.unhover(message);
await expect(
within(canvasElement.ownerDocument.body).getByRole('tooltip'),
- ).toHaveTextContent(args.message);
+ ).toHaveTextContent(MAILBOX_SYNC_LOST_MESSAGE);
await userEvent.keyboard('{Escape}');
await expect(message).toHaveFocus();
await waitFor(() =>
@@ -144,7 +176,7 @@ export const TruncatedMessage: Story = {
await userEvent.tab({ shift: true });
await expect(
await within(canvasElement.ownerDocument.body).findByRole('tooltip'),
- ).toHaveTextContent(args.message);
+ ).toHaveTextContent(MAILBOX_SYNC_LOST_MESSAGE);
await userEvent.tab();
await waitFor(() =>
expect(
@@ -155,35 +187,38 @@ export const TruncatedMessage: Story = {
await expect(message).toHaveFocus();
await expect(
await within(canvasElement.ownerDocument.body).findByRole('tooltip'),
- ).toHaveTextContent(args.message);
+ ).toHaveTextContent(MAILBOX_SYNC_LOST_MESSAGE);
await userEvent.click(canvas.getByRole('button', { name: /Reconnect/ }));
- await expect(args.button?.onClick).toHaveBeenCalledTimes(1);
+ await expect(onAction).toHaveBeenCalledTimes(1);
},
};
export const CompactLink: Story = {
args: {
- variant: 'compact',
- message: 'Connect your account to keep your contacts in sync.',
- button: { title: 'Connection settings', href: '#connection-settings' },
+ layout: 'compact',
+ children: 'Connect your account to keep your contacts in sync.',
+ action: (
+ <InlineBanner.Action href={'#connection-settings'}>
+ {'Connection settings'}
+ </InlineBanner.Action>
+ ),
},
};
export const CompactDanger: Story = {
args: {
- variant: 'compact',
- color: 'danger',
- message:
- 'Card payment is currently unavailable. Please verify your Stripe configuration or contact your workspace admin.',
+ layout: 'compact',
+ status: 'error',
+ children: CARD_PAYMENT_UNAVAILABLE_MESSAGE,
},
};
export const WrappingMessage: Story = {
args: CompactDanger.args,
parameters: { container: { width: 240 } },
- play: async ({ canvasElement, args }) => {
+ play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
- const message = canvas.getByText(args.message);
+ const message = canvas.getByText(CARD_PAYMENT_UNAVAILABLE_MESSAGE);
await expect(message.scrollWidth).toBeLessThanOrEqual(message.clientWidth);
await expect(getComputedStyle(message).whiteSpace).toBe('normal');
@@ -213,18 +248,21 @@ export const DestinationLink: Story = {
export const CustomLink: Story = {
args: {
...CompactLink.args,
- button: {
- title: 'Connection settings',
- href: 'https://twenty.com',
- target: '_blank',
- rel: 'noopener noreferrer',
- render: (
- <a href="https://twenty.com" aria-label="Open connection settings" />
- ),
- onClick: fn((event) => event.preventDefault()),
- },
+ action: (
+ <InlineBanner.Action
+ href={'https://twenty.com'}
+ target={'_blank'}
+ rel={'noopener noreferrer'}
+ render={
+ <a href="https://twenty.com" aria-label="Open connection settings" />
+ }
+ onClick={onLinkAction}
+ >
+ {'Connection settings'}
+ </InlineBanner.Action>
+ ),
},
- play: async ({ canvasElement, args }) => {
+ play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const link = canvas.getByRole('link', { name: 'Open connection settings' });
@@ -234,26 +272,37 @@ export const CustomLink: Story = {
await userEvent.tab();
await expect(link).toHaveFocus();
await userEvent.keyboard('{Enter}');
- await expect(args.button?.onClick).toHaveBeenCalledTimes(1);
+ await expect(onLinkAction).toHaveBeenCalledTimes(1);
},
};
export const CompactAction: Story = {
args: {
- variant: 'compact',
- color: 'danger',
- message: 'Your connection needs attention.',
- button: { title: 'Reconnect', onClick: fn() },
+ layout: 'compact',
+ status: 'warning',
+ variant: 'solid',
+ color: 'blue',
+ role: 'status',
+ children: 'Your connection needs attention.',
+ action: (
+ <InlineBanner.Action onClick={onAction}>
+ {'Reconnect'}
+ </InlineBanner.Action>
+ ),
},
- play: async ({ canvasElement, args }) => {
+ play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
const button = canvas.getByRole('button', { name: 'Reconnect' });
+ await expect(getComputedStyle(button).color).toBe(
+ getComputedStyle(canvas.getByRole('status')).color,
+ );
+
await userEvent.tab();
await expect(button).toHaveFocus();
await userEvent.keyboard('{Enter}');
await userEvent.keyboard(' ');
- await expect(args.button?.onClick).toHaveBeenCalledTimes(2);
+ await expect(onAction).toHaveBeenCalledTimes(2);
await expect(button).toHaveFocus();
},
};
@@ -261,7 +310,7 @@ export const CompactAction: Story = {
export const HiddenAction: Story = {
args: {
...Default.args,
- button: { title: 'Configure models', hidden: true, onClick: fn() },
+ action: null,
},
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/__tests__/InlineBanner.test.tsx b/packages/twenty-ui/src/components/feedback/InlineBanner/__tests__/InlineBanner.test.tsx
new file mode 100644
index 00000000000..b9bd8e01c7f
--- /dev/null
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/__tests__/InlineBanner.test.tsx
@@ -0,0 +1,79 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { describe, expect, it, vi } from 'vitest';
+
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { InlineBanner } from '../InlineBanner';
+import styles from '../InlineBanner.module.scss';
+
+runComponentConformance({
+ name: 'InlineBanner',
+ element: <InlineBanner layout="compact">Sync result</InlineBanner>,
+ refInstanceOf: HTMLDivElement,
+ ownClassName: styles.banner,
+});
+
+describe('InlineBanner composition', () => {
+ it('keeps rich content accessible and accepts multiple arbitrary actions', async () => {
+ const onRetry = vi.fn();
+ render(
+ <InlineBanner
+ status="error"
+ variant="solid"
+ color="blue"
+ icon={null}
+ action={
+ <>
+ <Button onClick={onRetry}>Retry sync</Button>
+ <Button href="/support">Contact support</Button>
+ </>
+ }
+ >
+ <a href="/connections">Review connections</a>
+ </InlineBanner>,
+ );
+ const content = screen.getByRole('link', { name: 'Review connections' });
+ expect(content).not.toHaveAttribute('tabindex');
+ expect(screen.queryByRole('tooltip')).not.toBeInTheDocument();
+ await userEvent.tab();
+ expect(content).toHaveFocus();
+ await userEvent.tab();
+ await userEvent.keyboard(' ');
+ expect(onRetry).toHaveBeenCalledTimes(1);
+ await userEvent.tab();
+ expect(screen.getByRole('link', { name: 'Contact support' })).toHaveFocus();
+ });
+
+ it('preserves caller-owned announcements across both layouts', () => {
+ const { rerender } = render(
+ <InlineBanner status="error" data-testid="feedback">
+ Sync failed
+ </InlineBanner>,
+ );
+ const banner = screen.getByTestId('feedback');
+ expect(banner).not.toHaveAttribute('role');
+ expect(banner).not.toHaveAttribute('aria-live');
+ expect(screen.getByText('Sync failed')).toHaveAttribute('tabindex', '0');
+ rerender(
+ <InlineBanner
+ layout="compact"
+ status="warning"
+ color="red"
+ role="status"
+ aria-live="polite"
+ data-testid="feedback"
+ >
+ Sync paused
+ </InlineBanner>,
+ );
+ expect(screen.getByRole('status')).toBe(banner);
+ expect(banner).toHaveAttribute('data-status', 'warning');
+ expect(banner).toHaveAttribute('data-color', 'red');
+ expect(banner).toHaveAttribute('data-variant', 'soft');
+ expect(banner).toHaveAttribute('data-layout', 'compact');
+ expect(banner).toHaveAttribute('aria-live', 'polite');
+ expect(screen.getByText('Sync paused')).not.toHaveAttribute('tabindex');
+ });
+});
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/internal/InlineBannerButton.tsx b/packages/twenty-ui/src/components/feedback/InlineBanner/internal/InlineBannerButton.tsx
deleted file mode 100644
index 435d17daedc..00000000000
--- a/packages/twenty-ui/src/components/feedback/InlineBanner/internal/InlineBannerButton.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-import { type BannerColor } from '@ui/primitives/feedback/Banner/Banner';
-import { isDefined } from '@ui/utilities/utils/isDefined';
-import { Button } from '@ui/primitives/input/Button/Button';
-import { type InlineBannerButtonProps } from '../types/InlineBannerButtonProps';
-
-export const InlineBannerButton = ({
- color,
- title,
- Icon,
- hidden,
- onClick,
- href,
- render,
- target,
- rel,
- download,
- disabled,
- 'aria-label': ariaLabel,
-}: InlineBannerButtonProps & { color: BannerColor }) => {
- if (hidden) {
- return null;
- }
-
- return (
- <Button
- onClick={onClick}
- href={href}
- render={render}
- target={target}
- rel={rel}
- download={download}
- disabled={disabled}
- aria-label={ariaLabel}
- size="sm"
- startIcon={isDefined(Icon) ? <Icon /> : undefined}
- variant="outline"
- color={color === 'danger' ? 'danger' : 'accent'}
- >
- {title}
- </Button>
- );
-};
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/internal/InlineBannerComponent.tsx b/packages/twenty-ui/src/components/feedback/InlineBanner/internal/InlineBannerComponent.tsx
new file mode 100644
index 00000000000..8a52fd7f4fa
--- /dev/null
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/internal/InlineBannerComponent.tsx
@@ -0,0 +1,56 @@
+import { isString } from '@sniptt/guards';
+import { clsx } from 'clsx';
+
+import { IconInfoCircle } from '@ui/icon/components/TablerIcons';
+import { Banner } from '@ui/primitives/feedback/Banner/Banner';
+import { OverflowingTextWithTooltip } from '@ui/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
+
+import { themeCssVariables } from '@ui/theme';
+import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';
+
+import styles from '../InlineBanner.module.scss';
+import { type InlineBannerProps } from '../types/InlineBannerProps';
+
+export const InlineBannerComponent = ({
+ children,
+ layout = 'standard',
+ variant = 'soft',
+ embedded = false,
+ icon = (
+ <IconInfoCircle size={themeCssVariables.icon.size.md} aria-hidden="true" />
+ ),
+ className,
+ ...props
+}: InlineBannerProps) => {
+ const isCompact = layout === 'compact';
+ const shouldTruncateText = !isCompact && isString(children);
+
+ return (
+ <Banner
+ {...props}
+ className={clsx(
+ styles.banner,
+ isCompact && styles.compact,
+ embedded && styles.embedded,
+ className,
+ )}
+ variant={variant}
+ data-layout={layout}
+ >
+ <div className={styles.bannerContent}>
+ {isRenderableSlot(icon) && <span className={styles.icon}>{icon}</span>}
+ <div className={styles.bannerText}>
+ {shouldTruncateText ? (
+ <OverflowingTextWithTooltip
+ isFocusable
+ text={<>{children}</>}
+ tooltipContent={children}
+ />
+ ) : (
+ children
+ )}
+ </div>
+ </div>
+ </Banner>
+ );
+};
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerButtonProps.ts b/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerButtonProps.ts
deleted file mode 100644
index f710eb75b6d..00000000000
--- a/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerButtonProps.ts
+++ /dev/null
@@ -1,18 +0,0 @@
-import { type IconComponent } from '@ui/icon/types/IconComponent';
-import { type ButtonProps } from '@ui/primitives/input/Button/types/ButtonProps';
-
-export type InlineBannerButtonProps = Pick<
- ButtonProps,
- | 'onClick'
- | 'href'
- | 'render'
- | 'target'
- | 'rel'
- | 'download'
- | 'disabled'
- | 'aria-label'
-> & {
- title?: string;
- hidden?: boolean;
- Icon?: IconComponent;
-};
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerLayout.ts b/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerLayout.ts
new file mode 100644
index 00000000000..a5fa3a07ab5
--- /dev/null
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerLayout.ts
@@ -0,0 +1 @@
+export type InlineBannerLayout = 'standard' | 'compact';
diff --git a/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerProps.ts b/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerProps.ts
index dd90603d2dd..f3f0184c2e7 100644
--- a/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerProps.ts
+++ b/packages/twenty-ui/src/components/feedback/InlineBanner/types/InlineBannerProps.ts
@@ -1,13 +1,8 @@
-import { type IconComponent } from '@ui/icon/types/IconComponent';
-import { type BannerColor } from '@ui/primitives/feedback/Banner/Banner';
-import { type InlineBannerButtonProps } from './InlineBannerButtonProps';
+import { type BannerProps } from '@ui/primitives/feedback/Banner/types/BannerProps';
-export type InlineBannerProps = {
- color?: BannerColor;
- message: string;
- variant?: 'standard' | 'compact';
+import { type InlineBannerLayout } from './InlineBannerLayout';
+
+export type InlineBannerProps = BannerProps & {
+ layout?: InlineBannerLayout;
embedded?: boolean;
- button?: InlineBannerButtonProps;
- LeftIcon?: IconComponent;
- className?: string;
};
diff --git a/packages/twenty-ui/src/components/feedback/index.ts b/packages/twenty-ui/src/components/feedback/index.ts
index 99d83b8c528..217d4b97863 100644
--- a/packages/twenty-ui/src/components/feedback/index.ts
+++ b/packages/twenty-ui/src/components/feedback/index.ts
@@ -11,7 +11,7 @@ export { Callout } from './Callout/Callout';
export type { CalloutProps } from './Callout/types/CalloutProps';
export type { CalloutVariant } from './Callout/types/CalloutVariant';
export { InlineBanner } from './InlineBanner/InlineBanner';
-export type { InlineBannerButtonProps } from './InlineBanner/types/InlineBannerButtonProps';
+export type { InlineBannerLayout } from './InlineBanner/types/InlineBannerLayout';
export type { InlineBannerProps } from './InlineBanner/types/InlineBannerProps';
export { useToast } from './Toast/hooks/useToast';
export { Toast } from './Toast/Toast';
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/Banner.module.scss b/packages/twenty-ui/src/primitives/feedback/Banner/Banner.module.scss
index 944e358b53d..f37eabf3d63 100644
--- a/packages/twenty-ui/src/primitives/feedback/Banner/Banner.module.scss
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/Banner.module.scss
@@ -12,28 +12,53 @@
min-height: 40px;
padding: var(--t-spacing-2);
width: 100%;
-}
-.primaryBlue {
- backdrop-filter: blur(5px);
- background: var(--t-color-blue);
- color: var(--t-font-color-inverted);
-}
+ &[data-color='gray'] {
+ --banner-solid-background: var(--t-color-gray);
+ --banner-soft-background: var(--t-background-transparent-secondary);
+ --banner-soft-color: var(--t-font-color-primary);
+ }
-.primaryDanger {
- backdrop-filter: blur(5px);
- background: var(--t-color-red);
- color: var(--t-font-color-inverted);
-}
+ &[data-color='blue'] {
+ --banner-solid-background: var(--t-color-blue);
+ --banner-soft-background: var(--t-background-transparent-blue);
+ --banner-soft-color: var(--t-color-blue);
+ }
+
+ &[data-color='green'] {
+ --banner-solid-background: var(--t-color-green);
+ --banner-soft-background: var(--t-background-transparent-success);
+ --banner-soft-color: var(--t-color-green);
+ }
+
+ &[data-color='orange'] {
+ --banner-solid-background: var(--t-color-orange);
+ --banner-soft-background: var(--t-background-transparent-orange);
+ --banner-soft-color: var(--t-color-orange);
+ }
-.secondaryBlue {
- backdrop-filter: none;
- background: var(--t-background-transparent-blue);
- color: var(--t-color-blue);
+ &[data-color='red'] {
+ --banner-solid-background: var(--t-color-red);
+ --banner-soft-background: var(--t-background-transparent-danger);
+ --banner-soft-color: var(--t-color-red);
+ }
+
+ &[data-variant='solid'] {
+ backdrop-filter: blur(5px);
+ background: var(--banner-solid-background);
+ color: var(--t-font-color-inverted);
+ }
+
+ &[data-variant='soft'] {
+ backdrop-filter: none;
+ background: var(--banner-soft-background);
+ color: var(--banner-soft-color);
+ }
}
-.secondaryDanger {
- backdrop-filter: none;
- background: var(--t-background-transparent-danger);
- color: var(--t-color-red);
+.icon,
+.action {
+ align-items: center;
+ display: flex;
+ flex-shrink: 0;
}
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/Banner.module.scss.d.ts b/packages/twenty-ui/src/primitives/feedback/Banner/Banner.module.scss.d.ts
index d8caafc2201..cbb44880c98 100644
--- a/packages/twenty-ui/src/primitives/feedback/Banner/Banner.module.scss.d.ts
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/Banner.module.scss.d.ts
@@ -1,8 +1,6 @@
declare const classNames: {
readonly banner: 'banner';
- readonly primaryBlue: 'primaryBlue';
- readonly primaryDanger: 'primaryDanger';
- readonly secondaryBlue: 'secondaryBlue';
- readonly secondaryDanger: 'secondaryDanger';
+ readonly icon: 'icon';
+ readonly action: 'action';
};
export default classNames;
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/Banner.tsx b/packages/twenty-ui/src/primitives/feedback/Banner/Banner.tsx
index 53d9dcfd650..d6584bd23c3 100644
--- a/packages/twenty-ui/src/primitives/feedback/Banner/Banner.tsx
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/Banner.tsx
@@ -1,44 +1,6 @@
-import { clsx } from 'clsx';
+import { BannerAction } from './internal/BannerAction';
+import { BannerComponent } from './internal/BannerComponent';
-import styles from './Banner.module.scss';
-
-export type BannerColor = 'blue' | 'danger';
-
-export type BannerVariant = 'primary' | 'secondary';
-
-const BANNER_VARIANT_COLOR_CLASS_NAMES = {
- primary: {
- blue: styles.primaryBlue,
- danger: styles.primaryDanger,
- },
- secondary: {
- blue: styles.secondaryBlue,
- danger: styles.secondaryDanger,
- },
-} as const;
-
-type BannerProps = {
- color?: BannerColor;
- variant?: BannerVariant;
- className?: string;
- children: React.ReactNode;
-};
-
-export const Banner = ({
- color = 'blue',
- variant = 'primary',
- className,
- children,
-}: BannerProps) => {
- return (
- <div
- className={clsx(
- styles.banner,
- BANNER_VARIANT_COLOR_CLASS_NAMES[variant][color],
- className,
- )}
- >
- {children}
- </div>
- );
-};
+export const Banner = Object.assign(BannerComponent, {
+ Action: BannerAction,
+});
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.module.scss b/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.module.scss
index 5139ef71d16..21fa331c818 100644
--- a/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.module.scss
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.module.scss
@@ -10,14 +10,6 @@
width: 100%;
}
-.invertedButton[data-variant='outline'] {
- --tw-button-active: var(--t-background-transparent-medium);
- --tw-button-background: transparent;
- --tw-button-border: var(--t-background-transparent-primary);
- --tw-button-color: var(--t-font-color-inverted);
- --tw-button-hover: var(--t-background-transparent-light);
-}
-
-.invertedIconButton {
- color: var(--t-font-color-inverted) !important;
+.closeButton[data-variant='ghost'] {
+ color: inherit;
}
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.module.scss.d.ts b/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.module.scss.d.ts
index b9dfd981df7..a32841232ed 100644
--- a/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.module.scss.d.ts
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.module.scss.d.ts
@@ -1,7 +1,6 @@
declare const classNames: {
readonly bannerContent: 'bannerContent';
+ readonly closeButton: 'closeButton';
readonly container: 'container';
- readonly invertedButton: 'invertedButton';
- readonly invertedIconButton: 'invertedIconButton';
};
export default classNames;
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.tsx b/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.tsx
index 60c1a016716..1fd76dad69f 100644
--- a/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.tsx
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/__stories__/Banner.stories.tsx
@@ -1,60 +1,48 @@
import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, within } from 'storybook/test';
-import { IconX } from '@ui/icon';
+import { IconInfoCircle, IconX } from '@ui/icon';
+import { Banner } from '@ui/primitives/feedback/Banner/Banner';
+import { type BannerColor } from '@ui/primitives/feedback/Banner/types/BannerColor';
+import { type BannerStatus } from '@ui/primitives/feedback/Banner/types/BannerStatus';
+import { type BannerVariant } from '@ui/primitives/feedback/Banner/types/BannerVariant';
+import { Button } from '@ui/primitives/input/Button/Button';
import {
A11Y_DEFER_COLOR_CONTRAST,
CatalogDecorator,
type CatalogStory,
ComponentDecorator,
} from '@ui/testing';
-import { Button } from '@ui/primitives/input/Button/Button';
-import {
- Banner,
- type BannerColor,
- type BannerVariant,
-} from '@ui/primitives/feedback/Banner/Banner';
import styles from './Banner.stories.module.scss';
-const getButtonColor = (color?: BannerColor) =>
- color === 'danger' ? 'danger' : 'accent';
-
-const BannerCloseButton = ({
- color,
- variant,
-}: {
- color?: BannerColor;
- variant?: BannerVariant;
-}) =>
- variant === 'primary' ? (
- <Button
- className={styles.invertedIconButton}
- size="sm"
- variant="ghost"
- aria-label="Close"
- startIcon={<IconX />}
- />
- ) : (
- <Button
- size="sm"
- variant="ghost"
- color={getButtonColor(color)}
- aria-label="Close"
- startIcon={<IconX />}
- />
- );
-
const meta: Meta<typeof Banner> = {
title: 'UI/Feedback/Banner',
component: Banner,
argTypes: {
+ status: {
+ control: 'select',
+ options: [
+ 'neutral',
+ 'info',
+ 'success',
+ 'warning',
+ 'error',
+ ] satisfies BannerStatus[],
+ },
color: {
control: 'select',
- options: ['blue', 'danger'] satisfies BannerColor[],
+ options: [
+ 'gray',
+ 'blue',
+ 'green',
+ 'orange',
+ 'red',
+ ] satisfies BannerColor[],
},
variant: {
control: 'select',
- options: ['primary', 'secondary'] satisfies BannerVariant[],
+ options: ['solid', 'soft'] satisfies BannerVariant[],
},
},
};
@@ -63,84 +51,102 @@ export default meta;
type Story = StoryObj<typeof Banner>;
export const Default: Story = {
- args: {
- color: 'blue',
- variant: 'primary',
- },
- render: (args) => (
- <div className={styles.container}>
- <Banner {...args}>
- <div className={styles.bannerContent}>
- Sync lost with mailbox [email protected]. Please reconnect for updates:
- <Button
- size="sm"
- variant="outline"
- color={
- args.variant === 'primary'
- ? 'neutral'
- : getButtonColor(args.color)
- }
- className={
- args.variant === 'primary' ? styles.invertedButton : undefined
- }
- >
- {'Reconnect'}
- </Button>
- </div>
- <BannerCloseButton color={args.color} variant={args.variant} />
- </Banner>
- </div>
- ),
- decorators: [ComponentDecorator],
-};
-
-export const Catalog: CatalogStory<Story, typeof Banner> = {
- args: {},
- argTypes: {
- color: { control: false },
- variant: { control: false },
- },
+ args: { status: 'info', variant: 'solid' },
render: (args) => (
<Banner {...args}>
<div className={styles.bannerContent}>
Sync lost with mailbox [email protected]. Please reconnect for updates:
- <Button
- size="sm"
- variant="outline"
- color={
- args.variant === 'primary' ? 'neutral' : getButtonColor(args.color)
- }
- className={
- args.variant === 'primary' ? styles.invertedButton : undefined
- }
- >
- {'Reconnect'}
- </Button>
+ <Banner.Action>Reconnect</Banner.Action>
</div>
- <BannerCloseButton color={args.color} variant={args.variant} />
+ <Button
+ className={styles.closeButton}
+ size="sm"
+ variant="ghost"
+ aria-label="Close"
+ startIcon={<IconX />}
+ />
</Banner>
),
+ decorators: [ComponentDecorator],
+};
+
+export const Catalog: CatalogStory<Story, typeof Banner> = {
+ args: {
+ children: 'Your account needs attention.',
+ role: 'status',
+ action: <Banner.Action>Review details</Banner.Action>,
+ },
parameters: {
a11y: A11Y_DEFER_COLOR_CONTRAST,
catalog: {
dimensions: [
{
name: 'variant',
- values: ['primary', 'secondary'] satisfies BannerVariant[],
+ values: ['solid', 'soft'] satisfies BannerVariant[],
props: (variant: BannerVariant) => ({ variant }),
},
{
- name: 'color',
- values: ['blue', 'danger'] satisfies BannerColor[],
- props: (color: BannerColor) => ({ color }),
+ name: 'status',
+ values: [
+ 'neutral',
+ 'info',
+ 'success',
+ 'warning',
+ 'error',
+ ] satisfies BannerStatus[],
+ props: (status: BannerStatus) => ({ status }),
},
],
- options: {
- elementContainer: {
- width: 700,
- },
- },
+ options: { elementContainer: { width: 700 } },
},
},
decorators: [CatalogDecorator],
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ for (const banner of canvas.getAllByRole('status')) {
+ const action = within(banner).getByRole('button', {
+ name: 'Review details',
+ });
+
+ await expect(getComputedStyle(action).color).toBe(
+ getComputedStyle(banner).color,
+ );
+ }
+ },
+};
+
+export const IndependentAppearance: Story = {
+ args: {
+ status: 'error',
+ color: 'blue',
+ variant: 'soft',
+ children: 'Sync could not finish.',
+ icon: <IconInfoCircle aria-hidden="true" />,
+ action: <Banner.Action>Retry sync</Banner.Action>,
+ role: 'status',
+ 'aria-live': 'polite',
+ 'aria-label': 'Sync result',
+ className: 'custom-banner',
+ style: { marginTop: 7 },
+ render: <section data-composed="true" />,
+ },
+ decorators: [ComponentDecorator],
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const banner = canvas.getByRole('status', { name: 'Sync result' });
+ await expect(banner.tagName).toBe('SECTION');
+ await expect(banner).toHaveAttribute('data-status', 'error');
+ await expect(banner).toHaveAttribute('data-color', 'blue');
+ await expect(banner).toHaveAttribute('data-variant', 'soft');
+ await expect(banner).toHaveAttribute('aria-live', 'polite');
+ await expect(banner).toHaveClass('custom-banner');
+ await expect(banner).toHaveStyle({ marginTop: '7px' });
+ const action = canvas.getByRole('button', { name: 'Retry sync' });
+
+ await expect(action).toBeVisible();
+ await expect(getComputedStyle(action).color).toBe(
+ getComputedStyle(banner).color,
+ );
+ },
};
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/__tests__/Banner.test.tsx b/packages/twenty-ui/src/primitives/feedback/Banner/__tests__/Banner.test.tsx
new file mode 100644
index 00000000000..8aaaba27133
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/__tests__/Banner.test.tsx
@@ -0,0 +1,94 @@
+import { render, screen } from '@testing-library/react';
+import userEvent from '@testing-library/user-event';
+import { describe, expect, it, vi } from 'vitest';
+
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+import { Button } from '@ui/primitives/input/Button/Button';
+
+import { Banner } from '../Banner';
+import styles from '../Banner.module.scss';
+
+runComponentConformance({
+ name: 'Banner',
+ element: <Banner>Sync result</Banner>,
+ refInstanceOf: HTMLDivElement,
+ ownClassName: styles.banner,
+});
+
+describe('Banner feedback', () => {
+ it('keeps status independent from appearance and explicit palette overrides', () => {
+ const { rerender } = render(
+ <Banner status="error" variant="soft" color="blue" data-testid="feedback">
+ Sync failed
+ </Banner>,
+ );
+ const banner = screen.getByTestId('feedback');
+ expect(banner).toHaveAttribute('data-status', 'error');
+ expect(banner).toHaveAttribute('data-variant', 'soft');
+ expect(banner).toHaveAttribute('data-color', 'blue');
+ rerender(
+ <Banner
+ status="success"
+ variant="solid"
+ color="blue"
+ data-testid="feedback"
+ >
+ Sync finished
+ </Banner>,
+ );
+ expect(banner).toHaveAttribute('data-status', 'success');
+ expect(banner).toHaveAttribute('data-variant', 'solid');
+ expect(banner).toHaveAttribute('data-color', 'blue');
+ rerender(
+ <Banner status="success" data-testid="feedback">
+ Sync finished
+ </Banner>,
+ );
+ expect(banner).toHaveAttribute('data-color', 'green');
+ });
+
+ it('leaves live-region semantics with the caller when feedback changes', () => {
+ const { rerender } = render(
+ <Banner status="error" data-testid="feedback">
+ Sync failed
+ </Banner>,
+ );
+ const banner = screen.getByTestId('feedback');
+ expect(banner).not.toHaveAttribute('role');
+ expect(banner).not.toHaveAttribute('aria-live');
+ rerender(
+ <Banner
+ status="success"
+ role="status"
+ aria-live="polite"
+ aria-atomic="true"
+ data-testid="feedback"
+ >
+ Sync finished
+ </Banner>,
+ );
+ expect(screen.getByRole('status')).toBe(banner);
+ expect(banner).toHaveAttribute('aria-live', 'polite');
+ expect(banner).toHaveAttribute('aria-atomic', 'true');
+ });
+
+ it('composes node content and actions without taking ownership of activation', async () => {
+ const onRetry = vi.fn();
+ render(
+ <Banner
+ icon={<span aria-label="Connection issue" />}
+ action={<Button onClick={onRetry}>Retry sync</Button>}
+ >
+ <a href="/connections">Review connections</a>
+ </Banner>,
+ );
+ expect(
+ screen.getByRole('link', { name: 'Review connections' }),
+ ).toHaveAttribute('href', '/connections');
+ expect(screen.getByLabelText('Connection issue')).toBeInTheDocument();
+ await userEvent.tab();
+ await userEvent.tab();
+ await userEvent.keyboard('{Enter}');
+ expect(onRetry).toHaveBeenCalledTimes(1);
+ });
+});
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/__tests__/BannerAction.test.tsx b/packages/twenty-ui/src/primitives/feedback/Banner/__tests__/BannerAction.test.tsx
new file mode 100644
index 00000000000..0c55863f2ba
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/__tests__/BannerAction.test.tsx
@@ -0,0 +1,11 @@
+import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
+
+import { Banner } from '../Banner';
+import styles from '../internal/BannerAction.module.scss';
+
+runComponentConformance({
+ name: 'Banner.Action',
+ element: <Banner.Action>Retry sync</Banner.Action>,
+ refInstanceOf: HTMLButtonElement,
+ ownClassName: styles.action,
+});
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.module.scss b/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.module.scss
new file mode 100644
index 00000000000..fdad63b30ff
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.module.scss
@@ -0,0 +1,8 @@
+.action[data-color][data-variant] {
+ --tw-button-active: color-mix(in srgb, currentColor 20%, transparent);
+ --tw-button-background: transparent;
+ --tw-button-border: color-mix(in srgb, currentColor 25%, transparent);
+ --tw-button-hover: color-mix(in srgb, currentColor 10%, transparent);
+
+ color: inherit;
+}
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.module.scss.d.ts b/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.module.scss.d.ts
new file mode 100644
index 00000000000..d6444d25cb7
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.module.scss.d.ts
@@ -0,0 +1,4 @@
+declare const classNames: {
+ readonly action: 'action';
+};
+export default classNames;
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.tsx b/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.tsx
new file mode 100644
index 00000000000..cb829c2468e
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerAction.tsx
@@ -0,0 +1,16 @@
+import { Button } from '@ui/primitives/input/Button/Button';
+import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
+
+import styles from './BannerAction.module.scss';
+import { type BannerActionProps } from '../types/BannerActionProps';
+
+export const BannerAction = ({ className, ...props }: BannerActionProps) => {
+ return (
+ <Button
+ {...props}
+ size="sm"
+ variant="outline"
+ className={mergeClassNames(styles.action, className)}
+ />
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerComponent.tsx b/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerComponent.tsx
new file mode 100644
index 00000000000..dcd76e004d8
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/internal/BannerComponent.tsx
@@ -0,0 +1,51 @@
+import { useRender } from '@base-ui/react/use-render';
+import { clsx } from 'clsx';
+
+import { isRenderableSlot } from '@ui/utilities/internal/isRenderableSlot';
+
+import styles from '../Banner.module.scss';
+import { type BannerColor } from '../types/BannerColor';
+import { type BannerProps } from '../types/BannerProps';
+import { type BannerStatus } from '../types/BannerStatus';
+
+const BANNER_STATUS_COLORS = {
+ neutral: 'gray',
+ info: 'blue',
+ success: 'green',
+ warning: 'orange',
+ error: 'red',
+} satisfies Record<BannerStatus, BannerColor>;
+
+export const BannerComponent = ({
+ status = 'info',
+ variant = 'solid',
+ color = BANNER_STATUS_COLORS[status],
+ icon,
+ action,
+ className,
+ children,
+ render,
+ ref,
+ ...props
+}: BannerProps) => {
+ return useRender({
+ render,
+ ref,
+ state: { status, variant, color },
+ props: {
+ ...props,
+ className: clsx(styles.banner, className),
+ children: (
+ <>
+ {isRenderableSlot(icon) && (
+ <span className={styles.icon}>{icon}</span>
+ )}
+ {children}
+ {isRenderableSlot(action) && (
+ <div className={styles.action}>{action}</div>
+ )}
+ </>
+ ),
+ },
+ });
+};
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerActionProps.ts b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerActionProps.ts
new file mode 100644
index 00000000000..de2690ab976
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerActionProps.ts
@@ -0,0 +1,3 @@
+import { type ButtonProps } from '@ui/primitives/input/Button/types/ButtonProps';
+
+export type BannerActionProps = Omit<ButtonProps, 'size' | 'variant' | 'color'>;
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerColor.ts b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerColor.ts
new file mode 100644
index 00000000000..0feda959694
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerColor.ts
@@ -0,0 +1 @@
+export type BannerColor = 'gray' | 'blue' | 'green' | 'orange' | 'red';
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerProps.ts b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerProps.ts
new file mode 100644
index 00000000000..072b0c23760
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerProps.ts
@@ -0,0 +1,18 @@
+import { type useRender } from '@base-ui/react/use-render';
+import { type ReactNode } from 'react';
+
+import { type BannerColor } from './BannerColor';
+import { type BannerState } from './BannerState';
+import { type BannerStatus } from './BannerStatus';
+import { type BannerVariant } from './BannerVariant';
+
+export type BannerProps = Omit<
+ useRender.ComponentProps<'div', BannerState>,
+ 'color'
+> & {
+ status?: BannerStatus;
+ variant?: BannerVariant;
+ color?: BannerColor;
+ icon?: ReactNode;
+ action?: ReactNode;
+};
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerState.ts b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerState.ts
new file mode 100644
index 00000000000..1a1a3da8afa
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerState.ts
@@ -0,0 +1,9 @@
+import { type BannerColor } from './BannerColor';
+import { type BannerStatus } from './BannerStatus';
+import { type BannerVariant } from './BannerVariant';
+
+export type BannerState = {
+ status: BannerStatus;
+ variant: BannerVariant;
+ color: BannerColor;
+};
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerStatus.ts b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerStatus.ts
new file mode 100644
index 00000000000..bd149c31030
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerStatus.ts
@@ -0,0 +1 @@
+export type BannerStatus = 'neutral' | 'info' | 'success' | 'warning' | 'error';
diff --git a/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerVariant.ts b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerVariant.ts
new file mode 100644
index 00000000000..b769b14f98a
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/feedback/Banner/types/BannerVariant.ts
@@ -0,0 +1 @@
+export type BannerVariant = 'solid' | 'soft';
diff --git a/packages/twenty-ui/src/primitives/feedback/index.ts b/packages/twenty-ui/src/primitives/feedback/index.ts
index 813d3a11895..493901a8548 100644
--- a/packages/twenty-ui/src/primitives/feedback/index.ts
+++ b/packages/twenty-ui/src/primitives/feedback/index.ts
@@ -7,8 +7,13 @@
* |___/
*/
-export type { BannerColor, BannerVariant } from './Banner/Banner';
export { Banner } from './Banner/Banner';
+export type { BannerActionProps } from './Banner/types/BannerActionProps';
+export type { BannerColor } from './Banner/types/BannerColor';
+export type { BannerProps } from './Banner/types/BannerProps';
+export type { BannerState } from './Banner/types/BannerState';
+export type { BannerStatus } from './Banner/types/BannerStatus';
+export type { BannerVariant } from './Banner/types/BannerVariant';
export { Loader } from './Loader/Loader';
export type { LoaderProps } from './Loader/types/LoaderProps';
export { ProgressBar } from './ProgressBar/ProgressBar';