mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-18 23:43:55 +01:00
Add .oxfmtignore to skip generated bindings and wasm-pack output. Add npm format script, update DEVELOPMENT.md for Vite+ toolchain, and format all non-generated files with oxfmt. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import classNames from "classnames";
|
|
import type { HotkeyAction } from "../../hooks/useHotKey";
|
|
import { useFormattedHotkey } from "../../hooks/useHotKey";
|
|
import { HStack } from "./Stacks";
|
|
|
|
interface Props {
|
|
action: HotkeyAction | null;
|
|
className?: string;
|
|
variant?: "text" | "with-bg";
|
|
}
|
|
|
|
export function Hotkey({ action, className, variant }: Props) {
|
|
const labelParts = useFormattedHotkey(action);
|
|
if (labelParts === null) {
|
|
return null;
|
|
}
|
|
|
|
return <HotkeyRaw labelParts={labelParts} className={className} variant={variant} />;
|
|
}
|
|
|
|
interface HotkeyRawProps {
|
|
labelParts: string[];
|
|
className?: string;
|
|
variant?: "text" | "with-bg";
|
|
}
|
|
|
|
export function HotkeyRaw({ labelParts, className, variant }: HotkeyRawProps) {
|
|
return (
|
|
<HStack
|
|
className={classNames(
|
|
className,
|
|
variant === "with-bg" &&
|
|
"rounded bg-surface-highlight px-1 border border-border text-text-subtle",
|
|
variant === "text" && "text-text-subtlest",
|
|
)}
|
|
>
|
|
{labelParts.map((char, index) => (
|
|
// oxlint-disable-next-line react/no-array-index-key
|
|
<div key={index} className="min-w-[1em] text-center">
|
|
{char}
|
|
</div>
|
|
))}
|
|
</HStack>
|
|
);
|
|
}
|