Elffuss BraidHub

kikocis/continue public

f433400a74a4 · 2.9 KiBRawPermalink
1import {
2 BoltIcon,
3 CircleStackIcon,
4 Cog6ToothIcon,
5 QuestionMarkCircleIcon,
6} from "@heroicons/react/24/outline";
7import { useState } from "react";
8import { useNavigate } from "react-router-dom";
9import { PageHeader } from "../../components/PageHeader";
10import { useNavigationListener } from "../../hooks/useNavigationListener";
11import { fontSize } from "../../util";
12import { AccountButton } from "./AccountButton";
13import { HelpCenterSection } from "./HelpCenterSection";
14import { IndexingSettingsSection } from "./IndexingSettingsSection";
15import KeyboardShortcuts from "./KeyboardShortcuts";
16import { UserSettingsForm } from "./UserSettingsForm";
17
18type TabOption = {
19 id: string;
20 label: string;
21 component: React.ReactNode;
22 icon: React.ReactNode;
23};
24
25function ConfigPage() {
26 useNavigationListener();
27 const navigate = useNavigate();
28 const [activeTab, setActiveTab] = useState("settings");
29
30 const tabs: TabOption[] = [
31 {
32 id: "settings",
33 label: "Settings",
34 component: <UserSettingsForm />,
35 icon: <Cog6ToothIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
36 },
37 {
38 id: "indexing",
39 label: "Indexing",
40 component: <IndexingSettingsSection />,
41 icon: <CircleStackIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
42 },
43 {
44 id: "help",
45 label: "Help",
46 component: <HelpCenterSection />,
47 icon: (
48 <QuestionMarkCircleIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
49 ),
50 },
51 {
52 id: "shortcuts",
53 label: "Shortcuts",
54 component: <KeyboardShortcuts />,
55 icon: <BoltIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
56 },
57 ];
58
59 return (
60 <div className="flex h-full flex-col overflow-y-auto">
61 <div className="bg-vsc-background sticky top-0 z-10">
62 <PageHeader
63 showBorder
64 onTitleClick={() => navigate("/")}
65 title="Chat"
66 rightContent={<AccountButton />}
67 />
68
69 {/* Tab Headers */}
70 <div className="bg-vsc-input-background grid cursor-pointer grid-cols-2 border-0 border-b-[1px] border-solid border-b-zinc-700 p-0.5 sm:flex sm:justify-center md:gap-x-2">
71 {tabs.map((tab) => (
72 <div
73 style={{
74 fontSize: fontSize(-2),
75 }}
76 key={tab.id}
77 className={`flex cursor-pointer items-center justify-center gap-1.5 rounded-md px-2 py-2 hover:brightness-125 ${
78 activeTab === tab.id ? "" : "text-gray-400"
79 }`}
80 onClick={() => setActiveTab(tab.id)}
81 >
82 {tab.icon}
83 {tab.label}
84 </div>
85 ))}
86 </div>
87 </div>
88
89 {/* Tab Content */}
90 <div className="flex-1 overflow-y-auto px-4">
91 {tabs.find((tab) => tab.id === activeTab)?.component}
92 </div>
93 </div>
94 );
95}
96
97export default ConfigPage;