Skip to content

The open alternative to Salesforce, designed for AI.

Unify shortcut formatting and presentation (#26973)

Raphaël Bosi9f228de882bc
diff --git a/packages/twenty-companion/src/renderer/components/ShortcutSetting.tsx b/packages/twenty-companion/src/renderer/components/ShortcutSetting.tsx
index 01717e48fe4..2b4e7a31a2b 100644
--- a/packages/twenty-companion/src/renderer/components/ShortcutSetting.tsx
+++ b/packages/twenty-companion/src/renderer/components/ShortcutSetting.tsx
@@ -1,6 +1,6 @@
import { DEFAULT_SETTINGS } from '../../shared/constants/DEFAULT_SETTINGS';
import { shortcutFromKeyboardEvent } from '../utils/shortcutFromKeyboardEvent';
-import { formatShortcut } from '../utils/formatShortcut';
+import { formatShortcut } from '@ui/primitives/typography/Shortcut/formatShortcut';
import { i18n } from '@lingui/core';
import { SettingsCardContent } from './SettingsCardContent';
import { THEME_COMMON } from '@ui/theme/constants/ThemeCommon';
@@ -74,10 +74,10 @@ export const ShortcutSetting = ({ state, isPending, command }: ActionProps) => {
>
{capturing
? i18n._('Press shortcut…')
- : formatShortcut(
- state.settings.openShortcut,
- navigator.platform.startsWith('Mac'),
- )}
+ : formatShortcut({
+ shortcut: state.settings.openShortcut.split('+'),
+ combinationSeparator: ' + ',
+ })}
</Button>
</div>
</div>
diff --git a/packages/twenty-companion/src/renderer/utils/__tests__/shortcut.test.ts b/packages/twenty-companion/src/renderer/utils/__tests__/shortcut.test.ts
index 735276ab55e..8814648ace8 100644
--- a/packages/twenty-companion/src/renderer/utils/__tests__/shortcut.test.ts
+++ b/packages/twenty-companion/src/renderer/utils/__tests__/shortcut.test.ts
@@ -1,7 +1,5 @@
import { describe, expect, it } from 'vitest';
import { shortcutFromKeyboardEvent } from '../shortcutFromKeyboardEvent';
-import { formatShortcut } from '../formatShortcut';
-import { DEFAULT_SETTINGS } from '../../../shared/constants/DEFAULT_SETTINGS';
const key = {
key: 'a',
@@ -40,14 +38,3 @@ describe('shortcut capture', () => {
expect(shortcutFromKeyboardEvent(event)).toBeNull();
});
});
-
-it('formats the shared default for macOS and other platforms', () => {
- expect(formatShortcut(DEFAULT_SETTINGS.openShortcut, true)).toBe(
- '⌘ + Shift + Space',
- );
- expect(formatShortcut(DEFAULT_SETTINGS.openShortcut, false)).toBe(
- 'Ctrl + Shift + Space',
- );
- expect(formatShortcut('Control+Alt+7', true)).toBe('Ctrl + ⌥ + 7');
- expect(formatShortcut('Control+Alt+7', false)).toBe('Ctrl + Alt + 7');
-});
diff --git a/packages/twenty-companion/src/renderer/utils/formatShortcut.ts b/packages/twenty-companion/src/renderer/utils/formatShortcut.ts
deleted file mode 100644
index 6b5f0434fb9..00000000000
--- a/packages/twenty-companion/src/renderer/utils/formatShortcut.ts
+++ /dev/null
@@ -1,12 +0,0 @@
-export const formatShortcut = (shortcut: string, isMac: boolean): string => {
- const modifiers: Record<string, string> = {
- CommandOrControl: isMac ? '⌘' : 'Ctrl',
- Command: '⌘',
- Control: 'Ctrl',
- Alt: isMac ? '⌥' : 'Alt',
- };
- return shortcut
- .split('+')
- .map((key) => modifiers[key] ?? key)
- .join(' + ');
-};
diff --git a/packages/twenty-docs/docs.json b/packages/twenty-docs/docs.json
index c9b638dd325..bee453491ba 100644
--- a/packages/twenty-docs/docs.json
+++ b/packages/twenty-docs/docs.json
@@ -609,6 +609,7 @@
"pages": [
"ui/primitives/typography/heading",
"ui/primitives/typography/text",
+ "ui/primitives/typography/shortcut",
"ui/primitives/typography/overflowing-text-with-tooltip"
]
}
diff --git a/packages/twenty-docs/navigation/base-structure.json b/packages/twenty-docs/navigation/base-structure.json
index 4987449f15b..398e234d1cb 100644
--- a/packages/twenty-docs/navigation/base-structure.json
+++ b/packages/twenty-docs/navigation/base-structure.json
@@ -626,6 +626,7 @@
"pages": [
"ui/primitives/typography/heading",
"ui/primitives/typography/text",
+ "ui/primitives/typography/shortcut",
"ui/primitives/typography/overflowing-text-with-tooltip"
]
}
diff --git a/packages/twenty-docs/snippets/ui/generated/components/dropdown.mdx b/packages/twenty-docs/snippets/ui/generated/components/dropdown.mdx
index 1696c629fc6..3aef91befcf 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/dropdown.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/dropdown.mdx
@@ -214,15 +214,6 @@
Shows a chevron indicating that the item opens a submenu.
</ParamField>
-<ParamField body="ActionItem.hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="ActionItem.hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="ActionItem.nativeButton" type="boolean" default="true when render is omitted; false otherwise">
Whether the component renders a native `<button>` element when replacing it
via the `render` prop.
@@ -237,6 +228,15 @@
Element rendered as the row instead of a native button. Custom components must forward the supplied props and ref.
</ParamField>
+<ParamField body="ActionItem.shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="ActionItem.shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="ActionItem.startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
@@ -280,15 +280,6 @@
Shows a chevron indicating that the item opens a submenu.
</ParamField>
-<ParamField body="OptionItem.hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="OptionItem.hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="OptionItem.indicator" type="&quot;check&quot; | &quot;checkbox&quot; | &quot;none&quot;">
Selection indicator: a check icon after the content, a checkbox before it, or none. Defaults to `checkbox` when `multiple` is set, otherwise `check`.
</ParamField>
@@ -311,6 +302,15 @@
Whether the option is selected. Exposed as `aria-checked` in menus and `aria-pressed` in other dropdown types.
</ParamField>
+<ParamField body="OptionItem.shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="OptionItem.shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="OptionItem.startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
@@ -448,15 +448,6 @@
Shows a chevron indicating that the item opens a submenu.
</ParamField>
-<ParamField body="Back.hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="Back.hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="Back.nativeButton" type="boolean" default="true when render is omitted; false otherwise">
Whether the component renders a native `<button>` element when replacing it
via the `render` prop.
@@ -467,6 +458,15 @@
Element rendered as the row instead of a native button. Custom components must forward the supplied props and ref.
</ParamField>
+<ParamField body="Back.shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="Back.shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="Back.startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
@@ -540,15 +540,6 @@
Shows a chevron indicating that the item opens a submenu.
</ParamField>
-<ParamField body="SubmenuTrigger.hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="SubmenuTrigger.hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="SubmenuTrigger.nativeButton" type="boolean" default="true when render is omitted; false otherwise">
Whether the component renders a native `<button>` element when replacing it
via the `render` prop.
@@ -563,6 +554,15 @@
Element rendered as the row instead of a native button. Custom components must forward the supplied props and ref.
</ParamField>
+<ParamField body="SubmenuTrigger.shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="SubmenuTrigger.shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="SubmenuTrigger.startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/components/menu-item.mdx b/packages/twenty-docs/snippets/ui/generated/components/menu-item.mdx
index 73ec240d7c5..c4c45383a4d 100644
--- a/packages/twenty-docs/snippets/ui/generated/components/menu-item.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/components/menu-item.mdx
@@ -39,14 +39,6 @@
Shows a submenu chevron; does not create a submenu.
</ParamField>
-<ParamField body="hotKeys" type="Nullable&lt;string[]&gt;">
- Visible shortcut hints. Register handlers in the application.
-</ParamField>
-
-<ParamField body="hotKeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="iconButtons" type="ReactNode">
Trailing action elements.
</ParamField>
@@ -99,6 +91,14 @@
Applies selected appearance without owning selection state.
</ParamField>
+<ParamField body="shortcut" type="ShortcutDefinition">
+ Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Register handlers in the application.
+</ParamField>
+
+<ParamField body="shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="testId" type="string">
Value of the row’s data-testid attribute.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/input/button.mdx b/packages/twenty-docs/snippets/ui/generated/input/button.mdx
index 024c62142bd..fe0e8c3059b 100644
--- a/packages/twenty-docs/snippets/ui/generated/input/button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/input/button.mdx
@@ -36,10 +36,6 @@
Expands the button to fill its container width.
</ParamField>
-<ParamField body="hotkeys" type="string[]">
- Keyboard shortcut hints displayed on non-mobile screens.
-</ParamField>
-
<ParamField body="href" type="string">
Destination URL. Enables native link semantics instead of button semantics.
</ParamField>
@@ -52,6 +48,14 @@
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="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="shortcutJoinLabel" type="string">
+ Localized text between sequence steps. Defaults to then.
+</ParamField>
+
<ParamField body="size" type="&quot;md&quot; | &quot;sm&quot;" default="md">
Button height: `sm` (24px) or `md` (32px). The `link` variant uses its content height at either size.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/input/light-button.mdx b/packages/twenty-docs/snippets/ui/generated/input/light-button.mdx
index 7fea383ff30..55602291016 100644
--- a/packages/twenty-docs/snippets/ui/generated/input/light-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/input/light-button.mdx
@@ -40,10 +40,6 @@
Expands the button to fill its container width.
</ParamField>
-<ParamField body="hotkeys" type="string[]">
- Keyboard shortcut hints displayed on non-mobile screens.
-</ParamField>
-
<ParamField body="href" type="string">
Destination URL. Enables native link semantics instead of button semantics.
</ParamField>
@@ -56,6 +52,14 @@
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="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="shortcutJoinLabel" type="string">
+ Localized text between sequence steps. Defaults to then.
+</ParamField>
+
<ParamField body="size" type="&quot;md&quot; | &quot;sm&quot;" default="sm">
Button height: `sm` (24px) or `md` (32px). The `link` variant uses its content height at either size.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/input/main-button.mdx b/packages/twenty-docs/snippets/ui/generated/input/main-button.mdx
index 5d8e8b668f6..1c052241a2a 100644
--- a/packages/twenty-docs/snippets/ui/generated/input/main-button.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/input/main-button.mdx
@@ -36,10 +36,6 @@
Expands the button to fill its container width.
</ParamField>
-<ParamField body="hotkeys" type="string[]">
- Keyboard shortcut hints displayed on non-mobile screens.
-</ParamField>
-
<ParamField body="href" type="string">
Destination URL. Enables native link semantics instead of button semantics.
</ParamField>
@@ -52,6 +48,14 @@
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="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="shortcutJoinLabel" type="string">
+ Localized text between sequence steps. Defaults to then.
+</ParamField>
+
<ParamField body="size" type="&quot;md&quot; | &quot;sm&quot;">
Button height: `sm` (24px) or `md` (32px). The `link` variant uses its content height at either size.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx b/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
index ca09278b73c..486fa3058f1 100644
--- a/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/navigation/list-item.mdx
@@ -48,15 +48,6 @@
Shows a chevron indicating that the item opens a submenu.
</ParamField>
-<ParamField body="hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`; pass an empty string to omit it.
-</ParamField>
-
<ParamField body="indicator" type="&quot;check&quot; | &quot;checkbox&quot; | &quot;none&quot;" default="none">
Selection indicator: a check icon after the content or a checkbox before
it.
@@ -74,6 +65,15 @@
`indicator` is set.
</ParamField>
+<ParamField body="shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`; pass an empty string to omit it.
+</ParamField>
+
<ParamField body="startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/surfaces/menu.mdx b/packages/twenty-docs/snippets/ui/generated/surfaces/menu.mdx
index 81fe85c0f01..50056d8774d 100644
--- a/packages/twenty-docs/snippets/ui/generated/surfaces/menu.mdx
+++ b/packages/twenty-docs/snippets/ui/generated/surfaces/menu.mdx
@@ -240,15 +240,6 @@
Icon rendered after the content.
</ParamField>
-<ParamField body="Item.hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="Item.hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="Item.label" type="string">
Overrides the text label to use when the item is matched during keyboard text navigation.
</ParamField>
@@ -270,6 +261,15 @@
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
+<ParamField body="Item.shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="Item.shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="Item.startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
@@ -323,15 +323,6 @@
Icon rendered after the content.
</ParamField>
-<ParamField body="CheckboxItem.hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="CheckboxItem.hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="CheckboxItem.label" type="string">
Overrides the text label to use when the item is matched during keyboard text navigation.
</ParamField>
@@ -357,6 +348,15 @@
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
+<ParamField body="CheckboxItem.shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="CheckboxItem.shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="CheckboxItem.startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
@@ -441,15 +441,6 @@
Icon rendered after the content.
</ParamField>
-<ParamField body="RadioItem.hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="RadioItem.hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="RadioItem.label" type="string">
Overrides the text label to use when the item is matched during keyboard text navigation.
</ParamField>
@@ -471,6 +462,15 @@
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
+<ParamField body="RadioItem.shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="RadioItem.shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="RadioItem.startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
@@ -646,15 +646,6 @@
Icon rendered after the content.
</ParamField>
-<ParamField body="SubmenuTrigger.hotkeys" type="string[]">
- Keyboard shortcut keys displayed at the end of the row. Registering the
- shortcut is up to the application.
-</ParamField>
-
-<ParamField body="SubmenuTrigger.hotkeysJoinLabel" type="string">
- Text between shortcut keys. Defaults to `then`.
-</ParamField>
-
<ParamField body="SubmenuTrigger.label" type="string">
Overrides the text label to use when the item is matched during keyboard text navigation.
</ParamField>
@@ -680,6 +671,15 @@
Accepts a `ReactElement` or a function that returns the element to render.
</ParamField>
+<ParamField body="SubmenuTrigger.shortcut" type="ShortcutDefinition">
+ Keyboard shortcut keys displayed at the end of the row. Registering the
+ shortcut is up to the application.
+</ParamField>
+
+<ParamField body="SubmenuTrigger.shortcutJoinLabel" type="string">
+ Text between sequential shortcut steps. Defaults to `then`.
+</ParamField>
+
<ParamField body="SubmenuTrigger.startIcon" type="ReactNode">
Icon rendered before the content.
</ParamField>
diff --git a/packages/twenty-docs/snippets/ui/generated/typography/shortcut.mdx b/packages/twenty-docs/snippets/ui/generated/typography/shortcut.mdx
new file mode 100644
index 00000000000..0c55bcf885f
--- /dev/null
+++ b/packages/twenty-docs/snippets/ui/generated/typography/shortcut.mdx
@@ -0,0 +1,36 @@
+{/*
+ * _____ _
+ *|_ _|_ _____ _ __ | |_ _ _
+ * | | \ \ /\ / / _ \ '_ \| __| | | | Auto-generated file
+ * | | \ V V / __/ | | | |_| |_| | DO NOT EDIT - changes will be overwritten
+ * |_| \_/\_/ \___|_| |_|\__|\__, | Generated by: npx nx generate:ui twenty-docs
+ * |___/
+ *
+ * This file is generated from the documentation data in packages/twenty-ui/generated.
+ * To update it, edit the component prop types or design tokens in twenty-ui and run:
+ * npx nx generate:ui twenty-docs
+ */}
+
+<ParamField body="combinationSeparator" type="string">
+ Optional separator between simultaneous keys. Defaults to no separator on Apple devices and a space elsewhere.
+</ParamField>
+
+<ParamField body="platform" type="&quot;mac&quot; | &quot;other&quot;">
+ Optional mac or other platform override. Defaults to server-safe device detection.
+</ParamField>
+
+<ParamField body="sequenceJoinLabel" type="string">
+ Text between sequence steps. Defaults to then.
+</ParamField>
+
+<ParamField body="shortcut" type="ShortcutDefinition" required>
+ Flat key array for a simultaneous combination, or nested key arrays for an ordered sequence of combinations.
+</ParamField>
+
+<ParamField body="variant" type="&quot;button&quot; | &quot;keys&quot; | &quot;text&quot;" default="keys">
+ Keycaps, inline text, or a separated button hint.
+</ParamField>
+
+<ParamField body="visibility" type="&quot;always&quot; | &quot;desktop&quot;" default="always">
+ Always visible by default. Desktop hints hide on mobile viewports.
+</ParamField>
diff --git a/packages/twenty-docs/ui/components/dropdown.mdx b/packages/twenty-docs/ui/components/dropdown.mdx
index 28a12fc89c7..8d2202dcc9d 100644
--- a/packages/twenty-docs/ui/components/dropdown.mdx
+++ b/packages/twenty-docs/ui/components/dropdown.mdx
@@ -302,7 +302,7 @@ Right-clicking elsewhere while the menu is open moves it to the new point.
## Labels
-Each part owns its text: supply `Search.placeholder` and native accessible names, `Close` accessible attributes, and children for `Back`, `Loading`, and `Empty`. `Back` defaults to `Back`; loading and empty states have no built-in message. Item parts accept `hotkeysJoinLabel` to replace the default `then` between shortcut keys. Native `aria-labelledby` takes precedence over `aria-label`.
+Each part owns its text: supply `Search.placeholder` and native accessible names, `Close` accessible attributes, and children for `Back`, `Loading`, and `Empty`. `Back` defaults to `Back`; loading and empty states have no built-in message. Item parts accept `shortcutJoinLabel` to replace the default `then` between sequential shortcut steps. Native `aria-labelledby` takes precedence over `aria-label`.
## Props
diff --git a/packages/twenty-docs/ui/components/menu-items.mdx b/packages/twenty-docs/ui/components/menu-items.mdx
index de72a5731de..4822662781a 100644
--- a/packages/twenty-docs/ui/components/menu-items.mdx
+++ b/packages/twenty-docs/ui/components/menu-items.mdx
@@ -19,7 +19,7 @@ import { MenuItem } from 'twenty-ui/components';
import { IconCopy } from 'twenty-ui/icon';
export const CopyRowPreview = () => (
- <MenuItem text="Copy record" LeftIcon={IconCopy} hotKeys={['⌘', 'C']} />
+ <MenuItem text="Copy record" LeftIcon={IconCopy} shortcut={['Mod', 'C']} />
);
```
diff --git a/packages/twenty-docs/ui/primitives/input/button.mdx b/packages/twenty-docs/ui/primitives/input/button.mdx
index 8df6b93013c..520ad2059cc 100644
--- a/packages/twenty-docs/ui/primitives/input/button.mdx
+++ b/packages/twenty-docs/ui/primitives/input/button.mdx
@@ -69,7 +69,7 @@ export const CreateRecord = () => (
);
```
-Choose `solid`, `outline`, `soft`, `ghost`, or `link` independently of the `neutral`, `accent`, `danger`, or `success` color. Sizes are `sm` and `md`; the defaults are `outline`, `neutral`, and `md`. `fullWidth` fills the available width. `startIcon` and `endIcon` accept elements and are decorative. `elevated` adds a shadow and backdrop blur. Neutral outline buttons also gain a bordered surface with matching text and interaction colors. Other variants and semantic colors keep their existing palette. It defaults to `false` and does not change size or position. `hotkeys` displays keyboard hints on larger screens; bind the shortcuts in your application.
+Choose `solid`, `outline`, `soft`, `ghost`, or `link` independently of the `neutral`, `accent`, `danger`, or `success` color. Sizes are `sm` and `md`; the defaults are `outline`, `neutral`, and `md`. `fullWidth` fills the available width. `startIcon` and `endIcon` accept elements and are decorative. `elevated` adds a shadow and backdrop blur. Neutral outline buttons also gain a bordered surface with matching text and interaction colors. Other variants and semantic colors keep their existing palette. It defaults to `false` and does not change size or position. `shortcut` displays keyboard hints on larger screens; bind the shortcuts in your application.
`link` uses compact text with no border or filled background. It follows its content height at either size, with a smaller font and narrower padding. Its neutral color uses stronger text on hover. The appearance does not determine semantics: use `onClick` for actions and `href` for navigation.
@@ -183,3 +183,5 @@ export const LogOut = ({ onLogOut }: LogOutProps) => (
## Props
<ButtonReference />
+
+Pass `shortcut={['Mod', 'Enter']}` for simultaneous keys or `shortcut={[['G'], ['P']]}` for successive presses. See [Shortcut](/ui/primitives/typography/shortcut) for nested combinations and the shared string formatter.
diff --git a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
index 6c89dce3787..5e0f7a8ce98 100644
--- a/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
+++ b/packages/twenty-docs/ui/primitives/navigation/list-item.mdx
@@ -28,13 +28,13 @@ ListItem
└── endIcon
```
-| Slot | Requirement | Purpose |
-| ------------------------------------ | -------------------------------- | ------------------------------------------------------------------------------- |
-| `children` | Required for a visible row label | Supplies the main text. |
-| `startIcon`, `endIcon` | Optional | Add supporting icons at either end of the row content. |
-| `description` | Optional | Adds supporting text inline or at the end, according to `descriptionPlacement`. |
-| `actions` | Optional | Adds trailing content, such as a separately focusable action. |
-| `indicator`, `hotkeys`, `hasSubmenu` | Optional | Configure built-in selection marks, shortcut hints, and the submenu indicator. |
+| Slot | Requirement | Purpose |
+| ------------------------------------- | -------------------------------- | ------------------------------------------------------------------------------- |
+| `children` | Required for a visible row label | Supplies the main text. |
+| `startIcon`, `endIcon` | Optional | Add supporting icons at either end of the row content. |
+| `description` | Optional | Adds supporting text inline or at the end, according to `descriptionPlacement`. |
+| `actions` | Optional | Adds trailing content, such as a separately focusable action. |
+| `indicator`, `shortcut`, `hasSubmenu` | Optional | Configure built-in selection marks, shortcut hints, and the submenu indicator. |
The row supplies layout. Use `render` to choose its element and semantics. For a row with independent action buttons, keep the row itself non-interactive so those buttons remain separate controls.
@@ -58,7 +58,7 @@ export const DuplicateAction = ({ onDuplicate }: DuplicateActionProps) => (
);
```
-The default element is a `div`. Use `render` to give an interactive row appropriate semantics, such as a button or link. `hotkeys` displays shortcut hints; your application must register the shortcuts.
+The default element is a `div`. Use `render` to give an interactive row appropriate semantics, such as a button or link. `shortcut` displays shortcut hints; your application must register the shortcuts.
## Settings row
@@ -211,10 +211,12 @@ export const ContactRow = ({ onOpen }: ContactRowProps) => (
## Labels
-Use `hotkeysJoinLabel` to customize the text between shortcut keys. It defaults to `then`; an empty string removes the join text. The same prop is available on `Menu` and `Dropdown` item parts. The legacy `MenuItem` composition uses `hotKeysJoinLabel` alongside `hotKeys`.
+Use `shortcutJoinLabel` to customize the text between sequential shortcut steps. It defaults to `then`; an empty string removes the join text. The same prop is available on `Menu` and `Dropdown` item parts. The legacy `MenuItem` composition uses `shortcutJoinLabel` alongside `shortcut`.
## Props
The reference is generated from the public component types. Native attributes, including accessible names and event handlers, are also accepted on parts that render elements.
<ListItemReference />
+
+Pass `shortcut={['Mod', 'Enter']}` for simultaneous keys or `shortcut={[['G'], ['P']]}` for successive presses. See [Shortcut](/ui/primitives/typography/shortcut) for nested combinations and the shared string formatter.
diff --git a/packages/twenty-docs/ui/primitives/surfaces/menu.mdx b/packages/twenty-docs/ui/primitives/surfaces/menu.mdx
index 60a55d364c1..7cfc157f398 100644
--- a/packages/twenty-docs/ui/primitives/surfaces/menu.mdx
+++ b/packages/twenty-docs/ui/primitives/surfaces/menu.mdx
@@ -68,7 +68,7 @@ export const RecordMenu = ({ onDuplicate, onDelete }: RecordMenuProps) => (
);
```
-`defaultOpen` defaults to `false`, so it can be omitted. Action items close the menu when selected by default. `disabled` prevents selection. `hotkeys` displays shortcut hints; register shortcut handlers in your application.
+`defaultOpen` defaults to `false`, so it can be omitted. Action items close the menu when selected by default. `disabled` prevents selection. `shortcut` displays shortcut hints; register shortcut handlers in your application.
## Controlled state
@@ -230,7 +230,7 @@ It uses the [theme's portal container](/ui/theming) by default.
## Labels
-Supply labels through each part’s children and native accessible attributes. `Item`, `CheckboxItem`, `RadioItem`, and `SubmenuTrigger` accept `hotkeysJoinLabel` to replace the default `then` between shortcut keys.
+Supply labels through each part’s children and native accessible attributes. `Item`, `CheckboxItem`, `RadioItem`, and `SubmenuTrigger` accept `shortcutJoinLabel` to replace the default `then` between sequential shortcut steps.
## Props
diff --git a/packages/twenty-docs/ui/primitives/typography/shortcut.mdx b/packages/twenty-docs/ui/primitives/typography/shortcut.mdx
new file mode 100644
index 00000000000..42a7933f27b
--- /dev/null
+++ b/packages/twenty-docs/ui/primitives/typography/shortcut.mdx
@@ -0,0 +1,59 @@
+---
+title: Shortcut
+description: Display simultaneous key combinations and sequential shortcuts.
+---
+
+import { StoryEmbed } from '/snippets/ui/StoryEmbed.mdx';
+import ShortcutReference from '/snippets/ui/generated/typography/shortcut.mdx';
+
+<StoryEmbed
+ storyId="ui-typography-shortcut--documentation"
+ title="Shortcut presentations"
+ height={200}
+/>
+
+Import `Shortcut` and `formatShortcut` from `twenty-ui/primitives/typography`. Both share the same model, symbols, and separators. Register shortcuts in your application.
+
+```tsx
+import { Shortcut, formatShortcut } from 'twenty-ui/primitives/typography';
+
+export const ShortcutExamples = () => (
+ <>
+ <Shortcut shortcut={['Enter']} />
+ <Shortcut shortcut={['Mod', 'K']} />
+ <Shortcut shortcut={[['G'], ['P']]} sequenceJoinLabel="then" />
+ <Shortcut
+ shortcut={[
+ ['Mod', 'K'],
+ ['Mod', 'C'],
+ ]}
+ sequenceJoinLabel="then"
+ />
+ </>
+);
+
+const hint = formatShortcut({
+ shortcut: ['Mod', 'Enter'],
+});
+```
+
+A flat array is a simultaneous combination: `['Mod', 'K']` means press Mod and K together. A nested array is an ordered sequence: `[['G'], ['P']]` means press G, then P. Each nested array is one combination, so `[['Mod', 'K'], ['Mod', 'C']]` means press Mod and K, then Mod and C. Use a one-element array for a single key. Both array forms can be readonly.
+
+`Mod` and `CommandOrControl` display Command on macOS and iOS, and Control elsewhere. Explicit `Command`, `Control`, `Alt`, and `Enter` keys also have display labels. Other strings are displayed as supplied. Device detection is safe without browser globals; `platform` optionally overrides it with `mac` or `other`.
+
+Use `sequenceJoinLabel` for localized join text. `combinationSeparator` can preserve a host convention such as `+`. The default text separator is empty on Apple devices and a space elsewhere. `variant` selects `keys`, `text`, or `button`. `visibility="desktop"` hides the hint at mobile viewport widths while `always` remains visible.
+
+Key symbols have readable accessible names. Supply `aria-label` or `aria-labelledby` for a localized name, or `aria-hidden` for a decorative hint. Buttons keep their action names and hide their decorative hints on mobile. Menu and list rows keep their hints visible.
+
+## Migration
+
+| Previous prop | Replacement |
+| ----------------------------------------------------- | -------------------------------------------------------------------------- |
+| Button `hotkeys={['⌘', 'K']}` | `shortcut={['Mod', 'K']}` |
+| ListItem or MenuItem sequential `hotkeys` / `hotKeys` | `shortcut={[['G'], ['P']]}` |
+| `hotkeysJoinLabel` / `hotKeysJoinLabel` | `shortcutJoinLabel` on Button, ListItem, MenuItem, Menu and Dropdown parts |
+| Manual tooltip key concatenation | `formatShortcut({ shortcut: ['Mod', 'Enter'] })` |
+
+Flat stored arrays that represent successive key presses need nesting before being passed to `shortcut`: `hotKeys.map((key) => [key])`. Arrays that represent simultaneous keys can be passed directly. Key strings remain literal tokens, so `['Mod', '+']` contains a plus key and `['Space']` contains the Space key; no shortcut-string parsing is required.
+
+<ShortcutReference />
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-dropdown.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-dropdown.front-component.tsx
index 6b27a38167b..a9470e4f963 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-dropdown.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-dropdown.front-component.tsx
@@ -25,8 +25,8 @@ const DropdownExample = () => {
<Dropdown.Section>
<Dropdown.ActionItem
page="assignees"
- hotkeys={['G', 'A']}
- hotkeysJoinLabel="followed by"
+ shortcut={[['G'], ['A']]}
+ shortcutJoinLabel="followed by"
>
Assign person
</Dropdown.ActionItem>
@@ -48,8 +48,8 @@ const DropdownExample = () => {
<Dropdown.OptionItem
key={assignee}
selected={selection === assignee}
- hotkeys={['G', assignee.charAt(0)]}
- hotkeysJoinLabel="next"
+ shortcut={[['G'], [assignee.charAt(0)]]}
+ shortcutJoinLabel="next"
onSelect={() => setSelection(assignee)}
>
{assignee}
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-label-overrides.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-label-overrides.front-component.tsx
index 7aea92289e1..3a97e1d1d6b 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-label-overrides.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-label-overrides.front-component.tsx
@@ -14,14 +14,14 @@ const LabelOverrides = () => {
isClosable
closeLabel="Dismiss notice"
/>
- <ListItem hotkeys={['G', 'D']}>Default shortcut</ListItem>
- <ListItem hotkeys={['G', 'S']} hotkeysJoinLabel="followed by">
+ <ListItem shortcut={[['G'], ['D']]}>Default shortcut</ListItem>
+ <ListItem shortcut={[['G'], ['S']]} shortcutJoinLabel="followed by">
Supplied shortcut
</ListItem>
<MenuItem
text="Legacy shortcut"
- hotKeys={['G', 'L']}
- hotKeysJoinLabel="next"
+ shortcut={[['G'], ['L']]}
+ shortcutJoinLabel="next"
/>
</TwentyUiGalleryCard>
);
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-menu.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-menu.front-component.tsx
index e35a4197647..cdf16d8fddb 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-menu.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-menu.front-component.tsx
@@ -15,8 +15,8 @@ const MenuExample = () => {
<Menu.Group>
<Menu.GroupLabel>Record</Menu.GroupLabel>
<Menu.Item
- hotkeys={['G', 'A']}
- hotkeysJoinLabel="followed by"
+ shortcut={[['G'], ['A']]}
+ shortcutJoinLabel="followed by"
onClick={() => setAction('duplicated')}
>
Duplicate
diff --git a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-responsive-hooks.front-component.tsx b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-responsive-hooks.front-component.tsx
index 2241c678868..407319b6e83 100644
--- a/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-responsive-hooks.front-component.tsx
+++ b/packages/twenty-front-component-renderer/src/__stories__/twenty-ui-gallery/twenty-ui-responsive-hooks.front-component.tsx
@@ -14,7 +14,7 @@ const ResponsiveHooks = () => {
<>
<Text>Mobile layout: {String(isMobile)}</Text>
<Text>Touch input: {String(isTouchDevice)}</Text>
- <Button hotkeys={['S']} onClick={() => setActivations(activations + 1)}>
+ <Button shortcut={['S']} onClick={() => setActivations(activations + 1)}>
Save record
</Button>
<Button onClick={() => setActivations(activations + 1)}>
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 ddfa40c646e..942c7791522 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
@@ -3,7 +3,12 @@ import { defineFrontComponent } from 'twenty-sdk/define';
import { Section } from 'twenty-ui/components';
import { VisibilityHidden } from 'twenty-ui/primitives/accessibility';
import { Button } from 'twenty-ui/primitives/input';
-import { Heading, Text } from 'twenty-ui/primitives/typography';
+import {
+ Heading,
+ Text,
+ Shortcut,
+ formatShortcut,
+} from 'twenty-ui/primitives/typography';
import { ThemeProvider } from 'twenty-ui/theme';
import {
@@ -31,6 +36,21 @@ const SectionExample = () => {
};
const TYPOGRAPHY_ENTRIES: GalleryEntry[] = [
+ {
+ name: 'Shortcut',
+ node: (
+ <>
+ <Shortcut shortcut={['Mod', 'K']} platform="mac" />
+ <Shortcut shortcut={[['G'], ['P']]} sequenceJoinLabel="next" />
+ <Text>
+ {formatShortcut({
+ shortcut: ['Mod', 'K'],
+ platform: 'other',
+ })}
+ </Text>
+ </>
+ ),
+ },
{
name: 'Heading',
node: (
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 22d3b89b8c5..baad7d0d270 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
@@ -17,6 +17,14 @@ export const typographyTest: TwentyUiGalleryPlayFunction = async (context) => {
canvas.getByRole('heading', { level: 2, name: 'Workspace preferences' }),
).toHaveAccessibleDescription('Manage the settings for your workspace.');
+ await expect(
+ canvas.getByRole('img', { name: 'Command + K' }),
+ ).toHaveTextContent('⌘K');
+ await expect(canvas.getByRole('img', { name: 'G next P' })).toHaveTextContent(
+ 'G next P',
+ );
+ await expect(canvas.getByText('Ctrl K')).toBeVisible();
+
const button = canvas.getByRole('button', { name: 'Edit workspace' });
await userEvent.click(button);
await waitFor(() =>
diff --git a/packages/twenty-front/src/modules/ai/components/AiChatAddMenu.tsx b/packages/twenty-front/src/modules/ai/components/AiChatAddMenu.tsx
index 5b91885c49b..e5e6d57bfa3 100644
--- a/packages/twenty-front/src/modules/ai/components/AiChatAddMenu.tsx
+++ b/packages/twenty-front/src/modules/ai/components/AiChatAddMenu.tsx
@@ -72,14 +72,14 @@ export const AiChatAddMenu = ({ editor }: AiChatAddMenuProps) => {
</Dropdown.ActionItem>
<Dropdown.ActionItem
startIcon={<IconAddressBook />}
- hotkeys={['@']}
+ shortcut={['@']}
page={AI_CHAT_ADD_MENU_PAGE.RECORDS}
>
{t`Records`}
</Dropdown.ActionItem>
<Dropdown.ActionItem
startIcon={<IconBook />}
- hotkeys={['/']}
+ shortcut={['/']}
page={AI_CHAT_ADD_MENU_PAGE.SKILLS}
>
{t`Skills`}
diff --git a/packages/twenty-front/src/modules/command-menu-item/components/RecordPageSidePanelWidgetCommandMenuItems.tsx b/packages/twenty-front/src/modules/command-menu-item/components/RecordPageSidePanelWidgetCommandMenuItems.tsx
index ffb1e4ab92f..0cdb60f9573 100644
--- a/packages/twenty-front/src/modules/command-menu-item/components/RecordPageSidePanelWidgetCommandMenuItems.tsx
+++ b/packages/twenty-front/src/modules/command-menu-item/components/RecordPageSidePanelWidgetCommandMenuItems.tsx
@@ -24,7 +24,7 @@ export const RecordPageSidePanelWidgetCommandMenuItems = () => {
<commandMenuItem.Icon />
) : undefined
}
- hotkeys={commandMenuItem.hotkeys}
+ shortcut={commandMenuItem.shortcut}
onClick={commandMenuItem.onClick}
disabled={commandMenuItem.disabled}
variant={commandMenuItem.isPrimaryCTA ? 'solid' : 'outline'}
diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx
index 5440767fc2c..352975b8863 100644
--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItem.tsx
@@ -1,31 +1,14 @@
+import { type CommandMenuItemProps } from '@/command-menu/types/CommandMenuItemProps';
import { useLingui } from '@lingui/react/macro';
import { isNonEmptyString } from '@sniptt/guards';
-import { type ReactNode } from 'react';
import { MenuItem } from 'twenty-ui/components';
-import { IconArrowUpRight, type IconComponent } from 'twenty-ui/icon';
+import { IconArrowUpRight } from 'twenty-ui/icon';
import { useCommandMenuOnItemClick } from '@/command-menu/hooks/useCommandMenuOnItemClick';
import { isSelectedItemIdComponentFamilyState } from '@/ui/layout/selectable-list/states/isSelectedItemIdComponentFamilyState';
import { useAtomComponentFamilyStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomComponentFamilyStateValue';
-import { type Nullable } from 'twenty-shared/types';
import { isDefined } from 'twenty-shared/utils';
-export type CommandMenuItemProps = {
- label: string;
- description?: string;
- to?: string;
- id: string;
- onClick?: () => void;
- Icon?: IconComponent;
- hotKeys?: Nullable<string[]>;
- LeftComponent?: ReactNode;
- RightComponent?: ReactNode;
- contextualTextPosition?: 'left' | 'right';
- hasSubMenu?: boolean;
- isSubMenuOpened?: boolean;
- disabled?: boolean;
-};
-
export const CommandMenuItem = ({
label,
description,
@@ -61,8 +44,8 @@ export const CommandMenuItem = ({
text={label}
contextualText={description}
contextualTextPosition={contextualTextPosition}
- hotKeys={hotKeys}
- hotKeysJoinLabel={t`then`}
+ shortcut={isDefined(hotKeys) ? hotKeys.map((key) => [key]) : undefined}
+ shortcutJoinLabel={t`then`}
onClick={
onClick || to
? () =>
diff --git a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemDropdown.tsx b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemDropdown.tsx
index 07df2816069..e0455a31b80 100644
--- a/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemDropdown.tsx
+++ b/packages/twenty-front/src/modules/command-menu/components/CommandMenuItemDropdown.tsx
@@ -1,7 +1,5 @@
-import {
- CommandMenuItem,
- type CommandMenuItemProps,
-} from '@/command-menu/components/CommandMenuItem';
+import { CommandMenuItem } from '@/command-menu/components/CommandMenuItem';
+import { type CommandMenuItemProps } from '@/command-menu/types/CommandMenuItemProps';
import { SIDE_PANEL_SELECTABLE_LIST_ID } from '@/side-panel/constants/SidePanelSelectableListId';
import {
Dropdown,
diff --git a/packages/twenty-front/src/modules/command-menu/types/CommandMenuItemProps.ts b/packages/twenty-front/src/modules/command-menu/types/CommandMenuItemProps.ts
new file mode 100644
index 00000000000..7343180018f
--- /dev/null
+++ b/packages/twenty-front/src/modules/command-menu/types/CommandMenuItemProps.ts
@@ -0,0 +1,19 @@
+import { type ReactNode } from 'react';
+import { type IconComponent } from 'twenty-ui/icon';
+import { type Nullable } from 'twenty-shared/types';
+
+export type CommandMenuItemProps = {
+ label: string;
+ description?: string;
+ to?: string;
+ id: string;
+ onClick?: () => void;
+ Icon?: IconComponent;
+ hotKeys?: Nullable<string[]>;
+ LeftComponent?: ReactNode;
+ RightComponent?: ReactNode;
+ contextualTextPosition?: 'left' | 'right';
+ hasSubMenu?: boolean;
+ isSubMenuOpened?: boolean;
+ disabled?: boolean;
+};
diff --git a/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuDialog.tsx b/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuDialog.tsx
index 55a2c99fc4f..cb260e759a8 100644
--- a/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuDialog.tsx
+++ b/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuDialog.tsx
@@ -1,13 +1,47 @@
-import {
- StyledContainer,
- StyledDialog,
- StyledHeading,
-} from './KeyboardShortcutMenuStyles';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from 'twenty-ui/theme';
import { t } from '@lingui/core/macro';
import { IconButton } from 'twenty-ui/components';
import { IconX } from 'twenty-ui/icon';
import { useIsMobile } from 'twenty-ui/utilities';
+const StyledDialog = styled.div<{ isMobile: boolean }>`
+ background: ${themeCssVariables.background.primary};
+ border-radius: ${themeCssVariables.border.radius.md};
+ box-shadow: ${themeCssVariables.boxShadow.strong};
+ font-family: ${themeCssVariables.font.family};
+ left: 50%;
+ max-width: 400px;
+ overflow: hidden;
+ padding: 0;
+ padding: ${themeCssVariables.spacing[1]};
+ position: fixed;
+ top: 30%;
+ transform: ${({ isMobile }) =>
+ isMobile ? 'translateX(-49.5%)' : 'translateX(-50%)'};
+ width: ${({ isMobile }) => (isMobile ? 'calc(100% - 40px)' : '100%')};
+ z-index: 1000;
+`;
+
+const StyledHeading = styled.div`
+ align-items: center;
+ border-bottom: 1px solid ${themeCssVariables.border.color.medium};
+ color: ${themeCssVariables.font.color.primary};
+ display: flex;
+ flex-direction: row;
+ font-weight: ${themeCssVariables.font.weight.semiBold};
+ justify-content: space-between;
+ padding: ${themeCssVariables.spacing[3]};
+`;
+
+const StyledContainer = styled.div`
+ gap: ${themeCssVariables.spacing[2]};
+ padding-bottom: ${themeCssVariables.spacing[4]};
+ padding-left: ${themeCssVariables.spacing[4]};
+ padding-right: ${themeCssVariables.spacing[4]};
+ padding-top: ${themeCssVariables.spacing[1]};
+`;
+
type KeyboardMenuDialogProps = {
onClose: () => void;
children: React.ReactNode | React.ReactNode[];
diff --git a/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuGroup.tsx b/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuGroup.tsx
index b18e5f5ab25..da485b0dfbc 100644
--- a/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuGroup.tsx
+++ b/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuGroup.tsx
@@ -1,4 +1,17 @@
-import { StyledGroup, StyledGroupHeading } from './KeyboardShortcutMenuStyles';
+import { styled } from '@linaria/react';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const StyledGroup = styled.div`
+ display: flex;
+ flex-direction: column;
+ gap: ${themeCssVariables.spacing[2]};
+`;
+
+const StyledGroupHeading = styled.label`
+ color: ${themeCssVariables.color.gray10};
+ padding-bottom: ${themeCssVariables.spacing[1]};
+ padding-top: ${themeCssVariables.spacing[4]};
+`;
type KeyboardMenuGroupProps = {
heading: string;
diff --git a/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuItem.tsx b/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuItem.tsx
index 2bc52fc6151..da2219a8ce3 100644
--- a/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuItem.tsx
+++ b/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuItem.tsx
@@ -1,35 +1,40 @@
-import {
- StyledItem,
- StyledShortcutKey,
- StyledShortcutKeyContainer,
-} from '@/keyboard-shortcut-menu/components/KeyboardShortcutMenuStyles';
-import { type Shortcut } from '@/keyboard-shortcut-menu/types/Shortcut';
+import { type Shortcut as ShortcutMenuEntry } from '@/keyboard-shortcut-menu/types/Shortcut';
+import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
+import { Fragment } from 'react';
+import { Shortcut } from 'twenty-ui/primitives/typography';
+import { themeCssVariables } from 'twenty-ui/theme';
+
+const StyledItem = styled.div`
+ align-items: center;
+ color: ${themeCssVariables.font.color.primary};
+ display: flex;
+ flex-direction: row;
+ font-weight: ${themeCssVariables.font.weight.regular};
+ height: 24px;
+ justify-content: space-between;
+`;
+
+const StyledShortcuts = styled.span`
+ align-items: center;
+ display: inline-flex;
+ gap: ${themeCssVariables.spacing[1]};
+`;
type KeyboardMenuItemProps = {
- shortcut: Shortcut;
+ shortcut: ShortcutMenuEntry;
};
-export const KeyboardMenuItem = ({ shortcut }: KeyboardMenuItemProps) => {
- return (
- <StyledItem>
- {shortcut.label}
- {shortcut.secondHotKey ? (
- shortcut.areSimultaneous ? (
- <StyledShortcutKeyContainer>
- <StyledShortcutKey>{shortcut.firstHotKey}</StyledShortcutKey>
- <StyledShortcutKey>{shortcut.secondHotKey}</StyledShortcutKey>
- </StyledShortcutKeyContainer>
- ) : (
- <StyledShortcutKeyContainer>
- <StyledShortcutKey>{shortcut.firstHotKey}</StyledShortcutKey>
- {t`then`}
- <StyledShortcutKey>{shortcut.secondHotKey}</StyledShortcutKey>
- </StyledShortcutKeyContainer>
- )
- ) : (
- <StyledShortcutKey>{shortcut.firstHotKey}</StyledShortcutKey>
- )}
- </StyledItem>
- );
-};
+export const KeyboardMenuItem = ({ shortcut }: KeyboardMenuItemProps) => (
+ <StyledItem>
+ {shortcut.label}
+ <StyledShortcuts>
+ {shortcut.shortcuts.map((definition, index) => (
+ <Fragment key={index}>
+ {index > 0 && t`or`}
+ <Shortcut shortcut={definition} sequenceJoinLabel={t`then`} />
+ </Fragment>
+ ))}
+ </StyledShortcuts>
+ </StyledItem>
+);
diff --git a/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuStyles.tsx b/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuStyles.tsx
deleted file mode 100644
index 96cb4a45725..00000000000
--- a/packages/twenty-front/src/modules/keyboard-shortcut-menu/components/KeyboardShortcutMenuStyles.tsx
+++ /dev/null
@@ -1,88 +0,0 @@
-import { styled } from '@linaria/react';
-
-import { themeCssVariables } from 'twenty-ui/theme';
-
-export const StyledDialog = styled.div<{ isMobile: boolean }>`
- background: ${themeCssVariables.background.primary};
- border-radius: ${themeCssVariables.border.radius.md};
- box-shadow: ${themeCssVariables.boxShadow.strong};
- font-family: ${themeCssVariables.font.family};
- left: 50%;
- max-width: 400px;
- overflow: hidden;
- padding: 0;
- padding: ${themeCssVariables.spacing[1]};
- position: fixed;
- top: 30%;
- transform: ${({ isMobile }) =>
- isMobile ? 'translateX(-49.5%)' : 'translateX(-50%)'};
- width: ${({ isMobile }) => (isMobile ? 'calc(100% - 40px)' : '100%')};
- z-index: 1000;
-`;
-
-export const StyledHeading = styled.div`
- align-items: center;
- border-bottom: 1px solid ${themeCssVariables.border.color.medium};
- color: ${themeCssVariables.font.color.primary};
- display: flex;
- flex-direction: row;
- font-weight: ${themeCssVariables.font.weight.semiBold};
- justify-content: space-between;
- padding: ${themeCssVariables.spacing[3]};
-`;
-
-export const StyledContainer = styled.div`
- gap: ${themeCssVariables.spacing[2]};
- padding-bottom: ${themeCssVariables.spacing[4]};
- padding-left: ${themeCssVariables.spacing[4]};
- padding-right: ${themeCssVariables.spacing[4]};
- padding-top: ${themeCssVariables.spacing[1]};
-`;
-
-export const StyledGroupHeading = styled.label`
- color: ${themeCssVariables.color.gray10};
- padding-bottom: ${themeCssVariables.spacing[1]};
- padding-top: ${themeCssVariables.spacing[4]};
-`;
-
-export const StyledGroup = styled.div`
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[2]};
-`;
-
-export const StyledItem = styled.div`
- align-items: center;
- color: ${themeCssVariables.font.color.primary};
- display: flex;
- flex-direction: row;
- font-weight: ${themeCssVariables.font.weight.regular};
- height: 24px;
- justify-content: space-between;
-`;
-
-export const StyledShortcutKey = styled.div`
- align-items: center;
- background-color: ${themeCssVariables.background.secondary};
- border: 1px solid ${themeCssVariables.border.color.strong};
- border-radius: ${themeCssVariables.border.radius.sm};
- box-shadow: ${themeCssVariables.boxShadow.underline};
- color: ${themeCssVariables.font.color.tertiary};
- display: flex;
- flex-direction: column;
- font-size: ${themeCssVariables.font.size.md};
- font-weight: ${themeCssVariables.font.weight.regular};
- height: 20px;
- justify-content: center;
- padding-left: ${themeCssVariables.spacing[1]};
- padding-right: ${themeCssVariables.spacing[1]};
- text-align: center;
-`;
-
-export const StyledShortcutKeyContainer = styled.div`
- align-items: center;
- color: ${themeCssVariables.font.color.tertiary};
- display: flex;
- flex-direction: row;
- gap: ${themeCssVariables.spacing[1]};
-`;
diff --git a/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsGeneral.ts b/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsGeneral.ts
index e3227d6ca77..9d660ef2f6b 100644
--- a/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsGeneral.ts
+++ b/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsGeneral.ts
@@ -1,22 +1,12 @@
-import {
- type Shortcut,
- ShortcutType,
-} from '@/keyboard-shortcut-menu/types/Shortcut';
-import { getOsControlSymbol } from 'twenty-ui/utilities';
+import { type Shortcut } from '@/keyboard-shortcut-menu/types/Shortcut';
export const KEYBOARD_SHORTCUTS_GENERAL: Shortcut[] = [
{
label: 'Open search',
- type: ShortcutType.General,
- firstHotKey: getOsControlSymbol(),
- secondHotKey: 'K',
- areSimultaneous: false,
+ shortcuts: [['Mod', 'K']],
},
{
label: 'Mark as favourite',
- type: ShortcutType.General,
- firstHotKey: '⇧',
- secondHotKey: 'F',
- areSimultaneous: false,
+ shortcuts: [['⇧', 'F']],
},
];
diff --git a/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsSidePanel.ts b/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsSidePanel.ts
index c07ffbf7ee9..f91168fa46e 100644
--- a/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsSidePanel.ts
+++ b/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsSidePanel.ts
@@ -1,32 +1,20 @@
-import {
- type Shortcut,
- ShortcutType,
-} from '@/keyboard-shortcut-menu/types/Shortcut';
+import { type Shortcut } from '@/keyboard-shortcut-menu/types/Shortcut';
export const KEYBOARD_SHORTCUTS_SIDE_PANEL: Shortcut[] = [
{
label: 'Clear search, go back, or close',
- type: ShortcutType.SidePanel,
- firstHotKey: 'esc',
- areSimultaneous: true,
+ shortcuts: [['esc']],
},
{
label: 'Go back when search is empty',
- type: ShortcutType.SidePanel,
- firstHotKey: '⌫',
- areSimultaneous: true,
+ shortcuts: [['⌫']],
},
{
label: 'Move through list items',
- type: ShortcutType.SidePanel,
- firstHotKey: '↑',
- secondHotKey: '↓',
- areSimultaneous: true,
+ shortcuts: [['↑'], ['↓']],
},
{
label: 'Open selected list item',
- type: ShortcutType.SidePanel,
- firstHotKey: '↵',
- areSimultaneous: true,
+ shortcuts: [['↵']],
},
];
diff --git a/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsTable.ts b/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsTable.ts
index 6a466ee384e..5e491103634 100644
--- a/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsTable.ts
+++ b/packages/twenty-front/src/modules/keyboard-shortcut-menu/constants/KeyboardShortcutsTable.ts
@@ -1,25 +1,16 @@
-import {
- type Shortcut,
- ShortcutType,
-} from '@/keyboard-shortcut-menu/types/Shortcut';
+import { type Shortcut } from '@/keyboard-shortcut-menu/types/Shortcut';
export const KEYBOARD_SHORTCUTS_TABLE: Shortcut[] = [
{
label: 'Move right',
- type: ShortcutType.Table,
- firstHotKey: '→',
- areSimultaneous: true,
+ shortcuts: [['→']],
},
{
label: 'Move left',
- type: ShortcutType.Table,
- firstHotKey: '←',
- areSimultaneous: true,
+ shortcuts: [['←']],
},
{
label: 'Clear selection',
- type: ShortcutType.Table,
- firstHotKey: 'esc',
- areSimultaneous: true,
+ shortcuts: [['esc']],
},
];
diff --git a/packages/twenty-front/src/modules/keyboard-shortcut-menu/types/Shortcut.ts b/packages/twenty-front/src/modules/keyboard-shortcut-menu/types/Shortcut.ts
index 6f17e2a290a..44d94fc48a8 100644
--- a/packages/twenty-front/src/modules/keyboard-shortcut-menu/types/Shortcut.ts
+++ b/packages/twenty-front/src/modules/keyboard-shortcut-menu/types/Shortcut.ts
@@ -1,13 +1,6 @@
-export enum ShortcutType {
- Table = 'Table',
- General = 'General',
- SidePanel = 'SidePanel',
-}
+import { type ShortcutDefinition } from 'twenty-ui/primitives/typography';
export type Shortcut = {
label: string;
- type: ShortcutType;
- firstHotKey?: string;
- secondHotKey?: string;
- areSimultaneous: boolean;
+ shortcuts: readonly ShortcutDefinition[];
};
diff --git a/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx b/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx
index 9a1609a516f..a118f05e932 100644
--- a/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx
+++ b/packages/twenty-front/src/modules/log-console/components/LogConsole.tsx
@@ -1,3 +1,4 @@
+import { formatShortcut } from 'twenty-ui/primitives/typography';
import { styled } from '@linaria/react';
import { useLingui } from '@lingui/react/macro';
import { useReducedMotion } from 'framer-motion';
@@ -13,10 +14,6 @@ import {
IconX,
} from 'twenty-ui/icon';
import { themeCssVariables, useTheme } from 'twenty-ui/theme';
-import {
- getOsControlSymbol,
- getOsShortcutSeparator,
-} from 'twenty-ui/utilities';
import { currentWorkspaceState } from '@/auth/states/currentWorkspaceState';
import { isClickHouseConfiguredState } from '@/client-config/states/isClickHouseConfiguredState';
@@ -352,9 +349,9 @@ export const LogConsole = () => {
setIsLogConsoleFullScreen(false);
};
- const toggleHotkeyLabel = [getOsControlSymbol(), 'J'].join(
- getOsShortcutSeparator(),
- );
+ const toggleHotkeyLabel = formatShortcut({
+ shortcut: ['Mod', 'J'],
+ });
const toggleHotkeyEffect = isLogConsoleAllowed ? (
<LogConsoleToggleHotkeyEffect onToggle={toggleLogConsoleOpen} />
diff --git a/packages/twenty-front/src/modules/object-record/record-merge/components/MergeRecordsFooter.tsx b/packages/twenty-front/src/modules/object-record/record-merge/components/MergeRecordsFooter.tsx
index 2d089aaf8b5..2f82602663b 100644
--- a/packages/twenty-front/src/modules/object-record/record-merge/components/MergeRecordsFooter.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-merge/components/MergeRecordsFooter.tsx
@@ -52,7 +52,7 @@ export const MergeRecordsFooter = ({
<Button
size="md"
startIcon={<IconArrowMerge />}
- hotkeys={isMerging ? undefined : ['⌘', '⏎']}
+ shortcut={isMerging ? undefined : ['Mod', 'Enter']}
onClick={handleMergeRecords}
disabled={isMerging}
variant="solid"
diff --git a/packages/twenty-front/src/modules/object-record/record-update-multiple/components/UpdateMultipleRecordsFooter.tsx b/packages/twenty-front/src/modules/object-record/record-update-multiple/components/UpdateMultipleRecordsFooter.tsx
index 45bbcc46bdf..c4b4eb7d681 100644
--- a/packages/twenty-front/src/modules/object-record/record-update-multiple/components/UpdateMultipleRecordsFooter.tsx
+++ b/packages/twenty-front/src/modules/object-record/record-update-multiple/components/UpdateMultipleRecordsFooter.tsx
@@ -67,7 +67,7 @@ export const UpdateMultipleRecordsFooter = ({
size="sm"
startIcon={<IconBoxMultiple />}
loading={isUpdating && !progressText}
- hotkeys={isUpdating ? undefined : ['⌘', '⏎']}
+ shortcut={isUpdating ? undefined : ['Mod', 'Enter']}
onClick={onUpdate}
disabled={isUpdating || isUpdateDisabled}
variant="solid"
diff --git a/packages/twenty-front/src/modules/page-layout/widgets/email-thread/components/EmailThreadComposer.tsx b/packages/twenty-front/src/modules/page-layout/widgets/email-thread/components/EmailThreadComposer.tsx
index aa734e3763c..b8f67da14ee 100644
--- a/packages/twenty-front/src/modules/page-layout/widgets/email-thread/components/EmailThreadComposer.tsx
+++ b/packages/twenty-front/src/modules/page-layout/widgets/email-thread/components/EmailThreadComposer.tsx
@@ -21,7 +21,6 @@ import {
IconX,
} from 'twenty-ui/icon';
import { themeCssVariables } from 'twenty-ui/theme';
-import { getOsControlSymbol } from 'twenty-ui/utilities';
const StyledReplyBar = styled.button`
align-items: center;
@@ -121,7 +120,7 @@ export const EmailThreadComposer = ({
label: t`Send`,
Icon: IconSend,
isPrimaryCTA: true,
- hotkeys: [getOsControlSymbol(), '⏎'],
+ shortcut: ['Mod', 'Enter'],
onClick: handleSend,
disabled: !canSendReply,
},
diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationForm.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationForm.tsx
index 505c6d6e98d..a9527574878 100644
--- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationForm.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/morph-relation/components/SettingsDataModelFieldRelationForm.tsx
@@ -1,7 +1,6 @@
import { Controller, useFormContext } from 'react-hook-form';
import { z } from 'zod';
-import { StyledContainer } from '@/keyboard-shortcut-menu/components/KeyboardShortcutMenuStyles';
import { SettingsMorphRelationMultiSelect } from '@/settings/components/SettingsMorphRelationMultiSelect';
import { FIELD_NAME_MAXIMUM_LENGTH } from '@/settings/data-model/constants/FieldNameMaximumLength';
import { RELATION_TYPES } from '@/settings/data-model/constants/RelationTypes';
@@ -21,6 +20,14 @@ import { isDefined } from 'twenty-shared/utils';
import { themeCssVariables } from 'twenty-ui/theme';
import { RelationType } from '~/generated-metadata/graphql';
+const StyledContainer = styled.div`
+ gap: ${themeCssVariables.spacing[2]};
+ padding-bottom: ${themeCssVariables.spacing[4]};
+ padding-left: ${themeCssVariables.spacing[4]};
+ padding-right: ${themeCssVariables.spacing[4]};
+ padding-top: ${themeCssVariables.spacing[1]};
+`;
+
const StyledSelectsContainer = styled.div<{ isMobile: boolean }>`
display: grid;
gap: ${themeCssVariables.spacing[4]};
diff --git a/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectSearchSection.tsx b/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectSearchSection.tsx
index e5d10eb875a..570d01669ec 100644
--- a/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectSearchSection.tsx
+++ b/packages/twenty-front/src/modules/settings/data-model/object-details/components/tabs/SettingsObjectSearchSection.tsx
@@ -1,3 +1,4 @@
+import { formatShortcut } from 'twenty-ui/primitives/typography';
import { useUpdateOneFieldMetadataItem } from '@/object-metadata/hooks/useUpdateOneFieldMetadataItem';
import { useUpdateOneObjectMetadataItem } from '@/object-metadata/hooks/useUpdateOneObjectMetadataItem';
import { type EnrichedObjectMetadataItem } from '@/object-metadata/types/EnrichedObjectMetadataItem';
@@ -185,7 +186,7 @@ export const SettingsObjectSearchSection = ({
<SettingsOptionCardContentSwitch
Icon={IconEye}
title={t`Global search`}
- description={t`Show this object's records in the command menu (⌘K).`}
+ description={t`Show this object's records in the command menu (${formatShortcut({ shortcut: ['Mod', 'K'] })}).`}
checked={isSearchable}
advancedMode
onChange={handleToggleSearchable}
diff --git a/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx b/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx
index 745cfb544a0..928f7c37b78 100644
--- a/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx
+++ b/packages/twenty-front/src/modules/settings/hooks/useSettingsNavigationItems.tsx
@@ -7,10 +7,8 @@ import { billingState } from '@/client-config/states/billingState';
import { supportChatState } from '@/client-config/states/supportChatState';
import { usePermissionFlagMap } from '@/settings/roles/hooks/usePermissionFlagMap';
import { getDocumentationUrl } from '@/support/utils/getDocumentationUrl';
-import {
- type NavigationDrawerItemIndentationLevel,
- type NavigationDrawerItemModifier,
-} from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
+import { type NavigationDrawerItemModifier } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerItemModifier';
+import { type NavigationDrawerItemIndentationLevel } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerItemIndentationLevel';
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
import { t } from '@lingui/core/macro';
import { isNonEmptyString } from '@sniptt/guards';
diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelExpandButton.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelExpandButton.tsx
index 16cd0972152..45484f8f202 100644
--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelExpandButton.tsx
+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelExpandButton.tsx
@@ -2,10 +2,7 @@ import { isNonEmptyString } from '@sniptt/guards';
import { isDefined } from 'twenty-shared/utils';
import { IconMaximize } from 'twenty-ui/icon';
import { IconButton } from 'twenty-ui/components';
-import {
- getOsControlSymbol,
- getOsShortcutSeparator,
-} from 'twenty-ui/utilities';
+import { formatShortcut } from 'twenty-ui/primitives/typography';
import { useSidePanelExpandTarget } from '@/side-panel/hooks/useSidePanelExpandTarget';
import { SIDE_PANEL_FOCUS_ID } from '@/side-panel/constants/SidePanelFocusId';
@@ -37,9 +34,7 @@ const SidePanelExpandButtonContent = () => {
const tooltipContent =
expandTarget.disabledReason ??
(expandTarget.hasExpandShortcut
- ? `${expandTarget.label} | ${[getOsControlSymbol(), '⏎'].join(
- getOsShortcutSeparator(),
- )}`
+ ? `${expandTarget.label} | ${formatShortcut({ shortcut: ['Mod', 'Enter'] })}`
: expandTarget.label);
return (
diff --git a/packages/twenty-front/src/modules/side-panel/components/SidePanelToggleButton.tsx b/packages/twenty-front/src/modules/side-panel/components/SidePanelToggleButton.tsx
index a751994dc1a..7da88f632f0 100644
--- a/packages/twenty-front/src/modules/side-panel/components/SidePanelToggleButton.tsx
+++ b/packages/twenty-front/src/modules/side-panel/components/SidePanelToggleButton.tsx
@@ -1,3 +1,4 @@
+import { formatShortcut } from 'twenty-ui/primitives/typography';
import { SIDE_PANEL_TOP_BAR_HEIGHT_MOBILE } from '@/side-panel/constants/SidePanelTopBarHeightMobile';
import { COMMAND_MENU_SIDE_PANEL_PAGES } from '@/side-panel/constants/CommandMenuSidePanelPages';
import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
@@ -14,7 +15,7 @@ import { SidePanelPages } from 'twenty-shared/types';
import { IconDotsVertical } from 'twenty-ui/icon';
import { IconButton } from 'twenty-ui/components';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
-import { getOsControlSymbol, useIsMobile } from 'twenty-ui/utilities';
+import { useIsMobile } from 'twenty-ui/utilities';
import { themeCssVariables } from 'twenty-ui/theme';
const StyledButtonWrapper = styled.div<{ alignToTop: boolean }>`
@@ -67,7 +68,7 @@ export const SidePanelToggleButton = () => {
}
const ariaLabel = t`Command Menu`;
- const tooltipContent = t`Command menu | ${getOsControlSymbol()}K`;
+ const tooltipContent = t`Command menu | ${formatShortcut({ shortcut: ['Mod', 'K'] })}`;
return (
<StyledButtonWrapper alignToTop={alignWithSidePanelTopBar}>
diff --git a/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelToggleButton.test.tsx b/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelToggleButton.test.tsx
index b032d3fec13..a99a82165fb 100644
--- a/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelToggleButton.test.tsx
+++ b/packages/twenty-front/src/modules/side-panel/components/__tests__/SidePanelToggleButton.test.tsx
@@ -22,7 +22,6 @@ let mockIsMobile = false;
jest.mock('twenty-ui/utilities', () => ({
useIsMobile: () => mockIsMobile,
- getOsControlSymbol: () => '⌘',
}));
const renderSidePanelToggleButton = ({
@@ -65,8 +64,13 @@ const renderSidePanelToggleButton = ({
describe('SidePanelToggleButton', () => {
beforeEach(() => {
mockIsMobile = false;
+ jest
+ .spyOn(window.navigator, 'userAgent', 'get')
+ .mockReturnValue('Macintosh; Intel Mac OS X');
});
+ afterEach(() => jest.restoreAllMocks());
+
it('opens the command menu when the side panel is closed', () => {
const { store } = renderSidePanelToggleButton();
diff --git a/packages/twenty-front/src/modules/side-panel/pages/compose-calendar-event/components/SidePanelComposeCalendarEventPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/compose-calendar-event/components/SidePanelComposeCalendarEventPage.tsx
index c7a1d9105e9..f8e7484b604 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/compose-calendar-event/components/SidePanelComposeCalendarEventPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/compose-calendar-event/components/SidePanelComposeCalendarEventPage.tsx
@@ -16,7 +16,6 @@ import { isDefined } from 'twenty-shared/utils';
import { IconButton, useToast } from 'twenty-ui/components';
import { IconCalendarEvent, IconTrash } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
-import { getOsControlSymbol } from 'twenty-ui/utilities';
import { PermissionFlagType } from '~/generated-metadata/graphql';
import { useNavigateSettings } from '~/hooks/useNavigateSettings';
@@ -115,7 +114,7 @@ export const SidePanelComposeCalendarEventPage = () => {
key="create"
size="sm"
startIcon={<IconCalendarEvent />}
- hotkeys={[getOsControlSymbol(), '⏎']}
+ shortcut={['Mod', 'Enter']}
onClick={composerState.handleCreate}
disabled={!composerState.canCreate}
variant="solid"
diff --git a/packages/twenty-front/src/modules/side-panel/pages/compose-email/components/SidePanelComposeEmailPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/compose-email/components/SidePanelComposeEmailPage.tsx
index f13cd418511..f4d9a9ba7bc 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/compose-email/components/SidePanelComposeEmailPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/compose-email/components/SidePanelComposeEmailPage.tsx
@@ -17,7 +17,6 @@ import { t } from '@lingui/core/macro';
import { IconPaperclip, IconSend, IconTrash } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
import { IconButton } from 'twenty-ui/components';
-import { getOsControlSymbol } from 'twenty-ui/utilities';
import { useAttachEmailFiles } from '@/activities/emails/hooks/useAttachEmailFiles';
@@ -116,7 +115,7 @@ export const SidePanelComposeEmailPage = () => {
key="send"
size="sm"
startIcon={<IconSend />}
- hotkeys={[getOsControlSymbol(), '⏎']}
+ shortcut={['Mod', 'Enter']}
onClick={composerState.handleSend}
disabled={!canSend}
variant="solid"
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/TabSettingsPlacementSection.tsx b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/TabSettingsPlacementSection.tsx
index fa218cd6498..a53ce28924e 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/TabSettingsPlacementSection.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/components/TabSettingsPlacementSection.tsx
@@ -1,7 +1,5 @@
-import {
- CommandMenuItem,
- type CommandMenuItemProps,
-} from '@/command-menu/components/CommandMenuItem';
+import { CommandMenuItem } from '@/command-menu/components/CommandMenuItem';
+import { type CommandMenuItemProps } from '@/command-menu/types/CommandMenuItemProps';
import { SidePanelGroup } from '@/side-panel/components/SidePanelGroup';
import { SelectableListItem } from '@/ui/layout/selectable-list/components/SelectableListItem';
import { useLingui } from '@lingui/react/macro';
diff --git a/packages/twenty-front/src/modules/side-panel/pages/page-layout/utils/getTabSettingsPlacementItems.ts b/packages/twenty-front/src/modules/side-panel/pages/page-layout/utils/getTabSettingsPlacementItems.ts
index 76226aec1c2..48e87870346 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/page-layout/utils/getTabSettingsPlacementItems.ts
+++ b/packages/twenty-front/src/modules/side-panel/pages/page-layout/utils/getTabSettingsPlacementItems.ts
@@ -1,4 +1,4 @@
-import { type CommandMenuItemProps } from '@/command-menu/components/CommandMenuItem';
+import { type CommandMenuItemProps } from '@/command-menu/types/CommandMenuItemProps';
import { TAB_SETTINGS_SELECTABLE_ITEM_IDS } from '@/side-panel/pages/page-layout/constants/settings/TabSettingsSelectableItemIds';
import { t } from '@lingui/core/macro';
import { isDefined } from 'twenty-shared/utils';
diff --git a/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/SidePanelRecordCreationFormPage.tsx b/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/SidePanelRecordCreationFormPage.tsx
index f387f23dc14..0c69b1bdbf3 100644
--- a/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/SidePanelRecordCreationFormPage.tsx
+++ b/packages/twenty-front/src/modules/side-panel/pages/record-creation-form/components/SidePanelRecordCreationFormPage.tsx
@@ -30,7 +30,6 @@ import { isDefined } from 'twenty-shared/utils';
import { IconPlus } from 'twenty-ui/icon';
import { Button } from 'twenty-ui/primitives/input';
import { useTheme, themeCssVariables } from 'twenty-ui/theme';
-import { getOsControlSymbol } from 'twenty-ui/utilities';
const StyledContainer = styled.div`
display: flex;
@@ -237,7 +236,7 @@ const SidePanelRecordCreationForm = ({
size="sm"
onClick={handleCreateClick}
loading={isSubmitting}
- hotkeys={[getOsControlSymbol(), '⏎']}
+ shortcut={['Mod', 'Enter']}
data-testid="record-creation-form-create-button"
variant="solid"
color="accent"
diff --git a/packages/twenty-front/src/modules/ui/layout/side-panel/types/SidePanelFooterCommandMenuItem.ts b/packages/twenty-front/src/modules/ui/layout/side-panel/types/SidePanelFooterCommandMenuItem.ts
index f4e0217d80d..709244fd0fd 100644
--- a/packages/twenty-front/src/modules/ui/layout/side-panel/types/SidePanelFooterCommandMenuItem.ts
+++ b/packages/twenty-front/src/modules/ui/layout/side-panel/types/SidePanelFooterCommandMenuItem.ts
@@ -1,3 +1,4 @@
+import { type ShortcutDefinition } from 'twenty-ui/primitives/typography';
import { type IconComponent } from 'twenty-ui/icon';
export type SidePanelFooterCommandMenuItem = {
@@ -8,5 +9,5 @@ export type SidePanelFooterCommandMenuItem = {
isPinned?: boolean;
onClick: () => void;
disabled?: boolean;
- hotkeys?: string[];
+ shortcut?: ShortcutDefinition;
};
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
index f604ce56ae7..72797c7034c 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx
@@ -1,3 +1,5 @@
+import { type NavigationDrawerItemProps } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerItemProps';
+import { isObject } from '@sniptt/guards';
import { useIsNavigationDrawerContentExpanded } from '@/navigation/hooks/useIsNavigationDrawerContentExpanded';
import { TooltipDelay } from '@/ui/layout/tooltip/constants/TooltipDelay';
import { NavigationDrawerAnimatedCollapseWrapper } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerAnimatedCollapseWrapper';
@@ -5,55 +7,24 @@ import { NavigationDrawerItemBreadcrumb } from '@/ui/navigation/navigation-drawe
import { NAVIGATION_DRAWER_COLLAPSED_BUTTON_SIZE } from '@/ui/navigation/navigation-drawer/constants/NavigationDrawerCollapsedButtonSize';
import { NavigationDrawerItemEditingContext } from '@/ui/navigation/navigation-drawer/contexts/NavigationDrawerItemEditingContext';
import { useNavigationDrawerTooltip } from '@/ui/navigation/navigation-drawer/hooks/useNavigationDrawerTooltip';
-import { type NavigationDrawerSubItemState } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerSubItemState';
import { isNavigationDrawerExpandedState } from '@/ui/navigation/states/isNavigationDrawerExpanded';
import { useMouseDownNavigation } from '@/ui/navigation/utils/hooks/useMouseDownNavigation';
-import { type TriggerEventType } from '@/ui/navigation/utils/types/TriggerEventType';
import { useIsMobile } from 'twenty-ui/utilities';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { styled } from '@linaria/react';
import { t } from '@lingui/core/macro';
-import { type JSX, type ReactNode, useContext } from 'react';
+import { useContext } from 'react';
import { Link } from 'react-router-dom';
import { isDefined } from 'twenty-shared/utils';
-import { type IconComponent, type TablerIconsProps } from 'twenty-ui/icon';
import { Pill } from 'twenty-ui/primitives/data-display';
import { Tooltip } from 'twenty-ui/primitives/surfaces';
import {
- Text,
+ Shortcut,
OverflowingTextWithTooltip,
} from 'twenty-ui/primitives/typography';
import { MOBILE_VIEWPORT, useTheme, themeCssVariables } from 'twenty-ui/theme';
const DEFAULT_INDENTATION_LEVEL = 1;
-export type NavigationDrawerItemIndentationLevel = 1 | 2;
-
-export type NavigationDrawerItemModifier =
- | 'soon'
- | 'new'
- | { keyboard: string[] };
-
-export type NavigationDrawerItemProps = {
- className?: string;
- label: string;
- secondaryLabel?: string;
- indentationLevel?: NavigationDrawerItemIndentationLevel;
- subItemState?: NavigationDrawerSubItemState;
- to?: string;
- onClick?: () => void;
- Icon?: IconComponent | ((props: TablerIconsProps) => JSX.Element);
- active?: boolean;
- modifier?: NavigationDrawerItemModifier;
- rightOptions?: ReactNode;
- alwaysShowRightOptions?: boolean;
- isDragging?: boolean;
- isRightOptionsDropdownOpen?: boolean;
- triggerEvent?: TriggerEventType;
- preventCollapseOnMobile?: boolean;
- isSelectedInEditMode?: boolean;
- variant?: 'default' | 'tertiary' | 'placeholder';
-};
-
type StyledItemProps = Pick<
NavigationDrawerItemProps,
| 'active'
@@ -171,21 +142,6 @@ const StyledItemSecondaryLabel = styled.span`
font-weight: ${themeCssVariables.font.weight.regular};
`;
-const StyledKeyBoardShortcut = styled.span`
- align-items: center;
- background: ${themeCssVariables.background.transparent.lighter};
- border: 1px solid ${themeCssVariables.border.color.strong};
- border-radius: ${themeCssVariables.border.radius.md};
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- gap: ${themeCssVariables.spacing[2]};
-
- height: ${themeCssVariables.spacing[4]};
- justify-content: center;
- width: ${themeCssVariables.spacing[4]};
-`;
-
const StyledNavigationDrawerItemContainer = styled.div`
display: flex;
width: 100%;
@@ -271,10 +227,7 @@ export const NavigationDrawerItem = ({
const isSoon = modifier === 'soon';
const isNew = modifier === 'new';
- const keyboardKeys =
- isDefined(modifier) && typeof modifier === 'object'
- ? modifier.keyboard
- : undefined;
+ const keyboardKeys = isObject(modifier) ? modifier.keyboard : undefined;
const showBreadcrumb = indentationLevel === 2;
const showStyledSpacer = isDefined(modifier) || isDefined(rightOptions);
@@ -432,9 +385,11 @@ export const NavigationDrawerItem = ({
{isDefined(keyboardKeys) && (
<NavigationDrawerAnimatedCollapseWrapper>
- <StyledKeyBoardShortcut className="keyboard-shortcuts">
- <StyledDisplayLabel>{keyboardKeys}</StyledDisplayLabel>
- </StyledKeyBoardShortcut>
+ <Shortcut
+ className="keyboard-shortcuts"
+ shortcut={keyboardKeys}
+ sequenceJoinLabel={t`then`}
+ />
</NavigationDrawerAnimatedCollapseWrapper>
)}
@@ -478,9 +433,3 @@ export const NavigationDrawerItem = ({
</StyledNavigationDrawerItemContainer>
);
};
-
-const StyledDisplayLabel = styled(Text)`
- color: var(--t-font-color-light);
- font-size: 11px;
- font-weight: var(--t-font-weight-semi-bold);
-`;
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem.tsx
index 539e0727b29..253df5bcd3e 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerSubItem.tsx
@@ -1,7 +1,5 @@
-import {
- NavigationDrawerItem,
- type NavigationDrawerItemProps,
-} from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
+import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
+import { type NavigationDrawerItemProps } from '@/ui/navigation/navigation-drawer/types/NavigationDrawerItemProps';
type NavigationDrawerSubItemProps = NavigationDrawerItemProps;
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawer.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawer.stories.tsx
index c6a827eea30..8c126a76ed8 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawer.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawer.stories.tsx
@@ -36,7 +36,6 @@ import {
IconUserCircle,
IconUsers,
} from 'twenty-ui/icon';
-import { getOsControlSymbol } from 'twenty-ui/utilities';
import { NavigationDrawer } from '@/ui/navigation/navigation-drawer/components/NavigationDrawer';
import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
@@ -91,7 +90,7 @@ export const Default: Story = {
<NavigationDrawerItem
label="Search"
Icon={IconSearch}
- modifier={{ keyboard: [`${getOsControlSymbol()}`, 'K'] }}
+ modifier={{ keyboard: ['Mod', 'K'] }}
/>
<NavigationDrawerItem
label="Settings"
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawerItem.stories.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawerItem.stories.tsx
index caa3192e587..e22b4261d08 100644
--- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawerItem.stories.tsx
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/__stories__/NavigationDrawerItem.stories.tsx
@@ -4,7 +4,6 @@ import { type Meta, type StoryObj } from '@storybook/react-vite';
import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItem';
import { IconSearch } from 'twenty-ui/icon';
import { CatalogDecorator, type CatalogStory } from 'twenty-ui/testing';
-import { getOsControlSymbol } from 'twenty-ui/utilities';
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
import { MemoryRouterDecorator } from '~/testing/decorators/MemoryRouterDecorator';
@@ -112,7 +111,7 @@ export const NewPill: Story = {
args={{
label: 'Feature with Keyboard Shortcut',
Icon: IconSearch,
- modifier: { keyboard: [getOsControlSymbol(), 'N'] },
+ modifier: { keyboard: ['Mod', 'N'] },
}}
/>
</StyledContainer>
@@ -210,7 +209,7 @@ export const Catalog: CatalogStory<Story, typeof NavigationDrawerItem> = {
: adornmentName === 'Keyboard Keys'
? {
modifier: {
- keyboard: [getOsControlSymbol(), 'K'],
+ keyboard: ['Mod', 'K'],
},
}
: {},
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemIndentationLevel.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemIndentationLevel.ts
new file mode 100644
index 00000000000..dbc76c17202
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemIndentationLevel.ts
@@ -0,0 +1 @@
+export type NavigationDrawerItemIndentationLevel = 1 | 2;
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemModifier.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemModifier.ts
new file mode 100644
index 00000000000..7691197e0e4
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemModifier.ts
@@ -0,0 +1,6 @@
+import { type ShortcutDefinition } from 'twenty-ui/primitives/typography';
+
+export type NavigationDrawerItemModifier =
+ | 'soon'
+ | 'new'
+ | { keyboard: ShortcutDefinition };
diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemProps.ts b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemProps.ts
new file mode 100644
index 00000000000..570fcbaf0ec
--- /dev/null
+++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/types/NavigationDrawerItemProps.ts
@@ -0,0 +1,27 @@
+import { type JSX, type ReactNode } from 'react';
+import { type IconComponent, type TablerIconsProps } from 'twenty-ui/icon';
+import { type NavigationDrawerItemIndentationLevel } from './NavigationDrawerItemIndentationLevel';
+import { type NavigationDrawerItemModifier } from './NavigationDrawerItemModifier';
+import { type NavigationDrawerSubItemState } from './NavigationDrawerSubItemState';
+import { type TriggerEventType } from '@/ui/navigation/utils/types/TriggerEventType';
+
+export type NavigationDrawerItemProps = {
+ className?: string;
+ label: string;
+ secondaryLabel?: string;
+ indentationLevel?: NavigationDrawerItemIndentationLevel;
+ subItemState?: NavigationDrawerSubItemState;
+ to?: string;
+ onClick?: () => void;
+ Icon?: IconComponent | ((props: TablerIconsProps) => JSX.Element);
+ active?: boolean;
+ modifier?: NavigationDrawerItemModifier;
+ rightOptions?: ReactNode;
+ alwaysShowRightOptions?: boolean;
+ isDragging?: boolean;
+ isRightOptionsDropdownOpen?: boolean;
+ triggerEvent?: TriggerEventType;
+ preventCollapseOnMobile?: boolean;
+ isSelectedInEditMode?: boolean;
+ variant?: 'default' | 'tertiary' | 'placeholder';
+};
diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepCmdEnterButton.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepCmdEnterButton.tsx
index 3aea8dc8cc8..e1d54baa8ed 100644
--- a/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepCmdEnterButton.tsx
+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/components/WorkflowStepCmdEnterButton.tsx
@@ -2,7 +2,6 @@ import { SIDE_PANEL_FOCUS_ID } from '@/side-panel/constants/SidePanelFocusId';
import { useHotkeysOnFocusedElement } from '@/ui/utilities/hotkey/hooks/useHotkeysOnFocusedElement';
import { Key } from 'ts-key-enum';
import { Button } from 'twenty-ui/primitives/input';
-import { getOsControlSymbol } from 'twenty-ui/utilities';
export const WorkflowStepCmdEnterButton = ({
title,
@@ -25,7 +24,7 @@ export const WorkflowStepCmdEnterButton = ({
size="sm"
onClick={onClick}
disabled={disabled}
- hotkeys={[getOsControlSymbol(), '⏎']}
+ shortcut={['Mod', 'Enter']}
variant={disabled ? 'outline' : 'solid'}
color="accent"
>
diff --git a/packages/twenty-shared/src/constants/DocumentationPaths.ts b/packages/twenty-shared/src/constants/DocumentationPaths.ts
index 3c7c095c0ca..dcfed9e1559 100644
--- a/packages/twenty-shared/src/constants/DocumentationPaths.ts
+++ b/packages/twenty-shared/src/constants/DocumentationPaths.ts
@@ -200,6 +200,7 @@ export const DOCUMENTATION_PATHS = {
UI_PRIMITIVES_TYPOGRAPHY_HEADING: '/ui/primitives/typography/heading',
UI_PRIMITIVES_TYPOGRAPHY_OVERFLOWING_TEXT_WITH_TOOLTIP:
'/ui/primitives/typography/overflowing-text-with-tooltip',
+ UI_PRIMITIVES_TYPOGRAPHY_SHORTCUT: '/ui/primitives/typography/shortcut',
UI_PRIMITIVES_TYPOGRAPHY_TEXT: '/ui/primitives/typography/text',
UI_SSR: '/ui/ssr',
UI_TESTING: '/ui/testing',
diff --git a/packages/twenty-ui/docs/buttonPropDescriptions.ts b/packages/twenty-ui/docs/buttonPropDescriptions.ts
index b9b00cb691c..d54f4cdb652 100644
--- a/packages/twenty-ui/docs/buttonPropDescriptions.ts
+++ b/packages/twenty-ui/docs/buttonPropDescriptions.ts
@@ -12,7 +12,9 @@ export const BUTTON_PROP_DESCRIPTIONS = {
'Adds a shadow and backdrop blur. Neutral outline buttons also use elevated surface colors.',
startIcon: 'Decorative content displayed before the label.',
endIcon: 'Decorative content displayed after the label.',
- hotkeys: 'Keyboard shortcut hints displayed on non-mobile screens.',
+ shortcutJoinLabel: 'Localized text between sequence steps. Defaults to then.',
+ shortcut:
+ 'Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Displayed on non-mobile screens.',
href: 'Destination URL. Enables native link semantics instead of button semantics.',
render:
'Caller-supplied root element or renderer. Preserve a native button, or an anchor when `href` is set. Router integration belongs to the caller.',
diff --git a/packages/twenty-ui/docs/components.ts b/packages/twenty-ui/docs/components.ts
index 75ecff80973..fd7b5555ddf 100644
--- a/packages/twenty-ui/docs/components.ts
+++ b/packages/twenty-ui/docs/components.ts
@@ -60,6 +60,24 @@ import { TOOLTIP_PROP_DESCRIPTIONS } from './tooltipPropDescriptions';
import { VISIBILITY_HIDDEN_PROP_DESCRIPTIONS } from './visibilityHiddenPropDescriptions';
export const DOCUMENTED_COMPONENTS = [
+ {
+ name: 'Shortcut',
+ source: 'primitives/typography/Shortcut/Shortcut.tsx',
+ entryPoint: 'twenty-ui/primitives/typography',
+ slug: 'typography/shortcut',
+ propDescriptions: {
+ shortcut:
+ 'Flat key array for a simultaneous combination, or nested key arrays for an ordered sequence of combinations.',
+ platform:
+ 'Optional mac or other platform override. Defaults to server-safe device detection.',
+ sequenceJoinLabel: 'Text between sequence steps. Defaults to then.',
+ combinationSeparator:
+ 'Optional separator between simultaneous keys. Defaults to no separator on Apple devices and a space elsewhere.',
+ variant: 'Keycaps, inline text, or a separated button hint.',
+ visibility:
+ 'Always visible by default. Desktop hints hide on mobile viewports.',
+ },
+ },
{
name: 'VisibilityHidden',
source: 'primitives/accessibility/components/VisibilityHidden.tsx',
@@ -260,8 +278,8 @@ export const DOCUMENTED_COMPONENTS = [
entryPoint: 'twenty-ui/primitives/navigation',
slug: 'navigation/list-item',
propDescriptions: {
- hotkeysJoinLabel:
- 'Text between shortcut keys. Defaults to `then`; pass an empty string to omit it.',
+ shortcutJoinLabel:
+ 'Text between sequential shortcut steps. Defaults to `then`; pass an empty string to omit it.',
actionsVisibility:
'When trailing actions are visible: on hover and focus, or always.',
},
@@ -314,16 +332,20 @@ export const DOCUMENTED_COMPONENTS = [
slug: 'surfaces/menu',
partPropDescriptions: {
Item: {
- hotkeysJoinLabel: 'Text between shortcut keys. Defaults to `then`.',
+ shortcutJoinLabel:
+ 'Text between sequential shortcut steps. Defaults to `then`.',
},
CheckboxItem: {
- hotkeysJoinLabel: 'Text between shortcut keys. Defaults to `then`.',
+ shortcutJoinLabel:
+ 'Text between sequential shortcut steps. Defaults to `then`.',
},
RadioItem: {
- hotkeysJoinLabel: 'Text between shortcut keys. Defaults to `then`.',
+ shortcutJoinLabel:
+ 'Text between sequential shortcut steps. Defaults to `then`.',
},
SubmenuTrigger: {
- hotkeysJoinLabel: 'Text between shortcut keys. Defaults to `then`.',
+ shortcutJoinLabel:
+ 'Text between sequential shortcut steps. Defaults to `then`.',
onClick: 'The click handler for the submenu trigger.',
},
},
diff --git a/packages/twenty-ui/docs/dropdownPartPropDescriptions.ts b/packages/twenty-ui/docs/dropdownPartPropDescriptions.ts
index cb5a94b8c0e..d0e6719bac8 100644
--- a/packages/twenty-ui/docs/dropdownPartPropDescriptions.ts
+++ b/packages/twenty-ui/docs/dropdownPartPropDescriptions.ts
@@ -27,7 +27,8 @@ const DROPDOWN_ROOT_PROP_DESCRIPTIONS = {
} satisfies Partial<Record<keyof DropdownRootProps, string>>;
const DROPDOWN_ITEM_PROP_DESCRIPTIONS = {
- hotkeysJoinLabel: 'Text between shortcut keys. Defaults to `then`.',
+ shortcutJoinLabel:
+ 'Text between sequential shortcut steps. Defaults to `then`.',
className: 'CSS class applied to the row.',
style: 'Inline styles applied to the row.',
render:
diff --git a/packages/twenty-ui/docs/label-ownership.md b/packages/twenty-ui/docs/label-ownership.md
index c124abd78c9..e155b899bed 100644
--- a/packages/twenty-ui/docs/label-ownership.md
+++ b/packages/twenty-ui/docs/label-ownership.md
@@ -2,20 +2,22 @@
This covers production exports under components, primitives, and icons, including the Dropdown compound API.
-| Surface | Text ownership |
-| ------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Callout | `title`, `description`, `action.label`, and `closeLabel` (default `Close`). |
-| ListItem and Menu item parts | Children, description, action slots, native accessible attributes, and `hotkeysJoinLabel` (default `then`). |
-| Dropdown | Children name actions, options, titles, sections, empty states, and loading states. `Back` children default to `Back`. Search accepts native placeholder and accessible attributes. Close requires a caller-supplied accessible label and accepts native `aria-labelledby`. Item parts pass `hotkeysJoinLabel` to ListItem. |
-| Legacy menu compositions | MenuItem exposes `text`, contextual slots, and `hotKeysJoinLabel` (default `then`). Avatar, draggable, suggestion, and picker presets receive their text from callers; they add no English fallback. Keep this additive option until their separate migration removes the exports. |
-| Button, MainButton, LightButton | Children and native accessible attributes. Applications compose upcoming-feature labels with Pill. Loading preserves the supplied name and marks the button busy; its spinner is decorative. Button shortcut key combinations contain no word separator. |
-| IconButton and LightIconButton | Caller-supplied accessible label and optional tooltip. Native `aria-labelledby` remains available and takes precedence. |
-| SearchInput | Caller-owned placeholder and native accessible name; `filterButtonAriaLabel` defaults to `Filter`. Referenced labels take precedence over explicit labels and placeholder fallback. |
-| Toast and Toaster | Children, description and action slots, `iconLabel`, `cancelLabel` (default `Cancel`), and `closeLabel` (default `Close`). Toaster accepts native accessible attributes over its `Notifications` region default. |
-| Chip and Avatar | Chip `emptyLabel` defaults to `Untitled`. Avatar accepts native accessible names over its interactive fallback of the supplied name or `Avatar`. The visual initial or dash is hidden from assistive technology; the image has empty alternative text. |
-| JsonTree | Callers supply empty string, array, and object labels and expanded/collapsed arrow names. JSON booleans, null, property names, and values are data. |
-| ResizeHandle and CodeEditor | ResizeHandle accepts native labels over `Resize`. CodeEditor exposes `resizeLabel` (default `Resize editor`) and Monaco `options`, including its editor accessible label. The loading indicator adds no text. Monaco owns its internal editor messages. |
-| Input, Textarea, Select, Field, Slider, Radio, RadioGroup, Checkbox, Switch, SegmentedControl | Native attributes, compound label/description/error parts, options, and children belong to the caller. Browser validation messages remain browser-owned; Field.Error children or render content can replace them. |
-| Dialog, AlertDialog, Popover, Tooltip, Tabs | Text belongs to title, description, close, trigger, tab, and popup parts. No built-in English action or status strings. |
-| Banner, InlineBanner, SettingsRow, Section, NavigationBar, CommandBlock | Content and labels belong to supplied props or children. |
-| Tag, Status, Pill, AvatarGroup, NotificationCounter, ColorSample, TintedIconTile, typography, layout and icon exports | Caller content, data values, native accessible attributes where supported, or decorative output. Loader and progress graphics add no built-in English loading message. |
+| Surface | Text ownership |
+| --------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Callout | `title`, `description`, `action.label`, and `closeLabel` (default `Close`). |
+| ListItem and Menu item parts | Children, description, action slots, native accessible attributes, and `shortcutJoinLabel` (default `then`). |
+| Dropdown | Children name actions, options, titles, sections, empty states, and loading states. `Back` children default to `Back`. Search accepts native placeholder and accessible attributes. Close requires a caller-supplied accessible label and accepts native `aria-labelledby`. Item parts pass `shortcutJoinLabel` to ListItem. |
+| Legacy menu compositions | MenuItem exposes `text`, contextual slots, and `shortcutJoinLabel` (default `then`). Avatar, draggable, suggestion, and picker presets receive their text from callers; they add no English fallback. Keep this additive option until their separate migration removes the exports. |
+| Button, MainButton, LightButton | Children and native accessible attributes. Applications compose upcoming-feature labels with Pill. Loading preserves the supplied name and marks the button busy; its spinner is decorative. Button hints use the shared Shortcut presentation and remain decorative. `shortcutJoinLabel` supplies the sequence join label. |
+| IconButton and LightIconButton | Caller-supplied accessible label and optional tooltip. Native `aria-labelledby` remains available and takes precedence. |
+| SearchInput | Caller-owned placeholder and native accessible name; `filterButtonAriaLabel` defaults to `Filter`. Referenced labels take precedence over explicit labels and placeholder fallback. |
+| Toast and Toaster | Children, description and action slots, `iconLabel`, `cancelLabel` (default `Cancel`), and `closeLabel` (default `Close`). Toaster accepts native accessible attributes over its `Notifications` region default. |
+| Chip and Avatar | Chip `emptyLabel` defaults to `Untitled`. Avatar accepts native accessible names over its interactive fallback of the supplied name or `Avatar`. The visual initial or dash is hidden from assistive technology; the image has empty alternative text. |
+| JsonTree | Callers supply empty string, array, and object labels and expanded/collapsed arrow names. JSON booleans, null, property names, and values are data. |
+| ResizeHandle and CodeEditor | ResizeHandle accepts native labels over `Resize`. CodeEditor exposes `resizeLabel` (default `Resize editor`) and Monaco `options`, including its editor accessible label. The loading indicator adds no text. Monaco owns its internal editor messages. |
+| Input, Textarea, Select, Field, Slider, Radio, RadioGroup, Checkbox, Switch, SegmentedControl | Native attributes, compound label/description/error parts, options, and children belong to the caller. Browser validation messages remain browser-owned; Field.Error children or render content can replace them. |
+| Dialog, AlertDialog, Popover, Tooltip, Tabs | Text belongs to title, description, close, trigger, tab, and popup parts. No built-in English action or status strings. |
+| Banner, InlineBanner, SettingsRow, Section, NavigationBar, CommandBlock | Content and labels belong to supplied props or children. |
+| Tag, Status, Pill, AvatarGroup, NotificationCounter, ColorSample, TintedIconTile, typography, layout and icon exports | Caller content, data values, native accessible attributes where supported, or decorative output. Loader and progress graphics add no built-in English loading message. |
+
+Shortcut owns symbol and separator formatting for visual hints and strings. Flat key arrays represent simultaneous combinations; nested key arrays represent ordered sequences of combinations. Hosts supply `sequenceJoinLabel` (default `then`), optional `combinationSeparator`, and native accessible labels. The `shortcutJoinLabel` props on host controls forward the sequence label.
diff --git a/packages/twenty-ui/docs/menuItemPropDescriptions.ts b/packages/twenty-ui/docs/menuItemPropDescriptions.ts
index 86cd7536598..3aed296da8a 100644
--- a/packages/twenty-ui/docs/menuItemPropDescriptions.ts
+++ b/packages/twenty-ui/docs/menuItemPropDescriptions.ts
@@ -28,7 +28,9 @@ export const MENU_ITEM_PROP_DESCRIPTIONS = {
hasSubMenu: 'Shows a submenu chevron; does not create a submenu.',
focused: 'Applies focused appearance without moving DOM focus.',
selected: 'Applies selected appearance without owning selection state.',
- hotKeys: 'Visible shortcut hints. Register handlers in the application.',
- hotKeysJoinLabel: 'Text between shortcut keys. Defaults to `then`.',
+ shortcut:
+ 'Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Register handlers in the application.',
+ shortcutJoinLabel:
+ 'Text between sequential shortcut steps. Defaults to `then`.',
isSubMenuOpened: 'Applies the open treatment to the submenu chevron.',
} satisfies Partial<Record<keyof ComponentProps<typeof MenuItem>, string>>;
diff --git a/packages/twenty-ui/docs/module-ownership.json b/packages/twenty-ui/docs/module-ownership.json
index e981c6aa2c3..f8c6e2d39db 100644
--- a/packages/twenty-ui/docs/module-ownership.json
+++ b/packages/twenty-ui/docs/module-ownership.json
@@ -28,6 +28,7 @@
"ResizeHandle",
"SegmentedControl",
"Select",
+ "Shortcut",
"Slider",
"Status",
"Switch",
diff --git a/packages/twenty-ui/docs/public-exports.json b/packages/twenty-ui/docs/public-exports.json
index c81c1ec24a4..fd5138551b0 100644
--- a/packages/twenty-ui/docs/public-exports.json
+++ b/packages/twenty-ui/docs/public-exports.json
@@ -836,12 +836,17 @@
"primitives/typography": {
"reExports": [],
"values": {
+ "formatShortcut": "primitives/typography/Shortcut/formatShortcut",
"Heading": "primitives/typography/Heading/Heading",
"OverflowingTextWithTooltip": "primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip",
+ "Shortcut": "primitives/typography/Shortcut/Shortcut",
"Text": "primitives/typography/Text/Text"
},
"types": {
- "HeadingProps": "primitives/typography/Heading/types/HeadingProps"
+ "HeadingProps": "primitives/typography/Heading/types/HeadingProps",
+ "ShortcutDefinition": "primitives/typography/Shortcut/types/ShortcutDefinition",
+ "ShortcutFormatOptions": "primitives/typography/Shortcut/types/ShortcutFormatOptions",
+ "ShortcutProps": "primitives/typography/Shortcut/types/ShortcutProps"
}
},
"styles": {
@@ -898,7 +903,6 @@
"values": {
"getMainColorNameFromPaletteColorName": "utilities/color/utils/getMainColorNameFromPaletteColorName",
"getOsControlSymbol": "utilities/device/getOsControlSymbol",
- "getOsShortcutSeparator": "utilities/device/getOsShortcutSeparator",
"getSafeUrl": "utilities/utils/getSafeUrl",
"getUserDevice": "utilities/device/getUserDevice",
"isDefined": "utilities/utils/isDefined",
diff --git a/packages/twenty-ui/generated/components.docs.json b/packages/twenty-ui/generated/components.docs.json
index cae5b3d429e..a82d57a66ed 100644
--- a/packages/twenty-ui/generated/components.docs.json
+++ b/packages/twenty-ui/generated/components.docs.json
@@ -1,4 +1,53 @@
[
+ {
+ "name": "Shortcut",
+ "entryPoint": "twenty-ui/primitives/typography",
+ "slug": "typography/shortcut",
+ "props": [
+ {
+ "name": "combinationSeparator",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional separator between simultaneous keys. Defaults to no separator on Apple devices and a space elsewhere."
+ },
+ {
+ "name": "platform",
+ "type": "\"mac\" | \"other\"",
+ "required": false,
+ "defaultValue": null,
+ "description": "Optional mac or other platform override. Defaults to server-safe device detection."
+ },
+ {
+ "name": "sequenceJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequence steps. Defaults to then."
+ },
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": true,
+ "defaultValue": null,
+ "description": "Flat key array for a simultaneous combination, or nested key arrays for an ordered sequence of combinations."
+ },
+ {
+ "name": "variant",
+ "type": "\"button\" | \"keys\" | \"text\"",
+ "required": false,
+ "defaultValue": "keys",
+ "description": "Keycaps, inline text, or a separated button hint."
+ },
+ {
+ "name": "visibility",
+ "type": "\"always\" | \"desktop\"",
+ "required": false,
+ "defaultValue": "always",
+ "description": "Always visible by default. Desktop hints hide on mobile viewports."
+ }
+ ]
+ },
{
"name": "VisibilityHidden",
"entryPoint": "twenty-ui/primitives/accessibility",
@@ -900,13 +949,6 @@
"defaultValue": null,
"description": "Expands the button to fill its container width."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut hints displayed on non-mobile screens."
- },
{
"name": "href",
"type": "string",
@@ -928,6 +970,20 @@
"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": "size",
"type": "\"md\" | \"sm\"",
@@ -1012,13 +1068,6 @@
"defaultValue": null,
"description": "Expands the button to fill its container width."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut hints displayed on non-mobile screens."
- },
{
"name": "href",
"type": "string",
@@ -1040,6 +1089,20 @@
"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": "size",
"type": "\"md\" | \"sm\"",
@@ -1117,13 +1180,6 @@
"defaultValue": "false",
"description": "Expands the button to fill its container width."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut hints displayed on non-mobile screens."
- },
{
"name": "href",
"type": "string",
@@ -1145,6 +1201,20 @@
"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": "size",
"type": "\"md\" | \"sm\"",
@@ -3045,20 +3115,6 @@
"defaultValue": "false",
"description": "Shows a chevron indicating that the item opens a submenu."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`; pass an empty string to omit it."
- },
{
"name": "indicator",
"type": "\"check\" | \"checkbox\" | \"none\"",
@@ -3080,6 +3136,20 @@
"defaultValue": "false",
"description": "Whether the item is selected. Shows the check or checkbox indicator when\n`indicator` is set."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`; pass an empty string to omit it."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -4430,20 +4500,6 @@
"defaultValue": null,
"description": "Icon rendered after the content."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "label",
"type": "string",
@@ -4472,6 +4528,20 @@
"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."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -4554,20 +4624,6 @@
"defaultValue": null,
"description": "Icon rendered after the content."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "label",
"type": "string",
@@ -4603,6 +4659,20 @@
"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."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -4732,20 +4802,6 @@
"defaultValue": null,
"description": "Icon rendered after the content."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "label",
"type": "string",
@@ -4774,6 +4830,20 @@
"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."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -5030,20 +5100,6 @@
"defaultValue": null,
"description": "Icon rendered after the content."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "label",
"type": "string",
@@ -5079,6 +5135,20 @@
"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."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -7027,20 +7097,6 @@
"defaultValue": null,
"description": "Shows a chevron indicating that the item opens a submenu."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "nativeButton",
"type": "boolean",
@@ -7062,6 +7118,20 @@
"defaultValue": null,
"description": "Element rendered as the row instead of a native button. Custom components must forward the supplied props and ref."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -7137,20 +7207,6 @@
"defaultValue": null,
"description": "Shows a chevron indicating that the item opens a submenu."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "indicator",
"type": "\"check\" | \"checkbox\" | \"none\"",
@@ -7186,6 +7242,20 @@
"defaultValue": null,
"description": "Whether the option is selected. Exposed as `aria-checked` in menus and `aria-pressed` in other dropdown types."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -7398,20 +7468,6 @@
"defaultValue": null,
"description": "Shows a chevron indicating that the item opens a submenu."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "nativeButton",
"type": "boolean",
@@ -7426,6 +7482,20 @@
"defaultValue": null,
"description": "Element rendered as the row instead of a native button. Custom components must forward the supplied props and ref."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -7555,20 +7625,6 @@
"defaultValue": "true",
"description": "Shows a chevron indicating that the item opens a submenu."
},
- {
- "name": "hotkeys",
- "type": "string[]",
- "required": false,
- "defaultValue": null,
- "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
- },
- {
- "name": "hotkeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "nativeButton",
"type": "boolean",
@@ -7590,6 +7646,20 @@
"defaultValue": null,
"description": "Element rendered as the row instead of a native button. Custom components must forward the supplied props and ref."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Keyboard shortcut keys displayed at the end of the row. Registering the\nshortcut is up to the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "startIcon",
"type": "ReactNode",
@@ -8610,20 +8680,6 @@
"defaultValue": "false",
"description": "Shows a submenu chevron; does not create a submenu."
},
- {
- "name": "hotKeys",
- "type": "Nullable<string[]>",
- "required": false,
- "defaultValue": null,
- "description": "Visible shortcut hints. Register handlers in the application."
- },
- {
- "name": "hotKeysJoinLabel",
- "type": "string",
- "required": false,
- "defaultValue": null,
- "description": "Text between shortcut keys. Defaults to `then`."
- },
{
"name": "iconButtons",
"type": "ReactNode",
@@ -8715,6 +8771,20 @@
"defaultValue": "false",
"description": "Applies selected appearance without owning selection state."
},
+ {
+ "name": "shortcut",
+ "type": "ShortcutDefinition",
+ "required": false,
+ "defaultValue": null,
+ "description": "Flat key array for simultaneous keys, or nested key arrays for an ordered sequence. Register handlers in the application."
+ },
+ {
+ "name": "shortcutJoinLabel",
+ "type": "string",
+ "required": false,
+ "defaultValue": null,
+ "description": "Text between sequential shortcut steps. Defaults to `then`."
+ },
{
"name": "testId",
"type": "string",
diff --git a/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx b/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx
index 8c2b16e1aa4..dbed2b1bcbc 100644
--- a/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx
+++ b/packages/twenty-ui/src/components/__stories__/LabelOverrides.stories.tsx
@@ -53,14 +53,14 @@ export const CalloutDismissal: Story = {
export const ShortcutLabels: Story = {
render: () => (
<>
- <ListItem hotkeys={['G', 'D']}>Default shortcut</ListItem>
- <ListItem hotkeys={['G', 'S']} hotkeysJoinLabel="followed by">
+ <ListItem shortcut={[['G'], ['D']]}>Default shortcut</ListItem>
+ <ListItem shortcut={[['G'], ['S']]} shortcutJoinLabel="followed by">
Supplied shortcut
</ListItem>
<MenuItem
text="Legacy shortcut"
- hotKeys={['G', 'L']}
- hotKeysJoinLabel="next"
+ shortcut={[['G'], ['L']]}
+ shortcutJoinLabel="next"
/>
</>
),
@@ -131,24 +131,27 @@ export const MenuShortcutLabels: Story = {
<Menu.Root>
<Menu.Trigger render={<Button>Open shortcuts</Button>} />
<Menu.Popup aria-label="Shortcuts">
- <Menu.Item hotkeys={['G', 'D']}>Default</Menu.Item>
- <Menu.Item hotkeys={['G', 'A']} hotkeysJoinLabel="followed by">
+ <Menu.Item shortcut={[['G'], ['D']]}>Default</Menu.Item>
+ <Menu.Item shortcut={[['G'], ['A']]} shortcutJoinLabel="followed by">
Action
</Menu.Item>
- <Menu.CheckboxItem hotkeys={['G', 'C']} hotkeysJoinLabel="next">
+ <Menu.CheckboxItem shortcut={[['G'], ['C']]} shortcutJoinLabel="next">
Checkbox
</Menu.CheckboxItem>
<Menu.RadioGroup value="radio">
<Menu.RadioItem
value="radio"
- hotkeys={['G', 'R']}
- hotkeysJoinLabel="afterwards"
+ shortcut={[['G'], ['R']]}
+ shortcutJoinLabel="afterwards"
>
Radio
</Menu.RadioItem>
</Menu.RadioGroup>
<Menu.SubmenuRoot>
- <Menu.SubmenuTrigger hotkeys={['G', 'S']} hotkeysJoinLabel="and">
+ <Menu.SubmenuTrigger
+ shortcut={[['G'], ['S']]}
+ shortcutJoinLabel="and"
+ >
Submenu
</Menu.SubmenuTrigger>
<Menu.Popup>
@@ -198,26 +201,26 @@ export const DropdownLabels: Story = {
/>
<Dropdown.Empty>No matching choices</Dropdown.Empty>
<Dropdown.Loading>Fetching choices</Dropdown.Loading>
- <Dropdown.ActionItem hotkeys={['G', 'D']}>
+ <Dropdown.ActionItem shortcut={[['G'], ['D']]}>
Default shortcut
</Dropdown.ActionItem>
<Dropdown.ActionItem
- hotkeys={['G', 'A']}
- hotkeysJoinLabel="followed by"
+ shortcut={[['G'], ['A']]}
+ shortcutJoinLabel="followed by"
>
Action
</Dropdown.ActionItem>
<Dropdown.OptionItem
selected={false}
- hotkeys={['G', 'O']}
- hotkeysJoinLabel="next"
+ shortcut={[['G'], ['O']]}
+ shortcutJoinLabel="next"
>
Option
</Dropdown.OptionItem>
<Dropdown.Submenu>
<Dropdown.SubmenuTrigger
- hotkeys={['G', 'S']}
- hotkeysJoinLabel="afterwards"
+ shortcut={[['G'], ['S']]}
+ shortcutJoinLabel="afterwards"
>
Submenu
</Dropdown.SubmenuTrigger>
diff --git a/packages/twenty-ui/src/components/input/IconButton/types/IconButtonProps.ts b/packages/twenty-ui/src/components/input/IconButton/types/IconButtonProps.ts
index af18571abc5..809fb0b9f13 100644
--- a/packages/twenty-ui/src/components/input/IconButton/types/IconButtonProps.ts
+++ b/packages/twenty-ui/src/components/input/IconButton/types/IconButtonProps.ts
@@ -12,7 +12,8 @@ export type IconButtonProps = Omit<
| 'children'
| 'startIcon'
| 'endIcon'
- | 'hotkeys'
+ | 'shortcut'
+ | 'shortcutJoinLabel'
| 'fullWidth'
> & {
size?: IconButtonSize;
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownActionItem.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownActionItem.tsx
index 83b151c0e87..a281d5c1e36 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownActionItem.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownActionItem.tsx
@@ -16,8 +16,8 @@ export const DropdownActionItem = ({
endIcon,
description,
descriptionPlacement,
- hotkeys,
- hotkeysJoinLabel,
+ shortcut,
+ shortcutJoinLabel,
hasSubmenu,
children,
render,
@@ -93,8 +93,8 @@ export const DropdownActionItem = ({
endIcon={endIcon}
description={description}
descriptionPlacement={descriptionPlacement}
- hotkeys={hotkeys}
- hotkeysJoinLabel={hotkeysJoinLabel}
+ shortcut={shortcut}
+ shortcutJoinLabel={shortcutJoinLabel}
hasSubmenu={hasSubmenu ?? isDefined(page)}
>
{children}
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownOptionItem.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownOptionItem.tsx
index 3250f169b28..a0e0387728f 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownOptionItem.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownOptionItem.tsx
@@ -18,8 +18,8 @@ export const DropdownOptionItem = ({
endIcon,
description,
descriptionPlacement,
- hotkeys,
- hotkeysJoinLabel,
+ shortcut,
+ shortcutJoinLabel,
hasSubmenu,
children,
render,
@@ -79,8 +79,8 @@ export const DropdownOptionItem = ({
endIcon={endIcon}
description={description}
descriptionPlacement={descriptionPlacement}
- hotkeys={hotkeys}
- hotkeysJoinLabel={hotkeysJoinLabel}
+ shortcut={shortcut}
+ shortcutJoinLabel={shortcutJoinLabel}
hasSubmenu={hasSubmenu}
>
{children}
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownSubmenuTrigger.tsx b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownSubmenuTrigger.tsx
index cdb5927ef4d..16dad24e3a8 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownSubmenuTrigger.tsx
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/internal/DropdownSubmenuTrigger.tsx
@@ -18,8 +18,8 @@ export const DropdownSubmenuTrigger = ({
endIcon,
description,
descriptionPlacement,
- hotkeys,
- hotkeysJoinLabel,
+ shortcut,
+ shortcutJoinLabel,
hasSubmenu = true,
children,
render,
@@ -98,8 +98,8 @@ export const DropdownSubmenuTrigger = ({
endIcon={endIcon}
description={description}
descriptionPlacement={descriptionPlacement}
- hotkeys={hotkeys}
- hotkeysJoinLabel={hotkeysJoinLabel}
+ shortcut={shortcut}
+ shortcutJoinLabel={shortcutJoinLabel}
hasSubmenu={hasSubmenu}
>
{children}
diff --git a/packages/twenty-ui/src/components/navigation/Dropdown/types/DropdownActionItemProps.ts b/packages/twenty-ui/src/components/navigation/Dropdown/types/DropdownActionItemProps.ts
index bac19f79860..092d688ecdc 100644
--- a/packages/twenty-ui/src/components/navigation/Dropdown/types/DropdownActionItemProps.ts
+++ b/packages/twenty-ui/src/components/navigation/Dropdown/types/DropdownActionItemProps.ts
@@ -14,8 +14,8 @@ export type DropdownActionItemProps = Omit<
| 'endIcon'
| 'description'
| 'descriptionPlacement'
- | 'hotkeys'
- | 'hotkeysJoinLabel'
+ | 'shortcut'
+ | 'shortcutJoinLabel'
| 'hasSubmenu'
> & {
render?: ReactElement;
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.tsx
index c786540b3a7..c7a4f19bda0 100644
--- a/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.tsx
+++ b/packages/twenty-ui/src/components/navigation/MenuItem/MenuItem.tsx
@@ -1,3 +1,4 @@
+import { isDefined } from '@ui/utilities/utils/isDefined';
import { IconChevronRight } from '@ui/icon';
import { type MouseEvent } from 'react';
import { type MenuItemProps } from './types/MenuItemProps';
@@ -7,7 +8,7 @@ import {
StyledHoverableMenuItemBase,
StyledMenuItemRightContent,
} from '@ui/components/navigation/MenuItem/parts/StyledMenuItemBase';
-import { MenuItemHotKeys } from '@ui/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys';
+import { Shortcut } from '@ui/primitives/typography/Shortcut/Shortcut';
import { useTheme } from '@ui/theme';
import { clsx } from 'clsx';
@@ -36,8 +37,8 @@ export const MenuItem = ({
disabled = false,
focused = false,
selected = false,
- hotKeys,
- hotKeysJoinLabel,
+ shortcut,
+ shortcutJoinLabel,
isSubMenuOpened = false,
}: MenuItemProps) => {
const theme = useTheme();
@@ -79,8 +80,8 @@ export const MenuItem = ({
{iconButtons}
</StyledMenuItemRightContent>
)}
- {hotKeys && (
- <MenuItemHotKeys hotKeys={hotKeys} joinLabel={hotKeysJoinLabel} />
+ {isDefined(shortcut) && (
+ <Shortcut shortcut={shortcut} sequenceJoinLabel={shortcutJoinLabel} />
)}
{RightIcon && (
<RightIcon size={theme.icon.size.md} stroke={theme.icon.stroke.sm} />
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/__stories__/MenuItem.stories.tsx b/packages/twenty-ui/src/components/navigation/MenuItem/__stories__/MenuItem.stories.tsx
index b428b4b6447..b0c860ab64e 100644
--- a/packages/twenty-ui/src/components/navigation/MenuItem/__stories__/MenuItem.stories.tsx
+++ b/packages/twenty-ui/src/components/navigation/MenuItem/__stories__/MenuItem.stories.tsx
@@ -144,9 +144,9 @@ export const Catalog: CatalogStory<Story, typeof MenuItem> = {
export const HotKeysCatalog: CatalogStory<Story, typeof MenuItem> = {
args: {
- text: 'Menu item with hotkeys',
+ text: 'Menu item with shortcut',
LeftIcon: IconBell,
- hotKeys: ['⌘', 'K'],
+ shortcut: ['Mod', 'K'],
},
argTypes: {
className: { control: false },
@@ -159,23 +159,25 @@ export const HotKeysCatalog: CatalogStory<Story, typeof MenuItem> = {
dimensions: [
{
name: 'hotKeyTypes',
- values: ['no hotkeys', 'single key', 'modifier + key'],
+ values: ['no shortcut', 'single key', 'modifier + key'],
props: (choice: string) => {
switch (choice) {
- case 'no hotkeys':
- return { hotKeys: undefined };
+ case 'no shortcut':
+ return { shortcut: undefined };
case 'single key':
- return { hotKeys: ['K'] };
+ return { shortcut: ['K'] };
case 'modifier + key':
- return { hotKeys: ['⌘', 'K'] };
+ return {
+ shortcut: ['Mod', 'K'],
+ };
default:
return {};
}
},
labels: (choice: string) => {
switch (choice) {
- case 'no hotkeys':
- return 'No hotkeys';
+ case 'no shortcut':
+ return 'No shortcut';
case 'single key':
return 'Single key (K)';
case 'modifier + key':
diff --git a/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemProps.ts b/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemProps.ts
index 68672c23a80..0bad177e6e3 100644
--- a/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemProps.ts
+++ b/packages/twenty-ui/src/components/navigation/MenuItem/types/MenuItemProps.ts
@@ -1,7 +1,7 @@
+import { type ShortcutDefinition } from '@ui/primitives/typography/Shortcut/types/ShortcutDefinition';
import { type MenuItemAccent } from '@ui/components/navigation/MenuItem/types/MenuItemAccent';
import { type IconComponent } from '@ui/icon';
import { type ThemeColor } from '@ui/theme';
-import { type Nullable } from '@ui/utilities/types/Nullable';
import { type MouseEvent, type ReactNode } from 'react';
export type MenuItemProps = {
@@ -28,7 +28,7 @@ export type MenuItemProps = {
hasSubMenu?: boolean;
focused?: boolean;
selected?: boolean;
- hotKeys?: Nullable<string[]>;
- hotKeysJoinLabel?: string;
+ shortcut?: ShortcutDefinition;
+ shortcutJoinLabel?: string;
isSubMenuOpened?: boolean;
};
diff --git a/packages/twenty-ui/src/components/navigation/TabButton/types/TabButtonProps.ts b/packages/twenty-ui/src/components/navigation/TabButton/types/TabButtonProps.ts
index 23ed18ef53a..0e9b9fc0997 100644
--- a/packages/twenty-ui/src/components/navigation/TabButton/types/TabButtonProps.ts
+++ b/packages/twenty-ui/src/components/navigation/TabButton/types/TabButtonProps.ts
@@ -3,7 +3,13 @@ import { type TabsTabProps } from '@ui/primitives/navigation/Tabs/types/TabsTabP
export type TabButtonProps = Omit<
ButtonProps,
- 'variant' | 'color' | 'fullWidth' | 'loading' | 'elevated' | 'hotkeys'
+ | 'variant'
+ | 'color'
+ | 'fullWidth'
+ | 'loading'
+ | 'elevated'
+ | 'shortcut'
+ | 'shortcutJoinLabel'
> &
Pick<TabsTabProps, 'badge'> & {
active?: boolean;
diff --git a/packages/twenty-ui/src/primitives/input/Button/Button.tsx b/packages/twenty-ui/src/primitives/input/Button/Button.tsx
index b440f27a426..77d1730406b 100644
--- a/packages/twenty-ui/src/primitives/input/Button/Button.tsx
+++ b/packages/twenty-ui/src/primitives/input/Button/Button.tsx
@@ -3,10 +3,9 @@ import { clsx } from 'clsx';
import { useContext } from 'react';
import { Loader } from '@ui/primitives/feedback/Loader/Loader';
-import { ButtonHotkeys } from '@ui/primitives/input/Button/internal/ButtonHotKeys';
+import { Shortcut } from '@ui/primitives/typography/Shortcut/Shortcut';
import { ButtonGroupContext } from '@ui/primitives/input/ButtonGroup/internal/ButtonGroupContext';
import { mergeClassNames } from '@ui/utilities/internal/mergeClassNames';
-import { useIsMobile } from '@ui/utilities';
import { isDefined } from '@ui/utilities/utils/isDefined';
import styles from './Button.module.scss';
@@ -21,7 +20,8 @@ export const Button = ({
elevated = false,
startIcon,
endIcon,
- hotkeys,
+ shortcut,
+ shortcutJoinLabel,
disabled = false,
href,
render,
@@ -33,7 +33,6 @@ export const Button = ({
const resolvedVariant = buttonGroup?.variant ?? variant;
const resolvedColor = buttonGroup?.color ?? color;
const resolvedSize = buttonGroup?.size ?? size;
- const isMobile = useIsMobile();
const isLink = isDefined(href);
const linkProps = isLink ? { href } : undefined;
@@ -68,7 +67,15 @@ export const Button = ({
{endIcon}
</span>
)}
- {isDefined(hotkeys) && !isMobile && <ButtonHotkeys hotkeys={hotkeys} />}
+ {isDefined(shortcut) && (
+ <Shortcut
+ shortcut={shortcut}
+ sequenceJoinLabel={shortcutJoinLabel}
+ variant="button"
+ visibility="desktop"
+ aria-hidden
+ />
+ )}
</span>
{loading && (
<span className={styles.loader} aria-hidden>
diff --git a/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx b/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
index 5937ce5a566..d22c55e59de 100644
--- a/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
+++ b/packages/twenty-ui/src/primitives/input/Button/__stories__/Button.stories.tsx
@@ -182,7 +182,7 @@ export const Icons: Story = {
args: {
startIcon: <IconPlus />,
endIcon: <IconArrowRight />,
- hotkeys: ['⌘', '⏎'],
+ shortcut: ['Mod', 'Enter'],
},
};
export const Truncation: Story = {
diff --git a/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.module.scss b/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.module.scss
deleted file mode 100644
index 589ee7a629d..00000000000
--- a/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.module.scss
+++ /dev/null
@@ -1,7 +0,0 @@
-.hotkeys {
- border-inline-start: 1px solid currentColor;
- font-weight: var(--t-font-weight-medium);
- margin-inline-start: var(--t-spacing-1);
- opacity: 0.7;
- padding-inline-start: var(--t-spacing-2);
-}
diff --git a/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.module.scss.d.ts b/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.module.scss.d.ts
deleted file mode 100644
index 84db7fe9039..00000000000
--- a/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.module.scss.d.ts
+++ /dev/null
@@ -1,4 +0,0 @@
-declare const classNames: {
- readonly hotkeys: 'hotkeys';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.tsx b/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.tsx
deleted file mode 100644
index b509a8e0db1..00000000000
--- a/packages/twenty-ui/src/primitives/input/Button/internal/ButtonHotKeys.tsx
+++ /dev/null
@@ -1,11 +0,0 @@
-import { getOsShortcutSeparator } from '@ui/utilities';
-
-import styles from './ButtonHotKeys.module.scss';
-
-type ButtonHotkeysProps = { hotkeys: string[] };
-
-export const ButtonHotkeys = ({ hotkeys }: ButtonHotkeysProps) => (
- <span className={styles.hotkeys} aria-hidden>
- {hotkeys.join(getOsShortcutSeparator())}
- </span>
-);
diff --git a/packages/twenty-ui/src/primitives/input/Button/types/ButtonProps.ts b/packages/twenty-ui/src/primitives/input/Button/types/ButtonProps.ts
index 2c66f2de478..99de908f102 100644
--- a/packages/twenty-ui/src/primitives/input/Button/types/ButtonProps.ts
+++ b/packages/twenty-ui/src/primitives/input/Button/types/ButtonProps.ts
@@ -1,3 +1,4 @@
+import { type ShortcutDefinition } from '@ui/primitives/typography/Shortcut/types/ShortcutDefinition';
import { type Button as ButtonPrimitive } from '@base-ui/react/button';
import { type ComponentPropsWithRef, type ReactNode } from 'react';
@@ -18,5 +19,6 @@ export type ButtonProps = Omit<
elevated?: boolean;
startIcon?: ReactNode;
endIcon?: ReactNode;
- hotkeys?: string[];
+ shortcut?: ShortcutDefinition;
+ shortcutJoinLabel?: string;
};
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
index aea618ea03a..e7bb71c7e9b 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/ListItem.tsx
@@ -1,10 +1,10 @@
import { useRender } from '@base-ui/react/use-render';
-import { isNonEmptyArray, isString } from '@sniptt/guards';
+import { isString } from '@sniptt/guards';
import { clsx } from 'clsx';
import { type MouseEvent } from 'react';
import { IconCheck, IconChevronRight } from '@ui/icon';
-import { MenuItemHotKeys } from '@ui/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys';
+import { Shortcut } from '@ui/primitives/typography/Shortcut/Shortcut';
import { OverflowingTextWithTooltip } from '@ui/primitives/typography/OverflowingTextWithTooltip/OverflowingTextWithTooltip';
import { isDefined } from '@ui/utilities/utils/isDefined';
@@ -25,8 +25,8 @@ export const ListItem = ({
descriptionPlacement = 'inline',
actions,
actionsVisibility = 'hover',
- hotkeys,
- hotkeysJoinLabel,
+ shortcut,
+ shortcutJoinLabel,
hasSubmenu = false,
className,
children,
@@ -93,10 +93,12 @@ export const ListItem = ({
{isRenderableSlot(actions) && (
<span className={styles.actions}>{actions}</span>
)}
- {isNonEmptyArray(hotkeys) && (
- <span className={styles.hotkeys}>
- <MenuItemHotKeys hotKeys={hotkeys} joinLabel={hotkeysJoinLabel} />
- </span>
+ {isDefined(shortcut) && (
+ <Shortcut
+ className={styles.hotkeys}
+ shortcut={shortcut}
+ sequenceJoinLabel={shortcutJoinLabel}
+ />
)}
{isRenderableSlot(endIcon) && (
<span className={styles.endIcon}>{endIcon}</span>
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItem.stories.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItem.stories.tsx
index abc53b0522d..ac935e930b8 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItem.stories.tsx
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/__stories__/ListItem.stories.tsx
@@ -163,7 +163,7 @@ type ListItemCatalogSlot =
| 'endIcon'
| 'description'
| 'endDescription'
- | 'hotkeys'
+ | 'shortcut'
| 'actions'
| 'submenu';
@@ -175,7 +175,7 @@ const LIST_ITEM_CATALOG_SLOT_PROPS: Record<
endIcon: { endIcon: <IconSettings /> },
description: { description: 'Description' },
endDescription: { description: '3 selected', descriptionPlacement: 'end' },
- hotkeys: { hotkeys: ['⌘', 'K'] },
+ shortcut: { shortcut: ['Mod', 'K'] },
actions: { actions: ACTIONS },
submenu: { hasSubmenu: true },
};
@@ -199,7 +199,7 @@ export const SlotsCatalog: CatalogStory<Story, typeof ListItem> = {
'endIcon',
'description',
'endDescription',
- 'hotkeys',
+ 'shortcut',
'actions',
'submenu',
] satisfies ListItemCatalogSlot[],
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.module.scss b/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.module.scss
deleted file mode 100644
index 52fc75463f6..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.module.scss
+++ /dev/null
@@ -1,29 +0,0 @@
-.commandTextContainer {
- align-items: center;
- display: flex;
- flex-direction: row;
- gap: var(--t-spacing-1);
- justify-content: center;
-}
-
-.commandText {
- color: var(--t-font-color-light);
- vertical-align: middle;
- white-space: nowrap;
-}
-
-.commandKey {
- box-sizing: content-box;
- align-items: center;
- background-color: var(--t-background-secondary);
- border: 1px solid var(--t-border-color-strong);
- // Concentric with the md dropdown container: parent radius minus its inset.
- border-radius: calc(var(--t-border-radius-md) - var(--t-spacing-1));
- box-shadow: var(--t-box-shadow-underline);
- display: flex;
- flex-direction: column;
- height: 18px;
- justify-content: center;
- text-align: center;
- width: var(--t-spacing-4);
-}
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.module.scss.d.ts b/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.module.scss.d.ts
deleted file mode 100644
index 1488ef1ec6a..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.module.scss.d.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-declare const classNames: {
- readonly commandTextContainer: 'commandTextContainer';
- readonly commandText: 'commandText';
- readonly commandKey: 'commandKey';
-};
-export default classNames;
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.tsx b/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.tsx
deleted file mode 100644
index 3d8bf740526..00000000000
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/internal/MenuItemHotKeys/MenuItemHotKeys.tsx
+++ /dev/null
@@ -1,28 +0,0 @@
-import React from 'react';
-
-import styles from './MenuItemHotKeys.module.scss';
-
-export type MenuItemHotKeysProps = {
- hotKeys?: string[];
- joinLabel?: string;
-};
-
-export const MenuItemHotKeys = ({
- hotKeys,
- joinLabel = 'then',
-}: MenuItemHotKeysProps) => {
- return (
- <div className={styles.commandText}>
- {hotKeys && (
- <div className={styles.commandTextContainer}>
- {hotKeys.map((hotKey, index) => (
- <React.Fragment key={index}>
- <div className={styles.commandKey}>{hotKey}</div>
- {index < hotKeys.length - 1 && joinLabel}
- </React.Fragment>
- ))}
- </div>
- )}
- </div>
- );
-};
diff --git a/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts b/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
index edbbf92f6f6..2e4df944e13 100644
--- a/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
+++ b/packages/twenty-ui/src/primitives/navigation/ListItem/types/ListItemProps.ts
@@ -1,3 +1,4 @@
+import { type ShortcutDefinition } from '@ui/primitives/typography/Shortcut/types/ShortcutDefinition';
import { type useRender } from '@base-ui/react/use-render';
import { type ReactNode } from 'react';
@@ -44,8 +45,8 @@ export type ListItemProps = Omit<
* Keyboard shortcut keys displayed at the end of the row. Registering the
* shortcut is up to the application.
*/
- hotkeys?: string[];
- hotkeysJoinLabel?: string;
+ shortcut?: ShortcutDefinition;
+ shortcutJoinLabel?: string;
/** Shows a chevron indicating that the item opens a submenu. */
hasSubmenu?: boolean;
};
diff --git a/packages/twenty-ui/src/primitives/surfaces/Menu/__stories__/Menu.stories.tsx b/packages/twenty-ui/src/primitives/surfaces/Menu/__stories__/Menu.stories.tsx
index 2a6fdea00a2..9ee65c1e194 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Menu/__stories__/Menu.stories.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Menu/__stories__/Menu.stories.tsx
@@ -25,7 +25,7 @@ type MenuStoryProps = MenuRootProps & { content?: MenuCatalogContent };
const BASIC_ITEMS = (
<>
- <Menu.Item startIcon={<IconCopy />} hotkeys={['⌘', 'D']}>
+ <Menu.Item startIcon={<IconCopy />} shortcut={['Mod', 'D']}>
Duplicate
</Menu.Item>
<Menu.Item startIcon={<IconDownload />} description="CSV">
diff --git a/packages/twenty-ui/src/primitives/surfaces/Menu/internal/getMenuListItemProps.tsx b/packages/twenty-ui/src/primitives/surfaces/Menu/internal/getMenuListItemProps.tsx
index d1e491c7451..3a147ff0311 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Menu/internal/getMenuListItemProps.tsx
+++ b/packages/twenty-ui/src/primitives/surfaces/Menu/internal/getMenuListItemProps.tsx
@@ -23,8 +23,8 @@ export const getMenuListItemProps = <
endIcon,
description,
descriptionPlacement,
- hotkeys,
- hotkeysJoinLabel,
+ shortcut,
+ shortcutJoinLabel,
disabled = false,
children,
render,
@@ -53,8 +53,8 @@ export const getMenuListItemProps = <
endIcon={endIcon}
description={description}
descriptionPlacement={descriptionPlacement}
- hotkeys={hotkeys}
- hotkeysJoinLabel={hotkeysJoinLabel}
+ shortcut={shortcut}
+ shortcutJoinLabel={shortcutJoinLabel}
{...getListItemState?.(state)}
>
{children}
diff --git a/packages/twenty-ui/src/primitives/surfaces/Menu/types/MenuItemSlotProps.ts b/packages/twenty-ui/src/primitives/surfaces/Menu/types/MenuItemSlotProps.ts
index 192e684e32d..ba36604c05f 100644
--- a/packages/twenty-ui/src/primitives/surfaces/Menu/types/MenuItemSlotProps.ts
+++ b/packages/twenty-ui/src/primitives/surfaces/Menu/types/MenuItemSlotProps.ts
@@ -7,6 +7,6 @@ export type MenuItemSlotProps = Pick<
| 'endIcon'
| 'description'
| 'descriptionPlacement'
- | 'hotkeys'
- | 'hotkeysJoinLabel'
+ | 'shortcut'
+ | 'shortcutJoinLabel'
>;
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/Shortcut.module.scss b/packages/twenty-ui/src/primitives/typography/Shortcut/Shortcut.module.scss
new file mode 100644
index 00000000000..590fb786d88
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/Shortcut.module.scss
@@ -0,0 +1,43 @@
+.root {
+ color: var(--t-font-color-secondary);
+ display: inline-flex;
+ flex: none;
+ font-size: inherit;
+ vertical-align: middle;
+ white-space: nowrap;
+
+ &[data-variant='text'] {
+ color: inherit;
+ }
+
+ &[data-variant='button'] {
+ border-inline-start: 1px solid currentColor;
+ color: inherit;
+ font-weight: var(--t-font-weight-medium);
+ margin-inline-start: var(--t-spacing-1);
+ padding-inline-start: var(--t-spacing-2);
+ }
+}
+
+.content,
+.combination {
+ align-items: center;
+ display: inline-flex;
+ gap: var(--t-spacing-1);
+}
+
+.key {
+ align-items: center;
+ background-color: var(--t-background-secondary);
+ border: 1px solid var(--t-border-color-strong);
+ border-radius: calc(var(--t-border-radius-md) - var(--t-spacing-1));
+ box-shadow: var(--t-box-shadow-underline);
+ box-sizing: content-box;
+ display: inline-flex;
+ font: inherit;
+ height: 18px;
+ justify-content: center;
+ min-inline-size: var(--t-spacing-4);
+ padding-inline: var(--t-spacing-0_5);
+ text-align: center;
+}
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/Shortcut.tsx b/packages/twenty-ui/src/primitives/typography/Shortcut/Shortcut.tsx
new file mode 100644
index 00000000000..d437ecc17e6
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/Shortcut.tsx
@@ -0,0 +1,66 @@
+import { isNonEmptyArray } from '@sniptt/guards';
+import { clsx } from 'clsx';
+import { Fragment } from 'react';
+
+import { useIsMobile } from '@ui/utilities/responsive/hooks/useIsMobile';
+
+import { getShortcutPresentation } from './internal/getShortcutPresentation';
+import styles from './Shortcut.module.scss';
+import { type ShortcutProps } from './types/ShortcutProps';
+
+export const Shortcut = ({
+ shortcut,
+ platform,
+ sequenceJoinLabel,
+ combinationSeparator,
+ variant = 'keys',
+ visibility = 'always',
+ className,
+ 'aria-label': ariaLabel,
+ ...props
+}: ShortcutProps) => {
+ const isMobile = useIsMobile();
+ const presentation = getShortcutPresentation({
+ shortcut,
+ platform,
+ sequenceJoinLabel,
+ combinationSeparator,
+ });
+
+ if (
+ !isNonEmptyArray(presentation.groups) ||
+ (visibility === 'desktop' && isMobile)
+ ) {
+ return null;
+ }
+
+ return (
+ <span
+ {...props}
+ className={clsx(styles.root, className)}
+ data-variant={variant}
+ role="img"
+ aria-label={ariaLabel ?? presentation.accessibleLabel}
+ >
+ <span className={styles.content} aria-hidden>
+ {variant !== 'keys'
+ ? presentation.text
+ : presentation.groups.map((keys, stepIndex) => (
+ <Fragment key={stepIndex}>
+ {stepIndex > 0 && (
+ <span>{` ${presentation.sequenceJoinLabel} `}</span>
+ )}
+ <span className={styles.combination}>
+ {keys.map((key, keyIndex) => (
+ <Fragment key={keyIndex}>
+ {keyIndex > 0 && presentation.separator}
+ <kbd className={styles.key}>{key}</kbd>
+ </Fragment>
+ ))}
+ </span>
+ </Fragment>
+ ))}
+ </span>
+ </span>
+ );
+};
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/__stories__/Shortcut.stories.tsx b/packages/twenty-ui/src/primitives/typography/Shortcut/__stories__/Shortcut.stories.tsx
new file mode 100644
index 00000000000..1ce25dcfa69
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/__stories__/Shortcut.stories.tsx
@@ -0,0 +1,119 @@
+import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { expect, within } from 'storybook/test';
+
+import { Button } from '@ui/primitives/input';
+import { ListItem } from '@ui/primitives/navigation';
+import { Shortcut, formatShortcut } from '@ui/primitives/typography';
+import { ComponentDecorator, overrideMediaQueryMatches } from '@ui/testing';
+import { MOBILE_MEDIA_QUERY } from '@ui/utilities';
+
+const meta: Meta<typeof Shortcut> = {
+ title: 'UI/Typography/Shortcut',
+ component: Shortcut,
+ decorators: [ComponentDecorator],
+ args: {
+ shortcut: ['Mod', 'K'],
+ platform: 'mac',
+ },
+};
+
+export default meta;
+type Story = StoryObj<typeof Shortcut>;
+
+export const Combination: Story = {
+ play: async ({ canvasElement, args }) => {
+ const shortcut = within(canvasElement).getByRole('img', {
+ name: 'Command + K',
+ });
+ await expect(shortcut).toHaveTextContent(formatShortcut(args));
+ await expect(shortcut).not.toHaveTextContent('then');
+ },
+};
+
+export const OtherPlatform: Story = {
+ args: { platform: 'other' },
+ play: async ({ canvasElement, args }) => {
+ const shortcut = within(canvasElement).getByRole('img', {
+ name: 'Control + K',
+ });
+ await expect(shortcut).toHaveTextContent(formatShortcut(args));
+ },
+};
+
+export const Sequence: Story = {
+ args: { shortcut: [['G'], ['P']] },
+ play: async ({ canvasElement, args }) => {
+ await expect(
+ within(canvasElement).getByRole('img', { name: 'G then P' }),
+ ).toHaveTextContent(formatShortcut(args));
+ },
+};
+
+export const LocalizedSequence: Story = {
+ args: {
+ shortcut: [
+ ['Control', 'K'],
+ ['Control', 'C'],
+ ],
+ platform: 'other',
+ sequenceJoinLabel: 'followed by',
+ 'aria-label': 'Control K followed by Control C',
+ },
+ play: async ({ canvasElement, args }) => {
+ await expect(
+ within(canvasElement).getByRole('img', { name: args['aria-label'] }),
+ ).toHaveTextContent(formatShortcut(args));
+ },
+};
+
+export const Presentations: Story = {
+ render: () => (
+ <>
+ <Button shortcut={['Mod', 'Enter']}>Save record</Button>
+ <ListItem shortcut={[['G'], ['P']]} shortcutJoinLabel="next">
+ Open people
+ </ListItem>
+ <Shortcut shortcut={['Mod', 'K']} variant="text" />
+ </>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(
+ canvas.getByRole('button', { name: 'Save record' }),
+ ).toBeVisible();
+ await expect(canvas.getByRole('img', { name: 'G next P' })).toBeVisible();
+ },
+};
+
+export const Mobile: Story = {
+ beforeEach: () => overrideMediaQueryMatches({ [MOBILE_MEDIA_QUERY]: true }),
+ render: () => (
+ <>
+ <Shortcut shortcut={['H']} visibility="desktop" />
+ <Shortcut shortcut={['V']} />
+ <Button shortcut={['S']}>Save</Button>
+ </>
+ ),
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ await expect(
+ canvas.queryByRole('img', { name: 'H' }),
+ ).not.toBeInTheDocument();
+ await expect(canvas.getByRole('img', { name: 'V' })).toBeVisible();
+ await expect(
+ canvas.getByRole('button', { name: 'Save' }),
+ ).toHaveTextContent(/^Save$/);
+ },
+};
+
+export const Documentation: Story = {
+ render: () => (
+ <>
+ <Button shortcut={['Mod', 'Enter']}>Save record</Button>
+ <ListItem shortcut={[['G'], ['P']]} shortcutJoinLabel="next">
+ Open people
+ </ListItem>
+ <Shortcut shortcut={['Mod', 'K']} variant="text" />
+ </>
+ ),
+};
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/__tests__/formatShortcut.test.ts b/packages/twenty-ui/src/primitives/typography/Shortcut/__tests__/formatShortcut.test.ts
new file mode 100644
index 00000000000..67aa951ad81
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/__tests__/formatShortcut.test.ts
@@ -0,0 +1,92 @@
+import { afterEach, describe, expect, it, vi } from 'vitest';
+
+import { formatShortcut } from '@ui/primitives/typography';
+
+afterEach(() => vi.unstubAllGlobals());
+
+describe('formatShortcut', () => {
+ it.each([
+ { platform: 'mac', expected: '⌘⏎' },
+ { platform: 'other', expected: 'Ctrl ⏎' },
+ ] as const)('formats combinations on $platform', ({ platform, expected }) => {
+ expect(
+ formatShortcut({
+ shortcut: ['Mod', 'Enter'],
+ platform,
+ }),
+ ).toBe(expected);
+ });
+
+ it('keeps combinations inside a localized sequence', () => {
+ expect(
+ formatShortcut({
+ shortcut: [
+ ['Control', 'K'],
+ ['Control', 'C'],
+ ],
+ platform: 'other',
+ sequenceJoinLabel: 'followed by',
+ }),
+ ).toBe('Ctrl K followed by Ctrl C');
+ });
+
+ it.each([
+ { userAgent: 'Macintosh; Intel Mac OS X', expected: '⌘K' },
+ { userAgent: 'iPhone; CPU iPhone OS', expected: '⌘K' },
+ { userAgent: 'iPad; CPU OS', expected: '⌘K' },
+ { userAgent: 'Windows NT 10.0', expected: 'Ctrl K' },
+ { userAgent: 'Linux', expected: 'Ctrl K' },
+ ])('detects the platform from $userAgent', ({ userAgent, expected }) => {
+ vi.stubGlobal('navigator', { userAgent });
+ expect(formatShortcut({ shortcut: ['Mod', 'K'] })).toBe(expected);
+ });
+
+ it('formats safely without browser globals', () => {
+ vi.stubGlobal('navigator', undefined);
+ expect(formatShortcut({ shortcut: ['Mod', '+'] })).toBe('Ctrl +');
+ });
+
+ it.each([
+ {
+ platform: 'mac',
+ keys: ['CommandOrControl', 'Shift', 'Space'],
+ expected: '⌘ + Shift + Space',
+ },
+ {
+ platform: 'other',
+ keys: ['CommandOrControl', 'Shift', 'Space'],
+ expected: 'Ctrl + Shift + Space',
+ },
+ {
+ platform: 'mac',
+ keys: ['Control', 'Alt', '7'],
+ expected: 'Ctrl + ⌥ + 7',
+ },
+ {
+ platform: 'other',
+ keys: ['Control', 'Alt', '7'],
+ expected: 'Ctrl + Alt + 7',
+ },
+ ] as const)(
+ 'preserves accelerator labels on $platform for $keys',
+ ({ platform, keys, expected }) => {
+ expect(
+ formatShortcut({
+ shortcut: keys,
+ platform,
+ combinationSeparator: ' + ',
+ }),
+ ).toBe(expected);
+ },
+ );
+
+ it('omits empty steps without adding separators', () => {
+ expect(
+ formatShortcut({
+ shortcut: [[], ['G'], [], ['P']],
+ }),
+ ).toBe('G then P');
+ expect(formatShortcut({ shortcut: [] })).toBe('');
+ expect(formatShortcut({ shortcut: [[], []] })).toBe('');
+ });
+});
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/formatShortcut.ts b/packages/twenty-ui/src/primitives/typography/Shortcut/formatShortcut.ts
new file mode 100644
index 00000000000..434560f4d89
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/formatShortcut.ts
@@ -0,0 +1,5 @@
+import { getShortcutPresentation } from './internal/getShortcutPresentation';
+import { type ShortcutFormatOptions } from './types/ShortcutFormatOptions';
+
+export const formatShortcut = (options: ShortcutFormatOptions) =>
+ getShortcutPresentation(options).text;
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/internal/getShortcutPresentation.ts b/packages/twenty-ui/src/primitives/typography/Shortcut/internal/getShortcutPresentation.ts
new file mode 100644
index 00000000000..2c87c8324e2
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/internal/getShortcutPresentation.ts
@@ -0,0 +1,65 @@
+import { isNonEmptyArray, isString } from '@sniptt/guards';
+
+import { isDefined } from '@ui/utilities/utils/isDefined';
+import { getUserDevice } from '@ui/utilities/device/getUserDevice';
+
+import { type ShortcutDefinition } from '../types/ShortcutDefinition';
+import { type ShortcutFormatOptions } from '../types/ShortcutFormatOptions';
+
+const ACCESSIBLE_KEY_LABELS = new Map<string, string>([
+ ['⌘', 'Command'],
+ ['⌥', 'Option'],
+ ['⇧', 'Shift'],
+ ['⌃', 'Control'],
+ ['Ctrl', 'Control'],
+ ['⏎', 'Enter'],
+ ['↵', 'Enter'],
+ ['⌫', 'Backspace'],
+ ['↑', 'Arrow up'],
+ ['↓', 'Arrow down'],
+ ['←', 'Arrow left'],
+ ['→', 'Arrow right'],
+ ['esc', 'Escape'],
+]);
+
+const isShortcutCombination = (
+ shortcut: ShortcutDefinition,
+): shortcut is readonly string[] => shortcut.every(isString);
+
+export const getShortcutPresentation = ({
+ shortcut,
+ platform,
+ sequenceJoinLabel = 'then',
+ combinationSeparator,
+}: ShortcutFormatOptions) => {
+ const device = getUserDevice();
+ const isMac =
+ platform === 'mac' ||
+ (!isDefined(platform) && (device === 'mac' || device === 'ios'));
+ const keySymbols = new Map<string, string>([
+ ['Mod', isMac ? '⌘' : 'Ctrl'],
+ ['CommandOrControl', isMac ? '⌘' : 'Ctrl'],
+ ['Command', '⌘'],
+ ['Control', 'Ctrl'],
+ ['Alt', isMac ? '⌥' : 'Alt'],
+ ['Enter', '⏎'],
+ ]);
+ const steps = isShortcutCombination(shortcut) ? [shortcut] : shortcut;
+ const groups = steps
+ .filter(isNonEmptyArray)
+ .map((keys) => keys.map((key) => keySymbols.get(key) ?? key));
+ const separator = combinationSeparator ?? (isMac ? '' : ' ');
+ const sequenceSeparator = ` ${sequenceJoinLabel} `;
+
+ return {
+ groups,
+ separator,
+ sequenceJoinLabel,
+ text: groups.map((keys) => keys.join(separator)).join(sequenceSeparator),
+ accessibleLabel: groups
+ .map((keys) =>
+ keys.map((key) => ACCESSIBLE_KEY_LABELS.get(key) ?? key).join(' + '),
+ )
+ .join(sequenceSeparator),
+ };
+};
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutDefinition.ts b/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutDefinition.ts
new file mode 100644
index 00000000000..038a0609035
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutDefinition.ts
@@ -0,0 +1,3 @@
+export type ShortcutDefinition =
+ | readonly string[]
+ | readonly (readonly string[])[];
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutFormatOptions.ts b/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutFormatOptions.ts
new file mode 100644
index 00000000000..407fa6940cb
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutFormatOptions.ts
@@ -0,0 +1,8 @@
+import { type ShortcutDefinition } from './ShortcutDefinition';
+
+export type ShortcutFormatOptions = {
+ shortcut: ShortcutDefinition;
+ platform?: 'mac' | 'other';
+ sequenceJoinLabel?: string;
+ combinationSeparator?: string;
+};
diff --git a/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutProps.ts b/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutProps.ts
new file mode 100644
index 00000000000..e104bbb4819
--- /dev/null
+++ b/packages/twenty-ui/src/primitives/typography/Shortcut/types/ShortcutProps.ts
@@ -0,0 +1,12 @@
+import { type ComponentPropsWithRef } from 'react';
+
+import { type ShortcutFormatOptions } from './ShortcutFormatOptions';
+
+export type ShortcutProps = Omit<
+ ComponentPropsWithRef<'span'>,
+ 'children' | 'role'
+> &
+ ShortcutFormatOptions & {
+ variant?: 'keys' | 'text' | 'button';
+ visibility?: 'always' | 'desktop';
+ };
diff --git a/packages/twenty-ui/src/primitives/typography/index.ts b/packages/twenty-ui/src/primitives/typography/index.ts
index 63e4e6350d4..e89bfa662b4 100644
--- a/packages/twenty-ui/src/primitives/typography/index.ts
+++ b/packages/twenty-ui/src/primitives/typography/index.ts
@@ -10,4 +10,9 @@
export { Heading } from './Heading/Heading';
export type { HeadingProps } from './Heading/types/HeadingProps';
export { OverflowingTextWithTooltip } from './OverflowingTextWithTooltip/OverflowingTextWithTooltip';
+export { formatShortcut } from './Shortcut/formatShortcut';
+export { Shortcut } from './Shortcut/Shortcut';
+export type { ShortcutDefinition } from './Shortcut/types/ShortcutDefinition';
+export type { ShortcutFormatOptions } from './Shortcut/types/ShortcutFormatOptions';
+export type { ShortcutProps } from './Shortcut/types/ShortcutProps';
export { Text } from './Text/Text';
diff --git a/packages/twenty-ui/src/utilities/device/__tests__/getOsShortcutSeparator.test.ts b/packages/twenty-ui/src/utilities/device/__tests__/getOsShortcutSeparator.test.ts
deleted file mode 100644
index 1deec0725ec..00000000000
--- a/packages/twenty-ui/src/utilities/device/__tests__/getOsShortcutSeparator.test.ts
+++ /dev/null
@@ -1,36 +0,0 @@
-import { type MockInstance, vi } from 'vitest';
-
-import { getOsShortcutSeparator } from '../getOsShortcutSeparator';
-
-describe('getOsShortcutSeparator', () => {
- let userAgentSpy: MockInstance<() => string>;
-
- beforeEach(() => {
- userAgentSpy = vi.spyOn(window.navigator, 'userAgent', 'get');
- });
-
- afterEach(() => {
- userAgentSpy.mockRestore();
- });
-
- it('should return space for Windows', () => {
- userAgentSpy.mockReturnValue(
- 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0',
- );
- expect(getOsShortcutSeparator()).toBe(' ');
- });
-
- it('should return empty string for Mac', () => {
- userAgentSpy.mockReturnValue(
- 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
- );
- expect(getOsShortcutSeparator()).toBe('');
- });
-
- it('should return empty string for iPad', () => {
- userAgentSpy.mockReturnValue(
- 'Mozilla/5.0 (iPad; CPU OS 17_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.4 Mobile/15E148 Safari/604.1',
- );
- expect(getOsShortcutSeparator()).toBe('');
- });
-});
diff --git a/packages/twenty-ui/src/utilities/device/getOsShortcutSeparator.ts b/packages/twenty-ui/src/utilities/device/getOsShortcutSeparator.ts
deleted file mode 100644
index db0ae00f2c7..00000000000
--- a/packages/twenty-ui/src/utilities/device/getOsShortcutSeparator.ts
+++ /dev/null
@@ -1,6 +0,0 @@
-import { getUserDevice } from '@ui/utilities/device/getUserDevice';
-
-export const getOsShortcutSeparator = () => {
- const device = getUserDevice();
- return device === 'mac' || device === 'ios' ? '' : ' ';
-};
diff --git a/packages/twenty-ui/src/utilities/index.ts b/packages/twenty-ui/src/utilities/index.ts
index ee96c4fa278..b2fb083df25 100644
--- a/packages/twenty-ui/src/utilities/index.ts
+++ b/packages/twenty-ui/src/utilities/index.ts
@@ -15,7 +15,6 @@ export {
} from './color/utils/stringToThemeColorP3String';
export { themeColorSchema } from './color/utils/themeColorSchema';
export { getOsControlSymbol } from './device/getOsControlSymbol';
-export { getOsShortcutSeparator } from './device/getOsShortcutSeparator';
export { getUserDevice } from './device/getUserDevice';
export { MOBILE_MEDIA_QUERY } from './responsive/constants/MobileMediaQuery';
export { TOUCH_DEVICE_MEDIA_QUERY } from './responsive/constants/TouchDeviceMediaQuery';
diff --git a/packages/twenty-ui/src/utilities/responsive/__stories__/ResponsiveHooks.stories.tsx b/packages/twenty-ui/src/utilities/responsive/__stories__/ResponsiveHooks.stories.tsx
index c7607e1bf54..1d91d33795a 100644
--- a/packages/twenty-ui/src/utilities/responsive/__stories__/ResponsiveHooks.stories.tsx
+++ b/packages/twenty-ui/src/utilities/responsive/__stories__/ResponsiveHooks.stories.tsx
@@ -19,7 +19,7 @@ const ResponsiveControls = () => {
<>
<Text>Mobile layout: {String(isMobile)}</Text>
<Text>Touch input: {String(isTouchDevice)}</Text>
- <Button hotkeys={['S']} onClick={() => setActivations(activations + 1)}>
+ <Button shortcut={['S']} onClick={() => setActivations(activations + 1)}>
Save record
</Button>
<Button onClick={() => setActivations(activations + 1)}>