mirror of
https://github.com/kamranahmedse/driver.js.git
synced 2026-11-01 05:07:12 +08:00
45 lines
1.8 KiB
TypeScript
45 lines
1.8 KiB
TypeScript
import { useState } from "react";
|
|
import type { CollectionEntry } from "astro:content";
|
|
|
|
type DocsHeaderProps = {
|
|
groupedGuides: Record<string, CollectionEntry<"guides">[]>;
|
|
activeGuideTitle: string;
|
|
};
|
|
|
|
export function DocsHeader(props: DocsHeaderProps) {
|
|
const { groupedGuides, activeGuideTitle } = props;
|
|
const [isActive, setIsActive] = useState(false);
|
|
|
|
return (
|
|
<>
|
|
<div className="border-b border-gray-200 flex items-center justify-between">
|
|
<div className="text-right flex justify-end py-3 px-6">
|
|
<a href="/" className="flex items-center justify-end text-xl font-bold">
|
|
<img src="/mascot-head.png" alt="driver.js logo" width={900} height={775} className="h-10 w-auto mr-2" />
|
|
driver.js
|
|
</a>
|
|
</div>
|
|
<div className="flex items-center pr-12">
|
|
<button onClick={() => setIsActive(!isActive)} className="p-[12px] -mr-[12px] hover:bg-gray-100 rounded-md">
|
|
<img src={isActive ? "/cross.svg" : "/burger.svg"} alt="menu" className="w-[14px] h-[14px]" />
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div className={`bg-gray-50 flex flex-col gap-5 px-6 py-6 border-b border-gray-200 ${isActive ? "block" : "hidden"}`}>
|
|
{Object.entries(groupedGuides).map(([category, guides]) => (
|
|
<div key={category} className="flex flex-col gap-2">
|
|
<div className="font-bold text-gray-900 text-sm uppercase">{category}</div>
|
|
<div className="flex flex-col">
|
|
{guides.map(guide => (
|
|
<a key={guide.id} href={`/docs/${guide.id}`} className={`${activeGuideTitle === guide.data.title ? 'text-black': 'text-gray-400'} hover:text-gray-900 py-1`}>
|
|
{guide.data.title}
|
|
</a>
|
|
))}
|
|
</div>
|
|
</div>
|
|
))}
|
|
</div>
|
|
</>
|
|
);
|
|
}
|