Skip to content

Commit 88e48e9

Browse files
authored
Merge pull request #11 from phucbm/search-darkmode
Search dark mode
2 parents e708418 + 7ca3f3a commit 88e48e9

File tree

5 files changed

+63
-12
lines changed

5 files changed

+63
-12
lines changed

app/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const metadata: Metadata = {
1414
// const banner = <Banner storageKey="some-key">This template was created with 🩸 and 💦 by <Link href="https://github.com/phucbm">PHUCBM</Link> 🐧</Banner>
1515
const navbar = (
1616
<Navbar
17+
projectLink="https://github.com/phucbm/nextra-docs-starter"
1718
logo={<img src="/images/general/logo.svg" alt="Logo" width={100} height={20}/>}
1819
// ... Your additional navbar options
1920
/>

components/nextra-search-dialog.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {Command as CommandPrimitive} from "cmdk";
88
import {cn} from "@/lib/utils";
99
import {useRouter} from "next/navigation";
1010
import {PageItem} from "@/lib/getPagesFromPageMap";
11+
import {Kbd} from "@/components/ui/kbd";
1112

1213
type Props = {
1314
placeholder?: string;
@@ -143,7 +144,7 @@ export function NextraSearchDialog({placeholder = "Search...", pages = []}: Prop
143144
showCloseButton={false}
144145
className="search-dialog !max-w-[800px] overflow-hidden !bg-transparent px-2 border-none [&_.bg-popover]:bg-transparent">
145146

146-
<div className="border-4 border-slate-200 rounded-2xl bg-white">
147+
<div className="border-4 rounded-2xl bg-background">
147148
<SearchInput
148149
placeholder={placeholder}
149150
query={query}
@@ -216,16 +217,16 @@ function SearchTrigger({placeholder, onClick}: { placeholder: string; onClick: (
216217
return (
217218
<button
218219
onClick={onClick}
219-
className="inline-flex items-center gap-2 px-3 py-2 text-sm
220-
bg-input text-foreground cursor-pointer
221-
border border-gray-200 rounded-md hover:border-gray-300 hover:bg-gray-50 transition-colors"
220+
className={cn(
221+
"inline-flex items-center gap-2 px-3 py-2 text-sm cursor-pointer hover:border-gray-300 dark:hover:border-white/40",
222+
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-all outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
223+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
224+
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive"
225+
)}
222226
>
223227
<SearchIcon className="size-4"/>
224228
<span>{placeholder}</span>
225-
<kbd
226-
className="hidden sm:inline-flex h-5 select-none items-center gap-1 rounded border border-gray-200 bg-gray-100 px-1.5 font-mono text-xs text-gray-600">
227-
<span className="text-xs"></span>K
228-
</kbd>
229+
<Kbd><span className="text-xs"></span>K</Kbd>
229230
</button>
230231
);
231232
}
@@ -278,7 +279,7 @@ function SearchItem({url, title, description, onSelect, value, parent}: {
278279
value?: string;
279280
}) {
280281
return (
281-
<CommandItem onSelect={() => onSelect(url)} value={value}>
282+
<CommandItem onSelect={() => onSelect(url)} value={value} className="cursor-pointer">
282283
<div className="flex flex-col gap-1 w-full">
283284
<div className="flex items-center gap-1">
284285
{parent && (
@@ -289,7 +290,7 @@ function SearchItem({url, title, description, onSelect, value, parent}: {
289290
)}
290291
<div className="font-semibold">{title}</div>
291292
</div>
292-
<div className="text-xs text-gray-600">
293+
<div className="text-xs text-muted-foreground">
293294
{description}
294295
</div>
295296
</div>
@@ -336,7 +337,7 @@ function highlightQuery(text: string, query: string) {
336337
const parts = text.split(regex);
337338

338339
return parts.map((part, index) =>
339-
regex.test(part) ? <mark key={index} className="bg-brand text-brand-foreground font-medium">{part}</mark> : part
340+
regex.test(part) ? <mark key={index} className="bg-primary text-primary-foreground rounded-[3px] font-medium">{part}</mark> : part
340341
);
341342
}
342343

components/ui/input.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as React from "react"
2+
3+
import { cn } from "@/lib/utils"
4+
5+
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
6+
return (
7+
<input
8+
type={type}
9+
data-slot="input"
10+
className={cn(
11+
"file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
12+
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
13+
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
14+
className
15+
)}
16+
{...props}
17+
/>
18+
)
19+
}
20+
21+
export { Input }

components/ui/kbd.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { cn } from "@/lib/utils"
2+
3+
function Kbd({ className, ...props }: React.ComponentProps<"kbd">) {
4+
return (
5+
<kbd
6+
data-slot="kbd"
7+
className={cn(
8+
"bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium select-none",
9+
"[&_svg:not([class*='size-'])]:size-3",
10+
"[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",
11+
className
12+
)}
13+
{...props}
14+
/>
15+
)
16+
}
17+
18+
function KbdGroup({ className, ...props }: React.ComponentProps<"div">) {
19+
return (
20+
<kbd
21+
data-slot="kbd-group"
22+
className={cn("inline-flex items-center gap-1", className)}
23+
{...props}
24+
/>
25+
)
26+
}
27+
28+
export { Kbd, KbdGroup }

next-env.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/// <reference types="next" />
22
/// <reference types="next/image-types/global" />
3-
import "./.next/types/routes.d.ts";
3+
import "./.next/dev/types/routes.d.ts";
44

55
// NOTE: This file should not be edited
66
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.

0 commit comments

Comments
 (0)