@@ -1,10 +1,13 @@
11 "use client";
22
3+import { useState } from "react";
34 import type { Thread } from "@/src/lib/db/schema";
45 import PlusIcon from "@/src/components/icons/PlusIcon";
56 import ChevronDownIcon from "@/src/components/icons/ChevronDownIcon";
67 import BowtieIcon from "@/src/components/icons/BowtieIcon";
7-import Anchor from "@/src/components/Anchor";
8+import GearIcon from "@/src/components/icons/GearIcon";
9+import SidebarButton from "@/src/components/SidebarButton";
10+import SettingsModal from "@/src/components/SettingsModal";
811
912 type SidebarProps = {
1013 threads: Thread[];
@@ -27,16 +30,17 @@ export default function Sidebar({
2730 onLoadMore,
2831 hasMoreThreads,
2932 }: SidebarProps) {
33+ const [isSettingsOpen, setIsSettingsOpen] = useState(false);
34+
3035 return (
31- <div className="h-full w-64 overflow-y-auto bg-neutral-50 p-1 text-neutral-800 dark:bg-neutral-950 dark:text-neutral-200">
32- <div className="flex flex-col gap-2 p-4">
33- <div className="flex justify-center pb-4">
34- <BowtieIcon className="h-12 w-12" />
35- </div>
36- <div className="flex flex-col gap-2">
37- <label className="text-neutral-500">Threads</label>
36+ <>
37+ <div className="h-full w-64 overflow-y-auto bg-neutral-50 p-1 text-neutral-800 dark:bg-neutral-950 dark:text-neutral-200">
38+ <div className="flex flex-col gap-2 p-4">
39+ <div className="flex justify-center pb-4">
40+ <BowtieIcon className="h-12 w-12" />
41+ </div>
3842 <div className="flex flex-col gap-2">
39- <Anchor
43+ <SidebarButton
4044 href="#"
4145 onClick={(e) => {
4246 e.preventDefault();
@@ -45,61 +49,68 @@ export default function Sidebar({
4549 >
4650 <PlusIcon className="h-4 w-4" />
4751 New Thread
48- </Anchor>
49- <div className="flex flex-col">
50- {threads.length === 0 ? (
51- <div className="px-3 py-2 text-neutral-600 dark:text-neutral-400">
52- No threads yet
53- </div>
54- ) : (
55- threads.map((thread) => {
56- const isSelected = currentThreadId === thread.id;
57- return (
58- <Anchor
59- key={thread.id}
60- href={`#thread-${thread.id}`}
61- onClick={(e) => {
62- e.preventDefault();
63- onThreadSelect(thread.id);
64- }}
65- isSelected={isSelected}
66- >
67- <span className="min-w-0 truncate">
68- {thread.title || `Thread ${thread.id}`}
69- </span>
70- </Anchor>
71- );
72- })
73- )}
74- </div>
75- </div>
76- {hasMoreThreads && (
77- <Anchor
52+ </SidebarButton>
53+ <SidebarButton
7854 href="#"
79- className="text-xs"
8055 onClick={(e) => {
8156 e.preventDefault();
82- onLoadMore();
57+ setIsSettingsOpen(true);
8358 }}
8459 >
85- <ChevronDownIcon className="mt-0.5 h-3 w-3" />
86- Load More
87- </Anchor>
88- )}
89- </div>
90- <div className="flex flex-col gap-2">
91- <label className="text-neutral-500">Theme</label>
92- <select
93- value={themeMode}
94- onChange={(e) => onThemeChange(e.target.value as "device" | "dark" | "light")}
95- className="bg-neutral-100 px-3 py-1 text-neutral-800 focus:outline-none dark:bg-neutral-900 dark:text-neutral-200"
96- >
97- <option value="device">Device</option>
98- <option value="dark">Dark</option>
99- <option value="light">Light</option>
100- </select>
60+ <GearIcon className="h-4 w-4" />
61+ Settings
62+ </SidebarButton>
63+ <label className="text-neutral-500">Threads</label>
64+ <div className="flex flex-col gap-2">
65+ <div className="flex flex-col">
66+ {threads.length === 0 ? (
67+ <div className="px-3 py-2 text-neutral-600 dark:text-neutral-400">
68+ No threads yet
69+ </div>
70+ ) : (
71+ threads.map((thread) => {
72+ const isSelected = currentThreadId === thread.id;
73+ return (
74+ <SidebarButton
75+ key={thread.id}
76+ href={`#thread-${thread.id}`}
77+ onClick={(e) => {
78+ e.preventDefault();
79+ onThreadSelect(thread.id);
80+ }}
81+ isSelected={isSelected}
82+ >
83+ <span className="min-w-0 truncate">
84+ {thread.title || `Thread ${thread.id}`}
85+ </span>
86+ </SidebarButton>
87+ );
88+ })
89+ )}
90+ </div>
91+ </div>
92+ {hasMoreThreads && (
93+ <SidebarButton
94+ href="#"
95+ className="text-xs"
96+ onClick={(e) => {
97+ e.preventDefault();
98+ onLoadMore();
99+ }}
100+ >
101+ <ChevronDownIcon className="mt-0.5 h-3 w-3" />
102+ Load More
103+ </SidebarButton>
104+ )}
105+ </div>
101106 </div>
102107 </div>
103- </div>
108+ <SettingsModal
109+ isOpen={isSettingsOpen}
110+ onClose={() => setIsSettingsOpen(false)}
111+ themeMode={themeMode}
112+ onThemeChange={onThemeChange}
113+ />
114+ </>
104115 );
105116 }