Skip to content

Commit 22ae47f

Browse files
committed
Replace Cmd with Ctrl on Windows computers
1 parent 1de8a17 commit 22ae47f

4 files changed

Lines changed: 42 additions & 6 deletions

File tree

apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/dashboards/page-client.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { FormDialog } from "@/components/form-dialog";
55
import { InputField } from "@/components/form-fields";
66
import { useRouter } from "@/components/router";
77
import { ActionDialog, Button, Typography } from "@/components/ui";
8+
import { getShortcutModifierKeyLabel } from "@/lib/keyboard-shortcuts";
89
import { useUpdateConfig } from "@/lib/config-update";
910
import {
1011
ChartBarIcon,
@@ -28,6 +29,7 @@ export default function PageClient() {
2829
const adminApp = useAdminApp();
2930
const project = adminApp.useProject();
3031
const config = project.useConfig();
32+
const modifierKeyLabel = getShortcutModifierKeyLabel();
3133
const updateConfig = useUpdateConfig();
3234
const router = useRouter();
3335
const [deleteDialogId, setDeleteDialogId] = useState<string | null>(null);
@@ -77,7 +79,9 @@ export default function PageClient() {
7779
<div>
7880
<Typography className="font-semibold text-foreground">No dashboards yet</Typography>
7981
<Typography variant="secondary" className="text-sm mt-1">
80-
Create a dashboard from the command palette (⌘ K) or click &quot;New Dashboard&quot; above.
82+
Create a dashboard from the command palette (
83+
<span suppressHydrationWarning>{modifierKeyLabel} K</span>
84+
) or click &quot;New Dashboard&quot; above.
8185
</Typography>
8286
</div>
8387
</div>

apps/dashboard/src/app/(main)/(protected)/projects/[projectId]/query-analytics/page-client.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import Editor from "@monaco-editor/react";
44
import type { Monaco } from "@monaco-editor/react";
55
import React, { useEffect, useMemo, useRef } from "react";
6+
import { getShortcutModifierKeyLabel } from "@/lib/keyboard-shortcuts";
67
import { Alert, Button, Textarea, Typography } from "@/components/ui";
78
import { PageLayout } from "../page-layout";
89
import { useAdminApp } from "../use-admin-app";
@@ -21,6 +22,7 @@ type CompletionItem = Parameters<Monaco["languages"]["registerCompletionItemProv
2122

2223
export default function PageClient() {
2324
const adminApp = useAdminApp();
25+
const modifierKeyLabel = getShortcutModifierKeyLabel();
2426
const [query, setQuery] = React.useState("SELECT 1 AS value;");
2527
const [resultText, setResultText] = React.useState("");
2628
const [error, setError] = React.useState<string | null>(null);
@@ -168,7 +170,7 @@ export default function PageClient() {
168170
loading={loading}
169171
disabled={loading || !queryRef.current.trim()}
170172
>
171-
Run query ( + enter)
173+
Run query (<span suppressHydrationWarning>{modifierKeyLabel}</span> + enter)
172174
</Button>
173175
</div>
174176

apps/dashboard/src/components/cmdk-search.tsx

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { useRouter } from "@/components/router";
4+
import { getShortcutModifierKeyLabel } from "@/lib/keyboard-shortcuts";
45
import { cn } from "@/lib/utils";
56
import {
67
LayoutIcon,
@@ -118,6 +119,8 @@ const CyclingPlaceholder = memo(function CyclingPlaceholder({
118119
}: {
119120
onSelectQuery?: (query: string) => void,
120121
}) {
122+
const modifierKeyLabel = getShortcutModifierKeyLabel();
123+
121124
return (
122125
<div className="h-full flex flex-col items-center select-none px-6">
123126
{/* Top spacer */}
@@ -149,7 +152,9 @@ const CyclingPlaceholder = memo(function CyclingPlaceholder({
149152
<div className="relative text-center mb-4">
150153
{/* Keybind reminder - like tape on the corner */}
151154
<span className="absolute -top-4 -right-8 rotate-[30deg] flex items-center gap-0.5 text-[10px] text-muted-foreground/40">
152-
<kbd className="px-1.5 py-0.5 rounded bg-foreground/[0.06] font-mono"></kbd>
155+
<kbd suppressHydrationWarning className="px-1.5 py-0.5 rounded bg-foreground/[0.06] font-mono">
156+
{modifierKeyLabel}
157+
</kbd>
153158
+
154159
<kbd className="px-1.5 py-0.5 rounded bg-foreground/[0.06] font-mono">K</kbd>
155160
</span>
@@ -204,7 +209,9 @@ const CyclingPlaceholder = memo(function CyclingPlaceholder({
204209
{/* Keyboard hints footer */}
205210
<div className="py-3 border-t border-foreground/[0.06] w-full flex items-center justify-center gap-5 text-[10px] text-muted-foreground/40">
206211
<div className="flex items-center gap-1.5">
207-
<kbd className="px-1.5 py-0.5 rounded bg-foreground/[0.06] font-mono"></kbd>
212+
<kbd suppressHydrationWarning className="px-1.5 py-0.5 rounded bg-foreground/[0.06] font-mono">
213+
{modifierKeyLabel}
214+
</kbd>
208215
+
209216
<kbd className="px-1.5 py-0.5 rounded bg-foreground/[0.06] font-mono">K</kbd>
210217
<span>open</span>
@@ -999,6 +1006,7 @@ export function CmdKSearch({
9991006
export function CmdKTrigger() {
10001007
const mouseCursorRef = useRef<HTMLDivElement>(null);
10011008
const mouseCursorParentRef = useRef<HTMLDivElement>(null);
1009+
const modifierKeyLabel = getShortcutModifierKeyLabel();
10021010

10031011
useEffect(() => {
10041012
const handleMouseMove = (e: MouseEvent) => {
@@ -1058,8 +1066,11 @@ export function CmdKTrigger() {
10581066
Control Center
10591067
</span>
10601068
<div className="pointer-events-none flex items-center gap-1">
1061-
<kbd className="flex h-5 min-w-[20px] select-none items-center justify-center rounded-md bg-foreground/[0.04] ring-1 ring-inset ring-foreground/[0.06] px-1.5 font-mono text-[10px] font-medium text-muted-foreground/50 group-hover:text-muted-foreground/70 transition-colors duration-300 group-hover:transition-none">
1062-
1069+
<kbd
1070+
suppressHydrationWarning
1071+
className="flex h-5 min-w-[20px] select-none items-center justify-center rounded-md bg-foreground/[0.04] ring-1 ring-inset ring-foreground/[0.06] px-1.5 font-mono text-[10px] font-medium text-muted-foreground/50 group-hover:text-muted-foreground/70 transition-colors duration-300 group-hover:transition-none"
1072+
>
1073+
{modifierKeyLabel}
10631074
</kbd>
10641075
<kbd className="flex h-5 min-w-[20px] select-none items-center justify-center rounded-md bg-foreground/[0.04] ring-1 ring-inset ring-foreground/[0.06] px-1.5 font-mono text-[10px] font-medium text-muted-foreground/50 group-hover:text-muted-foreground/70 transition-colors duration-300 group-hover:transition-none">
10651076
K
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
export function getShortcutModifierKeyLabel() {
2+
if (typeof navigator === "undefined") {
3+
return "⌘";
4+
}
5+
6+
const platform = navigator.platform;
7+
const userAgent = navigator.userAgent;
8+
const isAppleDevice =
9+
platform.startsWith("Mac") ||
10+
platform === "iPhone" ||
11+
platform === "iPad" ||
12+
platform === "iPod" ||
13+
userAgent.includes("Macintosh") ||
14+
userAgent.includes("iPhone") ||
15+
userAgent.includes("iPad") ||
16+
userAgent.includes("iPod");
17+
18+
return isAppleDevice ? "⌘" : "Ctrl";
19+
}

0 commit comments

Comments
 (0)