Download src/components/Sidebar.jsx from cheumk/studio: direct link, hf CLI and curl.
- Browser
- Download file 3.25 kB
-
https://huggingface.co/spaces/cheumk/studio/resolve/main/src/components/Sidebar.jsx
- Command line
-
hf download hf://spaces/cheumk/studio/src/components/Sidebar.jsx
-
curl -L -o Sidebar.jsx https://huggingface.co/spaces/cheumk/studio/resolve/main/src/components/Sidebar.jsx
3.25 kB
| import { X, PanelLeftClose, FolderKanban, SlidersHorizontal, Server, Bot, Wrench, Settings } from 'lucide-react' | |
| import ProjectPanel from './panels/ProjectPanel' | |
| import ConversationPanel from './panels/ConversationPanel' | |
| import ModelsPanel from './panels/ModelsPanel' | |
| import AgentsPanel from './panels/AgentsPanel' | |
| import ToolsPanel from './panels/ToolsPanel' | |
| import SettingsPanel from './panels/SettingsPanel' | |
| const TABS = [ | |
| { id: 'project', label: '專案', icon: FolderKanban, Panel: ProjectPanel }, | |
| { id: 'conversation', label: '對話', icon: SlidersHorizontal, Panel: ConversationPanel }, | |
| { id: 'models', label: '模型', icon: Server, Panel: ModelsPanel }, | |
| { id: 'agents', label: 'Agent', icon: Bot, Panel: AgentsPanel }, | |
| { id: 'tools', label: '工具', icon: Wrench, Panel: ToolsPanel }, | |
| { id: 'settings', label: '設定', icon: Settings, Panel: SettingsPanel }, | |
| ] | |
| /** | |
| * 側邊欄:所有設定與操作都集中在這裡。 | |
| * - 桌面(md 以上):固定在左側,可收合 | |
| * - 行動版:抽屜,從左側滑出,點遮罩或 X 關閉 | |
| */ | |
| export default function Sidebar({ tab, setTab, mobileOpen, onCloseMobile, desktopCollapsed, onCollapseDesktop }) { | |
| const Active = (TABS.find((t) => t.id === tab) || TABS[0]).Panel | |
| return ( | |
| <> | |
| {/* 行動版遮罩 */} | |
| <div | |
| className={`md:hidden fixed inset-0 z-30 bg-black/60 transition-opacity ${mobileOpen ? 'opacity-100' : 'opacity-0 pointer-events-none'}`} | |
| onClick={onCloseMobile} | |
| /> | |
| <aside | |
| className={`fixed md:static z-40 inset-y-0 left-0 w-[86vw] max-w-[340px] md:w-[330px] shrink-0 flex flex-col bg-panel border-r border-edge | |
| transition-transform duration-200 ${mobileOpen ? 'translate-x-0' : '-translate-x-full'} md:translate-x-0 | |
| ${desktopCollapsed ? 'md:hidden' : 'md:flex'}`} | |
| > | |
| <div className="h-12 shrink-0 flex items-center gap-2 px-3 border-b border-edge"> | |
| <img src="./vite.svg" className="w-6 h-6" alt="" /> | |
| <div className="font-bold flex-1">Agent Studio</div> | |
| <button type="button" className="hidden md:inline-flex p-1.5 rounded-lg hover:bg-field" onClick={onCollapseDesktop} title="收合側邊欄"> | |
| <PanelLeftClose className="w-4 h-4" /> | |
| </button> | |
| <button type="button" className="md:hidden p-1.5 rounded-lg hover:bg-field" onClick={onCloseMobile} aria-label="關閉側邊欄"> | |
| <X className="w-5 h-5" /> | |
| </button> | |
| </div> | |
| <nav className="shrink-0 grid grid-cols-6 border-b border-edge"> | |
| {TABS.map(({ id, label, icon: Icon }) => ( | |
| <button | |
| key={id} | |
| type="button" | |
| onClick={() => setTab(id)} | |
| className={`flex flex-col items-center gap-0.5 py-2 text-[11px] border-b-2 transition ${ | |
| tab === id ? 'border-purple-500 text-ink' : 'border-transparent text-muted hover:text-ink' | |
| }`} | |
| > | |
| <Icon className="w-4 h-4" /> | |
| {label} | |
| </button> | |
| ))} | |
| </nav> | |
| <div className="flex-1 overflow-y-auto"> | |
| <Active onDone={onCloseMobile} goTab={setTab} /> | |
| </div> | |
| </aside> | |
| </> | |
| ) | |
| } | |