Elffuss BraidHub

kikocis/continue public

2cb7a36ca613 · 1.2 KiBRawPermalink
1import { CommandLineIcon } from "@heroicons/react/24/outline";
2import { useContext } from "react";
3import { lightGray, vscForeground } from "../..";
4import { IdeMessengerContext } from "../../../context/IdeMessenger";
5import { extractCommand } from "../utils/commandExtractor";
6
7interface RunInTerminalButtonProps {
8 command: string;
9}
10
11export function RunInTerminalButton({ command }: RunInTerminalButtonProps) {
12 const ideMessenger = useContext(IdeMessengerContext);
13
14 function runInTerminal() {
15 // Extract just the command line
16 const extractedCommand = extractCommand(command);
17 void ideMessenger.post("runCommand", { command: extractedCommand });
18 }
19
20 return (
21 <div
22 className={`text-lightgray flex items-center border-none bg-transparent text-xs text-[${vscForeground}] cursor-pointer outline-none hover:brightness-125`}
23 onClick={runInTerminal}
24 >
25 <div
26 className="max-2xs:hidden flex items-center gap-1 transition-colors duration-200 hover:brightness-125"
27 style={{ color: lightGray }}
28 >
29 <>
30 <CommandLineIcon className="h-3 w-3 hover:brightness-125" />
31 <span className="text-lightgray max-sm:hidden">Run</span>
32 </>
33 </div>
34 </div>
35 );
36}