Skip to content

The open alternative to Salesforce, designed for AI.

Align Section and CommandBlock composition (#27584)

Raphaël Bosif8b333f6e32e
diff --git a/packages/twenty-companion/src/renderer/components/Home.tsx b/packages/twenty-companion/src/renderer/components/Home.tsx
index ef90ec4d993..10b88311303 100644
--- a/packages/twenty-companion/src/renderer/components/Home.tsx
+++ b/packages/twenty-companion/src/renderer/components/Home.tsx
@@ -143,7 +143,7 @@ export const Home = ({ state, command, isPending }: ActionProps) => {
>
<Section.Header
title={i18n._('Recordings')}
- adornment={
+ actions={
<Button
variant="ghost"
startIcon={<IconArrowUpRight />}
diff --git a/packages/twenty-docs/snippets/ui/generated/components/data-display/command-block.mdx b/packages/twenty-docs/snippets/ui/generated/components/data-display/command-block.mdx
index 38e8e141090..d52576f849e 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/data-display/command-block.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/data-display/command-block.mdx
@@ -11,10 +11,17 @@
* npx nx generate:ui twenty-docs
*/}
-<ParamField body="button" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt;">
- Optional action element beside the command lines, such as a copy button.
+<ParamField body="actions" type="ReactNode">
+ Content beside the command lines, such as a copy button, link or status.
</ParamField>
-<ParamField body="commands" type="string[]" required>
+<ParamField body="commands" type="readonly string[]" required>
Command lines to display. The component prefixes each line with > and does not execute commands.
</ParamField>
+
+<ParamField body="render" type="ReactElement&lt;unknown, string | JSXElementConstructor&lt;any&gt;&gt; | ComponentRenderFn&lt;HTMLProps, {}&gt;">
+ Allows you to replace the component's HTML element
+ with a different tag, or compose it with another component.
+
+ Accepts a `ReactElement` or a function that returns the element to render.
+</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/layout/section.mdx b/packages/twenty-docs/snippets/ui/generated/components/layout/section.mdx
index 3aaaf014fe3..3d5c1de5042 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/layout/section.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/layout/section.mdx
@@ -34,7 +34,7 @@
### Section.Header
-<ParamField body="Header.adornment" type="ReactNode">
+<ParamField body="Header.actions" type="ReactNode">
Content alongside the heading, such as an action button or status.
</ParamField>
@@ -43,11 +43,15 @@
</ParamField>
<ParamField body="Header.description" type="ReactNode">
- Supporting text associated with the heading. Strings support links and overflow tooltips; React nodes render as supplied.
+ Supporting text associated with the heading. Strings have optional truncation and overflow tooltips; React nodes render as supplied.
</ParamField>
-<ParamField body="Header.descriptionLineClamp" type="number" default="5">
- Maximum visible lines for a string description. Defaults to `5`. Overflowing descriptions can be read in a tooltip on hover or focus.
+<ParamField body="Header.descriptionLineClamp" type="number | false" default="5">
+ Maximum visible lines for a string description. Defaults to `5`; use `false` to display the full description without a tooltip.
+</ParamField>
+
+<ParamField body="Header.isDescriptionFocusable" type="boolean" default="false">
+ Adds a tab stop to a truncated string description so its overflow tooltip can open on focus. Defaults to `false`.
</ParamField>
<ParamField body="Header.level" type="1 | 2 | 3 | 4 | 5 | 6" default="2">
diff --git a/packages/twenty-docs/ui/components/data-display/command-block.mdx b/packages/twenty-docs/ui/components/data-display/command-block.mdx
index 6326541ca8c..93ebda25738 100644
--- a/packages/twenty-docs/ui/components/data-display/command-block.mdx
+++ b/packages/twenty-docs/ui/components/data-display/command-block.mdx
@@ -3,9 +3,10 @@ title: CommandBlock
description: Display command lines with an optional action.
---
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import CommandBlockReference from '/snippets/ui/generated/components/data-display/command-block.mdx';
-`CommandBlock` displays each supplied command with a prompt marker. It does not execute commands or provide copying automatically. Pass a [Button](/ui/primitives/input/button) as `button` to supply an action.
+`CommandBlock` displays each supplied command with a prompt marker. It does not execute commands or provide copying automatically. Supply `actions` with any React node, such as a [Button](/ui/primitives/input/button), link or status. Command text uses `pre` and `code` semantics, preserves line breaks, and wraps within the available width. Prompt markers are decorative.
```tsx
import { CommandBlock } from 'twenty-ui/components/data-display';
@@ -14,12 +15,20 @@ import { Button } from 'twenty-ui/primitives/input';
export const InstallCommand = ({ onCopy }: { onCopy: () => void }) => (
<CommandBlock
commands={['yarn add twenty-ui']}
- button={<Button onClick={onCopy}>Copy command</Button>}
+ actions={<Button onClick={onCopy}>Copy command</Button>}
/>
);
```
-The component accepts only `commands` and `button`. Additional native attributes are not forwarded.
+<StoryEmbed
+ storyId="ui-components-data-display-commandblock--documentation"
+ title="CommandBlock example"
+ height={160}
+/>
+
+Native attributes, event handlers, classes, styles and refs target the outer `div`. Use `render` to compose another root, for example `render={<section aria-label="Installation commands" />}`. `CommandBlockProps` is exported from `twenty-ui/components/data-display`.
+
+When migrating, replace `button` with `actions`.
## Props
diff --git a/packages/twenty-docs/ui/components/layout/section.mdx b/packages/twenty-docs/ui/components/layout/section.mdx
index 99d86181f5c..e268a17dddb 100644
--- a/packages/twenty-docs/ui/components/layout/section.mdx
+++ b/packages/twenty-docs/ui/components/layout/section.mdx
@@ -6,7 +6,7 @@ description: Group content with a heading, supporting description, and optional
import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
import SectionReference from '/snippets/ui/generated/components/layout/section.mdx';
-`Section.Root` groups related content. `Section.Header` combines [Heading](/ui/primitives/typography/heading) with a description and an optional `adornment`. Descriptions are ordinary text associated with the heading, so they do not add levels to the document outline.
+`Section.Root` groups related content. `Section.Header` combines [Heading](/ui/primitives/typography/heading) with a description and optional `actions` content. Descriptions are ordinary text associated with the heading, so they do not add levels to the document outline.
<StoryEmbed
storyId="ui-components-section--documentation"
@@ -26,7 +26,7 @@ export const WorkspaceSection = () => (
<Section.Header
title="Workspace settings"
description="Manage your workspace name and preferences."
- adornment={<Button>Edit workspace</Button>}
+ actions={<Button>Edit workspace</Button>}
/>
<Text>Workspace preferences appear here.</Text>
</Section.Root>
@@ -39,7 +39,9 @@ export const WorkspaceSection = () => (
## Description overflow
-String descriptions preserve line breaks, turn URLs into links, and show up to five lines. Set `descriptionLineClamp` to a positive integer to choose another limit. Hovering or focusing an overflowing description reveals its full text; Escape dismisses the tooltip.
+String descriptions show up to five lines. Set `descriptionLineClamp` to a positive integer to choose another limit, or `false` to display the full description without an overflow tooltip. Hover reveals overflowing text. Descriptions do not add a tab stop by default; set `isDescriptionFocusable` to enable focus access to the tooltip. Escape dismisses the tooltip.
+
+The heading accepts node content. Choose `level` for the document outline independently of visual `size` and `color`. Compose links and other rich content explicitly in a node description.
Pass a React node for richer supporting content. Rich descriptions render as supplied, without automatic truncation or tooltips.
@@ -47,6 +49,8 @@ Pass a React node for richer supporting content. Rich descriptions render as sup
Both parts forward native attributes, refs, class names, styles, and `render` to their outer element. For example, `Section.Root render={<section aria-label="Workspace settings" />}` provides a named section, and `Section.Header render={<header />}` uses a header container.
+When migrating, replace `adornment` with `actions`. Opt into description focus with `isDescriptionFocusable` when needed. `SectionRootProps` and `SectionHeaderProps` are exported from `twenty-ui/components/layout`.
+
## Props
<SectionReference />
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 4b554155e68..fbed16caa9f 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/TwentyUiGallery.stories.tsx
@@ -63,7 +63,7 @@ import { sliderRangeTest } from '@/__stories__/twenty-ui-gallery/utils/sliderRan
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 { commandBlockTest } from '@/__stories__/twenty-ui-gallery/utils/commandBlockTest';
import { calloutTest } from '@/__stories__/twenty-ui-gallery/utils/calloutTest';
const meta: Meta<typeof FrontComponentRenderer> = {
@@ -81,12 +81,12 @@ export default meta;
export const DataDisplayReact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-data-display-gallery',
runtime: 'react',
- play: colorSampleTest,
+ play: commandBlockTest,
});
export const DataDisplayPreact: Story = createGalleryStory({
frontComponentBundleName: 'twenty-ui-data-display-gallery',
runtime: 'preact',
- play: colorSampleTest,
+ play: commandBlockTest,
});
export const FeedbackReact: Story = createGalleryStory({
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
index 0f2968bc262..5252a51c64f 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/README.md
@@ -166,3 +166,10 @@ npx vitest run --config vitest.storybook.config.ts TwentyUiAutocomplete.stories.
npx vitest run --config vitest.storybook.config.ts TwentyUiCountrySelect.stories.tsx
npx vitest run --config vitest.storybook.config.ts TwentyUiReadingDirections.stories.tsx
```
+
+Section and CommandBlock composition is checked in the Typography and DataDisplay
+catalogs for React and Preact. The checks cover node titles/actions, heading
+levels, description line limits and optional focus, code semantics, native
+handlers, refs, and element/callback render composition. Description popup
+visibility and dismissal in the sandbox remain part of the existing portal and
+geometry acceptance work; standalone Section stories verify those behaviors.
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/command-block-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/command-block-example.tsx
new file mode 100644
index 00000000000..d037864061d
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/command-block-example.tsx
@@ -0,0 +1,51 @@
+import { createElement, useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { CommandBlock } from 'twenty-ui/components/data-display';
+import { Button } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
+
+export const CommandBlockExample = () => {
+ const [copies, setCopies] = useState(0);
+ const [clicks, setClicks] = useState(0);
+ const [renderClicks, setRenderClicks] = useState(0);
+
+ return (
+ <>
+ <CommandBlock
+ commands={['echo "<hello>"', 'npm run start']}
+ title="Application commands"
+ className="custom-commands"
+ style={{ marginTop: 7 }}
+ onClick={() => setClicks((count) => count + 1)}
+ render={(props) =>
+ createElement('section', {
+ ...props,
+ 'aria-label': 'Application commands',
+ })
+ }
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ actions={
+ <>
+ <Text render={<a href="#instructions" />}>Read instructions</Text>
+ <Button onClick={() => setCopies((count) => count + 1)}>
+ Copy commands
+ </Button>
+ </>
+ }
+ />
+ <CommandBlock
+ commands={['npm install']}
+ onClick={() => setRenderClicks((count) => count + 1)}
+ render={<div onClick={() => setClicks((count) => count + 1)} />}
+ actions={<Button>Composed action</Button>}
+ />
+ <Text aria-label="Command copies">{copies}</Text>
+ <Text aria-label="Command clicks">{clicks}</Text>
+ <Text aria-label="Command render clicks">{renderClicks}</Text>
+ </>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/section-example.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/section-example.tsx
new file mode 100644
index 00000000000..28491e55cbe
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/section-example.tsx
@@ -0,0 +1,74 @@
+import { createElement, useState } from 'react';
+import { isDefined } from 'twenty-shared/utils';
+import { Section } from 'twenty-ui/components/layout';
+import { Button } from 'twenty-ui/primitives/input';
+import { Text } from 'twenty-ui/primitives/typography';
+
+const LONG_DESCRIPTION =
+ 'Manage workspace preferences, connected accounts, notifications, members, billing, integrations, roles, and permissions for everyone in your workspace.';
+
+export const SectionExample = () => {
+ const [activations, setActivations] = useState(0);
+ const [focuses, setFocuses] = useState(0);
+
+ return (
+ <Section.Root
+ render={<section aria-label="Workspace settings" />}
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ >
+ <Section.Header
+ title={<Text render={<span />}>Workspace preferences</Text>}
+ description="Manage the settings for your workspace."
+ render={(props) =>
+ createElement('header', { ...props, title: 'Workspace header' })
+ }
+ ref={(element) => {
+ if (isDefined(element)) {
+ element.dataset.refTag = element.tagName;
+ }
+ }}
+ actions={
+ <>
+ <Text>Ready</Text>
+ <Button onClick={() => setActivations((count) => count + 1)}>
+ Edit workspace
+ </Button>
+ </>
+ }
+ />
+ <Section.Header
+ title="Truncated description"
+ level={4}
+ size="lg"
+ description={LONG_DESCRIPTION}
+ descriptionLineClamp={2}
+ style={{ maxWidth: 180 }}
+ />
+ <Section.Header
+ title="Focusable description"
+ description="Focusable workspace details"
+ descriptionLineClamp={1}
+ isDescriptionFocusable
+ onFocus={() => setFocuses((count) => count + 1)}
+ />
+ <Section.Header
+ title="Full description"
+ description={'First line of full details\nSecond line of full details'}
+ descriptionLineClamp={false}
+ isDescriptionFocusable
+ />
+ <Section.Header
+ title="Rich description"
+ description={
+ <Text render={<a href="#workspace" />}>Workspace documentation</Text>
+ }
+ />
+ <Text aria-label="Workspace edits">{activations}</Text>
+ <Text aria-label="Description focuses">{focuses}</Text>
+ </Section.Root>
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-data-display-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-data-display-gallery.front-component.tsx
index f22187d7873..e3e06233e89 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-data-display-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-data-display-gallery.front-component.tsx
@@ -1,11 +1,11 @@
import { defineFrontComponent } from 'twenty-sdk/define';
import {
AvatarGroup,
- CommandBlock,
NotificationCounter,
} from 'twenty-ui/components/data-display';
import { IconStar } from 'twenty-ui/icon';
+import { CommandBlockExample } from './command-block-example';
import { TintedIconTileExample } from './tinted-icon-tile-example';
import {
Avatar,
@@ -79,7 +79,7 @@ const DATA_DISPLAY_ENTRIES: GalleryEntry[] = [
},
{
name: 'CommandBlock',
- node: <CommandBlock commands={['npm install', 'npm run start']} />,
+ node: <CommandBlockExample />,
},
{
name: 'NotificationCounter',
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-typography-gallery.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-typography-gallery.front-component.tsx
index 79722546962..4c1acc6babe 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-typography-gallery.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-typography-gallery.front-component.tsx
@@ -1,10 +1,8 @@
-import { useState } from 'react';
import 'twenty-ui/style.css';
import { defineFrontComponent } from 'twenty-sdk/define';
-import { Section } from 'twenty-ui/components/layout';
+import { SectionExample } from './section-example';
import { TypographyCompositionExample } from './typography-composition-example';
import { VisuallyHiddenExample } from './visually-hidden-example';
-import { Button } from 'twenty-ui/primitives/input';
import {
Heading,
Text,
@@ -18,25 +16,6 @@ import {
type GalleryEntry,
} from '../shared/front-components/component-gallery';
-const SectionExample = () => {
- const [activations, setActivations] = useState(0);
-
- return (
- <Section.Root>
- <Section.Header
- title="Workspace preferences"
- description="Manage the settings for your workspace."
- adornment={
- <Button onClick={() => setActivations((count) => count + 1)}>
- Edit workspace
- </Button>
- }
- />
- <Text aria-label="Workspace edits">{activations}</Text>
- </Section.Root>
- );
-};
-
const TYPOGRAPHY_ENTRIES: GalleryEntry[] = [
{ name: 'Typography composition', node: <TypographyCompositionExample /> },
{
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/commandBlockTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/commandBlockTest.ts
new file mode 100644
index 00000000000..866d4c6b3c5
--- /dev/null
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/commandBlockTest.ts
@@ -0,0 +1,45 @@
+import { expect, userEvent, waitFor, within } from 'storybook/test';
+
+import { type TwentyUiGalleryPlayFunction } from '@/__stories__/twenty-ui-gallery/types/TwentyUiGalleryPlayFunction';
+import { colorSampleTest } from '@/__stories__/twenty-ui-gallery/utils/colorSampleTest';
+
+export const commandBlockTest: TwentyUiGalleryPlayFunction = async (
+ context,
+) => {
+ await colorSampleTest(context);
+ const canvas = within(context.canvasElement);
+ const root = canvas.getByRole('region', { name: 'Application commands' });
+ await waitFor(() =>
+ expect(root).toHaveAttribute('data-ref-tag', 'HTML-SECTION'),
+ );
+ await expect(root).toHaveClass('custom-commands');
+ await expect(root).toHaveStyle({ marginTop: '7px' });
+ const commands = within(root);
+ const code = commands.getByRole('code');
+ await expect(code.parentElement?.tagName).toBe('PRE');
+ await expect(code.textContent).toBe('> echo "<hello>"\n> npm run start');
+ await expect(
+ commands.getByRole('link', { name: 'Read instructions' }),
+ ).toHaveAttribute('href', '#instructions');
+ await userEvent.click(
+ commands.getByRole('button', { name: 'Copy commands' }),
+ );
+ await userEvent.keyboard('{Enter}');
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Command copies')).toHaveTextContent('2'),
+ );
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Command clicks')).toHaveTextContent('2'),
+ );
+ await userEvent.click(
+ canvas.getByRole('button', { name: 'Composed action' }),
+ );
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Command clicks')).toHaveTextContent('3'),
+ );
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Command render clicks')).toHaveTextContent(
+ '1',
+ ),
+ );
+};
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/typographyTest.ts b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/typographyTest.ts
index 36e01ac7510..8d3e4690043 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/typographyTest.ts
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/utils/typographyTest.ts
@@ -60,6 +60,41 @@ export const typographyTest: TwentyUiGalleryPlayFunction = async (context) => {
).toHaveTextContent('1'),
);
+ const section = canvas.getByRole('region', { name: 'Workspace settings' });
+ await waitFor(() =>
+ expect(section).toHaveAttribute('data-ref-tag', 'HTML-SECTION'),
+ );
+ const header = canvas.getByTitle('Workspace header');
+ await waitFor(() =>
+ expect(header).toHaveAttribute('data-ref-tag', 'HTML-HEADER'),
+ );
+ await expect(
+ canvas.getByRole('heading', { name: 'Truncated description', level: 4 }),
+ ).toHaveAttribute('data-size', 'lg');
+ const description = canvas.getByText(/^Manage workspace preferences,/);
+ await expect(description).not.toHaveAttribute('tabindex');
+ await expect(getComputedStyle(description).webkitLineClamp).toBe('2');
+ await expect(description.scrollHeight).toBeGreaterThan(
+ description.clientHeight,
+ );
+ const fullDescription = canvas.getByText(/First line of full details/);
+ await expect(fullDescription.textContent).toBe(
+ 'First line of full details\nSecond line of full details',
+ );
+ await expect(getComputedStyle(fullDescription).whiteSpace).toBe('pre-wrap');
+ await expect(fullDescription).not.toHaveAttribute('tabindex');
+ await expect(getComputedStyle(fullDescription).webkitLineClamp).toBe('none');
+ await expect(
+ canvas.getByRole('link', { name: 'Workspace documentation' }),
+ ).toHaveAttribute('href', '#workspace');
+ const focusableDescription = canvas.getByText('Focusable workspace details');
+ await expect(focusableDescription).toHaveAttribute('tabindex', '0');
+ focusableDescription.focus();
+ await expect(focusableDescription).toHaveFocus();
+ await waitFor(() =>
+ expect(canvas.getByLabelText('Description focuses')).toHaveTextContent('1'),
+ );
+
const button = canvas.getByRole('button', { name: 'Edit workspace' });
await userEvent.click(button);
await waitFor(() =>
diff --git a/packages/twenty-front/src/modules/log-console/components/LogConsoleDetailPanel.tsx b/packages/twenty-front/src/modules/log-console/components/LogConsoleDetailPanel.tsx
index f4611878e20..8344621345e 100644
--- a/packages/twenty-front/src/modules/log-console/components/LogConsoleDetailPanel.tsx
+++ b/packages/twenty-front/src/modules/log-console/components/LogConsoleDetailPanel.tsx
@@ -251,7 +251,7 @@ export const LogConsoleDetailPanel = () => {
<Section.Root>
<Section.Header
title={t`Message`}
- adornment={
+ actions={
<LightButton
startIcon={<IconCopy />}
onClick={() => copyToClipboard(message)}
@@ -294,7 +294,7 @@ export const LogConsoleDetailPanel = () => {
<Section.Root>
<Section.Header
title={t`Raw event`}
- adornment={
+ actions={
<LightButton
startIcon={<IconCopy />}
onClick={() =>
diff --git a/packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx b/packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx
index 5672f24997d..7e3775655c6 100644
--- a/packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx
+++ b/packages/twenty-front/src/modules/settings/admin-panel/ai/components/SettingsAdminAI.tsx
@@ -177,7 +177,7 @@ export const SettingsAdminAI = () => {
<Section.Header
title={t`Custom Providers`}
description={t`Add custom endpoints, private gateways, or additional regions.`}
- adornment={
+ actions={
<OrganizationAdornment
tooltipContent={customAiProviderTooltipContent}
/>
@@ -253,7 +253,7 @@ export const SettingsAdminAI = () => {
<Section.Header
title={t`AI Usage by Workspace`}
description={t`AI consumption across all workspaces.`}
- adornment={
+ actions={
hasEnterpriseAccess ? (
<Select
dropdownId="admin-ai-usage-period"
diff --git a/packages/twenty-front/src/modules/settings/components/SettingsTableListSection.tsx b/packages/twenty-front/src/modules/settings/components/SettingsTableListSection.tsx
index ffb8c684853..16bd44013f2 100644
--- a/packages/twenty-front/src/modules/settings/components/SettingsTableListSection.tsx
+++ b/packages/twenty-front/src/modules/settings/components/SettingsTableListSection.tsx
@@ -89,7 +89,7 @@ export const SettingsTableListSection = <
<Section.Header
title={title}
description={description}
- adornment={headerAdornment}
+ actions={headerAdornment}
/>
{isDefined(toolbar) && toolbar}
{items.length > 0 && (
diff --git a/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerSection.tsx b/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerSection.tsx
index f98b9987057..41ddaf6cb63 100644
--- a/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerSection.tsx
+++ b/packages/twenty-front/src/modules/settings/logic-functions/components/triggers/SettingsLogicFunctionTriggerSection.tsx
@@ -31,7 +31,7 @@ export const SettingsLogicFunctionTriggerSection = ({
<Section.Header
title={title}
description={description}
- adornment={
+ actions={
readonly ? undefined : (
<Switch
aria-label={title}
diff --git a/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/record-level-permissions/components/SettingsRolePermissionsObjectLevelRecordLevelSection.tsx b/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/record-level-permissions/components/SettingsRolePermissionsObjectLevelRecordLevelSection.tsx
index f0b9d60db9a..42aa0350e8b 100644
--- a/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/record-level-permissions/components/SettingsRolePermissionsObjectLevelRecordLevelSection.tsx
+++ b/packages/twenty-front/src/modules/settings/roles/role-permissions/object-level-permissions/record-level-permissions/components/SettingsRolePermissionsObjectLevelRecordLevelSection.tsx
@@ -47,7 +47,7 @@ export const SettingsRolePermissionsObjectLevelRecordLevelSection = ({
<Section.Header
title={t`Record-level`}
description={t`Ability to filter the records a user can interact with`}
- adornment={<OrganizationAdornment />}
+ actions={<OrganizationAdornment />}
/>
<StyledCardContainer>
<Card.Root rounded>
diff --git a/packages/twenty-front/src/modules/settings/security/components/SettingsSecuritySettings.tsx b/packages/twenty-front/src/modules/settings/security/components/SettingsSecuritySettings.tsx
index e9a7e8fbe52..614917352bd 100644
--- a/packages/twenty-front/src/modules/settings/security/components/SettingsSecuritySettings.tsx
+++ b/packages/twenty-front/src/modules/settings/security/components/SettingsSecuritySettings.tsx
@@ -160,7 +160,7 @@ export const SettingsSecuritySettings = () => {
<Section.Header
title={t`SSO`}
description={t`Configure an SSO connection`}
- adornment={<OrganizationAdornment />}
+ actions={<OrganizationAdornment />}
/>
{hasSsoEntitlement ? (
<SettingsSsoIdentitiesProvidersListCard />
@@ -218,7 +218,7 @@ export const SettingsSecuritySettings = () => {
<Section.Header
title={t`Audit Logs`}
description={t`Configure how long audit logs are retained`}
- adornment={<OrganizationAdornment />}
+ actions={<OrganizationAdornment />}
/>
{hasEnterpriseAccess ? (
<Card.Root rounded>
diff --git a/packages/twenty-front/src/modules/settings/usage/components/UsageBreakdownPieSection.tsx b/packages/twenty-front/src/modules/settings/usage/components/UsageBreakdownPieSection.tsx
index 3a7bedaae8a..06a86913477 100644
--- a/packages/twenty-front/src/modules/settings/usage/components/UsageBreakdownPieSection.tsx
+++ b/packages/twenty-front/src/modules/settings/usage/components/UsageBreakdownPieSection.tsx
@@ -97,7 +97,7 @@ export const UsageBreakdownPieSection = ({
<Section.Header
title={title}
description={resolvedDescription}
- adornment={
+ actions={
<Select
dropdownId={`${sectionId}-period`}
value={period}
diff --git a/packages/twenty-front/src/modules/settings/usage/components/UsageByUserTableSection.tsx b/packages/twenty-front/src/modules/settings/usage/components/UsageByUserTableSection.tsx
index ba93b045254..61650889aa4 100644
--- a/packages/twenty-front/src/modules/settings/usage/components/UsageByUserTableSection.tsx
+++ b/packages/twenty-front/src/modules/settings/usage/components/UsageByUserTableSection.tsx
@@ -80,7 +80,7 @@ export const UsageByUserTableSection = ({
<Section.Header
title={title}
description={description}
- adornment={
+ actions={
<Select
dropdownId={`${title.replace(/\s+/g, '-').toLowerCase()}-period`}
value={period}
diff --git a/packages/twenty-front/src/modules/settings/usage/components/UsageDailyChartSection.tsx b/packages/twenty-front/src/modules/settings/usage/components/UsageDailyChartSection.tsx
index bc932bf45f7..a1e1de4806f 100644
--- a/packages/twenty-front/src/modules/settings/usage/components/UsageDailyChartSection.tsx
+++ b/packages/twenty-front/src/modules/settings/usage/components/UsageDailyChartSection.tsx
@@ -76,7 +76,7 @@ export const UsageDailyChartSection = ({
<Section.Header
title={title}
description={description}
- adornment={
+ actions={
<Select
dropdownId={`${chartId}-period`}
value={period}
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 bb89e41acc3..9c4a0ee74c0 100644
--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx
+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiModel.tsx
@@ -369,7 +369,7 @@ export const SettingsAdminNewAiModel = () => {
? t`Select a known model or add a custom one`
: t`The model identifier used by the provider API`
}
- adornment={
+ actions={
<OrganizationAdornment
tooltipContent={customAiProviderTooltipContent}
/>
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 81aaa50590e..da26eae970a 100644
--- a/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx
+++ b/packages/twenty-front/src/pages/settings/admin-panel/SettingsAdminNewAiProvider.tsx
@@ -290,7 +290,7 @@ export const SettingsAdminNewAiProvider = () => {
<Section.Header
title={t`Provider`}
description={t`Select a known provider or create a custom one`}
- adornment={
+ actions={
<OrganizationAdornment
tooltipContent={customAiProviderTooltipContent}
/>
diff --git a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiUsageTab.tsx b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiUsageTab.tsx
index 8ddd65f025c..12f5df81617 100644
--- a/packages/twenty-front/src/pages/settings/ai/components/SettingsAiUsageTab.tsx
+++ b/packages/twenty-front/src/pages/settings/ai/components/SettingsAiUsageTab.tsx
@@ -40,7 +40,7 @@ export const SettingsAiUsageTab = () => {
<Section.Header
title={t`AI Usage`}
description={t`Track AI consumption across your workspace.`}
- adornment={<OrganizationAdornment />}
+ actions={<OrganizationAdornment />}
/>
<SettingsEnterpriseFeatureGateCard
title={t`Organization feature`}
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 9913ea4d3d4..5c6a2a3cdfd 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationConnectionsSection.tsx
@@ -66,7 +66,7 @@ export const SettingsApplicationConnectionsSection = ({
<Section.Header
title={provider.displayName}
description={t`Manage connections used by this app to call ${provider.displayName}.`}
- adornment={
+ actions={
isNonEmptyString(provider.logoUrl) ? (
<Avatar
shape="square"
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationDistributionTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationDistributionTab.tsx
index 5a45e6edc59..96c59ee911a 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationDistributionTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationRegistrationDistributionTab.tsx
@@ -61,7 +61,7 @@ export const SettingsApplicationRegistrationDistributionTab = ({
{isTarballSource && (
<CommandBlock
commands={publishCommands}
- button={
+ actions={
<Button
onClick={() => {
copyToClipboard(
diff --git a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsDeveloperTab.tsx b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsDeveloperTab.tsx
index 6745c04a069..9ca7eaac529 100644
--- a/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsDeveloperTab.tsx
+++ b/packages/twenty-front/src/pages/settings/applications/tabs/SettingsApplicationsDeveloperTab.tsx
@@ -99,7 +99,7 @@ export const SettingsApplicationsDeveloperTab = () => {
title={t`Create an application`}
description={t`You can either create a private app or share it to others`}
/>
- <CommandBlock commands={createCommands} button={createCopyButton} />
+ <CommandBlock commands={createCommands} actions={createCopyButton} />
<StyledButtonContainer>
<Button
startIcon={<IconArrowUpRight />}
diff --git a/packages/twenty-ui/docs/commandBlockPropDescriptions.ts b/packages/twenty-ui/docs/commandBlockPropDescriptions.ts
index c6285d4a3f0..367c9a7db4f 100644
--- a/packages/twenty-ui/docs/commandBlockPropDescriptions.ts
+++ b/packages/twenty-ui/docs/commandBlockPropDescriptions.ts
@@ -5,6 +5,6 @@ import { type CommandBlock } from '../src/components/data-display/CommandBlock/C
export const COMMAND_BLOCK_PROP_DESCRIPTIONS = {
commands:
'Command lines to display. The component prefixes each line with > and does not execute commands.',
- button:
- 'Optional action element beside the command lines, such as a copy button.',
+ actions:
+ 'Content beside the command lines, such as a copy button, link or status.',
} satisfies Partial<Record<keyof ComponentProps<typeof CommandBlock>, string>>;
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index 8dc58a71c92..dc005a3b7bb 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -45,6 +45,7 @@
},
"types": {
"AvatarGroupProps": "components/data-display/AvatarGroup/types/AvatarGroupProps",
+ "CommandBlockProps": "components/data-display/CommandBlock/types/CommandBlockProps",
"GetJsonNodeHighlighting": "components/data-display/JsonTree/types/GetJsonNodeHighlighting",
"IconTileColorShades": "components/data-display/TintedIconTile/utils/getIconTileColorShades",
"JsonNodeHighlighting": "components/data-display/JsonTree/types/JsonNodeHighlighting",
diff --git a/packages/twenty-ui/docs/sectionHeaderPropDescriptions.ts b/packages/twenty-ui/docs/sectionHeaderPropDescriptions.ts
index 90f3fad08e0..185499f0c47 100644
--- a/packages/twenty-ui/docs/sectionHeaderPropDescriptions.ts
+++ b/packages/twenty-ui/docs/sectionHeaderPropDescriptions.ts
@@ -5,9 +5,10 @@ export const SECTION_HEADER_PROP_DESCRIPTIONS = {
...HEADING_PROP_DESCRIPTIONS,
title: 'Content of the section heading.',
description:
- 'Supporting text associated with the heading. Strings support links and overflow tooltips; React nodes render as supplied.',
- adornment:
- 'Content alongside the heading, such as an action button or status.',
+ 'Supporting text associated with the heading. Strings have optional truncation and overflow tooltips; React nodes render as supplied.',
+ actions: 'Content alongside the heading, such as an action button or status.',
descriptionLineClamp:
- 'Maximum visible lines for a string description. Defaults to `5`. Overflowing descriptions can be read in a tooltip on hover or focus.',
+ 'Maximum visible lines for a string description. Defaults to `5`; use `false` to display the full description without a tooltip.',
+ isDescriptionFocusable:
+ 'Adds a tab stop to a truncated string description so its overflow tooltip can open on focus. Defaults to `false`.',
} satisfies Partial<Record<keyof SectionHeaderProps, string>>;
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index e9a7852dc64..8e6c1d1d626 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -9788,7 +9788,7 @@
"name": "Header",
"props": [
{
- "name": "adornment",
+ "name": "actions",
"type": "ReactNode",
"required": false,
"defaultValue": null,
@@ -9806,14 +9806,21 @@
"type": "ReactNode",
"required": false,
"defaultValue": null,
- "description": "Supporting text associated with the heading. Strings support links and overflow tooltips; React nodes render as supplied."
+ "description": "Supporting text associated with the heading. Strings have optional truncation and overflow tooltips; React nodes render as supplied."
},
{
"name": "descriptionLineClamp",
- "type": "number",
+ "type": "number | false",
"required": false,
"defaultValue": "5",
- "description": "Maximum visible lines for a string description. Defaults to `5`. Overflowing descriptions can be read in a tooltip on hover or focus."
+ "description": "Maximum visible lines for a string description. Defaults to `5`; use `false` to display the full description without a tooltip."
+ },
+ {
+ "name": "isDescriptionFocusable",
+ "type": "boolean",
+ "required": false,
+ "defaultValue": "false",
+ "description": "Adds a tab stop to a truncated string description so its overflow tooltip can open on focus. Defaults to `false`."
},
{
"name": "level",
@@ -10161,18 +10168,25 @@
"slug": "components/data-display/command-block",
"props": [
{
- "name": "button",
- "type": "ReactElement<unknown, string | JSXElementConstructor<any>>",
+ "name": "actions",
+ "type": "ReactNode",
"required": false,
"defaultValue": null,
- "description": "Optional action element beside the command lines, such as a copy button."
+ "description": "Content beside the command lines, such as a copy button, link or status."
},
{
"name": "commands",
- "type": "string[]",
+ "type": "readonly string[]",
"required": true,
"defaultValue": null,
"description": "Command lines to display. The component prefixes each line with > and does not execute commands."
+ },
+ {
+ "name": "render",
+ "type": "ReactElement<unknown, string | JSXElementConstructor<any>> | ComponentRenderFn<HTMLProps, {}>",
+ "required": false,
+ "defaultValue": null,
+ "description": "Allows you to replace the component's HTML element\nwith a different tag, or compose it with another component.\n\nAccepts a `ReactElement` or a function that returns the element to render."
}
]
},
diff --git a/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.module.scss b/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.module.scss
index d5012c943d8..93491cc040a 100644
--- a/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.module.scss
+++ b/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.module.scss
@@ -1,26 +1,35 @@
.container {
- border-radius: var(--t-border-radius-sm);
- border: 1px solid var(--t-border-color-medium);
+ align-items: center;
background: var(--t-background-secondary);
+ border: 1px solid var(--t-border-color-medium);
+ border-radius: var(--t-border-radius-sm);
display: flex;
- align-items: center;
+ gap: var(--t-spacing-3);
justify-content: space-between;
+ min-inline-size: 0;
padding: var(--t-spacing-3);
- gap: var(--t-spacing-3);
}
-.commandContain {
+.commands {
+ color: var(--t-font-color-primary);
font-family: var(--t-code-font-family);
+ margin: 0;
+ min-inline-size: 0;
+ overflow-wrap: anywhere;
+ white-space: pre-wrap;
+
+ code {
+ font: inherit;
+ }
}
-.buttonContainer {
+.actions {
+ align-items: center;
display: flex;
+ flex-shrink: 0;
+ gap: var(--t-spacing-2);
}
-.lineStartSpan {
+.prompt {
color: var(--t-code-text-orange);
}
-
-.lineSpan {
- color: var(--t-code-text-green);
-}
diff --git a/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.module.scss.d.ts b/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.module.scss.d.ts
index 155a1a29969..06b6d63e706 100644
--- a/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.module.scss.d.ts
+++ b/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.module.scss.d.ts
@@ -1,8 +1,7 @@
declare const classNames: {
readonly container: 'container';
- readonly commandContain: 'commandContain';
- readonly buttonContainer: 'buttonContainer';
- readonly lineStartSpan: 'lineStartSpan';
- readonly lineSpan: 'lineSpan';
+ readonly commands: 'commands';
+ readonly actions: 'actions';
+ readonly prompt: 'prompt';
};
export default classNames;
diff --git a/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.tsx b/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.tsx
index 3de3f0df4bd..0e9f9225ac8 100644
--- a/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.tsx
+++ b/packages/twenty-ui/src/components/data-display/CommandBlock/CommandBlock.tsx
@@ -1,26 +1,45 @@
-import { type ReactElement } from 'react';
+import { useRender } from '@base-ui/react/use-render';
+import { clsx } from 'clsx';
-import styles from './CommandBlock.module.scss';
+import { isDefined } from '@ui/utilities/utils/isDefined';
+
+import { type CommandBlockProps } from './types/CommandBlockProps';
-type CommandBlockProps = {
- commands: string[];
- button?: ReactElement;
-};
+import styles from './CommandBlock.module.scss';
-export const CommandBlock = ({ commands, button }: CommandBlockProps) => {
- return (
- <div className={styles.container}>
- <div className={styles.commandContain}>
+export const CommandBlock = ({
+ commands,
+ actions,
+ render,
+ ref,
+ className,
+ ...props
+}: CommandBlockProps) =>
+ useRender({
+ render,
+ ref,
+ props: {
+ ...props,
+ className: clsx(styles.container, className),
+ children: (
<>
- {commands.map((line, i) => (
- <div key={i}>
- <span className={styles.lineStartSpan}>{'> '}</span>
- <span className={styles.lineSpan}>{line}</span>
- </div>
- ))}
+ <pre className={styles.commands}>
+ <code>
+ {commands.map((line, index) => (
+ <span key={index}>
+ {index > 0 && '\n'}
+ <span className={styles.prompt} aria-hidden="true">
+ {'> '}
+ </span>
+ {line}
+ </span>
+ ))}
+ </code>
+ </pre>
+ {isDefined(actions) && (
+ <div className={styles.actions}>{actions}</div>
+ )}
</>
- </div>
- {button && <div className={styles.buttonContainer}>{button}</div>}
- </div>
- );
-};
+ ),
+ },
+ });
diff --git a/packages/twenty-ui/src/components/data-display/CommandBlock/__stories__/CommandBlock.stories.tsx b/packages/twenty-ui/src/components/data-display/CommandBlock/__stories__/CommandBlock.stories.tsx
new file mode 100644
index 00000000000..55430d79568
--- /dev/null
+++ b/packages/twenty-ui/src/components/data-display/CommandBlock/__stories__/CommandBlock.stories.tsx
@@ -0,0 +1,101 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, fn, userEvent, within } from 'storybook/test';
+
+import { Button } from '@ui/primitives/input/Button/Button';
+import { Text } from '@ui/primitives/typography/Text/Text';
+import { ComponentDecorator } from '@ui/testing';
+
+import { CommandBlock } from '../CommandBlock';
+
+const meta: Meta<typeof CommandBlock> = {
+ title: 'UI/Components/Data Display/CommandBlock',
+ component: CommandBlock,
+ decorators: [ComponentDecorator],
+ args: { commands: ['yarn add twenty-ui', 'yarn start'] },
+};
+
+export default meta;
+
+type Story = StoryObj<typeof CommandBlock>;
+
+export const Default: Story = {
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(canvas.getByRole('code').textContent).toBe(
+ '> yarn add twenty-ui\n> yarn start',
+ );
+ await expect(canvas.queryByRole('button')).not.toBeInTheDocument();
+ },
+};
+
+export const Documentation: Story = {
+ args: {
+ actions: (
+ <>
+ <Text>Ready to install</Text>
+ <Button>Copy commands</Button>
+ </>
+ ),
+ },
+};
+
+const handleCopy = fn();
+const handleRootFocus = fn();
+const handleRenderFocus = fn();
+
+export const Composition: Story = {
+ args: {
+ commands: ['echo "<hello>"', 'yarn start'],
+ actions: (
+ <>
+ <Text
+ render={<a href="#documentation" aria-label="Read instructions" />}
+ >
+ Read instructions
+ </Text>
+ <Button onClick={handleCopy}>Copy commands</Button>
+ </>
+ ),
+ onFocus: handleRootFocus,
+ render: <section aria-label="Installation" onFocus={handleRenderFocus} />,
+ ref: (element) => {
+ element?.setAttribute('data-ref-target', 'commands');
+ },
+ },
+ play: async ({ canvasElement }) => {
+ handleCopy.mockClear();
+ handleRootFocus.mockClear();
+ handleRenderFocus.mockClear();
+ const canvas = within(canvasElement);
+ const root = canvas.getByRole('region', { name: 'Installation' });
+ await expect(root).toHaveAttribute('data-ref-target', 'commands');
+ const code = canvas.getByRole('code');
+ await expect(code.parentElement?.tagName).toBe('PRE');
+ await expect(code.textContent).toBe('> echo "<hello>"\n> yarn start');
+ await userEvent.tab();
+ await expect(
+ canvas.getByRole('link', { name: 'Read instructions' }),
+ ).toHaveFocus();
+ await userEvent.tab();
+ await userEvent.keyboard('{Enter}');
+ await expect(handleCopy).toHaveBeenCalledTimes(1);
+ await expect(handleRootFocus).toHaveBeenCalledTimes(2);
+ await expect(handleRenderFocus).toHaveBeenCalledTimes(2);
+ },
+};
+
+export const LongCommand: Story = {
+ args: {
+ commands: [
+ 'yarn add twenty-ui --registry=https://registry.npmjs.org --network-timeout=120000',
+ ],
+ actions: <Button>Copy</Button>,
+ },
+ parameters: { container: { width: 260 } },
+ play: async ({ canvasElement }) => {
+ const root = within(canvasElement)
+ .getByRole('code')
+ .closest('pre')?.parentElement;
+ await expect(root?.scrollWidth).toBe(root?.clientWidth);
+ },
+};
diff --git a/packages/twenty-ui/src/components/data-display/CommandBlock/__tests__/CommandBlock.test.tsx b/packages/twenty-ui/src/components/data-display/CommandBlock/__tests__/CommandBlock.test.tsx
new file mode 100644
index 00000000000..ea1f7d7f95e
--- /dev/null
+++ b/packages/twenty-ui/src/components/data-display/CommandBlock/__tests__/CommandBlock.test.tsx
@@ -0,0 +1,60 @@
+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 { CommandBlock } from '../CommandBlock';
+import styles from '../CommandBlock.module.scss';
+
+runComponentConformance({
+ name: 'CommandBlock',
+ element: <CommandBlock commands={['yarn add twenty-ui']} />,
+ ownClassName: styles.container,
+ refInstanceOf: HTMLDivElement,
+ renderPropTagName: 'section',
+});
+
+describe('CommandBlock', () => {
+ it('displays literal command text with code semantics and preserved line breaks', () => {
+ render(<CommandBlock commands={['echo "<hello>"', 'yarn start']} />);
+ const code = screen.getByRole('code');
+ expect(code.parentElement?.tagName).toBe('PRE');
+ expect(code.textContent).toBe('> echo "<hello>"\n> yarn start');
+ expect(screen.queryByRole('button')).not.toBeInTheDocument();
+ });
+
+ it('composes action content and both root and render handlers', async () => {
+ const user = userEvent.setup();
+ const onFocus = vi.fn();
+ const onRenderFocus = vi.fn();
+ const onAction = vi.fn();
+ render(
+ <CommandBlock
+ commands={['yarn start']}
+ onFocus={onFocus}
+ render={
+ <section aria-label="Start application" onFocus={onRenderFocus} />
+ }
+ actions={
+ <>
+ <a href="#documentation">Read instructions</a>
+ <button onClick={onAction}>Copy</button>
+ <span>Ready</span>
+ </>
+ }
+ />,
+ );
+ expect(
+ screen.getByRole('region', { name: 'Start application' }),
+ ).toHaveTextContent('Ready');
+ await user.tab();
+ expect(
+ screen.getByRole('link', { name: 'Read instructions' }),
+ ).toHaveFocus();
+ await user.tab();
+ await user.keyboard('{Enter}');
+ expect(onAction).toHaveBeenCalledTimes(1);
+ expect(onFocus).toHaveBeenCalledTimes(2);
+ expect(onRenderFocus).toHaveBeenCalledTimes(2);
+ });
+});
diff --git a/packages/twenty-ui/src/components/data-display/CommandBlock/types/CommandBlockProps.ts b/packages/twenty-ui/src/components/data-display/CommandBlock/types/CommandBlockProps.ts
new file mode 100644
index 00000000000..8b3448eca06
--- /dev/null
+++ b/packages/twenty-ui/src/components/data-display/CommandBlock/types/CommandBlockProps.ts
@@ -0,0 +1,10 @@
+import { type useRender } from '@base-ui/react/use-render';
+import { type ReactNode } from 'react';
+
+export type CommandBlockProps = Omit<
+ useRender.ComponentProps<'div'>,
+ 'children'
+> & {
+ commands: readonly string[];
+ actions?: ReactNode;
+};
diff --git a/packages/twenty-ui/src/components/data-display/index.ts b/packages/twenty-ui/src/components/data-display/index.ts
index befec9449f0..40fd2c50b1b 100644
--- a/packages/twenty-ui/src/components/data-display/index.ts
+++ b/packages/twenty-ui/src/components/data-display/index.ts
@@ -10,6 +10,7 @@
export { AvatarGroup } from './AvatarGroup/AvatarGroup';
export type { AvatarGroupProps } from './AvatarGroup/types/AvatarGroupProps';
export { CommandBlock } from './CommandBlock/CommandBlock';
+export type { CommandBlockProps } from './CommandBlock/types/CommandBlockProps';
export { JsonTree } from './JsonTree/JsonTree';
export type { GetJsonNodeHighlighting } from './JsonTree/types/GetJsonNodeHighlighting';
export type { JsonNodeHighlighting } from './JsonTree/types/JsonNodeHighlighting';
diff --git a/packages/twenty-ui/src/components/layout/Section/SectionHeader.module.scss b/packages/twenty-ui/src/components/layout/Section/SectionHeader.module.scss
index 130af563116..9df004d29ed 100644
--- a/packages/twenty-ui/src/components/layout/Section/SectionHeader.module.scss
+++ b/packages/twenty-ui/src/components/layout/Section/SectionHeader.module.scss
@@ -18,7 +18,7 @@
min-inline-size: 0;
}
-.adornment {
+.actions {
align-items: center;
display: flex;
flex-shrink: 0;
diff --git a/packages/twenty-ui/src/components/layout/Section/SectionHeader.module.scss.d.ts b/packages/twenty-ui/src/components/layout/Section/SectionHeader.module.scss.d.ts
index a5567a6cbb5..c0a5e39e8ec 100644
--- a/packages/twenty-ui/src/components/layout/Section/SectionHeader.module.scss.d.ts
+++ b/packages/twenty-ui/src/components/layout/Section/SectionHeader.module.scss.d.ts
@@ -2,7 +2,7 @@ declare const styles: {
readonly header: string;
readonly titleRow: string;
readonly title: string;
- readonly adornment: string;
+ readonly actions: string;
readonly description: string;
};
export default styles;
diff --git a/packages/twenty-ui/src/components/layout/Section/__stories__/Section.stories.tsx b/packages/twenty-ui/src/components/layout/Section/__stories__/Section.stories.tsx
index 08b10ee6387..3ab4aeb36c4 100644
--- a/packages/twenty-ui/src/components/layout/Section/__stories__/Section.stories.tsx
+++ b/packages/twenty-ui/src/components/layout/Section/__stories__/Section.stories.tsx
@@ -1,11 +1,14 @@
import { Section } from '@ui/components/layout/Section/Section';
import { type Meta, type StoryObj } from '@storybook/react-vite';
-import { expect, fn, userEvent, within } from 'storybook/test';
+import { expect, fn, userEvent, waitFor, within } from 'storybook/test';
import { Button } from '@ui/primitives/input/Button/Button';
import { Text } from '@ui/primitives/typography/Text/Text';
import { ComponentDecorator } from '@ui/testing';
+const LONG_DESCRIPTION =
+ 'Manage your workspace name, members, preferences, connected accounts, and notification settings. These settings apply to everyone in your workspace.';
+
const meta: Meta<typeof Section.Header> = {
id: 'ui-components-section',
title: 'UI/Components/Layout/Section',
@@ -68,11 +71,11 @@ export const SecondaryColor: Story = {
const handleEdit = fn();
-export const WithAdornment: Story = {
+export const WithActions: Story = {
...WithDescription,
args: {
...WithDescription.args,
- adornment: <Button onClick={handleEdit}>Edit workspace</Button>,
+ actions: <Button onClick={handleEdit}>Edit workspace</Button>,
},
play: async ({ canvasElement }) => {
const button = within(canvasElement).getByRole('button', {
@@ -91,9 +94,9 @@ export const WithAdornment: Story = {
export const LongDescription: Story = {
...Default,
args: {
- description:
- 'Manage your workspace name, members, preferences, connected accounts, and notification settings. These settings apply to everyone in your workspace.',
+ description: LONG_DESCRIPTION,
descriptionLineClamp: 2,
+ isDescriptionFocusable: true,
},
parameters: { container: { width: 240 } },
play: async ({ canvasElement }) => {
@@ -112,6 +115,11 @@ export const LongDescription: Story = {
'These settings apply to everyone in your workspace.',
);
await userEvent.keyboard('{Escape}');
+ await waitFor(() =>
+ expect(
+ within(document.body).queryByRole('tooltip'),
+ ).not.toBeInTheDocument(),
+ );
},
};
@@ -138,3 +146,54 @@ export const CatalogDark: Story = {
tags: ['!autodocs'],
globals: { colorScheme: 'dark' },
};
+
+export const DefaultDescriptionFocus: Story = {
+ ...Default,
+ args: {
+ title: <Text render={<span />}>Workspace details</Text>,
+ level: 4,
+ size: 'lg',
+ description: LONG_DESCRIPTION,
+ descriptionLineClamp: 2,
+ actions: <Button>Edit details</Button>,
+ },
+ parameters: LongDescription.parameters,
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const heading = canvas.getByRole('heading', {
+ level: 4,
+ name: 'Workspace details',
+ });
+ await expect(heading).toHaveAttribute('data-size', 'lg');
+ const description = canvas.getByText(LONG_DESCRIPTION);
+ await expect(description).not.toHaveAttribute('tabindex');
+ await userEvent.tab();
+ await expect(
+ canvas.getByRole('button', { name: 'Edit details' }),
+ ).toHaveFocus();
+ await userEvent.hover(description);
+ const body = within(canvasElement.ownerDocument.body);
+ await expect(await body.findByRole('tooltip')).toHaveTextContent(
+ description.textContent ?? '',
+ );
+ await userEvent.unhover(description);
+ await waitFor(() =>
+ expect(body.queryByRole('tooltip')).not.toBeInTheDocument(),
+ );
+ },
+};
+
+export const FullDescription: Story = {
+ ...Default,
+ args: {
+ description: LONG_DESCRIPTION,
+ descriptionLineClamp: false,
+ },
+ parameters: LongDescription.parameters,
+ play: async ({ canvasElement }) => {
+ const description = within(canvasElement).getByText(LONG_DESCRIPTION);
+ await expect(getComputedStyle(description).webkitLineClamp).toBe('none');
+ await expect(description.scrollHeight).toBe(description.clientHeight);
+ await expect(description).not.toHaveAttribute('tabindex');
+ },
+};
diff --git a/packages/twenty-ui/src/components/layout/Section/__tests__/SectionHeader.test.tsx b/packages/twenty-ui/src/components/layout/Section/__tests__/SectionHeader.test.tsx
index d2a7a2c18a0..ea68d22f89c 100644
--- a/packages/twenty-ui/src/components/layout/Section/__tests__/SectionHeader.test.tsx
+++ b/packages/twenty-ui/src/components/layout/Section/__tests__/SectionHeader.test.tsx
@@ -1,6 +1,7 @@
import { Section } from '@ui/components/layout/Section/Section';
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
+import userEvent from '@testing-library/user-event';
import { runComponentConformance } from '@test-utilities/conformance/runComponentConformance';
@@ -57,3 +58,46 @@ describe('Section.Header', () => {
expect(screen.queryByText('your team')).not.toBeInTheDocument();
});
});
+
+describe('Section description composition', () => {
+ it('keeps string descriptions out of the tab order unless focus is requested', async () => {
+ const user = userEvent.setup();
+ const { rerender } = render(
+ <Section.Header
+ title={<span>Workspace</span>}
+ description="Details"
+ actions={<button>Edit</button>}
+ />,
+ );
+ expect(screen.getByText('Details')).not.toHaveAttribute('tabindex');
+ await user.tab();
+ expect(screen.getByRole('button', { name: 'Edit' })).toHaveFocus();
+ rerender(
+ <Section.Header
+ title="Workspace"
+ description="Details"
+ isDescriptionFocusable
+ />,
+ );
+ await user.tab();
+ expect(screen.getByText('Details')).toHaveFocus();
+ });
+
+ it('renders full string descriptions without a tooltip or a tab stop when truncation is disabled', () => {
+ render(
+ <Section.Header
+ title="Workspace"
+ description={'First line\nSecond line'}
+ descriptionLineClamp={false}
+ isDescriptionFocusable
+ />,
+ );
+ const description = screen.getByText(/First line/);
+ expect(description).toHaveStyle({ whiteSpace: 'pre-wrap' });
+ expect(description).not.toHaveAttribute('tabindex');
+ expect(description).not.toHaveAttribute('data-content-overflowing');
+ expect(screen.getByRole('heading')).toHaveAccessibleDescription(
+ 'First line\nSecond line',
+ );
+ });
+});
diff --git a/packages/twenty-ui/src/components/layout/Section/internal/SectionHeader.tsx b/packages/twenty-ui/src/components/layout/Section/internal/SectionHeader.tsx
index d1ac616ab7c..8cfa8f21e2c 100644
--- a/packages/twenty-ui/src/components/layout/Section/internal/SectionHeader.tsx
+++ b/packages/twenty-ui/src/components/layout/Section/internal/SectionHeader.tsx
@@ -3,6 +3,7 @@ import { isNonEmptyString, isString } from '@sniptt/guards';
import { clsx } from 'clsx';
import { useId } from 'react';
+import { Text } from '@ui/primitives/typography/Text/Text';
import { Heading } from '@ui/primitives/typography/Heading/Heading';
import { OverflowingTextWithTooltip } from '@ui/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
import { isDefined } from '@ui/utilities/utils/isDefined';
@@ -14,11 +15,12 @@ import styles from '../SectionHeader.module.scss';
export const SectionHeader = ({
title,
description,
- adornment,
+ actions,
level = 2,
size = 'md',
color = 'primary',
descriptionLineClamp = 5,
+ isDescriptionFocusable = false,
render,
ref,
className,
@@ -29,6 +31,14 @@ export const SectionHeader = ({
? isNonEmptyString(description)
: isDefined(description) && description !== false;
+ const shouldTruncateDescription =
+ isString(description) && descriptionLineClamp !== false;
+ const descriptionContent = isString(description) ? (
+ <Text style={{ whiteSpace: 'pre-wrap' }}>{description}</Text>
+ ) : (
+ description
+ );
+
return useRender({
render,
ref,
@@ -47,21 +57,21 @@ export const SectionHeader = ({
>
{title}
</Heading>
- {isDefined(adornment) && (
- <div className={styles.adornment}>{adornment}</div>
+ {isDefined(actions) && (
+ <div className={styles.actions}>{actions}</div>
)}
</div>
{hasDescription && (
<div id={descriptionId} className={styles.description}>
- {isString(description) ? (
+ {shouldTruncateDescription ? (
<OverflowingTextWithTooltip
text={description}
lineClamp={descriptionLineClamp}
isTooltipMultiline
- isFocusable
+ isFocusable={isDescriptionFocusable}
/>
) : (
- description
+ descriptionContent
)}
</div>
)}
diff --git a/packages/twenty-ui/src/components/layout/Section/types/SectionHeaderProps.ts b/packages/twenty-ui/src/components/layout/Section/types/SectionHeaderProps.ts
index f749f9bdc0e..1c22ad7bb4f 100644
--- a/packages/twenty-ui/src/components/layout/Section/types/SectionHeaderProps.ts
+++ b/packages/twenty-ui/src/components/layout/Section/types/SectionHeaderProps.ts
@@ -10,6 +10,7 @@ export type SectionHeaderProps = Omit<
Pick<HeadingProps, 'level' | 'size' | 'color'> & {
title: ReactNode;
description?: ReactNode;
- adornment?: ReactNode;
- descriptionLineClamp?: number;
+ actions?: ReactNode;
+ descriptionLineClamp?: number | false;
+ isDescriptionFocusable?: boolean;
};
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.picker.stories.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.picker.stories.tsx
index ea97a04281e..289f15e117b 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.picker.stories.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/__stories__/Dropdown.picker.stories.tsx
@@ -613,6 +613,7 @@ export const OptionWithTrailingAction: Story = {
const option = await body.findByRole('button', {
name: 'Overview',
});
+ await waitFor(() => expect(body.getByRole('dialog')).toBeVisible());
const action = body.getByRole('button', { name: 'Edit overview' });
expect(option.tagName).toBe('DIV');