Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

highlight-collection-related-info.tsx

28 lines648 Bytes

1import { useSearch } from "@tanstack/react-router";
2import type { ReactNode } from "react";
3import type { HighlightParam } from "@/components/tutorial";
4import { cn } from "@/lib/utils";
5​
6export function HighlightWrapper({
7 highlightId,
8 children,
9 // asChild,
10}: {
11 highlightId: Exclude<HighlightParam, undefined>;
12 children: ReactNode;
13 // asChild?: boolean;
14}) {
15 const searchParams = useSearch({ strict: false });
16​
17 return (
18 <div
19 className={cn(
20 searchParams.highlight &&
21 highlightId.startsWith(searchParams.highlight) &&
22 "outline-red-400 outline",
23 )}
24 >
25 {children}
26 </div>
27 );