import { kbdPropDefs } from "@radix-ui/themes/props" import type { Meta, StoryObj } from "@storybook/react" import { Kbd } from "./Kbd" const meta = { title: "base/communication/Kbd", component: Kbd, tags: ["autodocs"], argTypes: { children: { control: "text", description: "The key or key combination to display", }, size: { control: "select", options: kbdPropDefs.size.values, description: "The size of the keyboard element", }, }, parameters: { layout: "centered", }, args: { children: "⌘K", }, } satisfies Meta export default meta type Story = StoryObj /** * Default keyboard shortcut display. */ export const Default: Story = {} /** * Different sizes of keyboard elements. */ export const Sizes: Story = { render: () => (
⌘K ⌘K ⌘K ⌘K ⌘K
), } /** * Common keyboard shortcuts. */ export const CommonShortcuts: Story = { render: () => (
Search: ⌘K
Save: ⌘S
Copy: ⌘C
Paste: ⌘V
Undo: ⌘Z
Redo: ⌘⇧Z
), } /** * Key combinations with multiple keys. */ export const KeyCombinations: Story = { render: () => (
Force quit: ⌘⌥Esc
Screenshot: ⌘⇧3
Window screenshot: ⌘⇧4
Switch apps: ⌘Tab
Close window: ⌘W
Quit app: ⌘Q
), } /** * Windows keyboard shortcuts. */ export const WindowsShortcuts: Story = { render: () => (
Search: ⊞S
Task Manager: Ctrl⇧Esc
Screenshot: ⊞⇧S
Switch apps: AltTab
Close window: AltF4
Lock screen: ⊞L
), } /** * Linux keyboard shortcuts. */ export const LinuxShortcuts: Story = { render: () => (
Terminal: CtrlAltT
Switch workspace: CtrlAlt←
Screenshot: PrtScn
Window screenshot: AltPrtScn
Lock screen: CtrlAltL
Logout: CtrlAltDel
), } /** * Gaming keyboard shortcuts. */ export const GamingShortcuts: Story = { render: () => (
Move forward: W
Move backward: S
Move left: A
Move right: D
Jump: Space
Sprint: Shift
Crouch: Ctrl
Reload: R
), } /** * Function keys. */ export const FunctionKeys: Story = { render: () => (
Help: F1
Rename: F2
Search: F3
Address bar: F4
Refresh: F5
Spell check: F7
Full screen: F11
Save as: F12
Volume up: F10
Volume down: F9
), } /** * Inline keyboard shortcuts in text. */ export const InlineText: Story = { render: () => (

Press ⌘K to open the search dialog, or use ⌘⇧P to access the command palette.

To save your work, press ⌘S. For a quick undo, use ⌘Z.

Navigate between tabs using ⌘⇧[ and ⌘⇧].

To close the current window, press ⌘W, or ⌘Q to quit the application entirely.

), } /** * Different sizes in context. */ export const SizeContext: Story = { render: () => (

Small (size="1")

Press ⌘K to search. Use ⌘S to save.

Medium (size="5")

Press ⌘K to search. Use ⌘S to save.

Large (size="9")

Press ⌘K to search. Use ⌘S to save.

), }