diff --git a/src/components/view/Sidebar.tsx b/src/components/view/Sidebar.tsx index 1376658..1157d0c 100644 --- a/src/components/view/Sidebar.tsx +++ b/src/components/view/Sidebar.tsx @@ -1,6 +1,7 @@ import Enclave from "@/app/app"; import { Channel, ChannelKind } from "@/app/protocol"; -import { HashIcon } from "lucide-react"; +import { ChevronDown, ChevronUp, HashIcon } from "lucide-react"; +import { useState } from "react"; export function ChannelIcon({ kind }: { kind: ChannelKind["kind"] }) { switch (kind) { @@ -11,17 +12,37 @@ export function ChannelIcon({ kind }: { kind: ChannelKind["kind"] }) { } } +export function RenderCategory({ channel }: { channel: Channel }) { + if (channel.kind !== "category") return null; + + const [open, setOpen] = useState(true); + + return ( +
+
setOpen((v) => !v)} + > + {channel.name} + {open ? ( + + ) : ( + + )} +
+ {open && ( +
+ +
+ )} +
+ ); +} + export function RenderChannels({ channels }: { channels: Channel[] }) { return channels.map((channel) => channel.kind === "category" ? ( -
-
- {channel.name} -
-
- -
-
+ ) : (