diff --git a/gui/src/components/mainInput/Lump/sections/BaseIconButton.tsx b/gui/src/components/mainInput/Lump/sections/BaseIconButton.tsx new file mode 100644 index 000000000..fe2b71f78 --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/BaseIconButton.tsx @@ -0,0 +1,35 @@ +import { ComponentType, SVGProps } from "react"; +import { GhostButton } from "../../.."; +import { fontSize } from "../../../../util"; + +interface BaseIconButtonProps { + icon: ComponentType>; + text: string; + onClick: (e: React.MouseEvent) => void; + className?: string; + style?: React.CSSProperties; +} + +export function BaseIconButton({ + icon: Icon, + text, + onClick, + className = "w-full cursor-pointer rounded px-2 py-0.5 text-center", + style = { fontSize: fontSize(-3) }, +}: BaseIconButtonProps) { + return ( + { + e.preventDefault(); + onClick(e); + }} + > +
+ + {text} +
+
+ ); +} \ No newline at end of file diff --git a/gui/src/components/mainInput/Lump/sections/exploreBlocksLogic.ts b/gui/src/components/mainInput/Lump/sections/exploreBlocksLogic.ts new file mode 100644 index 000000000..718513cc2 --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/exploreBlocksLogic.ts @@ -0,0 +1,47 @@ +import { BlockType } from "@continuedev/config-yaml"; +import { + ArrowTopRightOnSquareIcon, + PlusIcon, +} from "@heroicons/react/24/outline"; +import { ComponentType, SVGProps } from "react"; + +export interface ExploreBlocksConfig { + icon: ComponentType>; + text: string; + action: () => void; +} + +export function getExploreBlocksConfig( + blockType: string, + isLocal: boolean, + onLocalAdd: (blockType: BlockType) => void, + onExplore: (blockType: string) => void +): ExploreBlocksConfig { + const Icon = isLocal ? PlusIcon : ArrowTopRightOnSquareIcon; + + const text = `${isLocal ? "Add" : "Explore"} ${ + blockType === "mcpServers" + ? "MCP Servers" + : blockType.charAt(0).toUpperCase() + blockType.slice(1) + }`; + + const action = () => { + if (isLocal) { + onLocalAdd(blockType as BlockType); + } else { + onExplore(blockType); + } + }; + + return { + icon: Icon, + text, + action, + }; +} + +export function formatBlockTypeName(blockType: string): string { + return blockType === "mcpServers" + ? "MCP Servers" + : blockType.charAt(0).toUpperCase() + blockType.slice(1); +} \ No newline at end of file