Skip to content

Commit 16eb7ba

Browse files
committed
Adds a prop so you can optionally hide the shortcut key
1 parent 14adb73 commit 16eb7ba

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

apps/webapp/app/components/navigation/SideMenu.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ export function SideMenu({
301301
variant="small-menu-item"
302302
data-action="ask-ai"
303303
shortcut={{ modifiers: ["mod"], key: "/" }}
304+
hideShortcutKey
304305
data-modal-override-open-class-ask-ai="true"
305306
onClick={() => {
306307
if (typeof window.Kapa === "function") {
@@ -317,6 +318,7 @@ export function SideMenu({
317318
className="flex items-center gap-1 py-1.5 pl-2.5 pr-2 text-xs"
318319
>
319320
Ask AI
321+
<ShortcutKey shortcut={{ modifiers: ["mod"], key: "/" }} variant="medium/bright" />
320322
</TooltipContent>
321323
</Tooltip>
322324
</TooltipProvider>

apps/webapp/app/components/primitives/Buttons.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ export type ButtonContentPropsType = {
177177
shortcutPosition?: "before-trailing-icon" | "after-trailing-icon";
178178
tooltip?: ReactNode;
179179
iconSpacing?: string;
180+
hideShortcutKey?: boolean;
180181
};
181182

182183
export function ButtonContent(props: ButtonContentPropsType) {
@@ -192,6 +193,7 @@ export function ButtonContent(props: ButtonContentPropsType) {
192193
className,
193194
tooltip,
194195
iconSpacing,
196+
hideShortcutKey,
195197
} = props;
196198
const variation = allVariants.variant[props.variant];
197199

@@ -207,6 +209,7 @@ export function ButtonContent(props: ButtonContentPropsType) {
207209
className={cn(shortcutClassName)}
208210
shortcut={shortcut}
209211
variant={variation.shortcutVariant ?? "medium"}
212+
hideShortcutKey={hideShortcutKey}
210213
/>
211214
);
212215

apps/webapp/app/components/primitives/ShortcutKey.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,23 @@ type ShortcutKeyProps = {
3333
shortcut: ShortcutKeyDefinition;
3434
variant: ShortcutKeyVariant;
3535
className?: string;
36+
hideShortcutKey?: boolean;
3637
};
3738

38-
export function ShortcutKey({ shortcut, variant, className }: ShortcutKeyProps) {
39+
export function ShortcutKey({
40+
shortcut,
41+
variant,
42+
className,
43+
hideShortcutKey = false,
44+
}: ShortcutKeyProps) {
3945
const { platform } = useOperatingSystem();
4046
const isMac = platform === "mac";
4147
let relevantShortcut = "mac" in shortcut ? (isMac ? shortcut.mac : shortcut.windows) : shortcut;
4248
const modifiers = relevantShortcut.modifiers ?? [];
4349
const character = relevantShortcut.key ? keyString(relevantShortcut.key, isMac, variant) : null;
4450

4551
return (
46-
<span className={cn(variants[variant], className)}>
52+
<span className={cn(variants[variant], hideShortcutKey && "hidden", className)}>
4753
{modifiers.map((k) => (
4854
<span key={k}>
4955
<span>{modifierString(k, isMac, variant)}</span>

0 commit comments

Comments
 (0)