Files
yaak/src-web/components/core/HotKey.tsx
Desperate Necromancer be82b67ed3 Allow disabling window decorations/controls (#176)
Co-authored-by: Gregory Schier <gschier1990@gmail.com>
2025-05-16 13:33:59 -07:00

34 lines
797 B
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 (
<HStack
className={classNames(
className,
variant === 'with-bg' && 'rounded border',
'text-text-subtlest',
)}
>
{labelParts.map((char, index) => (
<div key={index} className="min-w-[1.1em] text-center">
{char}
</div>
))}
</HStack>
);
}