Skip to content

Commit 0f8cb0f

Browse files
style: hotkey label
1 parent acece38 commit 0f8cb0f

File tree

2 files changed

+9
-23
lines changed

2 files changed

+9
-23
lines changed

packages/core/src/hotkeys/HotKeyLabel.tsx

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,9 @@ export const HotKeyLabel = ({
3232
const item = reduceHotKey({ keyCombo });
3333

3434
const label = [];
35-
const controls = [];
36-
if (item.alt)
37-
controls.push(
38-
<span key="alt" className="text-[0.875rem]">
39-
40-
</span>,
41-
);
42-
if (item.ctrl)
43-
controls.push(
44-
<span key="ctrl" className="text-[0.875rem]">
45-
46-
</span>,
47-
);
48-
if (item.meta)
49-
controls.push(
50-
<span key="meta" className="text-[0.875rem]">
51-
52-
</span>,
53-
);
54-
35+
if (item.alt) label.push("ALT");
36+
if (item.ctrl) label.push("CTRL");
37+
if (item.meta) label.push("META");
5538
if (item.shift) label.push("SHFT");
5639
if (item.key.toLowerCase() === "tab") label.push("TAB");
5740
else if (item.key.toLowerCase() === "space") label.push("SPC");
@@ -64,14 +47,14 @@ export const HotKeyLabel = ({
6447
else if (item.key.toLowerCase() === "escape") label.push("ESC");
6548
else if (item.key.toLowerCase() === "backspace") label.push("BKSPC");
6649
else label.push(item.key.toUpperCase());
67-
return [...controls, <span key="label">{label.join(" ")}</span>];
50+
return [<span key="label">{label.join(" ")}</span>];
6851
},
6952
[keyCombo],
7053
"HotKey label",
7154
);
7255

7356
return (
74-
<kbd className="hotkey-label inline-flex gap-1 items-center text-[0.625rem] leading-4 bg-tint-900/10 text-base/50 whitespace-nowrap rounded px-2 mx-1">
57+
<kbd className="hotkey-label inline-flex gap-1 select-none self-center font-mono items-center text-[0.625rem] leading-4 bg-tint-500/10 text-base/50 whitespace-nowrap rounded px-2 mx-1">
7558
{label}
7659
</kbd>
7760
);

packages/form/stories/inputs/Search.stories.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import type { Meta, StoryObj } from "@storybook/react";
2525
import { fn } from "@storybook/test";
2626
import { Search } from "../../src";
27+
import { HotKeyLabel } from "@react-fabric/core";
2728

2829
const meta: Meta = {
2930
component: Search,
@@ -46,7 +47,9 @@ type SearchStory = StoryObj<typeof Search>;
4647

4748
export const _Search: SearchStory = {
4849
render: (args) => {
49-
return <Search {...args} />;
50+
return (
51+
<Search {...args} decorateEnd={<HotKeyLabel keyCombo="shift+/" />} />
52+
);
5053
},
5154
args: {
5255
label: "Search input",

0 commit comments

Comments
 (0)