Skip to content

Commit e3a935e

Browse files
committed
feat: add hotkeys for get-started & theme-toggle
1 parent 3a165b0 commit e3a935e

3 files changed

Lines changed: 42 additions & 16 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"use client";
2+
3+
import Link from "next/link";
4+
import { useRouter } from "next/navigation";
5+
import { useHotkeys } from "react-hotkeys-hook";
6+
7+
import { ChevronRightIcon } from "lucide-react";
8+
import { buttonVariants } from "@/components/ui/button";
9+
10+
const GetStartedLink = () => {
11+
const navigate = useRouter();
12+
useHotkeys("c", () => navigate.push("/docs"));
13+
return (
14+
<Link
15+
href="/docs/getting-started/prerequisites"
16+
className={buttonVariants({
17+
size: "default",
18+
className: "group w-full md:w-auto",
19+
})}
20+
>
21+
<span>Get Started</span>
22+
<span className="rounded-sm bg-neutral-600/60 px-0.5 font-mono text-neutral-300 dark:bg-neutral-700/60">
23+
c
24+
</span>
25+
<ChevronRightIcon
26+
size={16}
27+
className="transition-transform group-hover:translate-x-0.5"
28+
/>
29+
</Link>
30+
);
31+
};
32+
33+
export default GetStartedLink;

apps/website/src/components/hero.tsx

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import Link from "next/link";
2-
import { ArrowUpRightIcon, ChevronRightIcon } from "lucide-react";
1+
import { ArrowUpRightIcon } from "lucide-react";
32

43
import { cn } from "@/utils/cn";
54
import { globals } from "@/globals";
65

76
import { GitHub } from "@/components/ui/svgs/github";
87
import { buttonVariants } from "@/components/ui/button";
8+
import GetStartedLink from "@/components/get-started-link";
99
import { ExternalLink } from "@/components/ui/external-link";
1010

1111
const Hero = () => {
@@ -32,19 +32,7 @@ const Hero = () => {
3232
"animate-in fill-mode-backwards fade-in slide-in-from-bottom-4 delay-100 duration-500",
3333
)}
3434
>
35-
<Link
36-
href="/docs/getting-started/prerequisites"
37-
className={buttonVariants({
38-
size: "default",
39-
className: "group w-full md:w-auto",
40-
})}
41-
>
42-
<span>Get Started</span>
43-
<ChevronRightIcon
44-
size={16}
45-
className="transition-transform group-hover:translate-x-0.5"
46-
/>
47-
</Link>
35+
<GetStartedLink />
4836
<ExternalLink
4937
title="View on GitHub"
5038
href={globals.githubUrl}

apps/website/src/components/theme-toggle.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@ import {
1010
DropdownMenuTrigger,
1111
} from "@/components/ui/dropdown-menu";
1212
import { buttonVariants } from "@/components/ui/button";
13+
import { useHotkeys } from "react-hotkeys-hook";
1314

1415
const ThemeToggle = () => {
1516
const { setTheme } = useTheme();
17+
useHotkeys("t", () =>
18+
setTheme((prev) => (prev === "light" ? "dark" : "light")),
19+
);
1620
return (
1721
<DropdownMenu>
1822
<DropdownMenuTrigger
23+
title="Toggle theme (t)"
1924
className={buttonVariants({ variant: "ghost", size: "icon" })}
2025
>
2126
<SunIcon
@@ -26,7 +31,7 @@ const ThemeToggle = () => {
2631
size={20}
2732
className="absolute scale-0 rotate-90 transition-all dark:scale-100 dark:rotate-0"
2833
/>
29-
<span className="sr-only">Toggle theme</span>
34+
<span className="sr-only">Toggle theme (t)</span>
3035
</DropdownMenuTrigger>
3136
<DropdownMenuContent align="end">
3237
<DropdownMenuItem onClick={() => setTheme("light")}>

0 commit comments

Comments
 (0)