import { useWorkspace } from "@/contexts/workspace-context"; import { Hotkey, isMacos } from "@/misc/keys"; import Path from "@/misc/path"; import { SearchOutlined } from "@ant-design/icons"; import { Button, Flex, LayoutProps, Select } from "antd"; import React, { FC, useMemo } from "react"; import { Menu } from "./menu"; interface OptionType { label: string | React.ReactNode; value: string; path: string; } export const TitleBar: FC = () => { const workspace = { allFiles: useWorkspace((state) => state.allFiles), fileTree: useWorkspace((state) => state.fileTree), isShowingSearch: useWorkspace((state) => state.isShowingSearch), onShowingSearch: useWorkspace((state) => state.onShowingSearch), open: useWorkspace((state) => state.open), name: useWorkspace((state) => state.path), }; const searchOptions = useMemo(() => { const options: OptionType[] = []; workspace.allFiles.forEach((path) => { const value = Path.relative(workspace.fileTree!.path, path).replaceAll(Path.sep, "/"); options.push({ label: (
{Path.basename(value)} {Path.dirname(value)}
), value: value, path: path, }); }); return options; }, [workspace.allFiles, workspace.fileTree]); return (
{!isMacos && }
{workspace.isShowingSearch && (