Repository navigation
Expand file tree
/
Copy pathDrawer.tsx
More file actions
152 lines (145 loc) · 4.03 KB
/
Copy pathDrawer.tsx
File metadata and controls
152 lines (145 loc) · 4.03 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import React, { useState } from "react";
import {
FaBars,
FaCog,
FaDiscord,
FaGithub,
FaQuestionCircle,
FaRobot,
FaTwitter,
} from "react-icons/fa";
import { BiPlus } from "react-icons/bi";
import FadeOut from "./motions/FadeOut";
import { AnimatePresence } from "framer-motion";
import clsx from "clsx";
const Drawer = ({
showHelp,
showSettings,
}: {
showHelp: () => void;
showSettings: () => void;
}) => {
const [showDrawer, setShowDrawer] = useState(false);
const [agents, setAgents] = React.useState<string[]>([]);
const toggleDrawer = () => {
setShowDrawer((prevState) => !prevState);
};
return (
<>
<button
hidden={showDrawer}
className="fixed left-2 top-2 z-40 rounded-md border-2 border-white/20 bg-zinc-900 p-2 text-white hover:bg-zinc-700 md:hidden"
onClick={toggleDrawer}
>
<FaBars />
</button>
<div
id="drawer"
className={clsx(
showDrawer ? "translate-x-0" : "-translate-x-full",
"z-30 m-0 h-screen w-72 flex-col justify-between bg-zinc-900 p-3 font-mono text-white shadow-3xl transition-all",
"absolute",
"flex md:static md:translate-x-0"
)}
>
<div className="flex flex-col gap-1 overflow-hidden">
<div className="mb-2 flex justify-center gap-2">
<DrawerItem
className="flex-grow"
icon={<BiPlus />}
border
text="New Agent"
onClick={() => location.reload()}
/>
<button
className="z-40 rounded-md border-2 border-white/20 bg-zinc-900 p-2 text-white hover:bg-zinc-700 md:hidden"
onClick={toggleDrawer}
>
<FaBars />
</button>
</div>
<AnimatePresence>
{agents.map((agent, index) => (
<FadeOut key={`${index}-${agent}`}>
<DrawerItem icon={<FaRobot />} text={agent} />
</FadeOut>
))}
{agents.length === 0 && (
<div>
Click the above button to restart. In the future, this will be a
list of your deployed agents!
</div>
)}
</AnimatePresence>
</div>
<div className="flex flex-col gap-1">
<hr className="my-5 border-white/20" />
{/*<DrawerItem*/}
{/* icon={<FaTrashAlt />}*/}
{/* text="Clear Agents"*/}
{/* onClick={() => setAgents([])}*/}
{/*/>*/}
<DrawerItem
icon={<FaQuestionCircle />}
text="Help"
onClick={showHelp}
/>
<DrawerItem icon={<FaCog />} text="Settings" onClick={showSettings} />
<DrawerItem
icon={<FaDiscord />}
text="Discord"
onClick={() =>
window.open("https://discord.gg/jdSBAnmdnY", "_blank")
}
/>
<DrawerItem
icon={<FaTwitter />}
text="Twitter"
onClick={() =>
window.open(
"https://twitter.com/asimdotshrestha/status/1644883727707959296",
"_blank"
)
}
/>
<DrawerItem
icon={<FaGithub />}
text="GitHub"
onClick={() =>
window.open("https://github.com/reworkd/AgentGPT", "_blank")
}
/>
</div>
</div>
</>
);
};
interface DrawerItemProps {
icon: React.ReactNode;
text: string;
border?: boolean;
onClick?: () => void;
className?: string;
}
const DrawerItem = ({
icon,
text,
border,
onClick,
className,
}: DrawerItemProps) => {
return (
<div
className={clsx(
"flex cursor-pointer flex-row items-center rounded-md rounded-md p-2 hover:bg-white/5",
border && "border-[1px] border-white/20",
`${className || ""}`
)}
onClick={onClick}
>
{icon}
<span className="text-md ml-4">{text}</span>
</div>
);
};
export default Drawer;