Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 974 Bytes
5916048 6294700 5916048 6294700 5916048 5be784e d2a6779 6294700 5916048 d2a6779 5916048 d2a6779 5916048 5be784e 5916048 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
"use client";
import { useState } from "react";
import { useMount } from "react-use";
import { EditorHeader } from "./header";
import { EditorSidebar } from "./sidebar";
import { usePathname } from "next/navigation";
export const Editor = ({ children }: any) => {
const [open, setOpen] = useState<boolean>(false);
const [collections, setCollections] = useState<string[]>([]);
const pathname = usePathname();
useMount(() => {
if (!pathname || pathname === "/") setCollections(["search"]);
const firstPath = pathname.split("/")[1];
if (firstPath) setCollections([firstPath]);
});
return (
<div className="bg-slate-950 w-full overflow-hidden shadow-xl h-[100vh]">
<EditorHeader onToggleMenu={() => setOpen(!open)} />
<main className="flex h-full">
<EditorSidebar
open={open}
collections={collections}
onCollections={setCollections}
/>
{children}
</main>
</div>
);
};
|